You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Dries Plessers <ap...@pandora.be> on 2003/10/08 19:58:03 UTC
message-resources
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 !
Re: message-resources
Posted by Vic Cekvenich <ce...@baseBeans.com>.
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: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: message-resources
Posted by Joe Germuska <Jo...@Germuska.com>.
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.
--
Joe Germuska
Joe@Germuska.com
http://blog.germuska.com
"We want beef in dessert if we can get it there."
-- Betty Hogan, Director of New Product Development, National
Cattlemen's Beef Association
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org