Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/drupal/3.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
Ajax JSF PrimeFaces rowSelect用于从另一个数据表调用一个数据表_Ajax_Jsf_Datatable - Fatal编程技术网

Ajax JSF PrimeFaces rowSelect用于从另一个数据表调用一个数据表

Ajax JSF PrimeFaces rowSelect用于从另一个数据表调用一个数据表,ajax,jsf,datatable,Ajax,Jsf,Datatable,我在一个选项卡中有一个Purchase数据表,其中列出了所有购买。当您选择一行时,应该会打开一个对话框,显示特定客户的购买列表。代码中还有一个用于添加新购买的对话框,在该对话框中,可以从数据表中以前的客户列表中选择客户 我的问题是,当我在purchase表中选择一行时,它会调用customer datatable中的rowSelectajax事件(从“New purchase”对话框中),而不是触发它自己的rowSelect事件来打开purchase对话框 <!DOCTYPE html P

我在一个选项卡中有一个
Purchase
数据表,其中列出了所有购买。当您选择一行时,应该会打开一个对话框,显示特定客户的购买列表。代码中还有一个用于添加新购买的对话框,在该对话框中,可以从数据表中以前的客户列表中选择
客户

我的问题是,当我在purchase表中选择一行时,它会调用customer datatable中的
rowSelect
ajax事件(从“New purchase”对话框中),而不是触发它自己的
rowSelect
事件来打开
purchase
对话框

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

</h:head>
<h:body>

    <p:growl id="messages" showDetail="true" />

    <h:form id="newPurchaseCommandForm" enctype="multipart/form-data">
        <p:commandButton value="New Purchase" process="@this"
            onclick="PF('newPurchase').show()" id="btnNewPurchase">
            <f:actionListener binding="#{purchasesDAO.init()}" />
        </p:commandButton>
    </h:form>

    <p:tabView id="tabView" dynamic="true" cache="true" scrollable="true"
        style="font-size:12px;">

        <p:tab id="tba1" title="Purchase List">
            <h:form id="purchaseTableForm" enctype="multipart/form-data">
                <p:dataTable id="PurchaseTable" var="purchaseVar"
                    rowKey="#{purchaseVar.id}"
                    selection="#{purchasesDAO.selectedPurchaseRow}"
                    widgetVar="purchasesTableSearch"
                    filteredValue="#{purchasesDAO.filteredPurchaseRow}"
                    selectionMode="single" value="#{purchasesDAO.purchaseList}"
                    style="font-size:10px;">

                    <!-- Opens dialog -->
                    <p:ajax event="rowSelect" listener="#{purchasesDAO.onRowSelect}"
                        update=":messages" oncomplete="PF('showPurchase').show()" />

...
                </p:dataTable>
            </h:form>
        </p:tab>

    </p:tabView>

    <p:dialog header="Purchase Details" widgetVar="showPurchase"
        id="dialog" resizable="true" modal="false" hideEffect="explode"
        height="500" width="990">

...

    </p:dialog>


    <p:dialog header="Add New Purchase" widgetVar="newPurchase"
        id="dialogNewPurchase" resizable="true" modal="true" hideEffect="explode"
        closeOnEscape="true" height="600" width="900">
        <h:form id="form-newcasedialog" enctype="multipart/form-data">

            <p:dataTable id="CustomerTable" var="customer"
                rowKey="#{customer.id}"
                selection="#{purchasesDAO.selectedCustomerRow}"
                widgetVar="purchasesTableSearch"
                filteredValue="#{purchasesDAO.filteredCustomerRow}"
                selectionMode="single" value="#{purchasesDAO.customerList}"
                style="font-size:10px;">

                <!-- Opens dialog -->

                <p:ajax event="rowSelect" listener="#{purchasesDAO.onRowSelect3}"
                    process="@this" />
...
                </p:dataTable>

        </h:form>
    </p:dialog>

</h:body>
</html>

...
...
...

这个问题的解决方案花了我很多时间才找到,但结果是一个简单的单行排版。 客户表和采购表的
widgetVar
是相同的:

<p:dataTable id="CustomerTable" var="customer"
    rowKey="#{customer.id}"
     selection="#{purchasesDAO.selectedCustomerRow}"
     widgetVar="purchasesTableSearch"
     filteredValue="#{purchasesDAO.filteredCustomerRow}"
     selectionMode="single" value="#{purchasesDAO.customerList}"
     style="font-size:10px;">

应该是:

<p:dataTable id="CustomerTable" var="customer"
    rowKey="#{customer.id}"
     selection="#{purchasesDAO.selectedCustomerRow}"
     widgetVar="customerTableSearch"
     filteredValue="#{purchasesDAO.filteredCustomerRow}"
     selectionMode="single" value="#{purchasesDAO.customerList}"
     style="font-size:10px;">

这是由于在开发过程中复制/粘贴代码,并且在更新代码时缺少
widgetVar
行造成的。将customer datatable中的
widgetVar
更改为与purchase表不同,解决了此问题