Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to handle checkbox in jsf

 
saravana kumar
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • 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
 
John Bartlett
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • 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
  • 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">
<hutputText value="Select All"/>
</f:facet>
<h:selectBooleanCheckbox value="{adminList.selected}"/>
</h:column>

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

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

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

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

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

</h:dataTable>

Regards
Saravanan
 
John Bartlett
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Hi,
Ya this is what i was expecting.
Thank you.

Regards,
Saravanan
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic