Jsf 如何正确使用<;用户界面:重复>;

Jsf 如何正确使用<;用户界面:重复>;,jsf,facelets,uirepeat,Jsf,Facelets,Uirepeat,我在JSF页面中使用时遇到问题。我有一个传递给它的arrayList,但是,它从不迭代以显示内容 我知道有内容,因为当我使用执行完全相同的操作时,它会显示内容。因此,如果有人能向我解释为什么使用不起作用,但使用却起作用,那就太好了 以下是代码: <h:dataTable value="#{proposalAction.proposal.proposalCountries}" var="pc" rendered="#{proposalAction.proposal.proposalCount

我在JSF页面中使用
时遇到问题。我有一个传递给它的
arrayList
,但是,它从不迭代以显示内容

我知道有内容,因为当我使用
执行完全相同的操作时,它会显示内容。因此,如果有人能向我解释为什么使用
不起作用,但使用
却起作用,那就太好了

以下是
代码:

<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" />      
        &#160;
        <h:outputText value="#{pc.country.getDisplayName(localeSelector.locale)}" />
    </h:column>
</h:dataTable>
<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" />      
            &#160;<h:outputText value="#{pc.country.getDisplayName(localeSelector.locale)}" />
        </li>
    </ui:repeat>
</ul>

 
下面是使用
代码的代码:

<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" />      
        &#160;
        <h:outputText value="#{pc.country.getDisplayName(localeSelector.locale)}" />
    </h:column>
</h:dataTable>
<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" />      
            &#160;<h:outputText value="#{pc.country.getDisplayName(localeSelector.locale)}" />
        </li>
    </ui:repeat>
</ul>
  •  

正如你所看到的,它们是相同的。数据表显示国家,但中继器不显示
中的任何内容。。。我不知所措。。。请帮忙

如果您有合适的getter和setter,那么尝试使用
{pc.country.displayName}
作为
h:outputText
标记的值<代码>用户界面:重复没有
属性,因此使用
。我假设
displayName
是主列表的
Country
的属性。您可以在getter中编写特定的
Locale
逻辑

这应该起作用:

<ul>
    <ui:repeat value="#{proposalAction.proposal.proposalCountries}" var="pc" rendered="#{proposalAction.proposal.proposalCountries !=null and proposalAction.proposal.proposalCountries.size() > 0}">
        <li>
            <h:outputText value="#{pc.country.displayName}" />
        </li>
    </ui:repeat>
</ul>
也对您的
img
标签进行此类调整。 您还应该将
呈现的
的逻辑放在后端bean中,并在UI上使用单布尔值。例如
redered=“#{displayCountries}

-)如此有效地实现了“rtfm”