You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Keith Hyland <kh...@aol.com> on 2004/03/08 17:10:59 UTC

internationalizing html:option tag, force to lookup resource file

Hi,

Sorry if this is a repeat post, but I don't think the original went through.

I'm just starting into looking at struts.

Is it possible to generate a select/ options list using the html:select 
and html:option(s) tags, where the labelProperties (i.e. the text 
displayed on the end users web browser) get looked up from a resource 
file, instead of been displayed directly.

e.g.

if we have a collection bean made up of 3 namevalue pairs {(1,one), 
(2,two), (3,three)}

     <html:select property="partnerId">
          <html:options collection="list.bean" property="name" 
labelProperty="value"/>
     </html:select>

produces

<select>
     <option value="1">one</option>
     <option value="2">two</option>
     <option value="3">three</option>
</select>

This produces a select box with the English values appearing on the web 
page regardless of the locale that is set.

What I want is for the one, two and three to be keys into the 
applicationResources.properties so that different locales can be setup.

If this is not available would it be useful to write a tag to do this?

Cheers,
Keith


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: internationalizing html:option tag, force to lookup resource file

Posted by Niall Pemberton <ni...@blueyonder.co.uk>.
The <html:option> tag already has this facility - you can specify a "key"
attribute.

If however you want yo use the <html:optionsCollection> tag, there was an
identical discussion on this list recently. You can find the start of that
thread here..

http://www.mail-archive.com/struts-user@jakarta.apache.org/msg93939.html

Niall

----- Original Message ----- 
From: "Keith Hyland" <kh...@aol.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Monday, March 08, 2004 4:10 PM
Subject: internationalizing html:option tag, force to lookup resource file


> Hi,
>
> Sorry if this is a repeat post, but I don't think the original went
through.
>
> I'm just starting into looking at struts.
>
> Is it possible to generate a select/ options list using the html:select
> and html:option(s) tags, where the labelProperties (i.e. the text
> displayed on the end users web browser) get looked up from a resource
> file, instead of been displayed directly.
>
> e.g.
>
> if we have a collection bean made up of 3 namevalue pairs {(1,one),
> (2,two), (3,three)}
>
>      <html:select property="partnerId">
>           <html:options collection="list.bean" property="name"
> labelProperty="value"/>
>      </html:select>
>
> produces
>
> <select>
>      <option value="1">one</option>
>      <option value="2">two</option>
>      <option value="3">three</option>
> </select>
>
> This produces a select box with the English values appearing on the web
> page regardless of the locale that is set.
>
> What I want is for the one, two and three to be keys into the
> applicationResources.properties so that different locales can be setup.
>
> If this is not available would it be useful to write a tag to do this?
>
> Cheers,
> Keith
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org