Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Kjeld Sigtermans
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic