----- Original Message -----
From: "Corey Klaasmeyer" <[EMAIL PROTECTED]>
To: "'Struts Users Mailing List'" <[EMAIL PROTECTED]>
Sent: Thursday, February 21, 2002 4:09 AM
Subject: RE: ActionForm and default values


> This is probably a common question, which should have a corresponding FAQ
> 'How do I pre-populate an HTML form using ActionForm?' I think the answer
is
> you either set the values in the constructor of your ActionForm subclass
> implementation, but this wasn't immediately obvious to me either. You can
> infer the answer from this paragraph the user guide:

What use is this if your prepopulation data comes from the session or
application (ServletContext) objects?  You don't have access to either from
the form beans constructor.

> "The form tag renders an HTML <form> element, based on the specified
> attributes. It also associates all of the fields within this form with a
> session scoped FormBean that is stored under the key logonForm. The Struts
> developer provides the Java implementation of this form bean, subclassing
> the Struts class ActionForm. This bean is used to provide initial values
for
> all of the input fields that have names matching the property names of the
> bean. If an appropriate bean is not found, a new one will be created
> automatically, using the specified Java class name."
>
> I think you can specify non-dynamic values for a form bean in the
> struts-config file if you extend DynaActionForm:
>
> * Use the standard class "org.apache.struts.action.DynaActionForm",
>   which will be populated with properties defined by <form-property>
>   elements nested inside the <form-bean> element.  Note that you can
>   also set initial values in the <form-property> element; these are
>   used in the default implementation of reset().  Intelligent defaults
>   take care of the most common cases.  Note that the default validate()
>   method does NO checking, so you will need to do everything in your
>   Action.
>
> Corey
>
> -----Original Message-----
> From: Jim Crossley [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, February 20, 2002 10:38 AM
> To: Struts Users Mailing List
> Subject: Re: ActionForm and default values
>
>
> Ian Beaumont <[EMAIL PROTECTED]> writes:
>
> > Ok - I want to select an item on one page which will take me to
> > another page where I can edit the selected item.
>
> Sounds common enough.
>
> > How do I pre-populate the form for the edit page in the action for
> > the selected item as the form won't exist at this point?
>
> As long as you have the "name" attribute set correctly for the
> appropriate <action> element of struts-config, the formbean will
> always exist!  The controller servlet creates it for you.
>
> -- Jim
>
> > -----Original Message-----
> > From: Jim Crossley [mailto:[EMAIL PROTECTED]]
> > Sent: 20 February 2002 16:06
> > To: Struts Users Mailing List
> > Subject: Re: ActionForm and default values
> >
> >
> > It's pretty simple, I think.
> >
> > 1) The formbean is passed to the action's perform method by the Struts
> > controller.
> >
> > 2) The action populates the formbean (ReportDataForm) from the value
> > object (ReportData).
> >
> > 3) The action returns the appropriate ActionForm to render the view.
> >
> > 4) The view (ReportData.jsp) need look no more complicated than this:
> >
> > <html:form action="/reportAction">
> >   <html:text property="reportName"/>
> > </html:form>
> >
> > -- Jim
> >
> > Ian Beaumont <[EMAIL PROTECTED]> writes:
> >
> > > This question seems to be going around and around this mailing list
> > and
> > > no
> > > one has produced an answer.
> > >
> > > -----Original Message-----
> > > From: Dua, Amit [mailto:[EMAIL PROTECTED]]
> > > Sent: 20 February 2002 15:46
> > > To: 'Struts Users Mailing List'
> > > Cc: '[EMAIL PROTECTED]'
> > > Subject: RE: ActionForm and default values
> > >
> > >
> > > But then how will I set the default values
> > >
> > > amit
> > >
> > > -----Original Message-----
> > > From: Keith [mailto:[EMAIL PROTECTED]]
> > > Sent: Wednesday, February 20, 2002 10:36 AM
> > > To: Struts Users Mailing List
> > > Subject: Re: ActionForm and default values
> > >
> > >
> > > try removing the value= attribute from your <html: text.
> > > hope that helps.
> > >
> > > --- "Dua, Amit" <[EMAIL PROTECTED]> wrote:
> > > > Hi
> > > >
> > > > I want to populate my page with default value
> > > >
> > > > So, in order to do that
> > > > I have a value object (ReportData), ReportDataForm (Form Bean)
> > > >
> > > > I populate the Value object through one of the Action classes and
> > then
> > > do
> > > a
> > > > Action Forward to one of the Jsp namely ReportData.jsp
> > > >
> > > > In the ReportData.jsp I do following
> > > >
> > > > ReportData reoportData =
> > > (ReportData)request.getAttribute("reportdata");
> > > > <html:form action="reportAction.do">
> > > > <html:text property="reportName"
> > > value="<%=reportData.getReportName()%>"/>
> > > > ..................
> > > > ..............
> > > >
> > > >
> > > > I do all the validation In ReportAction class which is mapped to
> > > > reportAction.do
> > > >
> > > > But when there is an error In the field , I am not able to get the
> > > value
> > > > populated for the text field.
> > > >
> > > >
> > > > Is there something wrong I am doing.
> > > > Or is there any other better way of doing this thing..
> > > >
> > > >
> > > > Amit
> > > >
> > > >
> > > > --
> > > > To unsubscribe, e-mail:
> > > <mailto:[EMAIL PROTECTED]>
> > > > For additional commands, e-mail:
> > > <mailto:[EMAIL PROTECTED]>
> > > >
> > >
> > >
> > > =====
> > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > > Search the archive:-
> > > http://www.mail-archive.com/struts-user%40jakarta.apache.org/
> > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > > Keith Bacon - Looking for struts work - South-East UK.
> > > phone UK 07960 011275
> > >
> > > __________________________________________________
> > > Do You Yahoo!?
> > > Yahoo! Sports - Coverage of the 2002 Olympic Games
> > > http://sports.yahoo.com
> > >
> > > --
> > > 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]>
> >
> > --
> > 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]>
>
> --
> 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