Win a copy of Rust Web Development this week in the Other Languages forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

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

 
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic