I have to dinamically produce a list of tables. Each of these have a variable number of columns (with fixed rows).
To perform this I first put a <p:panelGrid>
inside an <ui:repeat>
: so I correctly produced a list of tables.
Then, to dinamically produce the columns, I tried put both an <ui:repeat>
or a <c:forEach>
inside the <p:panelGrid>
. In the result I obtain no rows.
I written a minimal example here. In the bean testBackingBean
, I have defined (and initialized) the variable ArrayList<ArrayList<String>> tables
. This is the xhtml that does not produce the expected results:
<ui:repeat var="table" value="#{testBackingBean.tables}">
<p:panelGrid>
<f:facet name="header">
<p:row>
<p:column >header of #{table}</p:column>
</p:row>
</f:facet>
<p:row>
<c:forEach var="row" items="${table}">
<p:column>#{row}</p:column>
</c:forEach>
</p:row>
</p:panelGrid>
</ui:repeat>
Noteworthy the header-row correctly converts #{table}
into string. The problem is that I see no rows of data.
Also, if I use the <table>
instead of the <p:panelGrid>
everything work as excpected.
Also, I tried different permutations of <c:forEach>
and <ui:repeat>
with no succes.
So, how can I dinamically produce more tables (using prime-faces) and set a dinamical number of columns?
Thanks!
EDIT: I would like to use two <c:forEach>
, but even with one only <c:forEach>
I get an empty result. In fact if I try the following xhtml:
<c:forEach items="${testBackingBean.tables}" var="tabella">
current element: #{tabella}
</c:forEach>
then I get an empty result. (I know,this is a different question)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…