ADF Table: Select multiple rows using check box.

ADF Table: Select multiple rows using check box.

Today I’m going to explain very common case of selecting multiple rows in ADF table using checkboxes. This is very common requirement where user wants to select multiple rows using check box. Here I’m using hr schema employees table.

 

Step1: create Entity Object and View Object using Employees table.

Step2: Create transient attribute Boolean type on Employees View Object.

4-05-3

Step3: Set Control Type to Checkbox on Control Hint tab.

4-05-4

Step4: Create jspx page and drag-drop as Adf table from data control. Set row selection to multiple.

4-05-5

Step5: Create Adf button with following code on ActionListener event method.

  1. public void getSelectedRows(ActionEvent actionEvent) {  
  2.   
  3. BindingContext bindingctx=BindingContext.getCurrent();  
  4.   
  5. BindingContainer binding=bindingctx.getCurrentBindingsEntry();  
  6.   
  7. DCBindingContainer bindingsImpl = (DCBindingContainer) binding;  
  8.   
  9. DCIteratorBinding dciter = bindingsImpl.findIteratorBinding(“EmployeesView1Iterator”);  
  10.   
  11. ViewObject vo=dciter.getViewObject();  
  12.   
  13. Row rr=null;  
  14.   
  15. int i=0;  
  16.   
  17. int j=0;  
  18.   
  19. boolean flag=false;  
  20.   
  21. long rowc=vo.getEstimatedRowCount();  
  22.   
  23. for(int f=1;f<=rowc;f++)  
  24.   
  25. {  
  26.   
  27. if(i==0)  
  28.   
  29. {  
  30.   
  31. rr=vo.first();  
  32.   
  33. }  
  34.   
  35. else  
  36.   
  37. {  
  38.   
  39. rr=vo.next();  
  40.   
  41. }  
  42.   
  43. i++;  
  44.   
  45.    
  46.   
  47. flag=false;  
  48.   
  49. if((rr.getAttribute(“Mark”)) != null)  
  50.   
  51. {  
  52.   
  53. flag= (Boolean)rr.getAttribute(“Mark”);  
  54.   
  55. }  
  56.   
  57. if (flag)  
  58.   
  59. {  
  60.   
  61. System.out.println(“EmployeeId     Firstname            Salary”);  
  62.   
  63. System.out.println(rr.getAttribute(“EmployeeId”)+”             “+rr.getAttribute(“FirstName”)+”              “+rr.getAttribute(“Salary”));  
  64.   
  65. }  
  66.   
  67. }  
  68.   
  69. }  
  1. public void getSelectedRows(ActionEvent actionEvent) {  
  2.   
  3. BindingContext bindingctx=BindingContext.getCurrent();  
  4.   
  5. BindingContainer binding=bindingctx.getCurrentBindingsEntry();  
  6.   
  7. DCBindingContainer bindingsImpl = (DCBindingContainer) binding;  
  8.   
  9. DCIteratorBinding dciter = bindingsImpl.findIteratorBinding(“EmployeesView1Iterator”);  
  10.   
  11. ViewObject vo=dciter.getViewObject();  
  12.   
  13. Row rr=null;  
  14.   
  15. int i=0;  
  16.   
  17. int j=0;  
  18.   
  19. boolean flag=false;  
  20.   
  21. long rowc=vo.getEstimatedRowCount();  
  22.   
  23. for(int f=1;f<=rowc;f++)  
  24.   
  25. {  
  26.   
  27. if(i==0)  
  28.   
  29. {  
  30.   
  31. rr=vo.first();  
  32.   
  33. }  
  34.   
  35. else  
  36.   
  37. {  
  38.   
  39. rr=vo.next();  
  40.   
  41. }  
  42.   
  43. i++;  
  44.   
  45.    
  46.   
  47. flag=false;  
  48.   
  49. if((rr.getAttribute(“Mark”)) != null)  
  50.   
  51. {  
  52.   
  53. flag= (Boolean)rr.getAttribute(“Mark”);  
  54.   
  55. }  
  56.   
  57. if (flag)  
  58.   
  59. {  
  60.   
  61. System.out.println(“EmployeeId     Firstname            Salary”);  
  62.   
  63. System.out.println(rr.getAttribute(“EmployeeId”)+”             “+rr.getAttribute(“FirstName”)+”              “+rr.getAttribute(“Salary”));  
  64.   
  65. }  
  66.   
  67. }  
  68.   
  69. }  

 

 

Output:

4-05-7

 

4-05-8

Sample Code

About Manish Pandey

Manish is a Project Leader at Jagran Prakashan Ltd, focused on Jdeveloper Fusion Web Application(specifically Oracle ADF). He shares his knowledge through the OTN Jdev/ADF Forum. He has written more than 50 article about Oracle ADF and Jdeveloper.

Leave a Reply