You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Wendy Smoak <We...@asu.edu> on 2003/10/08 20:23:02 UTC
RE: message-resources
Dries Plessers [mailto:aplessers@pandora.be] 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 ?
Properties implements Map, so if you do the usual to read in a
.properties file, along the lines of...
ClassLoader cl = MyAction.class.getClassLoader();
Properties props = new Properties();
InputStream input = cl.getResourceAsStream( "countries.properties" );
props.load( props ) ;
Then you should be able to use the 'props' object with the <html:select>
tag. Not that I've tried it, but it seems like it should work.
Since countries will probably not change during runtime, you could do
this in a ContextListener and put the Map in Application scope. That
way it'll be there for everyone who needs it.
--
Wendy Smoak
Applications Systems Analyst, Sr.
Arizona State University, PA, IRM
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-dev-help@jakarta.apache.org