I don't think the option tag will work like that. You can either put your
Hashset in some scope, call it something like "persons" and then use the

<html:options collection="persons" property="name" />
<!-- you might need to use labelProperty="name" if you want getName() to be
the display value and use something like property="id" if getId() is the
value to be sent to the server -->

Or you could have two methods on your form, one that returns a collection of
Strings for the label and another that returns a collection of Strings for
the value. If they are the same then what you are doing <html:options
property="persons" /> will work but you need to change the getPersons method
to return a collection of strings instead of beans.

The options documentation is confusing but giving the tag any more
flexibility would only make it that much more complex. The fact that the
attributes "property" and "labelProperty" mean two different things
depending on whether "collection" is used makes it confusing. You basically
need the first usage with an alternate way of specifying the collection.

Disclaimer: I could be confused myself.

Hal

> -----Original Message-----
> From: Mikkel Bruun [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, May 24, 2001 6:13 AM
> To: '[EMAIL PROTECTED] '
> Subject: Options tag problem
>
>
>
> Hi Guys!
>
> I have an ActionForm which contains a HashSet named Persons that
> contains
> several instances of Person
>
> In my jsp i want a dropdown box showing the Person's name.
>
> code:
> <html:options property="persons" />
>
> This points to the getPersons() method in the ActionForm
> that'll return
> a
> HashSet...
> Now I need to access each elements getName() method, but
> looking through
> the
> options tag code, it seems like it can only handle Collections of
> Strings....is this correct????
>
> Any suggestions on how to solve it???
>
> thanks
>
> Mikkel

Reply via email to