You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Sebastian Ho <se...@bii.a-star.edu.sg> on 2004/08/19 03:36:12 UTC

how not to use actionform and pass things around

hi

1. If I need to make an object in a JSP to be available to the next JSP
(which is forwarded by my Action), how do I do that without using an
ActionForm? 

The reason I am asking this is that to use an ActionForm I have to write
the entities of my ActionForm into the JSP for it to be picked up, which
I do not want to do. I just want to make it available to the next JSP.

I do not wish to use an session for this if possible because there's
only two JSP.

In JSP, I remember there's a <param> or something else which pass
objects between pages (I might be mistaken here). 


2. If I have two actionforms in my JSP, in the same <form>. How do I
handle that because execute (in Action class) only have a form
parameter.

Thanks guys

Sebastian Ho




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: how not to use actionform and pass things around

Posted by Sebastian Ho <se...@bii.a-star.edu.sg>.
Guess you are right in a way. But I don't know how to solve this
scenario using struts..

Say I have three JSP (JSP1, JSP2 and JSP3). JSP1 populates my actionform
(AF1) and in my Action, I set it into my request (not using a session)
so that it is available to JSP2. 

In JSP2, I have yet another ActionForm to populate. Here I just want to
pass AF1, which is available in the current page (JSP2) to the next
JSP3.

Therefore I will have two actionforms in JSP2, the new actionform and
AF1 in a single form. 

Now, how do I pass both actionforms to the Action class of JSP2?

I might be asking something stupid here, but this is what I want to
achieve and I have no idea how to do it. I am new to struts.

sebastian


On Thu, 2004-08-19 at 09:59, Koon Yue Lam wrote:
> Hi !
> I don't see a good reason that you are not going to use action form.
> Since Action form is just a Java bean, which is pretty much the same
> as the "Object" that you want to pass around
> 
> and about this:
> "use an ActionForm I have to write the entities of my ActionForm into
> the JSP for it to be picked up"
> 
> If you use plain Object to pass around JSP, u still need to declare
> those object in order to use it (<bean: XX />). Which means u still
> need a Java bean in order to use it in JSP, and that's why Acton form
> is here to help u!
> 
> lastly, can u sure that your site will only has 2 page in the future?
> and won't do some validation?
> 
> hopes this help
> 
> Regards
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: how not to use actionform and pass things around

Posted by Koon Yue Lam <ki...@gmail.com>.
Hi !
I don't see a good reason that you are not going to use action form.
Since Action form is just a Java bean, which is pretty much the same
as the "Object" that you want to pass around

and about this:
"use an ActionForm I have to write the entities of my ActionForm into
the JSP for it to be picked up"

If you use plain Object to pass around JSP, u still need to declare
those object in order to use it (<bean: XX />). Which means u still
need a Java bean in order to use it in JSP, and that's why Acton form
is here to help u!

lastly, can u sure that your site will only has 2 page in the future?
and won't do some validation?

hopes this help

Regards

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: how not to use actionform and pass things around

Posted by Bill Siggelkow <bi...@bellsouth.net>.
Sebastian, the short answer is to set the object as a request attribute.

You would do something like the following in your action:

public ActionForward execute(...) {
   Foo myFoo = FooService.getFoo();
   request.setAttribute("myFoo", foo);
   return mapping.findForward("success");
}

Then on the success page you can access the object using the bean tags, 
the logic tags or anything else that searches for scoped variables by 
name -- you can also  use JSTL.

   <bean:write name="myFoo"/>
   <c:out value="${myFoo}"/>

...

HTH
Bill Siggelkow

Sebastian Ho wrote:
> hi
> 
> 1. If I need to make an object in a JSP to be available to the next JSP
> (which is forwarded by my Action), how do I do that without using an
> ActionForm? 
> 
> The reason I am asking this is that to use an ActionForm I have to write
> the entities of my ActionForm into the JSP for it to be picked up, which
> I do not want to do. I just want to make it available to the next JSP.
> 
> I do not wish to use an session for this if possible because there's
> only two JSP.
> 
> In JSP, I remember there's a <param> or something else which pass
> objects between pages (I might be mistaken here). 
> 
> 
> 2. If I have two actionforms in my JSP, in the same <form>. How do I
> handle that because execute (in Action class) only have a form
> parameter.
> 
> Thanks guys
> 
> Sebastian Ho


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org