How to set the current locale in JSF using Javascript?
Hi I want to change the locale using javascript in the JS开发者_如何学GoF.Can anyone give example.
Just let JavaScript send a HTTP request in some way (form.submit()
, window.location
, ajax, etc) so that JSF is able to do
String locale = getItAsRequestParameterOrSomething(); // "en", "en_US", etc
FacesContext.getCurrentInstance().getViewRoot().setLocale(new Locale(locale));
You can find a kickoff example which does that by a dropdown which is submitted by JS in this answer: Localization in JSF, how to remember selected locale per session instead of per request/view
精彩评论