对话框中的命令按钮不会使用给定

时间:2017-08-21 07:40:21

标签: java jsf primefaces datatable dialog

我在panelGrid中有一个outputText,它也位于id为" foo"的字段集中。我有一个对话框。此对话框中有一个数据表,数据表中有一个命令按钮。当我选择这个数据表的一个项目,并在点击命令按钮后,我想要" foo " outputText的值将使用对话框中数据表中的数据进行更改。但似乎没有任何事情发生。我可以使用任何帮助。提前致谢。下面是我的xhtml片段。 编辑:支持bean中的方法也被添加到帖子中。



<!-- I want the "foo" to be updated with selected data in the dialog's datatable -->
<p:fieldset id="groupConfigurationPanel"
                        legend="#{messages['notificationGroup.title.NotificationGroupConfiguration']}"
                        styleClass="fieldSet">

                <h:panelGrid columns="3"
                             columnClasses="formLayoutLabel, formLayoutInput, formLayoutValidator"
                             rowClasses="formLayoutOddRow, formLayoutEvenRow" cellpadding="0"
                             cellspacing="0" width="100%">
                    <h:outputText id="offerText" value="Offer" />
                    <h:outputText id="foo"
                                  rendered="#{notificationGroupSupport.instance.offers!=null}" />
                    <p:commandButton value="Select Offer" id="selectOfferButton"
                                     action="#{notificationGroupSupport.retrieveOfferList}"
                                     type="submit" update=":selectOfferForm"
                                     oncomplete="selectOfferVar.show();">
                    </p:commandButton>
                </h:panelGrid>
                
                </p:fieldset>

<!-- This is the dialog -->
<!-- This dialog has a datatable and the commandbutton in this datatable is supposed to update the outputText -->
<p:dialog id="offerDialog" header="Select Offer"
              widgetVar="selectOfferVar" modal="true" resizable="true">

        <h:form id="selectOfferForm">
            <h:panelGrid columns="3" bgcolor="#eff5fa" cellspacing="5"
                         frame="box" styleClass="center">


                <p:dataTable id="offerTable" var="offer" styleClass="dataList"
                             value="#{notificationGroupSupport.offerList}"
                             rowKey="#{offer.offerId}"
                             widgetVar="propertyTableVar" paginator="true" rows="12">
                    <f:facet name="header">
                        <div align="center">Offer List</div>
                    </f:facet>


                    <p:column selectionMode="single" style="width:18px" />
                    <p:column sortBy="#{offer.offerId}" headerText="ID"
                              filterBy="#{offer.offerId}" filterMatchMode="contains">
                        <h:outputText value="#{offer.offerId}" />
                    </p:column>


                    <p:column sortBy="#{offer.externalOfferId}"
                              headerText="External Offer Id"
                              filterBy="#{offer.externalOfferId}" filterMatchMode="contains">
                        <h:outputText value="#{offer.externalOfferId}" />
                    </p:column>

                    <p:column sortBy="#{offer.description}"
                              headerText="Description"
                              filterBy="#{offer.description}" filterMatchMode="contains">
                        <h:outputText value="#{offer.description}" />
                    </p:column>


                    <f:facet name="footer">
                        <p:commandButton value="Select" type="submit" id="nonajax"
                                         actionListener="#{notificationGroupSupport.updateOffer()}"
                                         styleClass="ui-priority-primary" ajax="false" update="foo"
                                         oncomplete="propertyTableVar.hide();" />
                    </f:facet>


                </p:dataTable>


            </h:panelGrid>
        </h:form>
    </p:dialog>
&#13;
&#13;
&#13;

// This is my method for this commandbutton's actionListener in my backing bean. I don't think this is an issue about my backing bean. The method called after select offer button got clicked
 public void updateOffer() 
 {
    campaignList = new ArrayList<Campaign>();
    lifecyclePolicyList = new ArrayList<LifecyclePolicy>();

    List<Offer> offers = getInstance().getOffers();

    for (Offer offer : offers) {

        if ( ( offer != null ) && ( offer.getOfferCampaignPairs() != null                )
                && ( offer.getOfferCampaignPairs().size() > 0 ) ) {
            for ( OfferCampaignPair pair : offer.getOfferCampaignPairs() ) {
                campaignList.add( pair.getCampaign() );
                if ( pair.getPrepaidLifecyclePolicy() != null ) {
                    lifecyclePolicyList.add( pair.getPrepaidLifecyclePolicy() );
                }
                if ( pair.getPostpaidLifecyclePolicy() != null ) {
                    lifecyclePolicyList.add( pair.getPostpaidLifecyclePolicy() );
                }
            }
        } else if ( offer == null ) {
            // todo
            getInstance().setCampaigns( campaignList );
            getInstance().setOffers( offerList );
            getInstance().setLifeCyclePolicies( lifecyclePolicyList );
        }
      }
      initConstants();
    }

0 个答案:

没有答案