You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Chris Pat <cp...@yahoo.com> on 2008/03/12 01:04:02 UTC

populate form bean

Hello
Excuse my niavete, but I have never used a formbean for other than retrieving string data from a form.  For output I have just used simple struts and jstl for output.  Now I want to reverse it and would like to use more sophisticated struts tags with collections in the form bean.  Simple (stupid,grin?) question.

Can I from an Action populate a formbean, from a database, set it in the session and forward to a jsp that is configured to use that formbean as the encompassing formbean for the form?  What is the syntax, where do I put the name of the formbean in the struts form tag to match the name of the formbean I populated from the action?  Yes, I know I should try it and answer it myself, I was just hoping for a headsup and general direction.  tia.

Re: populate form bean

Posted by Dave Newton <ne...@yahoo.com>.
--- Chris Pat <cp...@yahoo.com> wrote:
> Can I from an Action populate a formbean, from a database, set 
> it in the session and forward to a jsp that is configured to use that 
> formbean as the encompassing formbean for the form?

Sure, but you shouldn't need to set it in the session yourself; that (IIRC)
is handled in the configuration file.

Whether or not you should has been the subject of conversation here over the
years. I'm in the "no" camp; I'd rather keep as much as possible un-tied to
the S1 libraries. Just makes things easier. Other people will disagree with
that.

Fortunately I haven't done a new S1 app in a couple of years now, so it's
okay :)

> What is the syntax, where do I put the name of the formbean 
> in the struts form tag to match the name of the formbean 
> I populated from the action?

I thought in S1 the form bean was named in the S1 configuration file; you
shouldn't have to do anything in particular with the form tag.

Dave



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org