Hi I want to change the locale using javascript in the JSF.Can anyone give example.
Asked
Active
Viewed 720 times
1 Answers
3
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