我想使用ui:repeat或任何其他迭代标记来一次性显示多个组件用于数组列表中的每个项目。
<!-- print multiple mandates -->
<ui:repeat id="mandates" var="mandate" value="#{taxheadDirectDebit.mandates}">
<a4j:region id="remittanceDetailsSection"
rendered="#{(taxheadDirectDebit.accountFinancialInfo.registration.type != 'PREM') or (taxheadDirectDebit.accountFinancialInfo.registration.type != 'VAT')}">
<!-- Remittance Details -->
<fieldset><legend class="sub"> <h:outputText
value="#{msg['remittanceDetails.title']}" /> </legend>
<!-- Estimated Liability -->
<div class="field">
<div class="label"><label for="allocatedAmount"><h:outputText
for="estimatedLiability"
value="#{msg['remittanceDetails.estimatedLiability']}" /> </label><span
class="requiredFlag">*</span></div>
<div class="error">
<rich:message styleClass="errorText" for="estimatedLiability" />
</div>
<div class="input">
<h:inputText id="estimatedLiability" size="30"
maxlength="11" label="#{msg['registerContractPage1.subTaxNumber']}"
value="#{taxheadDirectDebit.estimatedLiability}">
<a4j:ajax event="change" render="remittanceFrequency" />
</h:inputText>
</div>
<br class="clear" />
</div>
<!-- Is Seasonal -->
<div class="field">
<div class="label"><label for="isSeasonal"> <h:outputText
for="isSeasonal"
value="#{msg['remittanceDetails.isTheNatureSeasonal']}" /> </label><span
class="requiredFlag">*</span></div>
<div class="error"><rich:message styleClass="errorText"
for="isSeasonal" /></div>
<div class="input"><h:selectOneRadio id="isSeasonal"
label="#{msg['remittanceDetails.isTheNatureSeasonal']}"
value="#{taxheadDirectDebit.isSeasonal}"
styleClass="radioLabelTop">
<ddo:twoOptionSelection />
<a4j:ajax event="click" render="remittanceFrequency" />
</h:selectOneRadio></div>
<br class="clear" />
</div>
</fieldset>
</a4j:region>
<!-- Remittance Frequency -->
<a4j:outputPanel id="remittanceFrequency">
<div class="field">
<div class="label"><label for="allocatedAmount"><h:outputText
for="estimatedLiability"
value="#{msg['remittanceDetails.estimatedLiability']}" /> </label><span
class="requiredFlag">*</span></div>
<div class="error">
<rich:message styleClass="errorText" for="estimatedLiability" />
</div>
<div class="input">
<h:inputText id="estimatedLiability" size="30"
maxlength="11" label="#{msg['registerContractPage1.subTaxNumber']}"
value="#{taxheadDirectDebit.estimatedLiability}">
<a4j:ajax event="change" render=":remittanceDetails:mandates:remittanceFrequency" />
</h:inputText>
</div>
<br class="clear" />
</div>
<fieldset><legend class="sub"> <h:outputText
value="#{msg['remittanceDetails.frequency']}" /> </legend>
<!-- Amount to be Debited -->
<div class="field">
<div class="label"><label for="amountEachMonth"><h:outputText
for="amountEachMonth"
value="#{msg['remittanceDetails.amountToBeDebited']}" /> </label></div>
<div class="error"><rich:message styleClass="errorText"
for="amountEachMonth" /></div>
<div class="input"><h:inputText id="amountEachMonth" size="30" readOnly="true"
maxlength="8" label="#{msg['remittanceDetails.amountToBeDebited']}"
value="#{mandate.remittanceDetails.amountEachMonth}">
<a4j:ajax event="change" render="remittanceFrequencyNoDebitedEachMonth"/>
</h:inputText></div>
<br class="clear" />
</div>
<a4j:outputPanel id="remittanceFrequencyNoDebitedEachMonth">
<!-- Months -->
<div class="field">
<div class="grid1"><h:outputText
value=" " /> 
</div>
<rich:panel styleClass="ddo-panel" rendered="#{taxheadDirectDebit.isSeasonal == 1}">
<div class="grid2"><div align="center">
<h:outputText value="#{msg['reviewDetails.reduce']}"/><div align="center"></div>
</div></div>
</rich:panel>
<rich:panel styleClass="ddo-panel" rendered="#{taxheadDirectDebit.action == 'AMEND'}">
<div class="grid3">
<div align="center">
<h:outputText value="#{msg['reviewDetails.suspend']}"/><div align="center"></div>
</div>
</div>
</rich:panel>
<rich:panel styleClass="ddo-panel" rendered="#{taxheadDirectDebit.isSeasonal == 1}">
<div class="grid2">
<div align="center">
<h:outputText value="#{msg['reviewDetails.exclude']}"/><div align="center"></div>
</div>
</div>
</rich:panel>
<br class="clear" />
<div class="floatleft">
<div class="row3">
<div class="row1">
<!-- January -->
<!-- Months Column -->
<div class="grid1">
<label>
<h:outputText readOnly="true" disabled="true" size="4" value="#{msg['calendar.month.0']}" />
</label>
</div>
<!-- Reduce check box -->
<rich:panel styleClass="ddo-panel" rendered="#{taxheadDirectDebit.isSeasonal == 1}">
<div class="grid2">
<div align="center">
<h:selectBooleanCheckbox
id="reduce12"
value="#{mandate.remittanceDetails.remittanceFrequencys[0].reduce}"
disabled="#{mandate.remittanceDetails.remittanceFrequencys[0].exclude}">
<a4j:ajax event="click" render="remittanceFrequency" />
</h:selectBooleanCheckbox>
</div>
</div>
</rich:panel>
<!-- Suspend check box -->
<rich:panel styleClass="ddo-panel" rendered="#{taxheadDirectDebit.isSeasonal != 1}">
<div class="grid2hidden">
<h:outputText value=" " />
</div>
</rich:panel>
<rich:panel styleClass="ddo-panel" rendered="#{taxheadDirectDebit.action == 'AMEND'}">
<div class="grid3">
<div align="center">
<h:selectBooleanCheckbox
id="suspend0"
value="#{mandate.remittanceDetails.remittanceFrequencys[0].suspend}">
<a4j:ajax event="change" />
</h:selectBooleanCheckbox>
</div>
</div>
</rich:panel>
<!-- Exclude check box -->
<rich:panel styleClass="ddo-panel" rendered="#{taxheadDirectDebit.isSeasonal == 1}">
<div class="grid2">
<div align="center">
<h:selectBooleanCheckbox
id="exclude0"
value="#{mandate.remittanceDetails.remittanceFrequencys[0].exclude}"
disabled="#{mandate.remittanceDetails.remittanceFrequencys[0].reduce}">
<a4j:ajax event="change" render="remittanceFrequency" />
</h:selectBooleanCheckbox>
</div>
</div>
</rich:panel>
<rich:panel styleClass="ddo-panel" rendered="#{taxheadDirectDebit.isSeasonal != 1}">
<div class="grid2hidden">
<h:outputText value=" " />
</div>
</rich:panel>
<div class="errorRemittance">
<rich:message styleClass="errorText" for="remittanceAmount0"/>
</div>
<!-- Monthly Amount field -->
<div class="grid5">
<h:inputText
id="remittanceAmount0" size="30" maxlength="8" readOnly="true"
value="#{mandate.remittanceDetails.remittanceFrequencys[0].amount}"
disabled="#{!mandate.remittanceDetails.remittanceFrequencys[0].reduce}"
label="#{msg['remittanceDetails.amountToBeDebited']}">
<a4j:ajax event="change" render="remittanceFrequency" />
</h:inputText>
</div>
</div>
</div>
<div class="errorText" font="bold">
<rich:message styleClass="errorTextNoPadding" for="continue"/>
</div>
</div>
</div>
</a4j:outputPanel>
</fieldset>
</a4j:outputPanel>
<rich:message>
<rich:message for="remittanceFrequency" ajaxRendered="true" />
</rich:message>
</ui:repeat>
我在这里去掉了很多代码,所以可能会有一些不可用的div等,但想法就在那里。
我有两个问题:
- 您可以看到,一些组件具有基于id呈现其他组件的更改事件。这些事件在repeat中不起作用
- 我正在使用webflow并将消息添加到消息上下文中,以便消息标记可以显示验证消息,但这些消息在迭代中也不起作用
我尝试过tr:iterator、c:forEach、a4j:repeat、tr:forEah。我很确定我想做的事情是不可能的,所以如果有人有尝试实现类似目标的经验,我会感谢你的帮助。我无法更改我正在使用的MVC框架,但也许可以使用jQuery。
我通过将ajax区域移动到repeat之外并只对整个区域调用render来解决这个问题。我知道这并不漂亮,但这是我能找到的最快的解决方案。
在消息方面,我只需将列表中正在迭代的项的索引添加到消息中。
"remittanceDetails:mandates:"+taxhead.getMandates().indexOF(mandate)+":remittanceAmount" + frequency.getMonth().getCode()
JSF负责其余部分。