3

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

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
gaffcz
  • 3,469
  • 14
  • 68
  • 108

2 Answers2

5

For Richfaces 3.3:

org.richfaces.component.html.HtmlDataTable

For Richfaces 4

org.richfaces.component.UIDataTable
Matt Handy
  • 29,855
  • 2
  • 89
  • 112
  • And that's the problem, this doesn't work in my project, therefore I'm asking again even you helped me with primefaces binding :] – gaffcz May 23 '11 at 18:10
  • @gaffcz: Are you sure you included the correct component and not eh standard jsf HtmlDataTable class? – Matt Handy May 23 '11 at 18:16
  • Is that component present in RF 4.0? OP is probably using RF 4.0. – BalusC May 23 '11 at 18:18
4

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:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Thank you, you've suggested me DataModel before, but I hadn´t a time yet. This time I'll try it :) – gaffcz May 23 '11 at 18:14
  • I googled somewhat and it look like that you should be using `org.richfaces.component.UIDataTable` (or at least one of its subclasses) for ``. Anyway, you can learn about the exact class by binding to `Object` and debugging the `getClass()` so that you can change it afterwards to the right one, as suggested in my answer. – BalusC May 23 '11 at 18:23
  • Thank you BalusC, that's it. I've also found it, but it didn't work yesterday, but today it does:) Could you, in nutshell, tell me something about advantages of DataModel? – gaffcz May 23 '11 at 18:41
  • BalusC, I've tried the second link you've posted, but there is java.io.NotSerializableException: javax.faces.model.ListDataModel. I've found only one solution, make the Model transient, but it is bullshit (bean.model value is empty). Don't you know where is the problem? – gaffcz May 23 '11 at 21:27
  • Ops, it's @viewScoped.. @requestScoped is enogh, it works >:) – gaffcz May 23 '11 at 21:35