Code: Select all
<p:dataTable id="table" value="#{search.listOfLists}" var="row" >
<c:forEach items="#{row}" var="numberOfColumns">
<p:column>
<f:facet name="header">
<h:outputText value="#{numberOfColumns.attributeID}" />
</f:facet>
<h:outputText value="#{numberOfColumns.attributeValue}" />
</p:column>
</c:forEach>
</p:dataTable>
Code: Select all
@ManagedBean(name = "search")
@SessionScoped
public class SearchBean implements Serializable {
private List<List<TreeEntryInfo>> listOfLists;
public SearchBean() {
listOfLists = new ArrayList<List<TreeEntryInfo>>();
List <TreeEntryInfo> example1 = new ArrayList<TreeEntryInfo>();
List <TreeEntryInfo> example2 = new ArrayList<TreeEntryInfo>();
List <TreeEntryInfo> example3 = new ArrayList<TreeEntryInfo>();
example1.add(new TreeEntryInfo("id1", "value1"));
example1.add(new TreeEntryInfo("id2", "value2"));
example1.add(new TreeEntryInfo("id3", "value3"));
example2.add(new TreeEntryInfo("id4", "value4"));
example2.add(new TreeEntryInfo("id5", "value5"));
example2.add(new TreeEntryInfo("id6", "value6"));
example3.add(new TreeEntryInfo("id7", "value7"));
example3.add(new TreeEntryInfo("id8", "value8"));
example3.add(new TreeEntryInfo("id9", "value9"));
listOfLists.add(example1);
listOfLists.add(example2);
listOfLists.add(example3);
}
public List<List<TreeEntryInfo>> getListOfLists() {
return listOfLists;
}
public void setListOfLists(List<List<TreeEntryInfo>> lol) {
this.listOfLists = lol;
}
I imagine this situation as follows: i get list of lists from my querry on ldap. So attribute var in dataTable has list of objects (id - value) that holds one result from querry. I give that list to my old friend - c:forEach. He or She :p iterate on collection and create columns . But this is not work:( When I give collection from my bean (for example: <c:forEach items="#{search.someCollection}" var="numberOfColumns">) then forEach work's fine - create columns. Please help me;] I use 2.0.1-SNAPSHOT version + Mojarra 2.0.2 (FCS b10) + glassfish 3 //+ weak english ;p
PrimeFaces KICK ASS! I love it at first sight:D