【发布时间】:2018-10-19 14:48:01
【问题描述】:
我在 JSF 页面中使用 <ui:repeat> 时遇到问题。我有一个 arrayList 传递给它,但是,它从不迭代显示内容。
我知道有内容,因为当我使用<h:datatable> 执行完全相同的操作时,它会显示内容。因此,如果有人可以向我解释为什么使用 <ui:repeat> 不起作用但使用 <h:datatable> 不起作用,那就太好了。
这里是<h:datatable> 代码:
<h:dataTable value="#{proposalAction.proposal.proposalCountries}" var="pc" rendered="#{proposalAction.proposal.proposalCountries !=null and proposalAction.proposal.proposalCountries.size() > 0}">
<h:column>
<img src="/resources/images/flags/#{utils.getValidCountryFlagDisplayCode(pc.country)}.png" title="#{pc.country.getDisplayName(localeSelector.locale)}" alt="#{pc.country.getDisplayName(localeSelector.locale)}" width="20" />
 
<h:outputText value="#{pc.country.getDisplayName(localeSelector.locale)}" />
</h:column>
</h:dataTable>
这是使用<ui:repeat>代码的代码:
<ul>
<ui:repeat items="#{proposalAction.proposal.proposalCountries}" var="pc" rendered="#{proposalAction.proposal.proposalCountries !=null and proposalAction.proposal.proposalCountries.size() > 0}">
<li>
<img src="/resources/images/flags/#{utils.getValidCountryFlagDisplayCode(pc.country)}.png" title="#{pc.country.getDisplayName(localeSelector.locale)}" alt="#{pc.country.getDisplayName(localeSelector.locale)}" width="20" />
 <h:outputText value="#{pc.country.getDisplayName(localeSelector.locale)}" />
</li>
</ui:repeat>
</ul>
如您所见,它们是相同的。数据表显示国家/地区,但转发器在<ul> 内没有显示任何内容……我不知所措……请帮忙!
【问题讨论】: