Sunday, June 6, 2010

Deleting multi-selected rows from adf table

Hi all,

Back from little trip from Karachi and today i will show how to delete multiple selected rows from adf table.

In this example i will selected rows using
1)  CTRL or SHIFT with mouse click
2)  Checkbox at the row
and press Delete button for ease of understanding i created 2 separate buttons in the examples.

Before start i assumed you already setup a Application with EO,VO and AM also using HR Connection

- Add a Transient Attribute to VO of Boolean type named "SelectedRow" We will use this to select row
Here the layout looks like

- Drag a Collection from DataControl as ADF Table to JSF page
- Dont Check RowSelection Checkbox
- Set the table RowSelection property to multiple
- Set EditingMode property to clickToEdit
- Surround your table with af:PanelCollection for look and feel give table a id "myTab"
- Add a toolbar in toolbar facet of Panelcollection
- Add 2 toolbar buttons to your toolbar
- Add partial triggers to your table reference both buttons on toolbar
- Create a backing bean
- Add a RichTable object to your bean with getter and setter methods.
- Set the binding property of the af:table to your Managed Bean
- Add Methods in Backing bean similar to the following code
- Link a method deleteAction to your "Delete Selected Rows" button and DeleteCheckedRows to other button.

Download example for more info

Note: Don't forget to commit your rows after delete :)

More Reading:
- Providing Multiselect capabilities Fusion developer guide

-How to add Transient Checkbox to Table A good example can also be found here

Processing on multi Rows another example from Mr.Steve Muench

Happy JDeveloping,


  1. Hi,

    I implemented the method and its deleting the row from the table. But its not deleting from the database. How to delete records programatically from database.

    Thanks & Regards,

  2. Well Raj Thanks for comments you have to use the Commit Operation after deleting the rows

    Simply Drag the Commit operation from data control to the layout

  3. Hello Zeeshan,
    Let's say I have a database table...instead of deleting row from the table, Is there anything ADF (11g) provides through which I can hide a database table row based on certain event (event maybe let's say when I click a command button, it should hide a single row or multiple rows (just on front end of web application) which I select and also change one of the database table column field value(s) to something else based on that event (clicking of a command button) for the row(s) I select ?
    also my email: ...if possible to email ?
    Thanks and regards,

  4. Zeeshan Baig ✆
    to asimran

    show details 5:47 PM (2 hours ago)


    Yes you can do this by updating a delete flag (custom column) instead of deleting rows...

    Fusion developer guide has cover this use case

    Hope it helps.

  5. Hi, Thanks for the example it works well but I have a little problem. If my table fetch more rows than the limit configured in the iterator, when I row the selected key, the next exception is raised: ADFv: Could not find row: __$ $__ with key: oracle.jbo.Key

    Could you help me??

  6. Hi Baig,
    I was going through your example. But when the table has multi selection enabled and all rows are selected through ctrl+A, then delete does not work properly i.e all the rows are not getting deleted.[Ex: if 10 rows are selectd only 7 of them gets deleted]. But if all the rows are selected manually through ctrl then it works fine.
    Please let us know if it a bug.


  7. Hi Praveen,

    You can try to debug, put some message in the loop to see if rows are coming or not.

    I will take a look later.


  8. Hi Baig,

    helping me much, but same goes to Praveen, try my best to fix somewhere but really hoping for your helps. Thanks.

  9. I tried the same implementation but getting the exception
    java.lang.ClassCastException: java.util.ArrayList cannot be cast to org.apache.myfaces.trinidad.model.CollectionModel

  10. Hi Baig,
    I have adf table ,which has exportCollectionActionListener in that one column is of type transient as selectBooleanCheckbox ,when we exported to excel it contains the selectBooleanCheckbox value as 'True' or 'False' how to remove this column value....


  11. Hi Megha,

    So far there is no control to hide any columns declaratively.

    Programmatic solution is possible. check this link

    Other option is (i havent tried yet) is to set Visible false of the component then do exportcollection and set visible true again.


  12. Hi Zeeshan,when we select multiple check boxes ,, and press delete, it does not delete all the rows,it only deletes some of them,,,i checked in the lopp,rows r getting,but when i try to print something after r.remove(),,,it is displayed for some rows and not for others.....means deleting some rows..kindly look into this.

  13. Hi Idris,

    One example will delete only selected rows if you press selected rows button.

    Other example will delete rows that you mark checked.

    Which JDEV version are you using i guess it was developed using PS4

    Hope it help,

    1. Hi Zeeshan,
      I am a regular visitor of your blog for some great stuff.
      I think Idris has a point. And I was facing this problem too. The issue is with the getEstimatedRowCount() method which decreases with each removal of record leaving the last few records to be left undeleted even though they are checked. I could not find a neat explanation elsewhere so wrote this blog.


  14. hi...

    i created one table..inside this table one column is boolean if i click on column checkbox inside that column all the rows should check..if i deselect it all row should deselect..for that i created a ValueChangeListener and inside the managedbean i code the below...

    public void SelectAllBoolean(ValueChangeEvent valueChangeEvent) {
    // Add event code here...
    //RepSetTableDemoVO1Iterator THIS IS MY ITERATOR NAME

    boolean isSelected = ((Boolean)valueChangeEvent.getNewValue()).booleanValue();
    DCBindingContainer dcb = (DCBindingContainer) evaluateEL("#{bindings}");
    DCIteratorBinding dciter =dcb.findIteratorBinding("RepSetTableDemoVO1Iterator");

    ViewObject vo = dciter.getViewObject();
    int i = 0;
    Row row = null;
    while (vo.hasNext()) {
    if (i == 0)
    row = vo.first();
    row =;
    // System.out.println("Changing row 1: " +
    // row.getAttribute("Name"));
    //System.out.println("xdebug c2: Changing row 2: " +
    row.setAttribute("ExportFromOffice", "Y");
    row.setAttribute("ExportFromOffice", "N");

    private static Object evaluateEL(String el) {
    FacesContext facesContext = FacesContext.getCurrentInstance();
    ELContext elContext = facesContext.getELContext();
    ExpressionFactory expressionFactory =
    ValueExpression exp =
    expressionFactory.createValueExpression(elContext, el,
    return exp.getValue(elContext);


    PLEASE TELL ME THIS IS CORRECT OR NOT...tell me the code for that problem...this is my iterator name RepSetTableDemoVO1Iterator.. this is my VO name RepSetTableDemoVO... this is my column name to set a boolean checkbox ExportFromOffice...
    how to do this..

  15. Hi Baig,

    I have implemented the the excample you provided above and it works fine. However I have an additional requirement: when user selects the check box on a row, I want to select all the related rows (programatically). Is there any way to do that?

    1. Hi,

      You can use cascading delete feature of association. Also write a custom method to retrieve all related rows and remove them.

      Check this entry to get little hint