You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "JB (JIRA)" <ji...@apache.org> on 2012/05/29 23:26:23 UTC
[jira] [Comment Edited] (WW-3048) %{getText('login.username')}
always uses the en_US locale instead of ActionContext's locale
[ https://issues.apache.org/jira/browse/WW-3048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13285146#comment-13285146 ]
JB edited comment on WW-3048 at 5/29/12 9:26 PM:
-------------------------------------------------
After a cursory configuration using Struts 2 version 2.1.6 running on Tomcat 7.0.11 I am unable to reproduce -- yet.
I will have another go and deploy to my Tomcat 6.x instance.
Note: I am not using Tiles or Spring, merely naked Struts 2.
was (Author: jeffblack360):
After a cursory configuration using Struts 2 version 2.0.9 running on Tomcat 7.0.11 I am unable to reproduce -- yet.
I will have another go and deploy to my Tomcat 6.x instance.
Note: I am not using Tiles or Spring, merely naked Struts 2.
> %{getText('login.username')} always uses the en_US locale instead of ActionContext's locale
> -------------------------------------------------------------------------------------------
>
> Key: WW-3048
> URL: https://issues.apache.org/jira/browse/WW-3048
> Project: Struts 2
> Issue Type: Bug
> Components: Other
> Affects Versions: 2.1.6
> Environment: Linux(Ubuntu) 2.6.24-19-generic; Sun Java 1.5.0_16; Tomcat 6.0.18; Intel x86 32-bit CPU; integrated with Tile 2.0.6 and Spring Framework 2.5.5
> Reporter: jason
> Fix For: 2.5
>
>
> I have two property files: Messages.properties (the default locale) and Messages_de.properties (German locale). But when i use the following tag with the browser's locale set to de_DE:
> <s:textfield id="username" name="username" label="%{getText('login.username')}" />
> The output always uses the default locale's property file, i.e. Messages.properties. I even tries to use the request_locale like this:
> http://myserver:8080/mycontext/myaction.action?request_locale=de
> But the result is the same!
> Then I tries to use <s:debug/> on the jsp page, and i can see the locale property for 'myaction' object in valueStack is set to 'en_US', but the com.opensymphony.xwork2.ActionContext.locale is set to de_DE.
> Then I copies the code from Debug.java and put it to myaction's execute() method:
> ValueStack stack = ActionContext.getContext().getActionInvocation().getStack();
>
> Iterator iter = stack.getRoot().iterator();
> List stackValues = new ArrayList(stack.getRoot().size());
> OgnlReflectionProvider reflectionProvider = new OgnlReflectionProvider();
> OgnlUtil ognlUtil = new OgnlUtil();
> reflectionProvider.setOgnlUtil(ognlUtil);
> while (iter.hasNext()) {
> Object o = iter.next();
> Map values;
> try {
> values = reflectionProvider.getBeanMap(o);
> } catch (Exception e) {
> throw new StrutsException("Caught an exception while getting the property values of " + o, e);
> }
> System.out.print(values);
> }
> Here i can see the locale property for 'myaction' object in valueStack is set to de_DE, this is correct.
> My question is why the <s:debug/> output for myaction object's locale property is always 'en_US' but my copied code outputs 'de_DE'? and does the "%{getText('login.username')} ognl expression use the ActionContext's locale?
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira