开发者

How to set the current locale in JSF using Javascript?

开发者 https://www.devze.com 2023-03-07 15:32 出处:网络
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 tha

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

0

精彩评论

暂无评论...
验证码 换一张
取 消