Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/jsf/5.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
Jsf 单击命令按钮时为空值_Jsf - Fatal编程技术网

Jsf 单击命令按钮时为空值

Jsf 单击命令按钮时为空值,jsf,Jsf,这里是XHTML代码,其中包含2primeface datatable。 我想用{invoice.id}值将对话框inputText值传递给托管Bean的addRow。 但所有inputText的值都变为空。 新的行数据将在invoiceTable中更新并显示new Entry <p:panelGrid columns="3"> <p:outputLabel value="Enter Invoice Number :" />

这里是XHTML代码,其中包含2primeface datatable。 我想用{invoice.id}值将对话框inputText值传递给托管Bean的addRow。 但所有inputText的值都变为空。 新的行数据将在invoiceTable中更新并显示new Entry

<p:panelGrid columns="3">
                <p:outputLabel value="Enter Invoice Number :" />
                <p:inputText id="inputInvoiceNumber"
                    value="#{invoiceBean.invoiceNumber}" />
                <p:commandButton value="Search" type="submit">
                    <f:ajax execute="inputInvoiceNumber" render="outputInvoiceNumber" />
                </p:commandButton>
            </p:panelGrid>
            <br />
            <p:dataTable id="outputInvoiceNumber"
                value="#{invoiceBean.invoices}" var="invoice">
                <p:column headerText="Invoice Id ">
                    <p:outputLabel value="#{invoice.id}" />
                </p:column>
                <p:column headerText="Email">
                    <p:outputLabel value="#{invoice.email}" />
                </p:column>
                <p:column headerText="Invoice Number ">
                    <p:outputLabel value="#{invoice.invoiceNumber}" />
                </p:column>
                <p:column headerText="Date">
                    <p:outputLabel value="#{invoice.date}" />
                </p:column>
                <p:column headerText="Delivery Note ">
                    <p:outputLabel value="#{invoice.deliveryNote}" />
                </p:column>
                <p:column headerText="Supplier Reference">
                    <p:outputLabel value="#{invoice.supplierReference}" />
                </p:column>
                <p:column headerText="Other Reference">
                    <p:outputLabel value="#{invoice.otherReference}" />
                </p:column>
                <p:column headerText="Buyer Name">
                    <p:outputLabel value="#{invoice.buyerName}" />
                </p:column>
                <p:column headerText="Buyer Address">
                    <p:outputLabel value="#{invoice.buyerAddress}" />
                </p:column>
                <p:column headerText="Dispatch Document Date">
                    <p:outputLabel value="#{invoice.dispatchDocumentDate}" />
                </p:column>
                <p:column headerText="Dispatch Through">
                    <p:outputLabel value="#{invoice.dispatchThrough}" />
                </p:column>
                <p:column headerText="Destination">
                    <p:outputLabel value="#{invoice.destination}" />
                </p:column>
                <p:column headerText="Terms Of Delivery">
                    <p:outputLabel value="#{invoice.termsOfdelivery}" />
                </p:column>
                <p:column headerText="Net Total">
                    <p:outputLabel value="#{invoice.netTotal}" />
                </p:column>
            </p:dataTable>

            <br />
            <p:dataTable id="invoiceTable" var="invoiceProductsServicesDetail"
                value="#{invoiceBean.invoiceProductsServicesDetails}" border="1"
                editable="true">

                <p:column headerText="Sr. No.">
                    <p:outputLabel
                        value="#{invoiceProductsServicesDetail.serialNumber}" />
                </p:column>

                <p:column headerText="Description of Goods">
                    <p:outputLabel
                        value="#{invoiceProductsServicesDetail.descriptionOfGoodsOrService}" />
                </p:column>

                <p:column headerText="HSN Code">
                    <p:outputLabel value="#{invoiceProductsServicesDetail.hsnCode}" />
                </p:column>

                <p:column headerText="Quantity">
                    <p:outputLabel value="#{invoiceProductsServicesDetail.quantity}" />
                </p:column>

                <p:column headerText="Rate">
                    <p:outputLabel value="#{invoiceProductsServicesDetail.rate}" />
                </p:column>

                <p:column headerText="Percentage Discount">
                    <p:outputLabel
                        value="#{invoiceProductsServicesDetail.percentDiscount}" />
                </p:column>

                <p:column headerText="Amount">
                    <p:outputLabel
                        value="#{(invoiceProductsServicesDetail.rate) * (invoiceProductsServicesDetail.percentDiscount) }" />
                </p:column>


                <p:summaryRow>
                    <p:column colspan="5" style="text-align:right">
                        <p:outputLabel value="Total" />
                    </p:column>
                    <p:column>
                        <p:outputLabel value="#{invoiceBean.netTotal}" />
                    </p:column>
                </p:summaryRow>

                <f:facet name="footer">
                    <p:commandButton value="Add Invoice" type="button"
                        onclick="PF('addInvoice').show();" />
                </f:facet>
            </p:dataTable>


            <p:dialog id="invoiceDialog" header="Add Invoice"
                widgetVar="addInvoice" minHeight="40" showEffect="explode"
                hideEffect="fold">
                <table border="1" id="dialogTable">
                    <tr>
                        <td><p:outputLabel value="Description Of Goods Or Services" /></td>
                        <td><p:outputLabel value="HSN Code" /></td>
                        <td><p:outputLabel value="Quantity" /></td>
                        <td><p:outputLabel value="Rate" /></td>
                        <td><p:outputLabel value="Percentage Discount" /></td>
                    </tr>
                    <tr>
                        <td><p:inputTextarea id="description"
                                value="#{invoiceBean.descriptionOfGoodsOrService}" cols="45"
                                required="true" label="Description"
                                requiredMessage="Description Require Entry" /></td>

                        <td><p:inputText value="#{invoiceBean.hsnCode}" size="6" /></td>

                        <td><p:inputText id="quaintity"
                                value="#{invoiceBean.quantity}" size="3" styleClass="Alingment"
                                required="true" label="Quantity"
                                requiredMessage="Quantity Require Entry" autocomplete="off" /></td>

                        <td><p:inputText id="rate" value="#{invoiceBean.rate}"
                                styleClass="Alingment" required="true" label="Rate"
                                requiredMessage="Rate Require Entry" autocomplete="off" /></td>

                        <td><p:inputText value="#{invoiceBean.percentDiscount}"
                                size="2" styleClass="Alingment" autocomplete="off" /></td>
                    </tr>
                </table>
                <p:commandButton type="submit" value="Save New Invoice"
                    action="#{invoiceBean.addRow}" update=":form:invoiceTable growl"
                    process="@this invoiceTable" onsuccess="PF('addInvoice').hide();"
                    onerror="PF('addInvoice').show();">
                    <f:ajax render=":form:invoiceTable" />
                </p:commandButton>
                <p:growl id="growl" showDetail="true" sticky="true" />
            </p:dialog>
            <br />
            <p:commandButton value="Create Pdf"
                action="#{createPdf.createPdfFile}" ajax="false">
                <f:setPropertyActionListener value="#{invoiceBean.invoiceNumber}"
                    target="#{createPdf.invoiceNumber}" />
            </p:commandButton>
        </h:panelGroup>

