Primefaces表单和LayoutUnit

时间:2019-02-01 08:48:48

标签: forms primefaces

我是primeface的新手,并且正在使用最新版本6.2。按照用户指南的指导,我使用2个表单(每个layoutunit一个)创建了一个模板,为每个表单设置了不同的ID。

<?xml version = "1.0" encoding = "UTF-8"?>
<!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:c="http://java.sun.com/jsp/jstl/core" xmlns:fn="http://java.sun.com/jsp/jstl/functions" xmlns:p="http://primefaces.org/ui">
    <ui:composition>
        <h:head>
            <title>#{messages.appname}</title>
            <link rel="shortcut icon" href="#{resource['images/favicon.ico']}" type="image/x-icon" />
        </h:head>
        <body>

                <p:layout fullPage="true" id="myPage">
                    <p:layoutUnit id="up" position="north" size="130" header="" resizable="true" closable="false" collapsible="true">
                        <h:form id="upform">
                            <ui:include src="/templates/top.xhtml" />
                        </h:form>                       
                    </p:layoutUnit>
                    <p:layoutUnit id="center" position="center">
                        <h:form id="centerform">
                            <ui:include src="/templates/center.xhtml" />
                        </h:form>               
                    </p:layoutUnit>
                    <p:layoutUnit id="down" position="south" size="60" header="" resizable="true" closable="true" collapsible="true">
                        <h:outputText value="© 2018 - IT" />
                    </p:layoutUnit>
                </p:layout>

        </body>
    </ui:composition>
</html>

我的问题是,当我在Chrome中加载页面并检查元素时,Chrome抱怨DOM,因为它跟踪具有非唯一ID的2个元素。

login.xhtml:1 [DOM] Found 2 elements with non-unique id #j_id1:javax.faces.ViewState:0: (More info:) <input type=..."hidden" name=..."javax.faces.ViewState" id=..."j_id1:...javax.faces.ViewState:...0" value=..."bla bla" autocomplete=..."off">... <input type=..."hidden" name=..."javax.faces.ViewState" id=..."j_id1:...javax.faces.ViewState:...0" value=..."bla bla 2" autocomplete=..."off">...

我怀疑这会导致JavaScript问题-如何解决这个问题?

0 个答案:

没有答案