You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Johan Wasserman <Jo...@mgxgroup.com> on 2003/03/19 11:19:30 UTC
[newbie] Prepopulating a form
Hi,
I need to populate a form from a StateBean (session) before displaying
it.
I cannot find anything to do it when using a FormBean (request) since
the bean is initialised when loading the form and no methods are
available to read the StateBean from the session (or so I think), any
suggestions will be welcome.
Thanks in advance.
Johan Wasserman
Re: [newbie] Prepopulating a form
Posted by Gemes Tibor <ti...@i-trade.hu>.
Johan Wasserman írta:
>Hi,
>I need to populate a form from a StateBean (session) before displaying
>it.
>I cannot find anything to do it when using a FormBean (request) since
>the bean is initialised when loading the form and no methods are
>available to read the StateBean from the session (or so I think), any
>suggestions will be welcome.
>
>
Create an action which loads the data into your actionform, and
reference this action instead of the
jsp which displays the form.
Hth,
Tib
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: [newbie] Prepopulating a form
Posted by Marco Maier <Ma...@ics-software.de>.
Hi Johan,
try this...
DynaActionForm yourForm = (DynaActionForm)
this.createDynaActionFormFromFormBeanConfig(yourFormName, mapping);
// prepopulate the form
httpSession.setAttribute(yourFormName, yourForm);
protected DynaActionForm
createDynaActionFormFromFormBeanConfig(String name, ActionMapping
mapping)
throws InstantiationException, IllegalAccessException
{
FormBeanConfig config = (FormBeanConfig)
mapping.getApplicationConfig().
findFormBeanConfig(name);
DynaActionFormClass dynaClass = DynaActionFormClass.
createDynaActionFormClass(config);
return ((DynaActionForm) dynaClass.newInstance());
}
hope this helps.
Marco
Johan Wasserman wrote:
> Hi,
> I need to populate a form from a StateBean (session) before displaying
> it.
> I cannot find anything to do it when using a FormBean (request) since
> the bean is initialised when loading the form and no methods are
> available to read the StateBean from the session (or so I think), any
> suggestions will be welcome.
>
> Thanks in advance.
>
> Johan Wasserman
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org