8 Replies Latest reply: Feb 13, 2013 5:29 AM by Timo Hahn RSS

    Insertions and deletions from inside Application Module

    dslack
      Hello all,

      I've generated a Impl class for my Application Module and I can't seem to use my getters for my ViewObjects. Calling getSolutionTools1() results in a null ViewObjectImpl for example. Here's a snippet of what I'm doing, all of this is in my AMImpl class. The ultimate goal is to retrieve the VO and make changes to its rows.

      public ViewObjectImpl getSolutionTools1() {
      return (ViewObjectImpl)findViewObject("SolutionTools1");
      }

      public void changeTools(Integer[] selectedIndxs) {
      this.deleteTools();
      this.insertTools(selectedIndxs);
      }

      private void deleteTools() {
      ViewObjectImpl solutions = this.getSolutionTools1();
      while (solutions.hasNext()) {
      solutions.next();
      solutions.removeCurrentRow();
      }
      this.getTransaction().commit();
      }

      private void insertTools(Integer[] selectedIndxs){
      ViewObjectImpl solutions = this.getSolutionTools1();
      if(selectedIndxs!=null){
      for(int i : selectedIndxs) {
      Row r1 = this.getAvailableTools1().getRowAtRangeIndex(i);
      Row r = solutions.createRow();
      solutions.insertRow(r);
      r.setAttribute("SolutionId", 4);
      r.setAttribute("TaskId", r1.getAttribute(0));
      r.validate();
      }
      this.getTransaction().commit();
      }
      }

      I heard this was best practice for making changes to your VO and ultimately your data in ADF, but its proving tricky...

      Thanks - Dylan