4 Replies Latest reply on Dec 23, 2010 12:54 AM by Whitetimer

    TypeError: Error #1016: Descendants operator (..)

    Whitetimer Level 1

      Hi All

       

      I am getting the following error message and just cant figure out how to correct it

       

      TypeError: Error #1016: Descendants operator (..) not supported on type HTTPService.as$34.HTTPOperation.
           at cart.views::shopView/productServiceResultHandler()[/home/julian/Workspace/testShop/cart/views/shopView.mxml:78]
           at cart.views::shopView/__productService_result()[/home/julian/Workspace/testShop/cart/views/shopView.mxml:16]
      

       

      This is the code

       

      <s:VGroup
              xmlns:fx="http://ns.adobe.com/mxml/2009"
              xmlns:s="library://ns.adobe.com/flex/spark"
              xmlns:mx="library://ns.adobe.com/flex/mx"
              xmlns:views="cart.views.*"
              width="900" height="100%"
              creationComplete="handleCreationCompleteEvent(event)">
      
          <!-- Properties of the parent ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
      
          <!-- Declarations ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
      
          <fx:Declarations>
              <s:HTTPService id="categoryService" url="http://localhost/testShop/data/categories1.xml" result="categoryServiceResultHandler(event)" fault="categoryServiceFaultHandler(event)" resultFormat="e4x" />
              <s:HTTPService id="productService" url="http://localhost/testShop/data/shopData2.xml" result="productServiceResultHandler(event)" fault="productServiceFaultHandler(event)" resultFormat="e4x" />
          </fx:Declarations>
      
          <!-- Metadata ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
      
          <fx:Metadata>
      
          </fx:Metadata>
      
          <!-- Styles ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
      
          <!-- Script ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
      
          <fx:Script>
              <![CDATA[
              // import statements ----------------------------------------
      
              import mx.collections.ArrayCollection;
              import mx.collections.XMLListCollection;
              import mx.events.FlexEvent;
              import mx.rpc.events.FaultEvent;
              import mx.rpc.events.ResultEvent;
              import cart.valueObjects.ProductVO;
              import cart.valueObjects.ShoppingCart;
              import cart.valueObjects.ShoppingCartItem;
      
              // variable declarations ------------------------------------
              [Bindable]
              public var categories:XMLListCollection;
              [Bindable]
              private var productInventory:ArrayCollection;
              [Bindable]
              private var product:ProductVO;
      
              [Bindable]
              private var shoppingCart:ShoppingCart = new ShoppingCart();
      
              // getter/setters -------------------------------------------
      
              // helper methods -------------------------------------------
      
              // event handlers -------------------------------------------
              private function handleCreationCompleteEvent(event:FlexEvent):void
              {
                  categoryService.send();
                  productService.send();
              }
      
              private function categoryServiceResultHandler(event:ResultEvent):void
              {
                  categories = new XMLListCollection(event.result.category);
              }
      
              private function categoryServiceFaultHandler(event:FaultEvent):void
              {
      
              }
      
                private function productServiceResultHandler(event:ResultEvent):void
                {
                     var products:Array = new Array();
                     
                     var resultData:XMLList = event.target..shopitem;
                     
                     for each ( var p:XML in resultData )
                     {
                          var product:ProductVO = ProductVO.buildProductsFromAttributes( p );
                          products.push( product );
                     }
                     
                     productInventory = new ArrayCollection( products );
                }
      
              private function productServiceFaultHandler(event:FaultEvent):void
              {
      
              }
      
              private function handleViewCartClick():void
              {
      
              }
      
              private function addToCart( product:ProductVO ):void
              {
                  var sci:ShoppingCartItem = new ShoppingCartItem( product );
                  shoppingCart.addItem( sci );
              }
      
              ]]>
          </fx:Script>
      
          <!-- States ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
          <s:states>
              <s:State id="gridViewState" name="gridViewState" />
              <s:State id="tileViewState" name="tileViewState" />
          </s:states>
      
          <!-- UI components ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
      
          <!-- APPLICATION CONTROL BAR -->
          <mx:ApplicationControlBar id="applicationControlBar" width="900" height="100">
              <s:VGroup width="100%" height="100%" verticalAlign="middle">
                  <s:Label text="Welcome To  The UWTH Store" />
                  <s:List dataProvider="{categories}" labelField="@catName">
                      <s:layout>
                          <s:HorizontalLayout />
                      </s:layout>
                  </s:List>
              </s:VGroup>
          </mx:ApplicationControlBar>
      
          <!-- SHOPPING CART VIEWS -->
          <s:HGroup width="100%" height="100%">
      
              <s:Panel id="shopViewPanel" width="100%" height="100%">
                  <s:layout>
                      <s:VerticalLayout verticalAlign="middle" horizontalAlign="center" />
                  </s:layout>
      
                  <s:Button label="Add To cart" click="addToCart( product )" />
                  <!--<views:gridView id="gridView" dataProvider="{productInventory}" />-->
                  <mx:DataGrid width="100%" dataProvider="{productInventory}">
                      <mx:columns>
      
                          <mx:DataGridColumn id="idDGC" width="100" headerText="Product #" dataField="id" />
                          <mx:DataGridColumn id="nameDGC" headerText="Product Name" dataField="name" />
                          <mx:DataGridColumn id="priceDGC" width="120" headerText="Product Price £" dataField="price" />
      
                      </mx:columns>
                  </mx:DataGrid>
              </s:Panel>
      
              <views:cartView id="cartView" />
      
      
      
          </s:HGroup>
      
      </s:VGroup>
      

       

      This is the XML Document thats being called

       

      <?xml version="1.0" encoding="utf-8" ?>
      <categories>
           <category catID="1" catName="Category One">
                <shopitem id='1001' catID='1' name='' description='' image='' price='25' />
                <shopitem id='1002' catID='1' name='' description='' image='' price='40' />
                <shopitem id='1003' catID='1' name='' description='' image='' price='' />
                <shopitem id='1004' catID='1' name='' description='' image='' price='' />
           </category>
      </categories>
      

       

      Any suggestions please ?

       

      Many Thanks

        • 1. Re: TypeError: Error #1016: Descendants operator (..)
          Whitetimer Level 1

          SORTED .. I'm such a numpty ..... I had

           

          var resultData:XMLList = event.target..shopitem;
          
          

           

          Instead of

           

          var resultData:XMLList = event.result..shopitem;
          
          

           

           

          I need a holiday ... haha

           

          Anyway, Merry Xmas Everyone

          • 2. Re: TypeError: Error #1016: Descendants operator (..)
            Whitetimer Level 1

            Now i am getting another error message

             

            TypeError: Error #1009: Cannot access a property or method of a null object reference.

            at cart.views::shopView/___shopView_Button1_click()[/home/julian/Workspace/shoppingCartMaste r/cart/views/shopView.mxml:133]

             

            <?xml version="1.0"?>
            <s:VGroup
                    xmlns:fx="http://ns.adobe.com/mxml/2009"
                    xmlns:s="library://ns.adobe.com/flex/spark"
                    xmlns:mx="library://ns.adobe.com/flex/mx"
                    xmlns:views="cart.views.*"
                    width="900" height="100%"
                    creationComplete="handleCreationCompleteEvent(event)">
            
                <!-- Properties of the parent ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
            
                <!-- Declarations ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
            
                <fx:Declarations>
                    <s:HTTPService id="categoryService" url="http://localhost/shoppingCartMaster/data/categories1.xml" result="categoryServiceResultHandler(event)" fault="categoryServiceFaultHandler(event)" resultFormat="e4x" />
                    <s:HTTPService id="productService" url="http://localhost/shoppingCartMaster/data/shopData2.xml" result="productServiceResultHandler(event)" fault="productServiceFaultHandler(event)" resultFormat="e4x" />
                </fx:Declarations>
            
                <!-- Metadata ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
            
                <fx:Metadata>
            
                </fx:Metadata>
            
                <!-- Styles ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
            
                <!-- Script ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
            
                <fx:Script>
                    <![CDATA[
                    // import statements ----------------------------------------
            
                    import mx.collections.ArrayCollection;
                    import mx.collections.XMLListCollection;
                    import mx.events.FlexEvent;
                    import mx.rpc.events.FaultEvent;
                    import mx.rpc.events.ResultEvent;
            
                    import cart.valueObjects.ProductVO;
                    import cart.model.ShoppingCart;
                    import cart.model.ShoppingCartItem;
            
                    // variable declarations ------------------------------------
                    [Bindable]
                    public var categories:XMLListCollection;
                    [Bindable]
                    private var productInventory:ArrayCollection;
                    [Bindable]
                    private var product:ProductVO;
            
                    [Bindable]
                    private var shoppingCart:ShoppingCart = new ShoppingCart();
            
                    // getter/setters -------------------------------------------
            
                    // helper methods -------------------------------------------
            
                    // event handlers -------------------------------------------
                    private function handleCreationCompleteEvent(event:FlexEvent):void
                    {
                        categoryService.send();
                        productService.send();
                    }
            
                    private function categoryServiceResultHandler(event:ResultEvent):void
                    {
                        categories = new XMLListCollection(event.result.category);
                    }
            
                    private function categoryServiceFaultHandler(event:FaultEvent):void
                    {
            
                    }
            
                    private function productServiceResultHandler(event:ResultEvent):void
                    {
                        var products:Array = new Array();
                        var resultData:XMLList = event.result..shopitem;
            
                        for each (var p:XML in resultData)
                        {
                            var product:ProductVO = ProductVO.buildProductsFromAttributes(p);
                            products.push(product);
                        }
                    }
            
                    private function productServiceFaultHandler(event:FaultEvent):void
                    {
            
                    }
            
                    private function handleViewCartClick():void
                    {
            
                    }
            
                    private function addToCart(product:ProductVO):void
                    {
                        var sci:ShoppingCartItem = new ShoppingCartItem( product );
                        shoppingCart.addItem(sci);
                    }
                    ]]>
                </fx:Script>
            
                <!-- States ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
                <s:states>
                    <s:State id="gridViewState" name="gridViewState" />
                    <s:State id="tileViewState" name="tileViewState" />
                </s:states>
            
                <!-- UI components ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
            
                <!-- APPLICATION CONTROL BAR -->
                <mx:ApplicationControlBar id="applicationControlBar" width="900" height="100">
                    <s:VGroup width="100%" height="100%" verticalAlign="middle">
                        <s:Label text="Welcome To  The UWTH Store" />
                        <s:List dataProvider="{categories}" labelField="@catName">
                            <s:layout>
                                <s:HorizontalLayout />
                            </s:layout>
                        </s:List>
                    </s:VGroup>
                </mx:ApplicationControlBar>
            
                <!-- SHOPPING CART VIEWS -->
                <s:HGroup width="100%" height="100%">
            
                    <s:Panel id="shopViewPanel" width="100%" height="100%">
                        <s:layout>
                            <s:VerticalLayout verticalAlign="middle" horizontalAlign="center" />
                        </s:layout>
            
                        <s:Button label="Add To cart" click="addToCart( productInventory.getItemAt(0) as ProductVO )" />
                        <!--<views:gridView id="gridView" dataProvider="{productInventory}" />-->
                        <s:List id="cartList" width="100%" height="100%" dataProvider="{shoppingCart.items}" />
                    </s:Panel>
            
                    <views:cartView id="cartView" />
            
            
            
                </s:HGroup>
            
            </s:VGroup>
            

             

            Any suggestions please ?

             

            Many Thanks

            • 3. Re: TypeError: Error #1016: Descendants operator (..)
              Flex harUI Adobe Employee

              Maybe productInventory is null?

              • 4. Re: TypeError: Error #1016: Descendants operator (..)
                Whitetimer Level 1

                This was missing in the end "productInventory = new ArrayCollection( products );"

                 

                Right off on holiday now ... lol

                 

                Many Thanks