-
1. Re: datatable list of lists
barbaraboie May 21, 2010 7:38 AM (in response to barbaraboie)I also tried:
<rich:dataTable value="#{lijstWaarden}" var="_list">
<a4j:repeat value="#{_list}" var="_waarde">
<rich:column>
<h:outputText value="#{_waarde.tekst}" />
</rich:column>
</a4j:repeat>
</rich:dataTable>
but then I don't get any result
-
2. Re: datatable list of lists
lmk May 21, 2010 8:27 AM (in response to barbaraboie)an example for subTable is available on Richfaces demo site, you can also use nested dataTable, ui:repeat or c:foreach.
-
3. Re: datatable list of lists
ilya_shaikovsky May 21, 2010 8:27 AM (in response to barbaraboie)should be
<rich:dataTable value="#{lijstWaarden}" var="_list"> <c:forEach value="#{_list}" var="_waarde"> <rich:column> <h:outputText value="#{_waarde.tekst}" /> </rich:column> </c:forEach> </rich:dataTable>
first code snippet output works just as expected. and the usage of repeat to create columns dynamically answered already at this forum and other ones.. e.g. - http://www.ilikespam.com/blog/c:foreach-vs-ui:repeat-in-facelets
-
4. Re: datatable list of lists
barbaraboie May 21, 2010 9:13 AM (in response to ilya_shaikovsky)<rich:dataTable value="#{lijstWaarden}" var="_list">
<c:forEach items="#{_list}" var="_waarde">
<rich:column>
<h:outputText value="test2 #{_waarde.tekst}" />
</rich:column>
</c:forEach>
</rich:dataTable>Thanks for your answer, Ilya.
I tried c:foreach with items instead of value because that gave an error, so I have something like this:
but I got an empty table. So I tried this:
<rich:dataTable value="#{lijstWaarden}" var="_list">
<rich:column>
<h:outputText value="test1" />
</rich:column>
<c:forEach items="#{_list}" var="_waarde">
<rich:column>
<h:outputText value="test2 #{_waarde.tekst}" />
</rich:column>
</c:forEach>
</rich:dataTable>and the result was this:
test1 test1 test1 so the items in _list are not shown...
-
5. Re: datatable list of lists
ilya_shaikovsky May 24, 2010 2:47 AM (in response to barbaraboie)check please generated HTML - if there are c:forEach tags ? maybe you just used wrong namespace?
-
6. Re: datatable list of lists
barbaraboie May 25, 2010 3:59 AM (in response to ilya_shaikovsky)<rich:dataTable value="#{lijstWaarden}" var="_list">
<rich:column>
<h:outputText value="size #{_list.size}" />
</rich:column>
<c:forEach items="#{_list}" var="_waarde">
<rich:column>
<h:outputText value="test2 #{_waarde.tekst}" />
</rich:column>
</c:forEach>
</rich:dataTable>
As you can see in the html-code, the size of _list is 5 for each of the 3 lists, but there is no sign of the for-each loop...
<table id="j_id2:j_id5" border="0" cellpadding="0" cellspacing="0">
<colgroup span="1"></colgroup>
<tbody id="j_id2:j_id5:tb">
<tr>
<td id="j_id2:j_id5:0:j_id6">size 5</td>
</tr>
<tr>
<td id="j_id2:j_id5:1:j_id6">size 5</td>
</tr>
<tr>
<td id="j_id2:j_id5:2:j_id6">size 5</td>
</tr>
</tbody>
</table> -
7. Re: datatable list of lists
nbelaevski May 25, 2010 8:00 AM (in response to barbaraboie)Hi Barbara,
This code:
<rich:dataTable value="#{lijstWaarden}" var="_list"> <rich:column> <h:outputText value="size #{_list.size}" /> </rich:column> <c:forEach items="#{_list}" var="_waarde"> <rich:column> <h:outputText value="test2 #{_waarde.tekst}" /> </rich:column> </c:forEach> </rich:dataTable>
is not correct. Variable of iteration component like rich:dataTable cannot be used as value for c:forEach.
-
8. Re: datatable list of lists
ilya_shaikovsky May 26, 2010 7:47 AM (in response to nbelaevski)Thanks Nick for pointing to my fault.
Barbara, sorry please.. yes, c:forEach is the only way define creation of components dynamically declarativelly from the page. But it will not works properly in your case as its creates the components while building/restoring view and dataTable var - available only at render responce during table encoding.
The same limitation exist for columns component - them should not use Var variable of the table according to the same problem.(see the demo - it uses it's own list for columns creation)