部分状态保存和MyFaces CODI重复ID错误

时间:2012-11-23 09:55:51

标签: jsf-2 primefaces myfaces codi

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

在显示特定页面(所有后续页面操作)后,我收到重复的Id错误。使用debug分析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作为问题的潜在来源。但由于我在选项卡或选项卡中的其他页面没有任何问题,我怀疑这不是问题。

请在此处提出可能存在的问题以及可能的解决方法。

0 个答案:

没有答案