Freek Segers wrote:
> 
> Hello,
> 
> I'm currently working on my first Struts application and I'm facing two problems.
> 
> First, I've created a custom tag that creates different types of HTML form fields.
> The number of fields generated varies and the names of the fields are dynamic.
> I can't figure out how to let Struts populate the ActionForm that's linked to the 
>Action that handles the form.
> I thought I read somewhere that you can use some feature of the JavaBean specs to 
>tell Struts what method to call (maybe by using PropertyDescriptors?), but I can't 
>find anything about this.

The controller uses reflection. If the ActionForm has a property that
matches the name of a parameter, it populates the property with the
parameter's value. 

There are also ways to use hashtables behind ActionForms. See 

http://jguru.com/forums/view.jsp?EID=567079



> Second, I don't know how I can restore any previously submitted values when the form 
>is shown for a second time, for example in case of a validation error. Do I have 
>access to the ActionForm from a custom tag implementation somehow? Or can I let the 
>ActionForm set properties in my custom tag?
> I've been looking at the source code for the Struts <html:select>-tag but found no 
>clues to how Struts manages to make the last submitted item selected when the form is 
>redisplayed.
> When I use the following Stuts HTML
> 
>  <html:select property="selectedDocTypeId">
>  <html:options collection="docTypeList" property="id" labelProperty="name"/>
>  </html:select>
> 
> how does the select-tag know which ActionForm bean it should use to get the selected 
>item. I've recompiled the select-tag with some debugging output and put it in my own 
>taglib, but the I get the Exception I expected: there is no form bean under the 
>default name used in the select-tag in pageContext.

It looks at the Action specified by the enclosing html:form, and uses
whatever ActionForm is specified by that Action. Alternatively, you can
specify the name of the bean yourself. 


> I'm really at a loss and I hope you can help me with this.
> 
> Thanks in advance,
> 
> Freek Segers

-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Building Java web applications with Struts.
-- Tel +1 585 737-3463.
-- Web http://www.husted.com/struts/

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

Reply via email to