struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Schuster Joel M Contr ESC/NDC <>
Subject RE: Correct Prepopulate Method
Date Fri, 11 Mar 2005 16:50:59 GMT
I'm not sure I understand the need for the moduleConfig and such for
creating the DynaActionForm.

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 :))

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

-----Original Message-----
From: Hubert Rabago [] 
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 "/"
and "/", where submitForm is configured as:

<action path="/submitForm" name="myForm" ...>....</action>

Then in the action for showPage, you'd:

    ModuleConfig moduleConfig =
    FormBeanConfig formBeanConfig =
    DynaActionForm myForm = (DynaActionForm)
    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);


On Fri, 11 Mar 2005 09:18:15 -0700, Schuster Joel M Contr ESC/NDC
<> wrote:
> I've read a number of articles about correct pre-populate forms methods,
> including the following:
> 1.
> <>
> 2.
> <>
> 3.
> p1
> ep1>
> I have some questions.
> The first article does not talk specifics about how Lazy-Loading would be
> implemented.
> The second doesn't talk about how the actual pre-population would be
> implemented in the action.
> And the third does it in a way that's different from how others do it.
> Here's what I've gotten so far...
> There are two different ways that I see to do it.
> 1.      Load the FormBean up in the constructor.
> a.      This does not work in Dyna*Forms since there's no actual
> implementation
> b.      This then moves the logic to the actual form bean which is not
> it's supposed to be.
> 2.      Load the FormBean in a precursor Action
> a.      This works well but every example I've seen then does something
> this:
> Request.getSession().setAttribute( '"formBean", bean);
> This seems like a bad idea since it places the bean into the session
> I've tried doing this by putting it directly into request but of course
> jsp then doesn't have access to it because the request on the Action is
> in the same scope as the 'form'.jsp
> So I guess I'm at a loss on how best to pre-populate Dyna*Forms. Examples
> that have worked from your experience would be appreciated.

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

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

View raw message