首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2EE开发 >

JSF中怎么用程序更改语言环境

2012-03-09 
JSF中如何用程序更改语言环境?我的代码:JSF中的代码:h:formh:commandLink actionListener#{FuncBean.

JSF中如何用程序更改语言环境?
我的代码:
JSF中的代码:
  <h:form>
  <h:commandLink actionListener="#{FuncBean.changLangEnv}" value="中文" />
  <h:outputLabel value=" "/><h:outputLabel value=" "/>
  <h:commandLink actionListener="#{FuncBean.changLangEnv}" value="English" />
  </h:form>
事件监听函数中的代码:
  public void changLangEnv(ActionEvent ae){
  HtmlCommandLink hlink=(HtmlCommandLink)ae.getComponent();
  String lang=(String)hlink.getValue();
  if(lang.equals("English")){
  FacesContext.getCurrentInstance().getApplication().setDefaultLocale(new Locale("en_US"));
  }else if(lang.equals("中文")){
  FacesContext.getCurrentInstance().getViewRoot().setLocale(new Locale("zh_CN"));
  }
   
  }
编译通过,运行没反应。
请大家指教,另外请问从哪里可下载jsf的api参考

[解决办法]
顶一下,
FacesContext.getCurrentInstance().getViewRoot().setLocale(Locale.US);
[解决办法]

热点排行