3 Replies Latest reply: Apr 18, 2013 4:04 AM by Viral Patel RSS

    How to programatically change data of TreeTable parent and child rows

    Viral Patel
      Hi,

      I have a requirement of change the data of the rows based on some selection.

      I have two VOs with a master/detail relationship defined with a View Link. The master VO has a bind variable to change which set of rows to return.

      I have af:treeTable derived from the master VO with child nodes derived from the detail VO.

      I have one selectOneChoice and depend upon the selection I want to change the value of the inputText of tree table.

      The selectOneChoice contains 3 values : Val1, Val2, Val3.

      If I select Val1 then it will change the value of inputText of all the parent and child which are from country USA.
      If I select Val2 then it will change the value of inputText of all the parent and child which are from country UK.
      If I select Val3 then it will change the value of inputText of all the parent and child which are from country FRANCE.

      The data will remain unchanged if no selection performed.


      For achieve the requirement I have created valuechange listener of selectOneChoice and into it I am trying to get the iterator binding of tree table.
      I have binding of tree table into the backing bean of page flow scope.

      I am able to get iterator and get the desired values and able to change the values of parents but not able to get the children and change it.

      I am changing the data using below value change listener method.

      public void valueChg(ValueChangeEvent valueChangeEvent) {


      String newValue = (String)valueChangeEvent.getNewValue();

      if (newValue != null)
      {
      for (Row row : ADFUtils.findIterator("MasterIterator").getAllRowsInRange() ) {

      String desc = (String)row.getAttribute("Country");

      if (newValue!=null && desc != null && newValue.equalsIgnoreCase("val1") && desc.equalsIgnoreCase("USA"))
      row.setAttribute("Selected", "eligible for Val1");

      if (newValue!=null && desc != null && newValue.equalsIgnoreCase("val2") && desc.equalsIgnoreCase("UK"))
      row.setAttribute("Selected", "eligible for Val2");

      if (newValue!=null && desc != null && newValue.equalsIgnoreCase("val3") && desc.equalsIgnoreCase("FRANCE"))
      row.setAttribute("Selected", "eligible for Val3");

      }
      }
      AdfFacesContext.getCurrentInstance().addPartialTarget(treeTable1);

      }


      I can see the updated data in parent using above method.

      I have tried to get the children using code below. I got it but not able to change the value.

      CollectionModel model = (CollectionModel)tree.getValue();
      JUCtrlHierBinding treeBinding = (JUCtrlHierBinding)model.getWrappedData();

      JUCtrlHierNodeBinding nodeBinding = treeBinding.getRootNodeBinding();



      Can some one help me out

      I am using JDeveloper 11.1.1.6.0.

      Thanks,

      Viral