2 Replies Latest reply: May 7, 2012 7:24 AM by 876181 RSS

    Re: Get Latest Displayed data from master detailed table

    876181
      Hi,

      I have a dropdown menu, and a detailed table. The dropdown determines what is displayed in the detailed table. How do I problematically access the latest data displayed in the detailed table based on the user's dropdown menu selection? I have attempted to use a interator, however it displays the previous data from a previous selection.

      Below is the code I am using

      BindingContainer bindings = BindingContext.getCurrent().getCurrentBindingsEntry();
      DCIteratorBinding dciter1 = (DCIteratorBinding) bindings.get("OccCrewView3Iterator");
      dciter1.invalidateCache();
      dciter1.executeQuery();
      dciter1.refresh(DCIteratorBinding.RANGESIZE_UNLIMITED);
      ViewObject object = dciter1.getViewObject();
      RowSetIterator iterator = dciter1.getRowSetIterator();
      Row[] allRowsInRange = iterator.getAllRowsInRange();
      for(int i =0; i< allRowsInRange.length; i++) {
      System.out.println(allRowsInRange.getAttribute("CrftWgt")+" i "+i);
      Object attribute = allRowsInRange[i].getAttribute("CrftWgt");
      allRowsInRange[i].setAttribute("CraftHours",attribute);
      }
      iterator.closeRowSetIterator();

      My table is refreshing with new data, however my iterator is not refreshing with new data.

      thank you

      Edited by: John on May 6, 2012 11:11 AM

      Edited by: John on May 6, 2012 8:50 PM
        • 1. Re: Get Latest Displayed data from master detailed table
          Frank Nimphius-Oracle
          John,

          see my comments in your code
          BindingContainer bindings = BindingContext.getCurrent().getCurrentBindingsEntry();
          DCIteratorBinding dciter1 = (DCIteratorBinding) bindings.get("OccCrewView3Iterator");
          Don't know what the next line is for. It is definitvely not needed for a master-detail synchronization
          dciter1.invalidateCache();
          If the drop down is created by dragging the parent collection and then choosing Navigation --> ADF Navigation List from the context menu then master-detail refresh should happen automatically and all you need to do is to ensure the table is refreshed based on the list selection (PartialTrigger defined between table and list, or in newer versions the ChangeEventPolicy being set to ppr on the dependent iterator)

          So the below is unnecessary!
          dciter1.executeQuery();
          The next line too doesn't make sense ...
          dciter1.refresh(DCIteratorBinding.RANGESIZE_UNLIMITED);
          The following line is a typical beginner mistake and violates ADF rule #1 to always work through the binding layer. The same information that you read from the View Object can be read from the DCIteratorBinding directly
          ViewObject object = dciter1.getViewObject();
          RowSetIterator iterator = dciter1.getRowSetIterator();
          Row[] allRowsInRange = iterator.getAllRowsInRange();
          for(int i =0; i< allRowsInRange.length; i++) {
          System.out.println(allRowsInRange.getAttribute("CrftWgt")+" i "+i);
          Object attribute = allRowsInRange.getAttribute("CrftWgt");
          allRowsInRange.setAttribute("CraftHours",attribute);
          }
          Why do you close the iterator. You didn't create it! If an iterator is created by the framework, leave it to the framework to close it. Ruke number #2: Don't fight the framework
          iterator.closeRowSetIterator();
          Frank
          • 2. Re: Get Latest Displayed data from master detailed table
            876181
            What would happen if the dropdown is based on a cascading LOV. For example, user selects country, this cascades the selection to states. States LOV (dropdown) has a master detail relationship between cities. Cities is a detailed table of cities. Do I have the detailed table have a partial trigger with the first LOV which is country or do I have a partial trigger on the second LOV states?

            thank you