選択ボックスを使用して JSF アプリケーションのロケールを動的に変更しようとしています。しかし、faces-config.xml の設定を変更した場合にのみ、ロケールが変更されます。これで私を助けて..enter code here
<application>
<locale-config>
<default-locale>en</default-locale>
</locale-config>
<resource-bundle>
<base-name>com.messages.messages_en</base-name>
<var>msg</var>
</resource-bundle>
</application>
私の価値観チェンジリスナーは、
public void countryLocaleCodeChanged(ValueChangeEvent e){
String newLocaleValue = e.getNewValue().toString();
//loop country map to compare the locale code
for (Map.Entry<String, Object> entry : countries.entrySet()) {
if(entry.getValue().toString().equals(newLocaleValue)){
FacesContext.getCurrentInstance()
.getViewRoot().setLocale((Locale)entry.getValue());
}
}