我有一个SessionScoped
包含地图列表的 bean。我正在尝试<rich:dataTable>
使用<a4j:repeat>
.
尽管没有 dataTable 输出,但地图列表已正确填充。通过阅读有关堆栈溢出的文章,我认为我的问题可能是由于生命周期问题或我对带有richfaces的jsf的新手理解而发生的。
使用: Tomcat 7、JSF 2.1x - Mojarra、Richfaces 4.x
这是我到目前为止所拥有的;
<rich:dataTable value="#{myBean.myMap}" var="map">
<a4j:repeat value="#{myBean.myMap[0].keySet().toArray()}" var="key">
#{map[key]}
</a4j:repeat>
</rich:dataTable>
如果有人能指出我正确的方向,我们将不胜感激!
回答:
如下所述,解决方案是改为使用<c:forEach>
和使用<rich:columns>
.
解决方案:
<rich:dataTable value="#{queryBean.test}" var="map">
<c:forEach items="#{queryBean.test[0].keySet().toArray()}" var="key">
<rich:column style="text-align:left; width:auto;">
<f:facet name="header">
<h:outputText value="#{key}" />
</f:facet>
<h:outputText value="#{map[key]}" />
</rich:column>
</c:forEach>
</rich:dataTable>