1

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!

geeehhdaa
  • 822
  • 5
  • 17
  • 30

2 Answers2

2

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

niksvp
  • 5,545
  • 2
  • 24
  • 41
1

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>
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555