In Struts 1.0.1, init() is called if the ActionForm is instantiated by
the JavaServer Page. In Struts 1.0, this only happens when the
ActionForm is instantiated by the ActionServlet. Of course, any default
values assigned to the fields in the ActionForm class itself will be
available in either case. The recommended control flow is to go through
an Action first, and populate the ActionForm there. Populating the
ActionForm from the JSP is a Model 1 strategy.

-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Custom Software ~ Technical Services.
-- Tel +1 716 737-3463
-- http://www.husted.com/struts/


David Lauta wrote:
> 
> Is there a method in the framework that gets invoked allowing you to
> initialize the ActionForm before the JSP is displayed?
> 
> Brett Porter wrote:
> 
> > That's an interesting design decision. I have always had a form bean and
> > then another bean containing the actual data. The action copies it across,
> > processes it, and stores it.
> >
> > The reason I'd do it that way is that I imagine the message is a "business
> > class", and you don't really want you model "polluted" by extending an
> > ActionForm. Maybe I've been living in OOAD land too long though ;)
> >
> > This can trip you up though - at least once I have added the form element,
> > added it to the bean, added it to the form bean, and forgetten to do the
> > setter in the action :) The way around that is probably a function in the
> > form bean that says "fill my business class" and "fill from a business
> > class". Actually, I might put that in my todo list :D
> >
> > Cheers,
> > Brett
> >
> > -----Original Message-----
> > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> > Sent: Thursday, 29 November 2001 12:48 PM
> > To: Struts Users Mailing List
> > Subject: Re: Hidden Field in a form. Do I use struts taglib or vanilla
> > ht ml?
> >
> > The data I am storing in the bean is logically different from what the
> > hidden field value is,  I have a message
> >
> > message
> > {
> >    string  Recipent
> >    string  From
> >    string  MessageBode
> > }
> >
> > And the hidden field is   action=sendMessage and I didn't think that
> >
> > message
> > {
> >    string  Action
> >    string  Recipent
> >    string  From
> >    string  MessageBode
> > }
> >
> > would be the correct thing to do, but I am open to suggestions.  If it
> > works out easier to put this extra field in my message formbean then I
> > will do it.  What do you think?
> >
> > Cheers
> >
> > Tony
> >
> > Brett Porter wrote:
> >
> > > The question I ask is why you wouldn't put it in your form bean?
> > >
> > > I prefer form.getAction() over httpServletRequest.getParameter( "action" )
> > > any day! :)
> > >
> > > -----Original Message-----
> > > From: Yee Keat [mailto:[EMAIL PROTECTED]]
> > > Sent: Thursday, 29 November 2001 12:36 PM
> > > To: Struts Users Mailing List
> > > Subject: Re: Hidden Field in a form. Do I use struts taglib or vanilla
> > > html?
> > >
> > >
> > > Yup, using the taglib makes it compulsory to have that field in your
> > > FormBean
> > >
> > > On Thursday 29 November 2001 09:25 am, you wrote:
> > >
> > >>Hi
> > >>
> > >>I want to include a hidden field in a form which I have.  I do not want
> > >>this information to be included in the formbean which is defined for
> > >>this page.  How can I do this?  Should I just use plain html
> > >>
> > >><INPUT TYPE=hidden NAME=action VALUE=send>
> > >>
> > >>without using the html taglib supplied with struts?
> > >>
> > >>Cheers
> > >>
> > >>Tony
> > >>
> > >
> >
> > --
> > To unsubscribe, e-mail:
> > <mailto:[EMAIL PROTECTED]>
> > For additional commands, e-mail:
> > <mailto:[EMAIL PROTECTED]>
> 
> --
> Thank you,
> David Lauta
> [EMAIL PROTECTED]
> (561)272-2698
> (561)289-0502 cell
> 
> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to