1

I have a <rich:dataTable> in JSF page.

<rich:dataTable id="transactionTable" rendered="#{tellerBean.userTransactions.size() > 0}"
    value="#{tellerBean.userTransactions}" var="transaction">

When I press a search button, the backing list gets filled and I re-render the table. However this does not work, because the rendered attribute is server side and the grid never gets converted to HTML in the first place so re-rendering fails. How can I have the grid to be hidden when the backing list is of 0 size, and shown when the list size is > 0?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
user1730789
  • 5,157
  • 8
  • 36
  • 57

1 Answers1

1

Wrap it in a component which is always rendered and update it instead.

<h:panelGroup id="transactionTableGroup">
    <rich:dataTable ... rendered="#{not empty tellerBean.userTransactions}">

    </rich:dataTable>
</h:panelGroup>

(note that I improved the EL expression in the rendered attribute as well; yours was clumsy and would only produce a XML syntax error when using Facelets instead of legacy JSP)

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555