Hi,
It would be better to understand if you can explain how you obtain the array of rows.
I have implemented something like this using a request scope bean. I have a dataTable with a checkbox for each row and then some actions I want to perform on the selected rows. It may not be the best way to approach this, but it works.
The way I do it is:
Let's say I have a collection of User objects. Each user has a name, email, phone number, etc. I also add a boolean field called "selected" to the User.
Now when creating the dataTable, I have a value binding for the checkbox to my user's selected field.
When the request is posted, I just iterate over the users and select the users for which isSelected is true.
The code looks something like this
I have a backing bean called UserBean which has a list of Users.
<x:dataTable
var="user"
id="userData"
value="#{UserBean.users}"
width="100%"
rowClasses="tableRowAll"
headerClass="tableColumnHeader"
>
<h:column>
<f:facet name="header">
<h:selectBooleanCheckbox id="ckbHeader" value="false" />
</f:facet>
<h:selectBooleanCheckbox id="ckbRow" value="#{user.selected}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Name"/>
</f:facet>
<x:outputText value="#{user.name}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="User Name"/>
</f:facet>
<x:outputText value="#{user.username}"/>
</h:column>
Cheers
Amit
-----Original Message-----
From: Alessandro Polverini [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, January 19, 2005 10:12 AM
To: MyFaces Discussion
Subject: Strange problem with dataTable and checkboxes
Hello,
I'm facing a strange problem and since I'm not yet expert of JSF I don't
understand if this is a bug or the right behaviour.
I'm rendering a form with a text field (call it t1), a checkbox (call it
b1) and a dataTable.
On every row of the table I have a checkbox, so that I can choose which
elements to operate on when I press on the appropriate command button.
Think to usual web mail systems where you select messages in the index
page and then you press a button to delete them.
If the backing bean of the form has session scope, in the actionListener
associated to the command button I'm able to check the state of all the
rows, and so to operate on them correctly.
Now, the problem is that the array of rows is empty if I set the backing
bean to have request scope: is this the correct behaviour?
If it is, why I can correctly get the state of t1 and b1, and be unable
to get the values of the others components? That's what seems strange to
me.
I try to not use session beans because if the user has multiple open
windows to the same application, bad things can happens on pages like
that one.
An advice would be much appreciated :)
Alex
P.S.: Please excuse me for my poor English

