• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

Iterating an HtmlDataTable.

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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">
<h:outputText value="Name"/>
</f:facet>
<h:outputText value="#{res.username}"/>
</h:column>

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

Can anybody help me in this ???

Thanks ...
 
Ranch Hand
Posts: 536
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<h:selectBooleanCheckbox value="#{login.someVariable}"/>
 
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

Thanks for the help everybody

Regards ...
 
BWA HA HA HA HA HA HA! Tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic