Struts 2 - s:select using Map

16,887

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)" />
Share:
16,887
Panos
Author by

Panos

Updated on July 29, 2022

Comments

  • Panos
    Panos almost 2 years

    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?

  • Panos
    Panos about 12 years
    I found it before I saw this answer and yes I confirm this is the solution! Thanks! <s:select list="myMap" listKey="key" listValue="getTranslation(value)" />