将JSF与Primefaces一起使用时出现问题。我在dataTable中使用了ConfirmDialog。
经过如此多次(至少3次)后,我单击了CommandButton,confirmDialog无法正常工作,并且动作缓慢。我该如何解决或有其他建议?

这是我的JSF页面的形式。

<h:form id="salePersonTableForm">
    <h:commandLink action="#{ManageSalePersonActionBean.createNewSalePerson}">
        <h:panelGrid columns="2">
            <h:graphicImage value="/images/add.png" styleClass="command-image" />
            <h:outputText value="#{label['COMMON_ADDNEW_LINK']}" styleClass="command-link" />
        </h:panelGrid>
    </h:commandLink>
    <p:outputPanel id="listPanel">
        <table>
            <tr>
                <td>
                    <p:selectOneMenu converter="omnifaces.SelectItemsIndexConverter" id="selectSalePersonCriteria" value="#{ManageSalePersonActionBean.selectedCriteria}"
                        style="width:150px;font-size:13px;">
                        <f:selectItem itemLabel="Select Criteria" />
                        <f:selectItems value="#{ManageSalePersonActionBean.criteriaItems}" var="criteriaItem" />
                    </p:selectOneMenu>
                </td>
                <td>
                    <p:inputText id="customerCriteria" style="width:150px;" value="#{ManageSalePersonActionBean.criteria.criteriaValue}" />
                </td>
                <td>
                    <p:commandButton action="#{ManageSalePersonActionBean.searchSalePerson}" id="searchSalePersonButtonBtn" update=":salePersonTableForm" value="Search" style="font-size:13px;" />
                </td>
                <td>
                    <p:commandButton action="#{ManageSalePersonActionBean.init()}" id="resetSalePersonButtonBtn" update=":salePersonTableForm" value="Reset" style="font-size:13px;" />
                </td>
            </tr>
        </table>
        <p:dataTable var="salePerson" value="#{ManageSalePersonActionBean.salePersonList}" id="salePersonTable" paginator="true" rows="10" style="width:100%;"
            paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" rowsPerPageTemplate="5,10, 15"
            rowIndexVar="index">
            <p:column headerText="No" style="width:50px;font-size:13px;">
                <h:outputText value="#{index + 1}" style="font-size:13px;" />
            </p:column>
            <p:column headerText="SalePersonID" style="font-size:13px;">
                <h:outputText value="#{salePerson.salePersonCode}" style="font-size:13px;" />
            </p:column>
            <p:column headerText="Name" style="font-size:13px;">
                <h:outputText value="#{salePerson.salePersonName}" style="font-size:13px;" />
            </p:column>
            <p:column headerText="AccountStatus" style="font-size:13px;">
                <h:outputText value="#{salePerson.accountDisable == true ? 'lock' : 'unlock'}" style="font-size:13px;" />
            </p:column>
            <!-- Lock/Unlock -->
            <p:column style="width:70px;">
                <p:commandButton action="#{ManageSalePersonActionBean.changeLockStatus(salePerson)}" value="#{salePerson.accountDisable == false ? 'lock' : 'unlock'}"
                    update="salePersonTable" style="font-size:13px;">
                    <p:confirm header="Confirmation" message="Are you sure?" icon="ui-icon-alert" />
                </p:commandButton>
            </p:column>
            <!-- ########## -->
            <p:column style="width:30px;">
                <p:commandLink action="#{ManageSalePersonActionBean.prepareUpdateSalePerson(salePerson)}" update=":salePersonEntryForm">
                    <p:graphicImage value="/images/edit.png" styleClass="command-image" />
                </p:commandLink>
            </p:column>
            <p:column style="width:30px;">
                <p:commandLink id="deletesalePersonLink" actionListener="#{ManageSalePersonActionBean.deleteSalePerson(salePerson)}" update=":salePersonTableForm">
                    <p:graphicImage value="/images/delete.png" styleClass="command-image" />
                    <p:confirm header="Confirmation" message="Are you sure?" icon="ui-icon-alert" />
                </p:commandLink>
            </p:column>
        </p:dataTable>
        <p:confirmDialog global="true" showEffect="fade" hideEffect="explode">
            <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>
    </p:outputPanel>
</h:form>


这是在ManagedBean中进行的过程。

public void changeLockStatus(SalePerson salePerson) {
    try {
        salePerson.setAccountDisable(!salePerson.isAccountDisable());
        salePersonService.updateSalePerson(salePerson);
    } catch (SystemException e) {
        handelSysException(e);
    }
}

最佳答案

我有一个类似的问题。在我的情况下,使用像您这样的结构,每次通过ajax更新表单时,都会在html页面中添加一个附加对话框<div id="j_idt63" class="ui-confirm-dialog...

如果我将<p:confirmDialog>放在<h:form>之外,则我只有一个对话框实例,它可以正常工作。

关于java - 数据表中的Primefaces ConfirmDialog问题,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/27103782/

10-11 02:55