You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Balaji Saranathan <ba...@wipro.com> on 2005/09/09 17:58:20 UTC
Selecting checkboxes in the backing bean
Hi,
I have a page where there is a SelectOneMenu and a dataTable beneath. I
would like to select a couple of rows in the dataTable based on the
selection of the SelectOneMenu.
I have registered a ValueChangeListener to the SelectOneMenu and my
method is getting called.
But how do I actually check the CheckBoxes created in the DataTable
programatically based on one of the column information. Assuming I have
a colum called name, and I have to select all the rows containing the
name "XXX", how would I get a handle to the column rows and the
checkboxes to select it.
Is looping through the UIViewRoot, the only way?
Does anyone have any ideas?
Thanks
Balaji
Confidentiality Notice
The information contained in this electronic message and any attachments to this message are intended
for the exclusive use of the addressee(s) and may contain confidential or privileged information. If
you are not the intended recipient, please notify the sender at Wipro or Mailadmin@wipro.com immediately
and destroy all copies of this message and any attachments.
RE: Selecting checkboxes in the backing bean
Posted by Dave <ja...@yahoo.com>.
Yes. I tried to avoid it. But it does not belong to data model in persistence.(transient)
Balaji Saranathan <ba...@wipro.com> wrote:Which then doesnt mean, we are violating the MVC model which the JSF is actually trying to achieve?
-----Original Message-----
From: Dave [mailto:javaone9@yahoo.com]
Sent: Friday, September 09, 2005 3:06 PM
To: MyFaces Discussion; balaji.saranathan@wipro.com
Subject: RE: Selecting checkboxes in the backing bean
You are right on the coupling UI and data model. I found it more clean. Make sure the property is transient only for UI. :-)
Balaji Saranathan <ba...@wipro.com> wrote: Hi,
Isnt there any other way to do it? Assuming, UserInfo is the member class of the collection (datamodel), why should a property exist on it, that is something to do with the presentation on the UI. It actually is not a property of the class at all. I think this would mean we couple UI and model tightly.
Therefore, on the backing bean, I have a class level variable UISelectBoolean selected as specified by Craig in this forum http://forum.java.sun.com/thread.jspa?forumID=427&threadID=486654 . This variable is bounded to the Checkbox. As per my understanding, the dataTable internally handles the state of each checkbox mapped to this variable.
However, on my code I loop through the rows displayed and set the selected.setSelected(true). However, this doesnt seem to have any effect at all.
Note:
"table" here refers to an instance of UITable that is binded to the DataTable.
int firstRow = table.getFirst();
int numRows = table.getRows();
for (int index = firstRow; index < (firstRow + numRows); index++)
{
table.setRowIndex( index );
selected.setSelected(true);
}
Thanks
Bala
-----Original Message-----
From: Dave [mailto:javaone9@yahoo.com]
Sent: Friday, September 09, 2005 1:51 PM
To: MyFaces Discussion; balaji.saranathan@wipro.com
Subject: Re: Selecting checkboxes in the backing bean
Add a property in backing bean data model(member class of collection) such as selected, and bind the checkbox to the property.
Balaji Saranathan <ba...@wipro.com> wrote:
Hi,
I have a page where there is a SelectOneMenu and a dataTable beneath. I would like to select a couple of rows in the dataTable based on the selection of the SelectOneMenu.
I have registered a ValueChangeListener to the SelectOneMenu and my method is getting called.
But how do I actually check the CheckBoxes created in the DataTable programatically based on one of the column information. Assuming I have a colum called name, and I have to select all the rows containing the name "XXX", how would I get a handle to the column rows and the checkboxes to select it.
Is looping through the UIViewRoot, the only way?
Does anyone have any ideas?
Thanks
Balaji
Confidentiality Notice
The information contained in this electronic message and any attachments to this message are intended
for the exclusive use of the addressee(s) and may contain confidential or privileged information. If
you are not the intended recipient, please notify the sender at Wipro or Mailadmin@wipro.com immediately
and destroy all copies of this message and any attachments.
---------------------------------
Click here to donate to the Hurricane Katrina relief effort.
Confidentiality Notice
The information contained in this electronic message and any attachments to this message are intended
for the exclusive use of the addressee(s) and may contain confidential or privileged information. If
you are not the intended recipient, please notify the sender at Wipro or Mailadmin@wipro.com immediately
and destroy all copies of this message and any attachments.
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
Confidentiality Notice
The information contained in this electronic message and any attachments to this message are intended
for the exclusive use of the addressee(s) and may contain confidential or privileged information. If
you are not the intended recipient, please notify the sender at Wipro or Mailadmin@wipro.com immediately
and destroy all copies of this message and any attachments.
---------------------------------
Click here to donate to the Hurricane Katrina relief effort.
RE: Selecting checkboxes in the backing bean
Posted by Balaji Saranathan <ba...@wipro.com>.
Which then doesnt mean, we are violating the MVC model which the JSF is
actually trying to achieve?
-----Original Message-----
From: Dave [mailto:javaone9@yahoo.com]
Sent: Friday, September 09, 2005 3:06 PM
To: MyFaces Discussion; balaji.saranathan@wipro.com
Subject: RE: Selecting checkboxes in the backing bean
You are right on the coupling UI and data model. I found it more clean.
Make sure the property is transient only for UI. :-)
Balaji Saranathan <ba...@wipro.com> wrote:
Hi,
Isnt there any other way to do it? Assuming, UserInfo is the member
class of the collection (datamodel), why should a property exist on it,
that is something to do with the presentation on the UI. It actually is
not a property of the class at all. I think this would mean we couple UI
and model tightly.
Therefore, on the backing bean, I have a class level variable
UISelectBoolean selected as specified by Craig in this forum
<http://forum.java.sun.com/thread.jspa?forumID=427&threadID=486654>
http://forum.java.sun.com/thread.jspa?forumID=427&threadID=486654 . This
variable is bounded to the Checkbox. As per my understanding, the
dataTable internally handles the state of each checkbox mapped to this
variable.
However, on my code I loop through the rows displayed and set the
selected.setSelected(true). However, this doesnt seem to have any effect
at all.
Note:
"table" here refers to an instance of UITable that is binded to the
DataTable.
int firstRow = table.getFirst();
int numRows = table.getRows();
for (int index = firstRow; index < (firstRow + numRows); index++)
{
table.setRowIndex( index );
selected.setSelected(true);
}
Thanks
Bala
-----Original Message-----
From: Dave [mailto:javaone9@yahoo.com]
Sent: Friday, September 09, 2005 1:51 PM
To: MyFaces Discussion; balaji.saranathan@wipro.com
Subject: Re: Selecting checkboxes in the backing bean
Add a property in backing bean data model(member class of collection)
such as selected, and bind the checkbox to the property.
Balaji Saranathan <ba...@wipro.com> wrote:
Hi,
I have a page where there is a SelectOneMenu and a dataTable beneath. I
would like to select a couple of rows in the dataTable based on the
selection of the SelectOneMenu.
I have registered a ValueChangeListener to the SelectOneMenu and my
method is getting called.
But how do I actually check the CheckBoxes created in the DataTable
programatically based on one of the column information. Assuming I have
a colum called name, and I have to select all the rows containing the
name "XXX", how would I get a handle to the column rows and the
checkboxes to select it.
Is looping through the UIViewRoot, the only way?
Does anyone have any ideas?
Thanks
Balaji
Confidentiality Notice
The information contained in this electronic message and any attachments
to this message are intended
for the exclusive use of the addressee(s) and may contain confidential
or privileged information. If
you are not the intended recipient, please notify the sender at Wipro or
Mailadmin@wipro.com immediately
and destroy all copies of this message and any attachments.
_____
Click here to donate to <http://store.yahoo.com/redcross-donate3/> the
Hurricane Katrina relief effort.
Confidentiality Notice
The information contained in this electronic message and any attachments
to this message are intended
for the exclusive use of the addressee(s) and may contain confidential
or privileged information. If
you are not the intended recipient, please notify the sender at Wipro or
Mailadmin@wipro.com immediately
and destroy all copies of this message and any attachments.
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
Confidentiality Notice
The information contained in this electronic message and any attachments to this message are intended
for the exclusive use of the addressee(s) and may contain confidential or privileged information. If
you are not the intended recipient, please notify the sender at Wipro or Mailadmin@wipro.com immediately
and destroy all copies of this message and any attachments.
RE: Selecting checkboxes in the backing bean
Posted by Dave <ja...@yahoo.com>.
You are right on the coupling UI and data model. I found it more clean. Make sure the property is transient only for UI. :-)
Balaji Saranathan <ba...@wipro.com> wrote:Hi,
Isnt there any other way to do it? Assuming, UserInfo is the member class of the collection (datamodel), why should a property exist on it, that is something to do with the presentation on the UI. It actually is not a property of the class at all. I think this would mean we couple UI and model tightly.
Therefore, on the backing bean, I have a class level variable UISelectBoolean selected as specified by Craig in this forum http://forum.java.sun.com/thread.jspa?forumID=427&threadID=486654 . This variable is bounded to the Checkbox. As per my understanding, the dataTable internally handles the state of each checkbox mapped to this variable.
However, on my code I loop through the rows displayed and set the selected.setSelected(true). However, this doesnt seem to have any effect at all.
Note:
"table" here refers to an instance of UITable that is binded to the DataTable.
int firstRow = table.getFirst();
int numRows = table.getRows();
for (int index = firstRow; index < (firstRow + numRows); index++)
{
table.setRowIndex( index );
selected.setSelected(true);
}
Thanks
Bala
-----Original Message-----
From: Dave [mailto:javaone9@yahoo.com]
Sent: Friday, September 09, 2005 1:51 PM
To: MyFaces Discussion; balaji.saranathan@wipro.com
Subject: Re: Selecting checkboxes in the backing bean
Add a property in backing bean data model(member class of collection) such as selected, and bind the checkbox to the property.
Balaji Saranathan <ba...@wipro.com> wrote:
Hi,
I have a page where there is a SelectOneMenu and a dataTable beneath. I would like to select a couple of rows in the dataTable based on the selection of the SelectOneMenu.
I have registered a ValueChangeListener to the SelectOneMenu and my method is getting called.
But how do I actually check the CheckBoxes created in the DataTable programatically based on one of the column information. Assuming I have a colum called name, and I have to select all the rows containing the name "XXX", how would I get a handle to the column rows and the checkboxes to select it.
Is looping through the UIViewRoot, the only way?
Does anyone have any ideas?
Thanks
Balaji
Confidentiality Notice
The information contained in this electronic message and any attachments to this message are intended
for the exclusive use of the addressee(s) and may contain confidential or privileged information. If
you are not the intended recipient, please notify the sender at Wipro or Mailadmin@wipro.com immediately
and destroy all copies of this message and any attachments.
---------------------------------
Click here to donate to the Hurricane Katrina relief effort.
Confidentiality Notice
The information contained in this electronic message and any attachments to this message are intended
for the exclusive use of the addressee(s) and may contain confidential or privileged information. If
you are not the intended recipient, please notify the sender at Wipro or Mailadmin@wipro.com immediately
and destroy all copies of this message and any attachments.
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
RE: Selecting checkboxes in the backing bean
Posted by Balaji Saranathan <ba...@wipro.com>.
Hi,
Isnt there any other way to do it? Assuming, UserInfo is the member
class of the collection (datamodel), why should a property exist on it,
that is something to do with the presentation on the UI. It actually is
not a property of the class at all. I think this would mean we couple UI
and model tightly.
Therefore, on the backing bean, I have a class level variable
UISelectBoolean selected as specified by Craig in this forum
<http://forum.java.sun.com/thread.jspa?forumID=427&threadID=486654>
http://forum.java.sun.com/thread.jspa?forumID=427&threadID=486654 . This
variable is bounded to the Checkbox. As per my understanding, the
dataTable internally handles the state of each checkbox mapped to this
variable.
However, on my code I loop through the rows displayed and set the
selected.setSelected(true). However, this doesnt seem to have any effect
at all.
Note:
"table" here refers to an instance of UITable that is binded to the
DataTable.
int firstRow = table.getFirst();
int numRows = table.getRows();
for (int index = firstRow; index < (firstRow + numRows); index++)
{
table.setRowIndex( index );
selected.setSelected(true);
}
Thanks
Bala
-----Original Message-----
From: Dave [mailto:javaone9@yahoo.com]
Sent: Friday, September 09, 2005 1:51 PM
To: MyFaces Discussion; balaji.saranathan@wipro.com
Subject: Re: Selecting checkboxes in the backing bean
Add a property in backing bean data model(member class of collection)
such as selected, and bind the checkbox to the property.
Balaji Saranathan <ba...@wipro.com> wrote:
Hi,
I have a page where there is a SelectOneMenu and a dataTable beneath. I
would like to select a couple of rows in the dataTable based on the
selection of the SelectOneMenu.
I have registered a ValueChangeListener to the SelectOneMenu and my
method is getting called.
But how do I actually check the CheckBoxes created in the DataTable
programatically based on one of the column information. Assuming I have
a colum called name, and I have to select all the rows containing the
name "XXX", how would I get a handle to the column rows and the
checkboxes to select it.
Is looping through the UIViewRoot, the only way?
Does anyone have any ideas?
Thanks
Balaji
Confidentiality Notice
The information contained in this electronic message and any attachments
to this message are intended
for the exclusive use of the addressee(s) and may contain confidential
or privileged information. If
you are not the intended recipient, please notify the sender at Wipro or
Mailadmin@wipro.com immediately
and destroy all copies of this message and any attachments.
_____
Click here to donate to the <http://store.yahoo.com/redcross-donate3/>
Hurricane Katrina relief effort.
Confidentiality Notice
The information contained in this electronic message and any attachments to this message are intended
for the exclusive use of the addressee(s) and may contain confidential or privileged information. If
you are not the intended recipient, please notify the sender at Wipro or Mailadmin@wipro.com immediately
and destroy all copies of this message and any attachments.
Re: Selecting checkboxes in the backing bean
Posted by Dave <ja...@yahoo.com>.
Add a property in backing bean data model(member class of collection) such as selected, and bind the checkbox to the property.
Balaji Saranathan <ba...@wipro.com> wrote:
Hi,
I have a page where there is a SelectOneMenu and a dataTable beneath. I would like to select a couple of rows in the dataTable based on the selection of the SelectOneMenu.
I have registered a ValueChangeListener to the SelectOneMenu and my method is getting called.
But how do I actually check the CheckBoxes created in the DataTable programatically based on one of the column information. Assuming I have a colum called name, and I have to select all the rows containing the name "XXX", how would I get a handle to the column rows and the checkboxes to select it.
Is looping through the UIViewRoot, the only way?
Does anyone have any ideas?
Thanks
Balaji
Confidentiality Notice
The information contained in this electronic message and any attachments to this message are intended
for the exclusive use of the addressee(s) and may contain confidential or privileged information. If
you are not the intended recipient, please notify the sender at Wipro or Mailadmin@wipro.com immediately
and destroy all copies of this message and any attachments.
---------------------------------
Click here to donate to the Hurricane Katrina relief effort.