primefaces动态导航无法正常工作

时间:2017-08-25 10:29:37

标签: jsf primefaces

你好,我有这个页面正常工作,我动态更改页面 来自bean的include标签:

    <!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:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:p="http://primefaces.org/ui">

<h:head></h:head>
<h:body>
    <p:layout fullPage="true">
        <p:layoutUnit position="north" size="50" id="top">
            <ui:include src="/WEB-INF/template/header.xhtml" />
        </p:layoutUnit>
        <p:layoutUnit position="south" size="20">
            <ui:include src="/WEB-INF/template/footer.xhtml" />
        </p:layoutUnit>
        <p:layoutUnit position="west" size="400">
            <h:form>
                <f:ajax render=":centerContentPanel" execute="@this">
                    <h:commandLink value="page1" action="#{navigationBean.doNav}" update=":centerContentPanel">
                        <f:param name="test" value="/WEB-INF/pages/profil" />
                    </h:commandLink>
                    <h:commandLink value="page2" action="#{navigationBean.doNav}" process="@this">
                        <f:param name="test" value="/WEB-INF/pages/users" />
                    </h:commandLink>
                </f:ajax>
            </h:form>
        </p:layoutUnit>
        <p:layoutUnit position="center" size="400">
            <h:panelGroup id="centerContentPanel">
                <ui:include src="#{navigationBean.pageName}.xhtml" />
            </h:panelGroup>
        </p:layoutUnit>
    </p:layout>
</h:body>
</html>

在包含的页面中,我有一个对话框,其中也包含和包含页面。 当我打开对话框时屏幕卡住,我无法更改任何内容或按任何内容,它就像一个禁用的页面。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:p="http://primefaces.org/ui"
    xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
        <h:form id="form">
            <p:growl id="message" showDetail="true" globalOnly="true" />

            <p:dataTable var="user" value="#{usersBean.users}" paginator="true"
                reflow="true" widgetVar="multipleDT" resizableColumns="true"
                id="multipleDT"
                paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                rowsPerPageTemplate="5,10,15" selectionMode="single"
                selection="#{usersBean.selectedUser}" rowKey="#{user.util}">

                <p:ajax event="rowSelect" listener="#{usersBean.onRowSelect}"
                    update="b4 b3 :form:pickList :form:Submit" />
                <p:ajax event="rowUnselect" listener="#{usersBean.onRowUnselect}"
                    update="b4 b3 :form:pickList :form:Submit" />

                <p:column headerText="util" filterMatchMode="contains"
                    filterBy="#{user.util}" sortBy="#{user.util}" reflow="true">
                    <h:outputText value="#{user.util}" />
                </p:column>

                <p:column headerText="nom" filterMatchMode="contains"
                    filterBy="#{user.nom}" sortBy="#{user.nom}" reflow="true">
                    <h:outputText value="#{user.nom}" />
                </p:column>

                <p:column headerText="prenom" filterMatchMode="contains"
                    filterBy="#{user.prenom}" sortBy="#{user.prenom}" reflow="true">
                    <h:outputText value="#{user.prenom}" />
                </p:column>

                <p:column headerText="mail" filterMatchMode="contains"
                    filterBy="#{user.mail}" sortBy="#{user.mail}" reflow="true">
                    <h:outputText value="#{user.mail}" />
                </p:column>
                <f:facet name="footer">

                    <p:commandButton id="b3" value="ajouter"
                        oncomplete="PF('dlg3').show();" process="@this" ajax="true"
                        update="@widgetVar(dlg3) multipleDT">

                    </p:commandButton>
                    <p:commandButton id="b4" value="modifier"
                        disabled="#{usersBean.dis}" oncomplete="PF('dlg2').show();"
                        ajax="true" process="@this" update="@widgetVar(dlg2) multipleDT">

                    </p:commandButton>
                </f:facet>
            </p:dataTable>

            <p:pickList id="pickList" value="#{usersBean.profilNonAffecte}"
                var="Profil" itemLabel="#{Profil.libProfil}" itemValue="#{Profil}"
                effect="bounce" responsive="true" showSourceFilter="true"
                showTargetFilter="true" filterMatchMode="contains"
                disabled="#{usersBean.dis}" style="width:50%;margin-top:20px;"
                converter="primeFacesPickListConverter">
                <f:facet name="sourceCaption">Available</f:facet>
                <f:facet name="targetCaption">Starting</f:facet>
            </p:pickList>

            <p:commandButton id="Submit" value="Submit" style="margin-top:5px"
                action="#{usersBean.commit}" update="pickList form:message"
                disabled="#{usersBean.dis}" />
        </h:form>
        <h:form>
            <p:dialog style="font-size:12px;" widgetVar="dlg3" resizable="false"
                width="800" showEffect="explode" hideEffect="explode" modal="true"
                id="dlg3" dynamic="true">
                <ui:include src="/WEB-INF/pages/ajoutUser.xhtml" />
            </p:dialog>
        </h:form>
        <h:form>
            <p:dialog style="font-size:12px;" widgetVar="dlg2" resizable="false"
                width="800" showEffect="explode" hideEffect="explode" modal="true"
                id="dlg2" dynamic="true">
                <ui:include src="/WEB-INF/pages/modifUser.xhtml" />
            </p:dialog>
        </h:form>