您的对话框提交按钮

<p:commandButton type="submit" value="Save New Invoice"
                action="#{invoiceBean.addRow}" update=":form:invoiceTable growl"
                process="@this invoiceTable" onsuccess="PF('addInvoice').hide();"
                onerror="PF('addInvoice').show();">
    <f:ajax render=":form:invoiceTable" />
</p:commandButton>

以处理整个对话框。此外,建议在自己的表单中包含一个对话框,以便能够处理表单,而不必处理与该对话框无关的所有周围输入元素。

谢谢老板,但我还希望addRow方法中的{invoices.id}值。我如何获得它???我担心打开对话框的按钮必须在后台bean中另外设置创建新发票的发票ID,因为您没有打开可以通过查询参数传输发票ID的新页面。是否可以在同一页面中?是,但是,您必须将要在处理对话框的代码中使用的发票ID存储在处理对话框的代码可以访问它的地方。您能给我举个这样的例子吗??
<p:commandButton type="submit" value="Save New Invoice"
                action="#{invoiceBean.addRow}" update=":form:invoiceTable growl"
                process="@this invoiceTable" onsuccess="PF('addInvoice').hide();"
                onerror="PF('addInvoice').show();">
    <f:ajax render=":form:invoiceTable" />
</p:commandButton>
process="@form invoiceTable"