wood burning stoves 2.0*
The moose likes Struts and the fly likes Struts2 select tag does not evaluate list values as resource bundle properties Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts2 select tag does not evaluate list values as resource bundle properties" Watch "Struts2 select tag does not evaluate list values as resource bundle properties" New topic
Author

Struts2 select tag does not evaluate list values as resource bundle properties

Kjeld Sigtermans
Ranch Hand

Joined: Aug 10, 2006
Posts: 125
Hi everyone,

I am using a Struts2 select tag like this:

The 'choices' are of type enum Choice, having a property getMessage returning resource bundle property keys like text.choices.choiceA, text.choices.choiceB, etc.
I'd like the select box to show the values I have configured in the package.properties bundle for these keys returned by Choice.getMessage, but instead it is literally showing the keys.

Does anyone know how to have struts select tag show resource bundle values?

Is this a template/theme thingie?

Kjeld Sigtermans - SCJP 1.4 - SCWCD 1.4
Kjeld Sigtermans
Ranch Hand

Joined: Aug 10, 2006
Posts: 125
Meanwhile I have found a solution to the problem by moving the bundle key/value translation to the Struts action class that is called before rendering the jsp. As the select tag is supposed to display an array of enum types, I have created a wrapper class for the enum type, which holds the enum type and a String message (I removed the message property from the enum). In the struts action class the collection is set up by filling it with the appropriate enums and their message strings: the latter are resolved by using the getText("[key]") method.
This way the select tag is presented a ready-filled collection of enums and their descriptions.

I found the wrapper necessary since it is not possible to put these dynamic descriptions in the enum definition, because getText can not be called from a static context.

Thanks.
 
 
subject: Struts2 select tag does not evaluate list values as resource bundle properties