In this post I will explain a way to implement checkbox in the rows of ADF Table component. This is a generic approach and can also be used in other components but we will take example of table component for this post.
This is common requirement in many features e.g. Multiple Delete or assigning multiple things by selecting checkbox.
Lets dive into the implementation.
Created a simple ADF app with HR Schema using Departments Table. Created DepartmentsEO,VO and AM.
First since we need a checbox in every row of the Departments table, we need to add a transient attribute in DepartmentVO of Type Boolean. The value of this boolean (false or true) will render the checkbox as (checked or unchecked).
Remember to make this transient attribute "SelectRow" as Boolean and Always Update.
Now in the property inspector for this new transient attribute, set control type as Check Box.
We are all set with the model part.
Now in the View Controller Project, Drag this DepartmentsVO on the page and create a read only table.
The important thing here is that it creates and outputText for selectrow column also. So delete the output text in Select Row colum and again from the data control, drag the selectrow attribute under the selectrow column of the table and select selectBooleanCheckbox.
So the table should look like below:
Now just added a button process, this button calls a method in the bean and there we get values of all the selected rows. Below is the code from the actionListener of process button.
We are all good. Just run the page as below.
We can see that every row has a checkbox. Now select some checkboxes and click on process button.
We selected Marketing , Human Resources and IT. Lets see what happens on clicking Process button in our action listener.
So we get handle of all the rows which were selected in the table !
Thats it.
Application Can be downloaded at CheckBoxInTableApp
Thanks
This is common requirement in many features e.g. Multiple Delete or assigning multiple things by selecting checkbox.
Lets dive into the implementation.
Created a simple ADF app with HR Schema using Departments Table. Created DepartmentsEO,VO and AM.
First since we need a checbox in every row of the Departments table, we need to add a transient attribute in DepartmentVO of Type Boolean. The value of this boolean (false or true) will render the checkbox as (checked or unchecked).
Remember to make this transient attribute "SelectRow" as Boolean and Always Update.
Now in the property inspector for this new transient attribute, set control type as Check Box.
We are all set with the model part.
Now in the View Controller Project, Drag this DepartmentsVO on the page and create a read only table.
The important thing here is that it creates and outputText for selectrow column also. So delete the output text in Select Row colum and again from the data control, drag the selectrow attribute under the selectrow column of the table and select selectBooleanCheckbox.
So the table should look like below:
Now just added a button process, this button calls a method in the bean and there we get values of all the selected rows. Below is the code from the actionListener of process button.
We are all good. Just run the page as below.
We can see that every row has a checkbox. Now select some checkboxes and click on process button.
We selected Marketing , Human Resources and IT. Lets see what happens on clicking Process button in our action listener.
So we get handle of all the rows which were selected in the table !
Thats it.
Application Can be downloaded at CheckBoxInTableApp
Thanks
How to validate is at least one check box is selected, before opening a popup
ReplyDeleteHow to validate is at least one check box is selected, before opening a popup
ReplyDeleteHi,
ReplyDeleteWhen I select any chk box first time below code returns null.
Row[] selectedRow = vo.getFilteredRows("Selected" , true);
When i select 2nd time,it gives the correct result.
can u suggest smthng
Try AutoSubmit in checkbox
DeleteI have the same problem with autoSubmit="true"
DeleteHi,
ReplyDeleteMy requirement is as soon as a select a checkbox that row should get inserted into a data object and if i remove the selection then it should delete it from the data object. This should happen for multiple rows also. How can i do that
When I query first time
ReplyDeleteRow[] selectedRows = vo.getFilteredRows("RowSelector", true);
it takes huge time approx 160 sec and on second process, time of exec is less than a couple of second. Is any cache related issue ?
Querying on selecting 2-3 rows every time
Thank you so much. I was actually looking for something a little different but change my view to match your idea after reading this article.
ReplyDeleteHow to set check box value to false from bean ??
ReplyDeleteThanks,
Vishal
i am unale to see the images
ReplyDeletelast month he share is herbal medicine in some medical hospital and now he is well recognize as one of the best in West Africa, you don’t have to be sad any more or share your tears any more on this virus when the cure have already be find in 2013 if you want to get in touch with him in private contact him on his email dr.chalaherbalhome@mail.com Or you can visit his website on https://
ReplyDeletedrchalaherbalhome.godaddysites.com or https://mywa.link/dr.chalaherbalhome