> -----Original Message----- > From: Eddie Bush [mailto:ekbush@;swbell.net] > Sent: Tuesday, November 12, 2002 8:31 AM > To: Struts Users Mailing List > Subject: Re: [SIDEBAR] Form population (Was RE: request.setAttribute() > for m confusion) > > > Martin Cooper wrote: > > >>-----Original Message----- > >>From: Eddie Bush [mailto:ekbush@;swbell.net] > >>Sent: Monday, November 11, 2002 2:46 PM > >>To: Struts Users Mailing List > >>Subject: Re: [SIDEBAR] Form population (Was RE: > request.setAttribute() > >>form confusion) > >> > >> > >>Sri, pardon me, but I don't see how what you've said has > >>anything to do > >>with the point I was making. My sole point is that the > >>actual creation > >>(instantiation) of the form bean itself is a very > mechanical act that > >>Struts can perform on your behalf. There is no need to ever > >>bother with > >>creating a bean and placing it into some scope - just > >>configure things > >>properly and let it be done for you. Yes, you may very > well need to > >>initialize it's values in an action - but that is a > seperate act from > >>instantiation. > >> > >> > >I think you missed the point here, Eddie (or perhaps I > missed that you > >didn't miss the point :). > > > >Think about it this way. Struts will create your form bean > automagically in > >a couple of cases: when it needs to populate one from an > incoming request, > >and when it needs to render a form but can't find the > corresponding form > >bean. > > > >Now consider the case where you need to populate the form > with some values > >that the Action came up with somehow. You'd do that by > having the values in > >the form bean properties, right? That way, the Struts HTML > tags will do the > >work for you. > > > >But now consider the case where you haven't yet invoked > anything in the app > >that would cause the appropriate form bean to be > instantiated. The action > >that came up with the values might have been invoked with a > different form > >bean, or perhaps no form bean at all. So Struts hasn't > instantiated the bean > >yet. Struts *will* instantiate the bean when it the > <html:form> tag is > >processed, but by then, it's too late for the Action to > populate the form > >bean. > > > Yes, but at this point it's not terribly important - assuming > the submit > of this form is the first time the form is really needed (for > capturing > values). I was just trying to empasize why a person wanted to trust > Struts to do this for them - not cover all bases of usage ;-)
Huh? What's not terribly important? If I don't have the form bean (which Struts has not yet created for me), how am I going to populate it with the values I want displayed in the form? > > >So the only way for the action to pre-populate the form > bean, so that those > >values are picked up by the Struts HTML tags to populate the > form is for the > >action to instantiate the form bean itself. > > > Huh? Ok I think I missed something here. I've always had my form > available to me if I told Struts an action used it. If you're not > pre-populating (for display) it's really not important to have it > created ahead of time. You're guaranteed the form will be there to Um, this whole thread is about pre-populating for display... That's what Sri is trying to do. In his scenario, there is *no way* to have Struts create the form bean for him automagically. -- Martin Cooper > capture any submit as we process the associated form (read: we check > for an existing form and instantiate one if it does not > exist) before we > populate. One of us is confused. My bet is that you misinterpreted > what I was getting at. Again, my sole point was that Struts > will create > forms for a person if they simply connect the dots between > the form and > the action so that Struts is aware that it needs to be done. > > >One way of creating the form bean is RequestUtils.createActionForm(). > > > >-- > >Martin Cooper > > > -- > Eddie Bush > > > > > -- > To unsubscribe, e-mail: > <mailto:struts-user-unsubscribe@;jakarta.apache.org> > For additional commands, e-mail: > <mailto:struts-user-help@;jakarta.apache.org> > > -- To unsubscribe, e-mail: <mailto:struts-user-unsubscribe@;jakarta.apache.org> For additional commands, e-mail: <mailto:struts-user-help@;jakarta.apache.org>

