Search code examples
jsf-2primefaces

Primefaces confirmDialog doesn't show up after one call


I have a problem with PrimeFaces <p:confirmDialog>, when I click on the <p:commandLink> that must show up the dialog and choose 'No', everything is fine. But when I click on yes,everything works just the first time. When the process is over and I click again on any <p:commandLink>, the dialog doesn't show up unless I refresh the whole page.I had try everything but I cannot figure out what can be the problem.

<h:form>
   <p:dataTable  border="0" rules="all" value="#{userBean.users}" var="user" autoUpdate="true" styleClass="table table-hover" paginator="true" paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" rowsPerPageTemplate="6,10,15" >
      <p:column>
         <f:facet name="header">
            <h:outputText value="Login" />
         </f:facet>
         <h:outputText value="#{user.login}" />
      </p:column>
      <p:column>
         <f:facet name="header">
            <h:outputText value="" />
         </f:facet>
         <p:commandLink class="badge bg-red marge-left"  onclick='PF("cdu#{user.id}").show()' title="Supprimer un utilisateur"><span class="fa fa-trash-o"/></p:commandLink>
         <p:confirmDialog ajax="true" message="Voulez vous vraiment supprimer l'utilisateur '#{user.login}'" closable="true"  header="Confirmation" severity="alert" widgetVar="cdu#{user.id}"  >
            <p:commandButton  value="oui" actionListener="#{userBean.deleteUser}"  update="@form" onclick='PF("cdu#{user.id}").hide()' styleClass="btn btn-primary"/>
            <p:commandButton  value="non" onclick='PF("cdu#{user.id}").hide()' type="button" styleClass="btn btn-danger" />
         </p:confirmDialog>
      </p:column>
   </p:dataTable>
</h:form>

Solution

  • I had finally resolved my problem. I changed the <p:confirmDialog> by a global one and it works.

    <h:form>
       <p:dataTable  border="0" rules="all" value="#{userBean.users}" var="user" autoUpdate="true" styleClass="table table-hover">
          <p:column>
             <f:facet name="header">
                <h:outputText value="Login" />
             </f:facet>
             <h:outputText value="#{user.login}" />
          </p:column>
          <p:column>
             <f:facet name="header">
                <h:outputText value="Nom" />
             </f:facet>
             <h:outputText value="#{user.firstName} #{user.lastName}" />
          </p:column>
          <p:column style="width:200px;">
             <f:facet name="header">
                <h:outputText value="Email" />
             </f:facet>
             <h:outputText value="#{user.email}" />
          </p:column>
          <p:column >
             <f:facet name="header">
                <h:outputText value="" />
             </f:facet>
             <p:commandLink class="badge bg-blue marge-left" action="#{userBean.getUserRowToEdit}" title="Editer un utilisateur" ><span class="fa fa-edit"/></p:commandLink>
             <p:commandLink class="glyphicon glyphicon-trash icon-trash"  actionListener="#{userBean.deleteUser}"  title="Supprimer un utilisateur"  update="@form">
                <p:confirm header="Confirmation" message="Voulez-vous vraiment supprimer l'utilisateur?" icon="ui-icon-alert"/>
             </p:commandLink>
          </p:column>
       </p:dataTable>
       <p:confirmDialog global="true">
          <p:commandButton value="Yes" type="button" styleClass="ui-confirmdialog-yes" icon="ui-icon-check"/>
          <p:commandButton value="No" type="button" styleClass="ui-confirmdialog-no" icon="ui-icon-close"/>
       </p:confirmDialog>
    </h:form>