I store this kind of info in db, and return it as collection to optionsCollection tag.
hth,
.V




At 7:58 PM +0200 10/8/03, Dries Plessers wrote:

I have a file (countries.properties) which contain all value and representations.
e.g.:
AD=ANDORRA
AG=ANTIGUA
AM=ARMENIA
....
How can use this resource file to create a html:select where the value equals the countryname and the representation the 2letters within the struts framework ?


Thx !


I would suggest writing an implementation of org.apache.struts.action.PlugIn. When initialized, the plugin could read in the properties file and create a list of org.apache.struts.util.LabelValueBean objects and put that list into the servlet (application) context so that it's available to anyone who needs it.

Using the "set-property" element in struts-config, you could make it so both the source of the properties file and the name under which it's stored in the servlet context are externally configurable, and then you'd have a generally reusable PlugIn which could take any Properties file and do this conversion to a List of LabelValue beans. Such a PlugIn might even be a welcome contribution to the Struts project, or perhaps the SourceForge project at struts.sourceforge.net.

Even if you have to read the documentation on all this stuff, you could probably write it in a couple of hours at most.

Joe

PS the only hitch would probably be that the Properties file wouldn't return its members in a reliable order, so if you wanted things alphabetically, you might have to add some mechanism to create a sorted list from the collection of LVBeans. That wouldn't be much harder, but it would be one more step.



--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to