You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by John Chang <jo...@yahoo.com> on 2001/03/14 23:43:06 UTC
How to generate a form bean manually?
Usually, a form bean is automatically created after a
user submit the form at the first time. But if I want
to generate the form bean before the form is shown,
how can I do that?
The reason for me to do so is for this case: some
information of the form are already in database. When
users fill the form, they don't have to input these
information.
Another question, how can I get the instance of the
form bean in my JSP file?
Thanks a lot!
John Chang
__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - Buy the things you want at great prices.
http://auctions.yahoo.com/
Re: How to generate a form bean manually?
Posted by Maya Muchnik <mm...@pumatech.com>.
It is my guess. Take as example logon.jsp and registration.jsp. The
first jsp uses a part of info for the second jsp (or form). I think you
need to have 2 form beans, one for fill in parameters, other one - for
full object.
John Chang wrote:
> Usually, a form bean is automatically created after a
> user submit the form at the first time. But if I want
> to generate the form bean before the form is shown,
> how can I do that?
>
> The reason for me to do so is for this case: some
> information of the form are already in database. When
> users fill the form, they don't have to input these
> information.
>
> Another question, how can I get the instance of the
> form bean in my JSP file?
>
> Thanks a lot!
>
> John Chang
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Auctions - Buy the things you want at great prices.
> http://auctions.yahoo.com/
Re: How to generate a form bean manually?
Posted by "Craig R. McClanahan" <cr...@apache.org>.
On Wed, 14 Mar 2001, John Chang wrote:
>
> Usually, a form bean is automatically created after a
> user submit the form at the first time. But if I want
> to generate the form bean before the form is shown,
> how can I do that?
>
> The reason for me to do so is for this case: some
> information of the form are already in database. When
> users fill the form, they don't have to input these
> information.
>
The example application does exactly this trick.
On the registration.jsp page, look at the link that is generated for
editing a subscription -- it goes back to an action
("/editSubscription") which will precreate and populate the form bean,
place it in request scope, and then forwards to subscription.jsp for
display.
> Another question, how can I get the instance of the
> form bean in my JSP file?
>
The <html:form> tag does this for you, at least as far as is required by
the various field tags like <html:text>. If you want to refer to this
bean with other tags and scriptlets, you can simply use <jsp:useBean> to
declare it, just like any other bean. If the bean already exists at that
point in time, it will not be recreated.
> Thanks a lot!
>
> John Chang
>
Craig McClanahan