struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris <>
Subject Re: s:if and locale
Date Tue, 10 Sep 2013 09:43:17 GMT

When you said : "But I used your solution" Did you mean with parameters in the links like
the sample ?
This sample works with the second jsp, called register.jsp , with links and parameter given
in the first jsp , called index.jsp
like this :

Please register for our prize drawing.

I don't know if I'll have to work with country's parameter in links....

But for your example, do you have to find the user's country ? I mean with his browser or
when he send his parameter himself with the link ( like the sample)

Or do you use the server's value , Locale.getDefault(), the same for everybody ?

 Thanks for your solution .
<s:if test="%{locale.language == 'en_US'}"> 
did not work! I don't know why !

But I used your solution which seems much better tahn mine !

~~Alireza Fattahi

From: Chris <>
To: Struts Users Mailing List <>; Alireza Fattahi <>;
Chris <> 
Sent: Monday, 9 September 2013, 7:49
Subject: Re: s:if and locale

Hello ,
Could you please write how do you define 

The locale is = ${locale}  //Here the correct locale is displayed!
I see in my browser  ( even source code ) 

The locale is =   //Here the correct locale is displayed!

Please try this expresion and tell us if it works
<s:if test="%{locale.language == 'en_US'}"> 

You will have to test your "locale" it in every jsp ? 
Couldn't you use for example, a file and struts.xml
<constant name="struts.custom.i18n.resources" value="global" />

in the file :cssfile=englshstyle.css
in the file :cssfile=spanishstyle.css
in yourjsp : <link href='<s:text name="cssfile" />' rel="stylesheet" type="text/css"
It works with sample
but the links are with parameter like .... action?request_locale=en
and you will need many properties file  

I have used the strtuts I18n feature for managing the localization.  The site works fine
and the messages are selected from correct resource bundels.
I have this problem....
I want to change css base on the user locale.
So I use below code in jsp:
The locale is = ${locale}  //Here the correct locale is displayed!
<s:if test="%{locale == 'en_US'}"> //This condition is always false
     <link href="site-en.css" rel="stylesheet" type="text/css" />
   <link href="site-other.css" rel="stylesheet" type="text/css" />

No matter what the locale value is, always the else condition is triggered !!
The jsp out puts 
The locale is=en_US
   <link href="site-other.css" rel="stylesheet" type="text/css" />

When I see the Struts ValueStack with <s:debug/> the locale value is correct and is
what it has too.

Is there any thing wrong with my test conditin please help!

~~Alireza Fattahi
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message