0

我正在使用 PrimeFaces3.3、MyFaces+CODI、OpenWebBeans 和 Tomcat7 开发 JSF Web 应用程序。

显示特定页面(所有后续页面操作)后,我收到重复的 Id 错误。用调试分析 viewroot,我真的找不到任何重复的 id,但我发现 'WindowContextIdHolderComponent' 的 id (j_id6) 被作为重复抛出。

自从我将 PARTIAL_STATE_SAVING 设置为“true”后,我就开始遇到这个问题。

我有一个包含选项卡的主视图,每个选项卡中都有菜单,每个菜单操作使用选项卡加载页面

下面是我的应用程序的代码和结构。

主页

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui">

<ui:composition template="/templates/simple3section.xhtml">

<ui:define name="headerarea">
    Banner Comes Here
</ui:define>
<ui:define name="contents">
<p:tabView dynamic="false" cache="false" id="mainTab">
    <p:tab title="Home">
        <ui:include src="employeehome.xhtml" />
    </p:tab>
    <p:tab title="Academics">
        <ui:include src="academicmain.xhtml" /> 
    </p:tab>
    <p:tab title="Transport">
        <ui:include src="transportmain.xhtml" />
    </p:tab>
    <p:tab title="Administration">
        <ui:include src="adminmain.xhtml" />
    </p:tab>
    <p:tab title="Finance" disabled="true">
        <ui:include src="financemain.xhtml" />
    </p:tab>
    <p:tab title="Shop" >
        <ui:include src="shopmain.xhtml" />
    </p:tab>        
</p:tabView>
</ui:define>    
</ui:composition>
</html>

Adminmain.xhtml 页面(标签页)

<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui"
xmlns:c="http://java.sun.com/jsp/jstl/core">
<h:head>

</h:head>
<h:body>
<div>
    <h:form>
        <p:menubar style="margin-bottom:5px;">
            <p:menuitem value="Employees" icon="ui-icon-star" ajax="true"
                actionListener="#{homeNavigationBean.setAdminPage('employeeinfo')}"
                update=":mainTab:adminContent">
            </p:menuitem>
            <p:menuitem value="Employee Authorization" icon="ui-icon-star" ajax="true"
                actionListener="#{homeNavigationBean.setAdminPage('authorization')}"
                update=":mainTab:adminContent">
            </p:menuitem>
            <p:menuitem value="Notices" icon="ui-icon-star" ajax="true"
                action="#{homeNavigationBean.setAdminPage('notices')}"
                actionListener="#{noticesBean.loadNotices(false)}"
                update=":mainTab:adminContent">
            </p:menuitem>
            <p:menuitem id="updgallery" value="Gallery" icon="ui-icon-star" ajax="true"  
                actionListener="#{homeNavigationBean.setAdminPage('adminGallery')}" 
                update=":mainTab:adminContent">
            </p:menuitem>
            <p:menuitem value="Location" icon="ui-icon-star" ajax="true"
                action="#{homeNavigationBean.setAdminPage('location')}"
                actionListener="#{locationBean.loadLocation}"
                update=":mainTab:adminContent">
            </p:menuitem>
            <p:menuitem value="Department" icon="ui-icon-star" ajax="true"
                action="#{homeNavigationBean.setAdminPage('department')}"
                actionListener="#{departmentBean.loadDepartment}"
                update=":mainTab:adminContent">
            </p:menuitem>
        </p:menubar>
    </h:form>
</div>
<div>
    <p:outputPanel id="adminContent" layout="block" style="border-style: none; padding: 0;">
            <ui:include src="admin/#{homeNavigationBean.adminPage}.xhtml" />
    </p:outputPanel>
    </div>
   </h:body>
   </html>

下面是导致重复ID错误的adminGallery页面(所有其他页面都没有这个问题)

<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui"
xmlns:c="http://java.sun.com/jsp/jstl/core">
<h:head>

</h:head>
<h:body>
<p:panelGrid style="width:98%;">
    <f:facet name="header">
        <p:row>
            <p:column colspan="2">
        <h:outputText value="Image Gallary"></h:outputText>  
    </p:column>
        </p:row>
    </f:facet>
    <p:row>
        <p:column style="width:200px;vertical-align:top">
            <h:form id="nodeForm">
                <p:tree id="nodeTree" value="#{galleryBean.imageTree}" var="node"
                    selectionMode="single" selection="#{galleryBean.selectedNode}" 
                    style="width:160px;border-style:none;padding:0;margin:0;">
                    <p:ajax event="select" listener="#{galleryBean.loadImages}"
                        update=":mainTab:imageForm:galaPanel" />
                    <p:treeNode id="treeNode">
                        <h:outputText value="#{node}"></h:outputText>
                    </p:treeNode>
                </p:tree>
            </h:form>
        </p:column>
        <p:column>
            <h:form id="imageForm">
                <p:outputPanel id="galaPanel">
                    <p:galleria var="image" id="imgGala"
                        value="#{galleryBean.imageList}" panelWidth="470"
                        style="padding:0;margin:0;">
                        <p:graphicImage value="#{imageHelper.getFilePhotoStream()}"
                            width="450">
                            <f:param name="imageName" value="#{image}" />
                        </p:graphicImage>
                    </p:galleria>
                </p:outputPanel>
            </h:form>
        </p:column>
    </p:row>

    <p:row>
        <p:column>
            <h:form id="nodeAddForm">
                <p:messages id="treemsgs" style="padding:0;margin:0;" />
                <p:panelGrid columns="2" style="width:100%">
                    <h:outputText value="Name:*" />
                    <p:inputText id="nodename" value="#{galleryBean.name}"
                        label="Node Name" />

                    <h:outputText value="External Visible:" />
                    <p:selectBooleanCheckbox id="extcheck"
                        value="#{galleryBean.externalvisible}" />
                    <f:facet name="footer">
                        <p:commandButton type="Submit" value="Add New Node"
                            actionListener="#{galleryBean.addImageNode}" ajax="true"
                            process="nodename extcheck" update=":mainTab:nodeForm:nodeTree treemsgs" />
                    </f:facet>
                </p:panelGrid>
            </h:form>
        </p:column>
        <p:column>
            <h:form id="imageAddForm">
                <p:messages id="imgmsgs" />
                <p:fileUpload mode="advanced"
                    fileUploadListener="#{galleryBean.addPhotoFile}"
                    allowTypes="/(\.|\/)(gif|jpe?g)$/" sizeLimit="1000000"
                    invalidSizeMessage="Please limit photo size to 1000Kb"
                    update=":mainTab:imageForm:galaPanel imgmsgs" />
            </h:form>
        </p:column>
    </p:row>
</p:panelGrid>
<p:spacer height="20"/>
</h:body>
</html>

此页面显示正确,但所有请求发布此页面显示都失败,并出现重复 ID 错误。

我的 Bean 是 CODI WindowScoped。

基于围绕 Duplicate Id 的各种建议答案,我只看到 ui:include 作为问题的潜在根源。但由于我对选项卡中或跨选项卡的其他页面没有任何问题,我怀疑这不是问题。

请提出这里可能存在的问题和潜在的解决方法。

4

0 回答 0