2016-12-14 3 views
1

у меня есть выпадающее меню, которое добавит новую строку ввод поля следующим образом:JSF a4j: Повторите оленью кожу связать значения резервного боба для динамически генерируемых строк

<h:selectOneMenu id="selBillingSelect" rendered="#participantController.enableMultipleBilling}"           title="#{awbInformationorderBundle.RATING_DETAILS_ADD_LBL_TIP}"           tabindex="#{headerBean.tabIndex}" styleClass="optional"           value="#{participantController.numberOfRows}" accesskey="6"           style="vertical-align:bottom"> 
<f:ajax event="change" listener="#{participantController.addBillingLines}"            render=":frmParticipantInfo:billingTable hidBillingSize"            execute=":frmParticipantInfo:billingTable"            onevent="billingAutoExpansion" /> 
<f:selectItem itemValue="0" itemLabel="Add a Carrier" /> 
<f:selectItem itemValue="1" itemLabel="1" /> 
<f:selectItem itemValue="2" itemLabel="2" /> 
<f:selectItem itemValue="3" itemLabel="3" /> 
<f:selectItem itemValue="4" itemLabel="4" /> 
</h:selectOneMenu> 

бэк-код боба добавить данные

public void addBillingLines(){ 
    BillingPartsInfoDto aBillingPartsInfoDto = null; 
    for (int i = 0; i < this.getNumberOfRows(); i++) { 
     if(this.getBillingSize()<this.getMaxAirlineCodeAllowed()){ 
      aBillingPartsInfoDto= new BillingPartsInfoDto(); 
      billingInfoDtos.add(aBillingPartsInfoDto); 
      this.setBillingSize(this.getBillingInfoDtos().size()); 
     } 
    } 
    this.setNumberOfRows(0); 
    return; 
} 

у меня есть a4j: повторить, чтобы отобразить данные следующим образом:

<h:panelGroup id="billingTable"></h:panelGroup> 

