7 Replies Latest reply: Feb 7, 2013 4:25 AM by 985680 RSS

    Delete

    985680
      Hello ,

      I am usinf Jdeveloper 11.1.2.3.0
      I want to delete a row from af:table and from database.
      I want to select the row using checkbox and click 'delete' to delete.
      I am using this function :

      DCBindingContainer bindings = (DCBindingContainer)getBindings();
      DCIteratorBinding iter = bindings.findIteratorBinding("InterviewView1Iterator");
      for (int i = 0; i < iter.getViewObject().getEstimatedRowCount(); i++) {
      Row row = iter.getRowAtRangeIndex(i);
      if (true == row.getAttribute("SelectedRow") )
      {
      row.remove();
      }


      the problem is if I select more than 1 row and click delete.. just 1 row is deleted.

      any siggestions ?


      FARAJ
        • 1. Re: Delete
          BrianV
          Check out example

          http://www.oracle.com/technetwork/developer-tools/adf/learnmore/99-checkbox-for-delete-in-table-1539659.pdf
          • 2. Re: Delete
            Timo Hahn
            FARAJ, Please format code you post here. Read the FAQ (https://forums.oracle.com/forums/help.jspa) to find out how to format code.


            I see some problem here. First of all, you are iterating over all rows. If you have many of them and only have a couple of selected rows, it's a big waste of time and memory. The af:table gives you the ability to select multiple rows which are accessable via the selectedRowKeys property. OK, then you don't select the rows using a checkbox.
            If you really want to use a checkbox, let me ask if you have added the transient attribute for this in the EO. Then you schould call a method in the application module or hte VO which does the work (remove the row in your case). You should not do this from a bean method.
            To to the 'How to iterate a rowset' question.
            you can use this code inside your VO
                private static ADFLogger _logger = ADFLogger.createADFLogger(EdossSexViewImpl.class);
            
                public void deletecheckedRows() {
                    RowSetIterator delRowIter = this.createRowSetIterator("del_me");
                    while (delRowIter.hasNext()) {
                        Row row = delRowIter.next();
                        if (true == row.getAttribute("SelectedRow")) {
                            String msg = row.getAttribute(0).toString();
                            _logger.info("Information:" + msg);
                            row.remove();    
                        }
                    }
                    delRowIter.closeRowSetIterator();
                }
            and call it via a button from the UI.

            Timo
            • 3. Re: Delete
              985680
              hello ,

              I used the steps in this example.
              I did the same but when I check more than a row and I click the delete button .. only 1 row is deleted.

              do u have any idea?

              FARAJ
              • 4. Re: Delete
                user404
                Is rowSelection="multiple" in your table component?
                • 5. Re: Delete
                  985680
                  yes it is 'multiple'

                  any idea ?
                  • 6. Re: Delete
                    985680
                    Hi timo ,

                    I used this code but i still have the problem.. if I check more than 1 box and I click the delete button.. not all the rows are deleted... any idea ?

                    thanks again,

                    FARAJ
                    • 7. Re: Delete
                      985680
                      I am getting this error :

                      Attempt to access dead view row of persistent id 1