This discussion is archived
11 Replies Latest reply: Jan 12, 2013 4:19 AM by 926790 RSS

Nested Iterator - Master Detail Listing

Kevin King Journeyer
Currently Being Moderated
So, I'm trying to display a flat list of a view object that has a linked object to it.
Here is my ViewObject Structure:

Parent (1 or more)
-parentID
-Child (1 or more)
--childID

so if Parent1 has 2 Children (A and B), and Parent2 has 1 Child (C) I should see
--------------------------
Parent1    |   ChildA
           |   ChildB
--------------------------
Parent2    |  ChildC
-------------------------
But instead I'm seeing:
--------------------------
Parent1    |   ChildC
--------------------------
Parent2    |  ChildC
-------------------------
My Code looks something like:
<af:iterator id="i3" value="#{bindings.Parents.collectionModel}" var="row">
 . . .
      <af:outputText value="#{row.parentId}"/>
      . . .
      <af:iterator id="i4" value="#{bindings.Children.collectionModel}" var="row2">
            <af:outputText value="#{row2.childId}"/>
      </af:iterator>
</af:iterator>
Note, they are linked, and work in master/detail table... however, that is not how its supposed to be displayed. I'm assuming I'll need to do some magic with setCurrentRow... but not sure where/how this should be done... Is there a way to access the linked view object from the parent?

Any help would be great!
-Kevin
  • 1. Re: Nested Iterator - Master Detail Listing
    826746 Newbie
    Currently Being Moderated
    Even some time back I tried this....... it involves little bit complexity.

    In master details it works because there is some action happening (like selecting master ) which is filtering the child VO to show corresponding child rows.

    where as , when we are displaying flat there is no such action happening to refresh child vo accordingly. We cant just depend on detail vo row set(default) which ADF is showing in UI. We need to figure out something here.

    I am trying on this, If I get something ... I will keep u informed.
  • 2. Re: Nested Iterator - Master Detail Listing
    859020 Newbie
    Currently Being Moderated
    Im doing some nested iteration too, and I cant get the bindings to refresh on every iteration. Ive also asked for help with this and told its just not possible with ADF. i.e. the bindings are resolved once per page, so basically the binding for the children is getting resolved once, and that data will show for all other iterations.

    If anyone has any updates on this or other methods to accomplish this I would greatly appreciate it.
  • 3. Re: Nested Iterator - Master Detail Listing
    856695 Newbie
    Currently Being Moderated
    Hello,

    If Parent ant Child view objects associated by ViewLink, Rarent view object row class has method, which returns RowIterator through corresponding Child rows. Nested af:iterator should have value attribute binded to this method.

    Regards,
    Natalia

    Edited by: 853692 on May 3, 2011 6:19 AM
  • 4. Re: Nested Iterator - Master Detail Listing
    859020 Newbie
    Currently Being Moderated
    What if the outer af:iterator is using a backing bean property (ie just some list in the bean, no data control) - and the inner af:iterator is passing the loop value to a data control method. In this scenario, you cannot create a master detail relationship because there is no second. And in fact, if your data control is a JavaBean data control (which mine is) you cant create view objects or view links anyway, right?
  • 5. Re: Nested Iterator - Master Detail Listing
    NavaneethaKrishnanNataraj Guru
    Currently Being Moderated
    Check the sample "MultiIteratar" which would provides input to resolve your use-case.
    Re: Access the Var Variable in a Collection Model

    Thanks,
    Navaneeth
  • 6. Re: Nested Iterator - Master Detail Listing
    859020 Newbie
    Currently Being Moderated
    Is there no way to do this without evaluating EL in your managed bean? The separation between your view and your code are completely broken when you have to resort to evaluating EL expressions to grab loop variables. Then you can no longer change your jspx without possibly breaking your code.
  • 7. Re: Nested Iterator - Master Detail Listing
    859020 Newbie
    Currently Being Moderated
    So there really is no way to use a binding multiple times with different parameters? If I have to reevaluate it inside my backing bean there there's no use in even using data control bindings in the first place. There has to be a way to use a binding inside an iterator and have the binding grab the data for each iteration (*without* custom java code). Is there anyone out there who has ever done this?
  • 8. Re: Nested Iterator - Master Detail Listing
    859020 Newbie
    Currently Being Moderated
    853692 wrote:

    If Parent ant Child view objects associated by ViewLink, Rarent view object row class has method, which returns RowIterator through corresponding Child rows. Nested af:iterator should have value attribute binded to this method.
    Im attempting this, and it seems af:iterator will not iterate over a RowIterator. My af:iterator tag is evaluated only once and the ViewRowSetImpl is passed as the "var". i.e. its not actually iterating over any elements, just giving me back my RowIterator.

    Why would af:iterator not be able to iterate over an ADF RowIterator object?
  • 9. Re: Nested Iterator - Master Detail Listing
    SantoshVaza Expert
    Currently Being Moderated
    Hi,

    create a new property in your backingBean (like Object goNext;)

    on the getter method of this property make your master iterator to go next row.
    public voig getGoNext(){
     DCBindingContainer dc=(DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
     dc.findIteratorBinding("xxIterator").getViewObject().next();
     return goNext;
    }
    Then at the end of your parent iterator call this property.. your code atlast will be like this.
    <af:iterator id="i3" value="#{bindings.Parents.collectionModel}" var="row">
     . . .
          <af:outputText value="#{row.parentId}"/>
          . . .
          <af:iterator id="i4" value="#{bindings.Children.collectionModel}" var="row2">
                <af:outputText value="#{row2.childId}"/>
          </af:iterator>
    <!--EDIT-->
     <af:outputText value="#{bean.goNext}"/>
    </af:iterator>
    See if this works.

    Regards,
    Santosh.
  • 10. Re: Nested Iterator - Master Detail Listing
    Alejandro Tovar Lanz Expert
    Currently Being Moderated
    Hi Guys,

    I am sorry for reviving this issue. Has somebody managed this to work??? I am in the same situation but "For Each"...

    Regards
  • 11. Re: Nested Iterator - Master Detail Listing
    926790 Newbie
    Currently Being Moderated
    Hello!

    I just had the same situation described above, I needed to show a table inside an iterator. There are some solutions at the ADF Code Corner, but they involve using the showDetail component and a manage bean to refresh the child iterators and I needed something a bit different.

    I found something really good at Andrejus Baranovskis's Blog (as usual), it's an example of using an iterator inside a table. Once they are both collection models, I just had to invert and it worked perfectly.

    Here's the link: http://andrejusb.blogspot.com.br/2012/01/master-detail-with-one-iterator.html

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points