Reputation: 31
In my jsp, I have a label inside an iterator over a list of objects which have a "text" property:
<s:iterator value="survey.questions">
<s:label for="d_%{id}" value="%{text}"></s:label>
.....
<s:iterator/>
Now, since I want to localize the text inside the label, I added a property for every single language I support (textEN, textIT, etc...), and so I want the property name to be read from a local variable I previously set in the page, for example with:
<s:set var="loc" value="textEN" />
I cannot manage to do this, I tried with the following expression
<s:label for="d_%{id}" value="%{#loc}"></s:label>
But it prints nothing.
Upvotes: 0
Views: 2688
Reputation: 31
SOLVED.
I had to add an id to the iterator
<s:iterator value="survey.questions" id="question">
and then directly access the property with this syntax:
<s:label for="d_%{id}" value="%{#question[#loc]}"/>
Thank you all.
Upvotes: 1
Reputation: 654
You must put the string into single quotes to stop struts from take this text as a variable name:
<s:set var="loc" value="'textEN'"/>
Now your %{#loc}
should work.
Upvotes: 0