• Post Reply Bookmark Topic Watch Topic
  • New Topic

Iterating an HtmlDataTable.  RSS feed

 
Armen Demirjian
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I have this HtmlDataTable, which obtains the first column from a DB, the other one is column of <h:selectBooleanCheckbox/>.

Anyways, the problem is that i want (after checking some of the boxes) to iterate through the HtmlDataTable and check for the checked boxes.

<h:dataTable binding="#{login.table}" value="#{login.users}" var="res">
<h:column binding="#{login.nameColumn}">
<f:facet name="header">
<hutputText value="Name"/>
</f:facet>
<hutputText value="#{res.username}"/>
</h:column>

<h:column binding="#{login.selectColumn}">
<f:facet name="header">
<hutputText value="Select"/>
</f:facet>
<h:selectBooleanCheckbox/>
</h:column>
</h:dataTable>

Can anybody help me in this ???

Thanks ...
 
Richard Green
Ranch Hand
Posts: 536
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<h:selectBooleanCheckbox value="#{login.someVariable}"/>
 
John Bartlett
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

If you have the ability to check boxes on multiple rows then referencing a boolean on the entity itself would be the way to go.



e.g. That way if you had some sort of delete method you could reference the boolean on the entity to see whether to delete it

however if you are just going to be selecting one row then referencing a boolean on your bean like has been shown above is the way to go.

John
[ February 07, 2007: Message edited by: John Bartlett ]
 
rajani varma
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

In the JSF page,

<h:selectBooleanCheckbox value="#{res.booleanValue}" >

and in the backingBean, to check for multiple selections,

private UIData HTMLTableName;

public UIData getHtmlTableName() {
return htmlTableName;
}
public void setHtmlTableName(UIData htmlTableName) {
this.htmlTableName = htmlTableName;
}

SelectableItem item = (SelectableItem) htmlTableNam.getRowData();
if (item.isSelected()) {

} else {
}


or

for (int i = 0; i < displayingList.size(); i++) {

SelectableItem item = (SelectableItem) displayingList.get(i);
if (item.isSelected()) {
}
else{
}

Hope this helps....

-Rajani.
 
Armen Demirjian
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

Thanks for the help everybody

Regards ...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!