<a4j:repeat id="billingLines#{rowIndex}" var="item" keepSaved="true" value="#{participantController.billingInfoDtos}" rowKeyVar="rowIndex">            <cc:customTable id="billingTable">            <cc:customTr styleClass="fieldTitle">             <cc:customTd valign="center">              <h:outputText value="Carrier Code"             escape="false" />             </cc:customTd>             <cc:customTd valign="center">              <h:outputText              value="#{participantBundle.BILLING_INVOICE_MEDIA_LBL}"               escape="false" />             </cc:customTd>             <cc:customTd><h:outputText styleClass="spacer20" />             </cc:customTd><cc:customTd valign="center">             <h:outputText value="#participantBundle.BILLING_INVOICE_FREQUENCY_LBL}"               escape="false" /></cc:customTd><cc:customTd><h:outputText tyleClass="spacer20" /> 

                <cc:customTd valign="center"> 
                 <h:outputText value="#{participantBundle.BILLING_INVOICE_SEQUENCE_LBL}"               escape="false" /></cc:customTd> 
                <cc:customTd> 
                 <h:outputText styleClass="spacer20" /> 
                </cc:customTd> 

                <cc:customTd valign="center"> 
                 <h:outputText 
                  value="#{participantBundle.BILLING_INVOICE_LANGUAGE_LBL}" 
                  escape="false" /> 
                </cc:customTd> 
                <cc:customTd> 
                 <h:outputText styleClass="spacer20" /> 
                </cc:customTd> 
                <cc:customTd valign="center"> 
                 <h:outputText 
                  value="#{participantBundle.BILLING_INVOICE_SITE_LBL}" 
                  escape="false" /> 
                </cc:customTd> 
                <cc:customTd> 
                 <h:outputText styleClass="spacer20" /> 
                </cc:customTd> 
                <cc:customTd valign="center"> 
                 <h:outputText 
                  value="#{participantBundle.BILLING_CURRENCY_LBL}" 
                  escape="false" /> 
                </cc:customTd> 
                <cc:customTd> 
                 <h:outputText styleClass="spacer20" /> 
                </cc:customTd> 
                <cc:customTd> 
                 <h:outputText style="vertical-align:top;" 
                  value="#{participantBundle.DETAILS_INVOICE_EMAIL_LBL}" /> 
                </cc:customTd> 
               </cc:customTr> 

               <cc:customTr> 
                <cc:customTd valign="top"> 
                 <h:selectOneMenu id="carrierCode" value="#{item.airline}" 
                 title="#{participantBundle.INVOICE_MEDIA_TIP}" rendered="#{participantController.enableMultipleBilling}" 
                  tabindex="#{headerBean.tabIndex}" style="width:50px;" 
                  accesskey="#{participantBundle.BILLING_INVOICE_MEDIA_AKEY}" 
                  styleClass="required"> 
                  <f:selectItems value="#{participantController.specificAirlines}"></f:selectItems> 
                 </h:selectOneMenu> 
                </cc:customTd> 
                <cc:customTd> 
                 <h:selectOneMenu id="invoiceMedia1" 
                  value="#{item.invoiceMedia}" 
                  title="#{participantBundle.INVOICE_MEDIA_TIP}" 
                  tabindex="#{headerBean.tabIndex}" 
                  accesskey="#{participantBundle.BILLING_INVOICE_MEDIA_AKEY}" 
                  styleClass="required"> 
                  <f:selectItem itemLabel=" " itemValue=" " /> 
                  <f:selectItem itemLabel="Descriptive" 
                   itemValue="Descriptive" /> 
                  <f:selectItem itemLabel="CASS Tape" itemValue="CASS Tape" /> 
                  <f:selectItem itemLabel="Government Form" 
                   itemValue="Government Form" /> 
                  <f:selectItem itemLabel="Literal" itemValue="Literal" /> 
                  <f:selectItem itemLabel="Tape" itemValue="Tape" /> 
                  <f:selectItem itemLabel="Email" itemValue="Email" /> 
                  <f:selectItem itemLabel="FTP" itemValue="FTP" /> 
                  <f:converter converterId="EnumConverter"></f:converter> 
                 </h:selectOneMenu> 
                </cc:customTd> 
                <cc:customTd></cc:customTd> 

                <cc:customTd> 
                 <h:selectOneMenu id="invoiceFrequency" 
                  value="#{item.invoiceFrequency}" 
                  title="#{participantBundle.INVOICE_FREQUENCY_TIP}" 
                  tabindex="#{headerBean.tabIndex}" styleClass="required"> 
                  <f:selectItem itemLabel=" " itemValue=" " /> 
                  <f:selectItem itemLabel="Weekly" itemValue="Weekly" /> 
                  <f:selectItem itemLabel="Bi-Monthly" 
                   itemValue="Bi-Monthly" /> 
                  <f:selectItem itemLabel="Daily" itemValue="Daily" /> 
                  <f:selectItem itemLabel="Demand" itemValue="Demand" /> 
                  <f:selectItem itemLabel="Monthly" itemValue="Monthly" /> 
                  <f:selectItem itemLabel="10 days" itemValue="10 days" /> 
                  <f:converter converterId="EnumConverter"></f:converter> 
                 </h:selectOneMenu> 
                </cc:customTd> 

                <cc:customTd></cc:customTd> 

                <cc:customTd> 
                 <h:selectOneMenu id="invoiceSequence" 
                  value="#{item.invoiceSequence}" 
                  title="#{participantBundle.INVOICE_SEQUENCE_TIP}" 
                  tabindex="#{headerBean.tabIndex}" styleClass="required"> 
                  <f:selectItem itemLabel=" " itemValue=" " /> 
                  <f:selectItem itemLabel="Ascending Order" 
                   itemValue="Ascending Order" /> 
                  <f:selectItem itemLabel="Double Space" 
                   itemValue="Double Space" /> 
                  <f:converter converterId="EnumConverter"></f:converter> 
                 </h:selectOneMenu> 
                </cc:customTd> 
                <cc:customTd> 
                 <h:inputText id="txtInvoiceLanguage" 
                  value="#{item.invoiceLanguage}" 
                  tabindex="#{headerBean.tabIndex}" size="3" maxlength="3" 
                  styleClass="required" 
                  title="#{participantBundle.INVOICE_LANGUAGE_TIP}" /> 
                </cc:customTd> 
                <cc:customTd></cc:customTd> 
                <cc:customTd> 
                 <h:inputText id="txtSite" 
                  value="#{item.invoiceSite}" 
                  tabindex="#{headerBean.tabIndex}" size="3" maxlength="3" 
                  styleClass="required" 
                  title="#{participantBundle.INVOICE_SITE_TIP}" /> 
                </cc:customTd> 
                <cc:customTd></cc:customTd> 
                <cc:customTd> 
                 <h:inputText id="txtBillingCurrency" 
                  value="#{item.currency}" 
                  tabindex="#{headerBean.tabIndex}" size="3" maxlength="3" 
                  styleClass="required" 
                  title="#{participantBundle.BILLING_CURRENCY_TIP}" /> 
                </cc:customTd> 
                <cc:customTd></cc:customTd> 
                <cc:customTd> 
                 <h:inputText id="txtInvoiceEmail" 
                  style="vertical-align:top;" 
                  value="#{item.invoiceEmail}" 
                  size="45" maxlength="68" styleClass="optional" 
                  title="#{participantBundle.DETAILS_EMAIL_TIP}" /></cc:customTd></cc:customTr></cc:customTable> 
</a4j:repeat> 

проблема при добавлении нового ро w с помощью раскрывающегося списка, а затем установите значение в поле ввода в компоненте a4j: repeat и отправьте форму, бэк-компонент будет установлен с нулевым значением для всех полей. Где и когда я не добавляю новую строку и сохраняю форму, данные сохраняются в бэкэнд.

ответ

0

Я думаю, это потому, что каждый раз, когда вы добавляете новые объекты aBillingPartsInfoDto в список billingInfoDtos и не задаете никаких значений для переменных dto.

if(this.getBillingSize()<this.getMaxAirlineCodeAllowed()){ 
      aBillingPartsInfoDto= new BillingPartsInfoDto(); 

      /* Set values to dto variables here */ 

      billingInfoDtos.add(aBillingPartsInfoDto); 
      this.setBillingSize(this.getBillingInfoDtos().size()); 
     } 
+0

Мое требование состоит в том, чтобы добавить новый пустой объект, который будет иметь набор полей пользовательского интерфейса. пользователь вводит данные в поля ввода. Данные вводятся пользователем при отправке формы в нуль. Где, как если бы я не добавлял никаких новых строк и не вводил значения в первую строку по умолчанию, а затем в форме subisiion, я не теряю никакого значения. – user2695833

+0

вы можете показать свой код внутри a4j: repeat component – Albin

+0

Я отредактировал сообщение, чтобы добавить a4j: repeat contents – user2695833

Смежные вопросы