You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Roxie Rochat <rr...@journee.com> on 2001/04/18 20:40:19 UTC

how to use a select option with a property from the form bean?

I would like to configure a form bean with a property that contains a
collection to be rendered as a select statement, but I can't get it to work.

If the options collection attribute is not specified, the docs say that you
can 
specify just the property:
"The value of this attribute is the name of a property of the
ActionForm bean associated with our form, which will return the collection."

What should this collection look like?  Can anyone point me at an example?

Thanks,
Roxie

Re: how to use a select option with a property from the form bean?

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Wed, 18 Apr 2001, Roxie Rochat wrote:

> I would like to configure a form bean with a property that contains a
> collection to be rendered as a select statement, but I can't get it to work.
> 
> If the options collection attribute is not specified, the docs say that you
> can 
> specify just the property:
> "The value of this attribute is the name of a property of the
> ActionForm bean associated with our form, which will return the collection."
> 
> What should this collection look like?  Can anyone point me at an example?
> 
> Thanks,
> Roxie
> 

On the "subscription.jsp" page of the Struts example application, you will
see one way to use this.  It assumes that an ArrayList of beans has been
stored under key "serverTypes", and that the beans have two properties:
  getLabel() to return the label
  getValue() to return the value

Now, the SELECT box is created like this:

  <html:select property="type">
    <html:options collection="serverTypes"
     property="value" labelProperty="label"/>
  </html:select>

Craig