Take the 2-minute tour ×

In order to get the row numbers of a datatable I got an answer here that I could bind the dataTable directly to the view (JSF 2 dataTable row index without dataModel).

I'm using that function in a composite component and there may be several of those in the same page. I believe that the binding makes it impossible to use more than one component on each page; is it possible to bind each table "separately" somehow?

share|improve this question
Well you will bind each table on different managed bean, or on different properties of backing bean? Why would it be the problem? –  partlov Feb 4 '13 at 14:29

1 Answer 1

up vote 1 down vote accepted

Create a backing component class with an UIData property.

public class FooComponent extends UINamingContainer {

    private UIData table;

    // +getter +setter

And bind it to #{cc.table} instead (the #{cc} refers the current backing component instance).

<cc:interface componentType="fooComponent">
    <h:dataTable binding="#{cc.table}" ...>
        <h:column>#{cc.table.rowIndex + 1}</h:column>
share|improve this answer
Works. Thank you! –  nivis Feb 4 '13 at 15:01
You're welcome. –  BalusC Feb 4 '13 at 15:17
Just noticed that I'm not able to use cc.table.RowIndex inside p:commandLink: <p:commandLink actionListener="#{bean.selectRow(cc.table.rowIndex)}"... I can see it beeing displayed in each table row, but it seems it's not available inside the actionListener. –  nivis Feb 4 '13 at 15:54

Your Answer


