Group visibility of rich:columns inside rich:datatable
I have a set of columns inside a rich:datatable, those columns are visible based on some preprocessed conditions. An example of what I want to do is this:
<rich:datatable value="tableList" var="list">
<h:panelGroup rendered="#{condition}">
<rich:column>
Component
<rich:column>
<rich:column>
Component
&开发者_开发知识库lt;rich:column>
</h:panelGroup>
<h:panelGroup rendered="#{not condition}">
<rich:column>
Component
</rich:column>
</h:panelGroup>
</rich:datatable>
The problem here is that the panelGroup tag never gets rendered inside the rich:datatable, even when I remove the "rendered" condition. I tried with an a4j:outputPanel and a few others but none worked.
I could remove the panel and put the condition in each column but that would be the last thing I would do.
Why is not working? Regards.
In fact, I am pretty sure that the <rich:dataTable>
will ignore any direct children that are not a UIColumn
or Column
object (I just had a look on org.richfaces.component.ColumnsIterator
, used by UIDataTable
).
In others words, your <h:panelGroup>
will simply be ignored by the <rich:dataTable>
, not matter when the rendered
attribute value is.
To solve your problem, I see three solutions:
- Put a
rendered
attribute on each<rich:column>
; - Use the
<rich:columnGroup>
component; - Define two
<rich:dataTable>
, one display when#{condition}
is evaluated totrue
, the other one when it isfalse
.
精彩评论