我有一个下拉菜单,它将添加新的输入字段行,如下所示:
<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>
支持bean代码添加数据
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>
问题是当我使用下拉列表添加新行,然后将值设置为a4j:repeat组件和提交表单中的输入框时,所有字段的支持bean都设置为null值。 当我没有添加任何新行并保存表单时,数据将保存在后端。
答案 0 :(得分: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());
}