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?
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.
Kjeld Sigtermans - SCJP 1.4 - SCWCD 1.4
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