更改语言后,view id为null

时间:2013-02-08 12:25:57

标签: jsf-2 primefaces

我使用的是PrimeFaces 3.4.1,MyFaces 2.0.7,Websphere Application Server 7.

我正在使用带有3个标签的 p:tabView 组件。当我在 first tab 中更改语言时,应用程序正常运行没有任何错误。但如果我去 second or third tab - >改变语言 - >然后导航到任何一个非活动选项卡。我得到以下异常。

 Caused by: java.io.FileNotFoundException: Facelet /.xhtml?REQUIRED=false not found at: file:/opt/IBM/WebSphere/AppServer/profiles/mblade140/installedApps/mblade140/ldapmanager-application-ear.ear/ldapmanager-application-web.war/.xhtml?REQUIRED=false
[08.02.13 12:55:42:349 CET] 00000090 SystemErr     R    at org.apache.myfaces.view.facelets.impl.DefaultFaceletFactory._createFacelet(DefaultFaceletFactory.java:286)

以下是我为 p:tabView 组件

编写代码的方法
    <h:form id="headerForm" prependId="false">
    <h:inputHidden id="activeTabIndexId" value="#{AppUserManagementBean.activeTabIndex}" />
    <p:remoteCommand update="tabView:fieldAppUserMgmt,tabView:filterApps,tabView:filterRoles,tabView:panel_grid_newuser" 
            name="onTabChange" 
            process="activeTabIndexId,@this" 
            actionListener="#{AppUserManagementBean.onTabChanged}" >
            <f:param name="REQUIRED" value="false"/>
    </p:remoteCommand>

    <p:tabView id="tabView" dynamic="true" cache="true" activeIndex="#{AppUserManagementBean.activeTabIndex}"
        onTabChange="document.getElementById('activeTabIndexId').value = index;onTabChange();">

        <p:tab id="userManagementTab" title="#{msgs.UserManagement_Title}">
            <ui:include src="UserManagement.xhtml" />
        </p:tab>
        <p:tab id="applicationUserManagementTab"
            title="#{msgs.AppUserMgmt_Title}">
            <ui:include src="AppUserManagement.xhtml" />
        </p:tab>
        <p:tab id="userGroupManagementTab"
            title="#{msgs.UserGroupMgmt_Title}">
            <ui:include src="UserGroupManagement.xhtml" />
        </p:tab>
    </p:tabView>
</h:form>

这是我为改变支持bean中的语言而编写的代码。在 p:selectOneMenu

中更改语言时会调用此方法
    public void setLocale(String selectedLocale) {
    System.out.println("Changing locale to "+selectedLocale);
    this.locale = selectedLocale;
    for (Map.Entry<String, Locale> entry : countryMap.entrySet()) {
        if (entry.getValue().toString().equals(selectedLocale)) {
            FacesContext.getCurrentInstance().getViewRoot()
                    .setLocale((Locale) entry.getValue());
        }
    }
}

我在这里做错了什么?有人可以阐明这一点。

1 个答案:

答案 0 :(得分:0)

搞定了......

问题在于 p:tabView 我设置了 dynamic=true 。我已移除 dynamic=true 。语言更改选项现在正在运行。我不知道为什么......