struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeromy Evans <jeromy.ev...@blueskyminds.com.au>
Subject Re: Selecting over Static Maps from Resource Bundle
Date Tue, 04 Mar 2008 01:38:10 GMT
Dave Newton wrote:
> --- Chris Pratt <thechrispratt@gmail.com> wrote:
>   
>> Is it possible to place the data for the list attribute of an
>> <s:select> tag in a resource bundle (so that it can be
>> internationalized)?  I have tried adding the data to my
>> application.properties file:
>>
>> gender.map='FEMALE':'Female','MALE':'Male'
>>
>> Then referencing it in the JSP as:
>>
>> <s:select name="gender" id="gender" list="#{(getText('gender.map'))}"/>
>>     
>
> You could try something like #{%{getText...}} but I suspect that wouldn't
> work.
>
> You might also try creating it with a specific map type:
>
> #@java.util.LinkedHashMap@{ getText... }
>
> and see if that affects statement parsing. I suspect that won't work either,
> though.
>
> You could also do the work in the action, converting the text values into a
> real list/map.
>
> Dave
>
>
>   

Interesting little problem... so you want to call a method, get the 
string result and have OGNL evaluate that string as if it were a Map.
Sounds plausible, but I don't like your chances.  I throw a breakpoint 
in ListUIBean to see what object you're getting from OGNL.

My guess is based on Dave's second one:

<s:select name="gender" id="gender" list="#@java.util.LinkedHashMap@{(getText('gender.map'))}"/>

parenthesis to ensure getText is evaluated first (should be anyway)
Then construct a map [1] using the string as the parameter

[1] 
http://www.ognl.org/2.6.9/Documentation/html/LanguageGuide/collectionConstruction.html#mapConstruction



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


Mime
View raw message