struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Adam Hardy <>
Subject Re: Action/Form Design Q
Date Mon, 22 Sep 2003 11:18:03 GMT
What you can do is make your action forward a redirect in the mapping, 
so that the browser is told to make a new request to that mapping. Then 
you can specify the form in your new mapping and struts takes care of it 

You just have to watch out for request parameters - that info will get 
lost unless you put it in a cookie or a session etc.


On 09/19/2003 06:06 PM Michael Thompson wrote:
> I've hit a stumbling block and I'm not quite sure how to work around 
> it.  I've written struts apps in the past and I've taken the approach of 
> putting everything in the ActionForm so that the jsp has a one stop shop 
> for all it's display needs.  So where I've hit an issue is when say I 
> have jsp A that is rendered with form A.  When user submits data to 
> action A, the ActionForm pushed to execute is form A.  What happens when 
> I need to forward from action A to jsp B which is rendered with form B?  
> I need to populate an ActionForm B to send to jsp B, but I don't have 
> one.  Is it "normal" to create a form of a different type in your 
> Action?  So essentially the code would look something like:
> public void execute(ActionMapping mapping, ActionForm form, 
> HttpServletRequest request, HttpServletResponse response)
>  throws Exception
> {
>    FormA inputForm = (FormA)form;
>    Result result = doSomeCrunchingOnDataSubmittedViaFormA(inputForm);
>      FormB outputForm = getInstanceOfFormB(mapping, request);  //this 
> would stash in request/session also
>    populateFormBWithResults(outputForm, result);
>    return mapping.findForward("success");
> }
> getInstanceOfFormB is a little hazy, but I did notice a method in 
> RequestUtils that might help.  Seems like this might be breaking some 
> struts abstractions by knowing what form to create etc.
> Is this the correct way to approach this or should I think about a 
> redesign of my forms and actions?  Thanks in advance!
>  --m
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

struts 1.1 + tomcat 4.1.27 + java 1.4.2
Linux 2.4.20 RH9

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message