Panos
Panos

Reputation: 7417

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?

Upvotes: 8

Views: 17756

Answers (1)

lschin
lschin

Reputation: 6811

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)" />

Upvotes: 16

Related Questions