Sam Brannen
May 19th, 2006, 07:11 PM
Hi everybody,
In JavascriptValidatorTag, there is a bug regarding the retrieval of the current locale. The existing code (spring modules 0.2 and 0.3) retrieves the locale in the following manner:
Locale locale = pageContext.getRequest().getLocale();
This works if you are relying on the "accepted languages" header sent by the browser; however, if you use Spring's support for locale resolution (e.g., LocaleResolver, etc.), you then need to replace the above code with the following:
final Locale locale = RequestContextUtils.getLocale((HttpServletRequest) pageContext.getRequest());
If one of the core developers wishes that I create a Jira issue for this, just let me know.
Thanks,
Sam
p.s. If you would like to see a concrete example that displays this error, simply download and test my example web app for spring modules - wizard validator. Link to forum post:
http://forum.springframework.org/showpost.php?p=62146&postcount=10
Steps to recreate this bug:
1) Change the current language via the "EN" or "DE" links (upper right navigation) to a language that is not your first listed "accepted language" in your browser.
2) Click "continue" (or "weiter") without filling out the fields (assuming JavaScript is enabled, of course).
You will then see that the error messages displayed via JavaScript do not reflect the currently selected language. My above code suggestion fixes this problem. ;)
In JavascriptValidatorTag, there is a bug regarding the retrieval of the current locale. The existing code (spring modules 0.2 and 0.3) retrieves the locale in the following manner:
Locale locale = pageContext.getRequest().getLocale();
This works if you are relying on the "accepted languages" header sent by the browser; however, if you use Spring's support for locale resolution (e.g., LocaleResolver, etc.), you then need to replace the above code with the following:
final Locale locale = RequestContextUtils.getLocale((HttpServletRequest) pageContext.getRequest());
If one of the core developers wishes that I create a Jira issue for this, just let me know.
Thanks,
Sam
p.s. If you would like to see a concrete example that displays this error, simply download and test my example web app for spring modules - wizard validator. Link to forum post:
http://forum.springframework.org/showpost.php?p=62146&postcount=10
Steps to recreate this bug:
1) Change the current language via the "EN" or "DE" links (upper right navigation) to a language that is not your first listed "accepted language" in your browser.
2) Click "continue" (or "weiter") without filling out the fields (assuming JavaScript is enabled, of course).
You will then see that the error messages displayed via JavaScript do not reflect the currently selected language. My above code suggestion fixes this problem. ;)