• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Web coding help

brikis98

Diamond Member
We are using struts 1.2.4 at work and I'm having a problem with html:messages tag. In the attached code, you can see that for the property "warning", I'm trying to display all the errors in the locale ${locale} (set dynamically to en_US, ru_RU, es_MX, etc).

The error messages show up just fine, but the problem is that they are ALWAYS in English.

No matter what I set ${locale} to, or even if I hard-code something like locale="ru_RU", the text is always pulled from my english resource bundle. I know my other 14 resource bundles work fine, as the rest of my UI shows up correctly in any language I need.

Is this a bug with struts and if so, is there a workaround?

 
Originally posted by: Argo
I don't usually use html:messages, but try passing ${pageContext.request.locale} as the parameter.

The page we're building is displaying multiple languages at once and is encoded in unicode.

Depending on a drop-down the user chooses, we set the variable ${locale} to the desired locale and use the fmt:setLocale tag (and locale attributes where necessary) so that the proper resource bundles are picked. This works everywhere except with this html:messages tag.

In short, we're not explicitly setting ${pageContext.request.locale} anywhere, and it always seems to be english (which could be the problem, but why the hell is the html:messages tag ignore the locale attribute?).

How/where does ${pageContext.request.locale} get set?
 
ok, i think i finally figured it out.

1. In the action class, I had to add the lines (not positive both are necessary):

response.setLocale(locale);
setLocale(locale, l);

2. In the JSP, I had to remove the locale attribute from the html:messages tag. No idea why, but once it was gone, and the two lines above were added, all worked smoothly.
 
Back
Top