Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Struts 2 - s:select using Map

In struts 2 I want to use s:select populated from a Map.
My map has values like "key1" , "value1" "key2" , "value2"

Keys are what I want to be posted (which are) but it diplays values. I don't want to show the values but the value returned form a method I use in others (like s:text) getTranslation("value1") and show that value.

If I try

<s:select ... list="myMap" listValue="getTranslation(myMap)">

It doesn't show anything, just empty boxes to select. How do I get the id of the iteration to populate to select so as to use something like:

<s:select ... list="myMap" listValue="getTranslation(myMap.get(  how do I get this id?   ))">

Or something similar?

like image 244
Panos Avatar asked May 03 '12 10:05

Panos


1 Answers

Rendering of

<s:select list="myMap" />

is equals to

<s:select list="myMap" listKey="key" listValue="value" />

then try the following

<s:select list="myMap" listValue="getTranslation(value)" />
like image 200
lschin Avatar answered Sep 30 '22 14:09

lschin