如何在PrimeFaces中的对话框小部件中使用数据表选择?

时间:2015-04-08 08:01:53

标签: jsf primefaces dialog

我正在尝试在对话框小部件中使用数据表选择。但我无法在我的bean中获得选定的值。如果我删除对话框小部件标记,则数据表选择正常。我正在使用PrimeFaces 4.0。我该如何解决这个问题?

passengerform.xhtml

<p:hotkey bind="esc" handler="dialogWidget.hide();" />
<p:dialog id="dialog" widgetVar="dialogWidget"
          header="Coupon List" modal="true" width="400" showEffect="fade"
          hideEffect="fade" appendTo="@(body)">

    <h:form id="formDialog">
        <h:outputLabel value="Lütfen E-ticket Kuponunu Seçiniz." />

        <p:dataTable id="singleDT" var="coupon"
                     value="#{passengerFormService.couponList}"
                     rowKey="#{coupon.id}" rowIndexVar="rowIndex"
                     selection="#{passengerFormService.selectedCoupon}"
                     selectionMode="single">
            <p:ajax event="rowSelect"
                    listener="#{passengerFormService.selectCoupon}"
                    update=":tab1:tab1_1:eticketform:formDialog">
                <f:setPropertyActionListener value="#{coupon}"
                                             target="#{passengerFormService.coupon}" />
            </p:ajax>

            <f:facet name="header"></f:facet>

            <h:inputHidden name="hidden1"
                           value="#{passengerFormService.passengerForm.id}" />

            <p:column style="width:20px" width="20">
                <f:facet name="header">
                    <h:outputText value="#" />
                </f:facet>
                <h:outputText value="#{rowIndex+1}" />
            </p:column>
            <p:column headerText="Id">
                <h:outputText value="#{coupon.id}" />
            </p:column>
            <p:column headerText="Departure Location">
                <h:outputText value="#{coupon.departureLocation}" />
            </p:column>

            <f:facet name="footer"></f:facet>
        </p:dataTable>

        <p:separator />
        <h:panelGrid columns="2" cellspacing="5"
                     columnClasses="alignLeft,alignRight" style="width:100%">

            <p:commandButton id="selectButton1" update=""
                             icon="ui-icon-close" value="İptal"
                             oncomplete="PF('dialogWidget').hide()" />
            <p:commandButton id="cancelSelectedButton1"
                             update=":tab1:tab1_1:passengerInsertform" 
                             icon="ui-icon-check"
                             value="Onayla" oncomplete="PF('dialogWidget').hide()" />
        </h:panelGrid>
    </h:form>
</p:dialog>

PassengerFormService.java

public void selectCoupon(SelectEvent event) {
    Log.getLogger().debug("New2 coupon selected...");
    Log.getLogger().debug("selected: " +getSelectedCoupon());
}

0 个答案:

没有答案