/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//I've been having issues with posting to this list, so I apologize if this is a repost.
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


That hits on some points, I did read that thread earlier this week(I'll even read it again), and I'm starting to agree on not shoving everything in the ActionForm, but I don't recall it hitting on an Action needing one form for input and one form for output. If I totally ignore it, the second page will render, but what if I need my html form in the second JSP(JSPB) to be prepopulated with the results of the processing in ActionA?

Scenario:
I have jspA that is rendered with ActionFormA. Now user submits that data to ActionA. ActionA recieves an ActionFormA as its input form in execute. Now ActionA needs to forward to jspB which expectes an ActionFormB, what is the cleanest way to handle this in struts(see code below). Do struts users run across this case often or do I need to rethink my Action/Form design?
--m



Robert Taylor wrote:


This was discussed earlier this week.

Some solutions are addressed here:
http://www.mail-archive.com/struts-user%40jakarta.apache.org/msg81101.html

robert




-----Original Message-----
From: Michael Thompson [mailto:[EMAIL PROTECTED]
Sent: Friday, September 19, 2003 6:10 PM
To: struts-user
Subject: Action Form Design Question


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 ActionForward 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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to