I may be wrong, Joel, but I think Joe and Hubert are thinking of you
instantiating a form that is not listed in your action mapping.  You
can readily figure out why they think this way.  You can, as you seem
to want to, avoid this complication that actually sort of takes you
out of the reason for the Struts framework by having your ActionForm
encompass the data in both the "pre-Action" and "post-Action" JSP/HTML
forms.

Jack


On Fri, 11 Mar 2005 11:57:33 -0700, Schuster Joel M Contr ESC/NDC
<[EMAIL PROTECTED]> wrote:
> I've been looking into the RequestProcessor and RequestUtils classes and it
> looks like as long as my action mapping specifies a name, even on a setup
> action goes through the same process... calling createActionForm().
> 
> Thus there is no reason to go through my own ModuleConfig again.
> 
> 
> -----Original Message-----
> From: Hubert Rabago [mailto:[EMAIL PROTECTED]
> Sent: Friday, March 11, 2005 10:13 AM
> To: Struts Users Mailing List
> Subject: Re: Correct Prepopulate Method
> 
> On Fri, 11 Mar 2005 09:50:59 -0700, Schuster Joel M Contr ESC/NDC
> <[EMAIL PROTECTED]> wrote:
> > I'm not sure I understand the need for the moduleConfig and such for
> > creating the DynaActionForm.
> 
> The FormBeanConfig object provides access to the createActionForm()
> method.  That's the object you actually need.  You can get to that
> through the ModuleConfig for the current module.
> 
> >
> > If we've specified the name="myForm" in the action config then shouldn't
> the
> > form coming into the execute be and empty version of my form? Thus
> allowing:
> >
> >      execute( ActionMapping mapping, ActionForm form ... {
> >             DynaActionForm myForm = (DynaActionForm) form;
> >      }
> >
> > (As a matter of fact I know this works :))
> >
> 
> This is true when you're in the action to which the form was
> submitted.  In the example I gave, this would be the /submitForm
> action.  In a setup action, this mapping may not be available or may
> be referring to a different form altogether.
> 
> > Also, using
> >
> > request.getSession().setAttribute("myForm", myForm);
> >
> > is exactly the issue. Although it then allows the follow up jsp to gain
> > access to the formbean during form(html) creation it doesn't determine how
> > then to remove the form from the session except by explicit removal in the
> > final update/submit action unless you config the submit as request scope
> > only. But that doesn't actually remove the formbean from the session scope
> > that we added it into... it just copies it into the request scope too.
> >
> > --- so back to sqare one. :P
> 
> You can specify which scope you want the form bean to be in (read the
> bottom of my prev email).  Struts uses session scope by default, which
> is why that's what I mentioned first.  You can choose to use request
> scope.
> 
> hth,
> Hubert
> 
> >
> >
> > -----Original Message-----
> > From: Hubert Rabago [mailto:[EMAIL PROTECTED]
> > Sent: Friday, March 11, 2005 9:36 AM
> > To: Struts Users Mailing List
> > Subject: Re: Correct Prepopulate Method
> >
> > You would usually do prepopulation in a setup form.  Which scope you
> > place the form in depends on how you configure the action that the
> > form will be submitted to.  For example, if you have "/showPage.do"
> > and "/submitForm.do", where submitForm is configured as:
> >
> > <action path="/submitForm" name="myForm" ...>....</action>
> >
> > Then in the action for showPage, you'd:
> >
> >     ModuleConfig moduleConfig =
> > ModuleUtils.getInstance().getModuleConfig(request);
> >     FormBeanConfig formBeanConfig =
> > moduleConfig.findFormBeanConfig("myForm");
> >     DynaActionForm myForm = (DynaActionForm)
> > formBeanConfig.createActionForm(getServlet());
> >
> >     myForm.set("propName",propValue);
> >     request.getSession().setAttribute("myForm", myForm);
> >
> > If you want to use request scope, change /submitForm to:
> > <action path="/submitForm" name="myForm" scope="request"...>....</action>
> >
> > then in showPage:
> >     request.setAttribute("myForm", myForm);
> >
> > Hubert
> >
> 
> ---------------------------------------------------------------------
> 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]
> 
> 


-- 
"You can lead a horse to water but you cannot make it float on its back."
~Dakota Jack~

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

Reply via email to