To build a dataTable with dynamic columns in RichFaces,
we may use <c:foreach /> or <rich:columns /> in <rich:dataTable />
But the same is not applicable in <p:dataTable />
because <ui:repeat /> and <c:foreach /> is not working in <p:dataTable />
Thus, the only solution to achieve dynamic column in <p:dataTable /> is to use <p:columns />
With <c:foreach /> or <ui:repeat />, more flexibilities could be achieved.
Since they are not working in <p:dataTable />, the only way to achieve looping is <p:columns /> with less flexibilities.
Done!!
we may use <c:foreach /> or <rich:columns /> in <rich:dataTable />
<rich:dataTable var="var" value="#{myBean.list}">
<c:foreach var="column" value="#{myBean.columns}">
<rich:column>
<f:facet name="header">
<h:outputLabel value="#{column.name}" />
</f:facet>
<h:outputLabel value="#{var[column.value]}" />
</rich:column>
</c:foreach>
</rich:dataTable>
But the same is not applicable in <p:dataTable />
because <ui:repeat /> and <c:foreach /> is not working in <p:dataTable />
Thus, the only solution to achieve dynamic column in <p:dataTable /> is to use <p:columns />
<p:dataTable var="var" value="#{myBean.list}">
<p:columns var="colomn" value="#{myBean.columns}">
<f:facet name="header">
<h:outputLabel value="#{column.name}" />
</f:facet>
<h:outputLabel value="#{var[column.value]}" />
</p:columns>
</p:dataTable>
With <c:foreach /> or <ui:repeat />, more flexibilities could be achieved.
Since they are not working in <p:dataTable />, the only way to achieve looping is <p:columns /> with less flexibilities.
Done!!
No comments:
Post a Comment