I have a SessionScoped
bean which has a list of maps. I am attempting to get a <rich:dataTable>
produced using <a4j:repeat>
.
The list of maps is being populated correctly, although there is no dataTable output. From reading articles on stack-overflow, I think my problem may be occuring due to the life-cycle problems or my novice understanding of jsf with richfaces.
Using: Tomcat 7, JSF 2.1x - Mojarra, Richfaces 4.x
Here is what I have so far;
<rich:dataTable value="#{myBean.myMap}" var="map">
<a4j:repeat value="#{myBean.myMap[0].keySet().toArray()}" var="key">
#{map[key]}
</a4j:repeat>
</rich:dataTable>
If someone could point my in the correct direction, the help would be greatly appreciated!
Answer:
As stated below the solution is to instead use <c:forEach>
and use <rich:columns>
.
Solution:
<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>
First of all <rich:dataTable>
has to contain columns - <rich:column>
Assuming you want to have dynamic table (the number of columns based on the length of the map) you will have to use <c:forEach>
instead of <a4j:repeat>
. I have answered a question about this a while ago, take a look.