</ui:composition>

对话框代码

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:p="http://primefaces.org/ui"
    xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
    <h:panelGrid columns="2" id="grid">
        <p:outputLabel for="ta4" value="date début :" />
        <p:calendar id="ta4" value="#{usersBean.selectedUser.dateDeb}"
            showOn="button" label="date début" required="true"
            binding="#{startDateComponent}" pattern="dd/MM/yyyy" navigator="true">
            <p:message for="ta4" />
            <p:ajax event="dateSelect" listener="#{usersBean.onDateSelect}"
                update="ta4" />
        </p:calendar>

        <p:outputLabel for="ta5" value="date fin :" />
        <p:calendar id="ta5" value="#{usersBean.selectedUser.dateFin}"
            showOn="button" label="date fin" required="true" pattern="dd/MM/yyyy"
            mode="popup">
            <f:validator validatorId="dateRangeValidator" />
            <f:attribute name="startDateComponent" value="#{startDateComponent}" />
            <p:message for="ta5" />
        </p:calendar>

        <p:outputLabel for="ta6" value="nom :" label="nom" />
        <p:inputText rows="6" cols="33" id="ta6"
            value="#{usersBean.selectedUser.nom}" required="true">
            <p:message for="ta6" />
        </p:inputText>

        <p:outputLabel for="ta7" value="prénom :" />
        <p:inputText rows="6" cols="33" id="ta7"
            value="#{usersBean.selectedUser.prenom}" required="true"
            label="prenom">
            <p:message for="ta7" />
        </p:inputText>

        <p:outputLabel for="ta8" value="mail :" />
        <p:inputText rows="6" cols="33" id="ta8"
            value="#{usersBean.selectedUser.mail}" required="true" label="mail"
            validatorMessage="email format error ">
            <f:validateRegex
                pattern="^[_A-Za-z0-9-\+]+(\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\.[A-Za-z0-9]+)*(\.[A-Za-z]{2,})$" />
            <p:message for="ta8" />
        </p:inputText>

        <p:outputLabel for="chk" value="Valid :" />
        <p:selectBooleanCheckbox value="#{usersBean.selectedUser.valid}"
            id="chk" />

        <p:commandButton value="confirmer" id="ajax"
            actionListener="#{usersBean.modifier}"
            styleClass="ui-priority-primary" update="grid form:message form:multipleDT" >
        </p:commandButton>
    </h:panelGrid>
</ui:composition>

1 个答案:

答案 0 :(得分:0)

我发现对话框中的问题是modal =“true”