Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Primefaces p:对话框未按预期工作?_Primefaces_Jsf 2_Facelets - Fatal编程技术网

Primefaces p:对话框未按预期工作?

Primefaces p:对话框未按预期工作?,primefaces,jsf-2,facelets,Primefaces,Jsf 2,Facelets,我有两个p:commandLink: <p:commandLink update=":form:livreDetail" oncomplete="PF('livreDialog').show()" title="View Detail"> <h:outputText styleClass="ui-icon ui-icon-search" style="margin:0 auto;" /> <f:setPropertyActionListener v

我有两个p:commandLink:

 <p:commandLink update=":form:livreDetail" oncomplete="PF('livreDialog').show()" title="View Detail">
    <h:outputText styleClass="ui-icon ui-icon-search" style="margin:0 auto;" />
    <f:setPropertyActionListener value="#{livre}" target="#{livreDataGridView.selectedLivre}" />
</p:commandLink>
<p:commandLink update=":form:ajoutPanel" oncomplete="if(#{ empty loginBean.c }){PF('connectDialog').show()}else {PF('ajoutLivrePanier').show()} " title="ajouter au panier">
    <h:outputText styleClass="ui-icon ui-icon-cart" style="margin:0 auto;" />
    <f:setPropertyActionListener value="#{livre}" target="#{livreDataGridView.selectedLivre}" />
</p:commandLink>

第一个p:commandLink one显示并更新LiverDialogp:dialog的内容

当loginBean.c属性为空时,第二个p:commandLink应显示connectDialogp:dialog;当loginBean.c属性为空时,第二个p:commandLink应显示AJVRepanierp:dialog

当loginBean属性为null时,我的代码正常工作。但当不是时,它会产生奇怪的结果:

  • 当我单击第一个p:commandLink时,它只显示liverdialogp:对话框,而不更新其内容。同时显示connectDialogp:对话框的验证消息。真奇怪
  • 当我单击第二个p:commandLink时,只会显示connectDialogp:dialog的验证消息,也很奇怪 以下是孔代码:

    <p:messages globalOnly="true" autoUpdate="true" showDetail="false"/>
    <h:form id="form">
        <p:dataGrid var="livre" value="#{livreListBean.livresList}" columns="3"
                    rows="12" paginator="true" id="livres"
                        paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                        rowsPerPageTemplate="6,12,16">
            <f:facet name="header">
                Livres
            </f:facet>
            <p:panel header="#{livre.titre}" style="text-align:center">
                <h:panelGrid columns="1" style="width:100%">
                    <h:outputText value="#{livre.auteur}" />
                    <h:outputText value="#{livre.datePublication}" />
                    <p:commandLink update=":form:livreDetail" oncomplete="PF('livreDialog').show()" title="View Detail">
                        <h:outputText styleClass="ui-icon ui-icon-search" style="margin:0 auto;" />
                        <f:setPropertyActionListener value="#{livre}" target="#{livreDataGridView.selectedLivre}" />
                    </p:commandLink>
                    <p:commandLink update=":form:ajoutPanel" oncomplete="if(#{ empty loginBean.c }){PF('connectDialog').show()}else {PF('ajoutLivrePanier').show()} " title="ajouter au panier">
                        <h:outputText styleClass="ui-icon ui-icon-cart" style="margin:0 auto;" />
                        <f:setPropertyActionListener value="#{livre}" target="#{livreDataGridView.selectedLivre}" />
                    </p:commandLink>
                </h:panelGrid>
            </p:panel>
        </p:dataGrid>
    
        <p:dialog header="Info Livre" widgetVar="livreDialog" modal="true" showEffect="fade" hideEffect="fade" resizable="false">
            <p:outputPanel id="livreDetail" style="text-align:center;">
                <p:panelGrid  columns="2" rendered="#{not empty livreDataGridView.selectedLivre}" columnClasses="label,value">
    
                    <h:outputText value="Titre:" />
                    <h:outputText value="#{livreDataGridView.selectedLivre.titre}" />
    
                    <h:outputText value="Auteur" />
                    <h:outputText value="#{livreDataGridView.selectedLivre.auteur}" />
    
                    <h:outputText value="Date de publication:" />
                    <h:outputText value="#{livreDataGridView.selectedLivre.datePublication}" />
    
                    <h:outputText value="Prix" />
                    <h:outputText value="$#{livreDataGridView.selectedLivre.prix}" />
                </p:panelGrid>
            </p:outputPanel>
        </p:dialog>
    
        <h:panelGroup id="livrePanier">
            <p:dialog header="Se connecter" widgetVar="connectDialog" modal="true" showEffect="fade" hideEffect="fade" resizable="false">
                <p:outputPanel id="connecterPanel" style="text-align:center;">
                    <h:panelGrid  columns="3" >
    
                        <p:outputLabel for="mail" value="E-mail:" />
                        <p:inputText id="mail" value="#{loginBean.email}" required="true" requiredMessage="Vous devez entrer votre e-mail"/>
                        <p:message for="mail"/>
    
                        <p:outputLabel for="password" value="Password:" />
                        <p:password id="password" value="#{loginBean.password}" required="true" requiredMessage="Vous devez entrer votre password"/>
                        <p:message for="password"/>
                        <p:commandButton value="Se connecter" action="#{loginBean.LoginProcess()}" process="connecterPanel" update="connecterPanel"/>
                    </h:panelGrid>
                </p:outputPanel>
            </p:dialog>
            <p:dialog header="Ajouter au panier" widgetVar="ajoutLivrePanier" modal="true" showEffect="fade" hideEffect="fade" resizable="false">
                <p:outputPanel id="ajoutPanel" style="text-align:center;" rendered="#{not empty livreDataGridView.selectedLivre}">
                    <p:outputLabel value="Voulez vous ajouter ce produit au panier ?"/> 
                    <h:panelGrid  columns="2" >
                        <p:outputLabel value="#{livreDataGridView.selectedLivre.titre}" />
                        <p:outputLabel value="#{livreDataGridView.selectedLivre.prix}" />
                        <p:commandButton value="Oui" action="#{livreDataGridView.ajouterLivreAuPanier()}" process="connecterPanel" update="connecterPanel" oncomplete="PF('ajoutLivrePanier').hide()"/>                                   
                        <p:commandButton value="Annuler" onclick="PF('ajoutLivrePanier').hide()"/>
                    </h:panelGrid>
                </p:outputPanel>
            </p:dialog>
        </h:panelGroup>
    </h:form>
    
    
    利弗尔斯
    
    我将非常感谢您帮助解决问题

    您需要在commandLinks上使用
    process=“@this”
    。如果没有它,JSF将处理整个表单,这就是为什么您会看到这些验证失败,这反过来会导致跳过调用应用程序阶段


    另请参见:。

    他还可以将对话框移到表单之外,并为它们提供自己的表单,从而避免使用过程。我肯定会这么做是的,我昨天解决了这个问题,将p:dialog-connectDialog移动到表单之外,正如@Jaqen H'ghar所说。但Vsevolod响应也应该起作用。谢谢你,伙计们