JSF: Empty space caused by rendered attribute
How can I get rid of the empty space by components not 开发者_如何学编程rendered via rendered attribute?
I want to display a list of objects in a dataTable and sort them by a property they have. I do it likes this: view plaincopy to clipboardprint?
<t:dataTable value="#{someBean.values}" var="value">
<h:column>
<f:facet name="header">
<t:outputText value="X" />
</f:facet>
<h:panelGroup rendered="#{value.property eq 'X'}">
<!-- some stuff -->
</h:panelGroup>
</h:column>
<h:column>
<f:facet name="header">
<t:outputText value="Y" />
</f:facet>
<h:panelGroup rendered="#{value.property eq 'Y'}">
<!-- some stuff -->
</h:panelGroup>
</h:column>
</t:dataTable>
It will display one item every row only, because of the rendered thingy. How can I avoid this? I stumpled upon this also on other occasions...
Thank you!
It is obvious to display one item every row with datatable
.
You can better have two different datatables, one rendering for x and other rendering for y and adjust your css
accordingly that looks like two column of the same table. Or else using richfaces, <rich:subTable>
would help you, such as having two subTable
in a single dataTable
Use a single column and render in there.
<t:dataTable value="#{someBean.values}" var="value">
<h:column>
<f:facet name="header">
<t:outputText value="#{value.property}" />
</f:facet>
<h:panelGroup rendered="#{value.property eq 'X'}">
<!-- some stuff -->
</h:panelGroup>
<h:panelGroup rendered="#{value.property eq 'Y'}">
<!-- some stuff -->
</h:panelGroup>
</h:column>
</t:dataTable>
精彩评论