• 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
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

How to handle checkbox in jsf

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
I am new to JSF framework. I have the following requirement
From the listing screen i have to select one or more record to perform delete operation thru checkbox. Can anyone tell me how to identify the selected records in jsf without using javascript...
Thanks for any help.

Regards,
Saravanan
 
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,

You will need to be more specific, where are you storing these records? In a datatable?

John
 
saravana kumar
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Please loot at the sample code in jsf

<h:dataTable var="adminList" id="mytable" value="#{messageList}" border="1" style="background-color:silver">

<h:column>
<f:facet name="header">
<h:outputText value="Select All"/>
</f:facet>
<h:selectBooleanCheckbox value="{adminList.selected}"/>
</h:column>

<h:column>
<f:facet name="header">
<h:outputText value="User Id"/>
</f:facet>
<h:commandLink action="#{userManager.editAdmin}" >
<h:outputText value="#{adminList.userId}"/>
</h:commandLink>
</h:column>

<h:column>
<f:facet name="header">
<h:outputText value="User Name"/>
</f:facet>
<h:outputText value="#{adminList.userName}"/>
</h:column>

<h:column>
<f:facet name="header">
<h:outputText value="Phone Number"/>
</f:facet>
<h:outputText value="#{adminList.phoneNumber}"/>
</h:column>

<h:column>
<f:facet name="header">
<h:outputText value="Email Id"/>
</f:facet>
<h:outputText value="#{adminList.emailAddress}"/>
</h:column>

<h:column>
<f:facet name="header">
<h:outputText value="Role"/>
</f:facet>
<h:outputText value="#{adminList.role}"/>
</h:column>

</h:dataTable>

Regards
Saravanan
 
John Bartlett
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To get this to work i normally bind the data table into my bean and then access the row via the getRowIndex() on that bound in table. e.g.

Add this attribute (and appropriate getter/setter methods) to your bean


then add this to your datatable declaration in the xhtml -



now that you have the component bound into your bean, in you action method where you are deleting. you can just do this



Now you have the selected message to delete....

Is this close to what you want to do?
[ June 07, 2007: Message edited by: John Bartlett ]
 
saravana kumar
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Ya this is what i was expecting.
Thank you.

Regards,
Saravanan
 
We noticed he had no friends. So we gave him this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic