joval
joval

Reputation: 516

messages bundle with dynamic key in struts2

I have a problem with displaying a message from messages bundle with key passed as a tag argument. Since version 2.3, struts tags don't allow runtime expressions.

I have a custom tag with fieldName parameter and I want to retrieve a message with use of this parameter, like in previous versions of the framework: <s:text name="${fieldName}"/>

Neither <s:text> nor <s:property> work for me.

I tried every solution found in web, but nothing works.

Upvotes: 1

Views: 516

Answers (1)

Aleksandr M
Aleksandr M

Reputation: 24406

Use OGNL or use <s:set> tag

<s:set name="fname">
  ${fieldName}
</s:set>

<s:text name="%{#fname}"/>

Upvotes: 4

Related Questions