Sorry to hijack the thread, but I've been having slightly different
issues with the select tag and a Map as the option list source.  As
you mentioned, the docs state "If the list is a Map (key, value), the
Map key will become the option 'value' parameter and the Map value
will become the option body."  However, it appears that the reverse is
occurring for a given tag like:

<@s.select labelposition='top' id='resourceType' label='Resource type'
name='resourceType' list='%{resourceTypes}' emptyOption='true'
cssClass="required" />

where resourceTypes is a Map of Strings to an enum type.  When this
gets rendered the enum (value) is put in the option value parameter
and the String key is put in the option body.

It's easily fixed by reversing the mapping, but just wanted to ask in
case the docs are wrong or there's a bug in the code.

Thanks!
Allen

On Tue, Aug 11, 2009 at 6:47 AM, Stephen Turner<stur...@mit.edu> wrote:
> Hello all,
>
> I'm playing with the Struts 2 <s:select> tag, trying to use a Map as the
> backing collection for the options list. This is Struts 2.0.11.
>
> From the docs: "Iterable source to populate from. If the list is a Map (key,
> value), the Map key will become the option
>  'value' parameter and the Map value will become the option body."
>
> So I have a Map, with values of type PayPeriod, which is a simple Java bean.
> What I get in the rendered values is the String representation of the class
> ( "yadda.yadda.payper...@dfg65" ). Is it possible to code something in the
> tag to get a PayPeriod bean attribute showing as the rendered value? I know
> I can cheat by defining a toString() method in the bean, but I wondered if
> there's a cleaner way of doing this.
>
> Thanks,
> Steve
>
> --
> Stephen Turner
> Senior Programmer/Analyst - SAIS
> MIT IS&T
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
>
>

-- 
Allen Lee
Center for the Study of Institutional Diversity [http://csid.asu.edu]
Arizona State University | P.O. Box 872402 | Tempe, Arizona 85287-2402
Office: 480.727.0401 | Fax: 480.965.7671

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org

Reply via email to