Search code examples
jsfjsf-2richfaces

How to bind <rich:dataTable> to backing bean?


Is there any way to bind rich:dataTable to the bean? I can show the items in non binding rich:dataTable, but when I add binding attribute, whole dataTable dissappear.

Part of code:

<rich:dataTable 
  id="tableDetail"
  value="#{myBdeCheck.dataListBde}"
  binding="#{myBdeCheck.dataTable}"
  var="bdeItem">

  <rich:column>
    <f:facet name="header">
      <h:outputText value="Select" />
    </f:facet>
    <h:selectBooleanCheckbox value="#{myBdeCheck.selectedRow}"/>
  </rich:column>

  <rich:column>
    <f:facet name="header">
     <h:outputText value="Shift" />
    </f:facet>
    <h:outputText value="#{bdeItem.dayShift}"/>
  </rich:column>

  <f:facet name="footer">  
    <h:commandButton id="btnAdd" action="#{myBdeCheck.add}"/>
  </f:facet>
</rich:dataTable>

For JSF is working private HtmlDataTable dataTable;.

Is there something else for richfaces? Thank you


Solution

  • The HtmlDataTable is for <h:dataTable>, not <rich:dataTable>.

    I'm not sure what component class <rich:dataTable> is using, but to findout that, you need to replace HtmlDataTable by Object and then in the setter print/debug the dataTable.getClass() so that you can learn which one it is.

    By the way, what do you need the binding for? To get the selected row? You could also use DataModel<E> as datatable value instead. For an example check the following answers: