You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Brian McSweeney <br...@aurium.net> on 2003/04/14 11:14:17 UTC

more internationalization questions

Hi all,

I've encountered several instances of a type of problem.
I have a form with drop down lists with info that is localized, eg, dates and countries.

I use the method Locale.getDisplayCountry( userLocale )

for each supported locale, which shows the country names in the user's 
locale. However, the user then will select one of the formatted strings. 
When the associated action receives the string it will be a localized string. 
How do I get back the country code for this localized string?

The same problem applies with dates. I can use DateFormatter to output the 
date in a certain language, but when the user selects the date in that language 
the string that is submitted I don't know how to create a date out of it again! 

A possible solution I've been thinking about is to pass a hidden parameter with the 
drop down lists which stays the same irrespective of language.

Any ideas?
thanks very much,
Brian

Re: more internationalization questions

Posted by Brian McSweeney <br...@aurium.net>.
excellent. That's exactly what I was looking for,
thanks Jason.


----- Original Message -----
From: "Jason Lea" <ja...@kumachan.net.nz>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Monday, April 14, 2003 11:48 AM
Subject: Re: more internationalization questions


> Brian McSweeney wrote:
> > Ah,
> >
> > The solution to my problem can be easily handled using the standard html
> > option tag:
> >
> >
> > <option value="80">8:00 PM</option>
> >
> > what confused me is that I use the html:options tag from struts as
follows
> >
> >    <html:select name="myForm" property="selectedTime">
> >     <html:options name="myForm" property="times" />
> >    </html:select>
> >
> > this sets the property selectedTime, in myForm, to be the
> > value selected in the drop-down box out of the collection "times". So
here
> > it seems that the displayed value is "times". But does this map directly
to
> > the standard option value tag?
> >
> > my problem is that I don't see a value tag. I'm getting confused by
this.
> >
> > Could it be done something like this:
> >
> >    <html:select name="myForm" property="selectedTime">
> >         <html:options
> >             name="myForm"
> > property="locales.getIsoCountry">locales.getDisplayCountry()
> >         </html:options>
> >    </html:select>
> >
> > sorry for the confusion :-(
>
> You want to use the 'labelProperty' and 'property' attributes:
>
> <html:select property="locale">
>    <html:options property="localeValues" labelProperty="localeLabels"/>
> </html:select>
>
> The 'property' becomes the value="" part which is returned to the server
> when the form is submitted.  The 'labelProperty' is what the user sees
> in the pull-down.
>
> Look here for more info...
> http://jakarta.apache.org/struts/struts-html.html#options
>
>
> --
> Jason Lea
>
>
> ---------------------------------------------------------------------
> 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


Re: more internationalization questions

Posted by Jason Lea <ja...@kumachan.net.nz>.
Brian McSweeney wrote:
> Ah,
> 
> The solution to my problem can be easily handled using the standard html
> option tag:
> 
> 
> <option value="80">8:00 PM</option>
> 
> what confused me is that I use the html:options tag from struts as follows
> 
>    <html:select name="myForm" property="selectedTime">
>     <html:options name="myForm" property="times" />
>    </html:select>
> 
> this sets the property selectedTime, in myForm, to be the
> value selected in the drop-down box out of the collection "times". So here
> it seems that the displayed value is "times". But does this map directly to
> the standard option value tag?
> 
> my problem is that I don't see a value tag. I'm getting confused by this.
> 
> Could it be done something like this:
> 
>    <html:select name="myForm" property="selectedTime">
>         <html:options
>             name="myForm"
> property="locales.getIsoCountry">locales.getDisplayCountry()
>         </html:options>
>    </html:select>
> 
> sorry for the confusion :-(

You want to use the 'labelProperty' and 'property' attributes:

<html:select property="locale">
   <html:options property="localeValues" labelProperty="localeLabels"/>
</html:select>

The 'property' becomes the value="" part which is returned to the server 
when the form is submitted.  The 'labelProperty' is what the user sees 
in the pull-down.

Look here for more info...
http://jakarta.apache.org/struts/struts-html.html#options


-- 
Jason Lea


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


Re: more internationalization questions

Posted by Brian McSweeney <br...@aurium.net>.
Ah,

The solution to my problem can be easily handled using the standard html
option tag:


<option value="80">8:00 PM</option>

what confused me is that I use the html:options tag from struts as follows

   <html:select name="myForm" property="selectedTime">
    <html:options name="myForm" property="times" />
   </html:select>

this sets the property selectedTime, in myForm, to be the
value selected in the drop-down box out of the collection "times". So here
it seems that the displayed value is "times". But does this map directly to
the standard option value tag?

my problem is that I don't see a value tag. I'm getting confused by this.

Could it be done something like this:

   <html:select name="myForm" property="selectedTime">
        <html:options
            name="myForm"
property="locales.getIsoCountry">locales.getDisplayCountry()
        </html:options>
   </html:select>

sorry for the confusion :-(



----- Original Message -----
From: "Brian McSweeney" <br...@aurium.net>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Monday, April 14, 2003 10:14 AM
Subject: more internationalization questions


Hi all,

I've encountered several instances of a type of problem.
I have a form with drop down lists with info that is localized, eg, dates
and countries.

I use the method Locale.getDisplayCountry( userLocale )

for each supported locale, which shows the country names in the user's
locale. However, the user then will select one of the formatted strings.
When the associated action receives the string it will be a localized
string.
How do I get back the country code for this localized string?

The same problem applies with dates. I can use DateFormatter to output the
date in a certain language, but when the user selects the date in that
language
the string that is submitted I don't know how to create a date out of it
again!

A possible solution I've been thinking about is to pass a hidden parameter
with the
drop down lists which stays the same irrespective of language.

Any ideas?
thanks very much,
Brian



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