2016-12-14 2 views
1

générées dynamiquement j'ai un menu déroulant qui va ajouter une nouvelle rangée de champs d'entrée comme suit:JSF a4j: Répéter lier doesnot les valeurs à sauvegarder bean pour les lignes

<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> 

support code bean pour ajouter des données

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; 
} 

j'ai un a4j: répéter pour afficher les données comme suit:

<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> 

Le problème est quand j'ajoute un nouveau ro w en utilisant la liste déroulante, puis définissez la valeur à la zone de saisie dans le formulaire a4j: repeat et submit, le bean backing est défini avec une valeur nulle pour tous les champs. Où comme lorsque je n'ajoute aucune nouvelle ligne et enregistrer le formulaire, les données sont sauvegardées dans le backend.

Répondre

0

Je pense que c'est parce que chaque fois que vous ajoutez de nouveaux objets de aBillingPartsInfoDto à la liste billingInfoDtos et ne définissez aucune valeur pour les variables dto.

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

      /* Set values to dto variables here */ 

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

mon exigence est d'ajouter un nouvel objet vide qui aura un ensemble de champs d'interface utilisateur. l'utilisateur va entrer les données dans les boîtes de saisie. Les données sont entrées par l'utilisateur sur la soumission du formulaire est nulle. Où comme quand je n'ajoute pas de nouvelles lignes et n'entre pas de valeur à la première ligne par défaut présente alors sur la forme du formulaire je perds toute valeur. – user2695833

+0

pouvez-vous montrer votre code à l'intérieur a4j: répéter composant – Albin

+0

J'ai édité le post pour ajouter le a4j: répéter le contenu – user2695833