2 Replies Latest reply on Feb 23, 2010 1:38 AM by PL.be

    Nested repeater & amfphp

    PL.be

      Hi every body,

       

      I encounter a problem with an application that get data from amfphp. The database has two tables (project and logo), I would like using the first (project) as a dataprovider for the Outer repeater and the second (logo) for the Inner repeater.

       

      Like this :

       

      project1 (outer)

           logo1(inner)

           logo2(inner)

           logo3(inner)


      project2

           ...


      project3

           ...

       

      I don't have trouble when a repeate just one at time or both separate, but when they are nested the second don't work.

       

      If someone has an idea that would help me a lot

      Read you soon (I hope )

       

      the code look like that :

      <mx:Script>
              <![CDATA[
                  import mx.controls.Alert;
                  import mx.rpc.events.FaultEvent;
                  import mx.rpc.events.ResultEvent;
                 
                  public function init():void{
                      myService.getOperation('getProjets').send();
                      myService.getOperation('getLogos').send();
                  }
                 
                  public function faultHandler1(e:FaultEvent):void{
                      Alert.show('...');
                  }
                 
                  public function faultHandler(e:FaultEvent):void{
                      Alert.show('...');
                  }
                 
                  public function resultHandler(e:ResultEvent):void{
                      outer.dataProvider = e.result;
                  }
                 
                  public function resultHandler2(e:ResultEvent):void{
                       inner.dataProvider = e.result;
                  }
              ]]>
         </mx:Script>

       

      <mx:RemoteObject id="monService" fault="faultHandler1(event)" showBusyCursor="true" source="votation" destination="amfphp">
           <mx:method name="getProjects" result="resultHandler(event)" fault="faultHandler(event)"/>
           <mx:method name="getLogos" result="resultHandler2(event)" fault="faultHandler(event)"/>

      </mx:RemoteObject>

       

          <mx:TabNavigator>
              <mx:Repeater id="outer">
                  <mx:Canvas>
                      <mx:label>{outer.currentItem.project_name}</mx:label>
                     
                      <mx:Repeater id="inner">
                          <mx:Canvas>
                              <mx:Image source="{inner.currentItem.url}" />
                          </mx:Canvas>
                      </mx:Repeater>
                  </mx:Canvas>
              </mx:Repeater>
          </mx:TabNavigator>

        • 1. Re: Nested repeater & amfphp
          P.o.l.a.c.o Level 1

          I wonder if is something like this what you want to get:

           

          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="populateData()">
              <mx:Script>
                  <![CDATA[
                      import mx.collections.ArrayCollection;
                      import mx.controls.Alert;
                      import mx.rpc.events.FaultEvent;
                      import mx.rpc.events.ResultEvent;
                    
                      public function populateData():void{
                          var arr:ArrayCollection = new ArrayCollection();
                          var inner:Object = null;
                          var obj:Object = new Object();
                          obj.project_name = "Project 1";
                          obj.logos = new Array();
                          inner = new Object();
                          inner.url = "myURLe1P1.jpg";
                          (obj.logos as Array).push(inner);
                          inner = new Object();
                          inner.url = "myURLe2P1.jpg";
                          (obj.logos as Array).push(inner);
                         
                          arr.addItem(obj);
                                        
                          obj = new Object();
                          obj.project_name = "Project 2";
                          obj.logos = new Array();
                          inner = new Object();
                          inner.url = "myURLe1P2.jpg";
                          (obj.logos as Array).push(inner);
                          inner = new Object();
                          inner.url = "myURLe2P2.jpg";
                          (obj.logos as Array).push(inner);
                         
                          arr.addItem(obj);
                          
                          outer.dataProvider = arr;
                          //myService.getOperation('getProjets').send();
                          //myService.getOperation('getLogos').send();
                      }
                    
                  ]]>
             </mx:Script>

           

           

           

              <mx:TabNavigator>
                  <mx:Repeater id="outer">
                      <mx:VBox width="100%">
                          <mx:Label text="{outer.currentItem.project_name}"></mx:Label>
                          <mx:Repeater id="inner" dataProvider="{outer.currentItem.logos}">
                            <mx:Label width="100%" text="{inner.currentItem.url}"/>
                          </mx:Repeater>
                     
                      </mx:VBox>
                  </mx:Repeater>
              </mx:TabNavigator>
          </mx:Application>

           

          hope it helps.

          1 person found this helpful
          • 2. Re: Nested repeater & amfphp
            PL.be Level 1

            Tank you very much P.o.l.a.c.o !

             

            Your mxml has helped me

            the rest of the problem was in the php function in amfphp.

             

            Best Regards.