1 Reply Latest reply on Aug 16, 2007 7:35 AM by ntsiii

    WebService (SOAP)  and repeaters

    Pascal_Robert
      I'm trying to display text box (with <mx:Text>) in a repeater, and the data provider is a WebService (SOAP). I can display the results in a DataGrid like :

      <mx:DataGrid id="datagrid" x="10" y="56" width="780" height="241" dataProvider="{service.loadCalendar.lastResult}">
      <mx:columns>
      <mx:DataGridColumn headerText="Événement" dataField="title" width="150"/>
      <mx:DataGridColumn headerText="Endroit" dataField="location" width="150"/>
      <mx:DataGridColumn headerText="Durée" dataField="duration" width="50"/>
      <mx:DataGridColumn headerText="Heure début" dataField="startDate" width="200"/>
      <mx:DataGridColumn headerText="Heure fin" dataField="endDate" width="200"/>
      </mx:columns>
      </mx:DataGrid>

      But if I try to display the same data in a mx:Repeater, like this :

      <mx:Repeater id="r" dataProvider="{service.loadCalendar.lastResult}">
      <mx:Text x="10" y="331" text="{r.currentItem.url}" width="780" height="20"/>
      </mx:Repeater>

      I get nothing. If I look at r.currentItem, it's a ObjectProxy but I don't see any propertie with name "url" (or any other property).

      My WSDL :

      <wsdl:definitions targetNamespace=" http://elvis.os.lan/cgi-bin/WebObjects/CalDynamique.woa/-5000/ws/CalService">
      <wsdl:types>
      <schema targetNamespace=" http://xml.apache.org/xml-soap">
      <import namespace=" http://schemas.xmlsoap.org/soap/encoding/"/>
      <complexType name="Map">
      <sequence>
      <element maxOccurs="unbounded" minOccurs="0" name="item">
      <complexType>
      <all>
      <element name="key" type="xsd:anyType"/>
      <element name="value" type="xsd:anyType"/>
      </all>
      </complexType>
      </element>
      </sequence>
      </complexType>
      </schema>
      <schema targetNamespace=" http://data.ical4j.fortuna.net">
      <import namespace=" http://schemas.xmlsoap.org/soap/encoding/"/>
      <complexType name="ParserException">
      <sequence>
      <element name="lineNo" type="xsd:int"/>
      </sequence>
      </complexType>
      </schema>
      </wsdl:types>
      <wsdl:message name="loadImagesResponse">
      <wsdl:part name="loadImagesReturn" type="soapenc:Array"/>
      </wsdl:message>
      <wsdl:message name="loadImagesRequest">
      </wsdl:message>
      <wsdl:message name="loadCalendarRequest">
      </wsdl:message>
      <wsdl:message name="loadCalendarResponse">
      <wsdl:part name="loadCalendarReturn" type="soapenc:Array"/>
      </wsdl:message>
      <wsdl:message name="ParserException">
      <wsdl:part name="fault" type="tns2:ParserException"/>
      </wsdl:message>
      <wsdl:portType name="CalService">
      <wsdl:operation name="loadCalendar">
      <wsdl:input message="impl:loadCalendarRequest" name="loadCalendarRequest"/>
      <wsdl:output message="impl:loadCalendarResponse" name="loadCalendarResponse"/>
      <wsdl:fault message="impl:ParserException" name="ParserException"/>
      </wsdl:operation>
      <wsdl:operation name="loadImages">
      <wsdl:input message="impl:loadImagesRequest" name="loadImagesRequest"/>
      <wsdl:output message="impl:loadImagesResponse" name="loadImagesResponse"/>
      </wsdl:operation>
      </wsdl:portType>
      <wsdl:binding name="CalServiceSoapBinding" type="impl:CalService">
      <wsdlsoap:binding style="rpc" transport=" http://schemas.xmlsoap.org/soap/http"/>
      <wsdl:operation name="loadCalendar">
      <wsdlsoap:operation soapAction=""/>
      <wsdl:input name="loadCalendarRequest">
      <wsdlsoap:body encodingStyle=" http://schemas.xmlsoap.org/soap/encoding/" namespace=" http://DefaultNamespace" use="encoded"/>
      </wsdl:input>
      <wsdl:output name="loadCalendarResponse">
      <wsdlsoap:body encodingStyle=" http://schemas.xmlsoap.org/soap/encoding/" namespace=" http://elvis.os.lan/cgi-bin/WebObjects/CalDynamique.woa/-5000/ws/CalService" use="encoded"/>
      </wsdl:output>
      <wsdl:fault name="ParserException">
      <wsdlsoap:fault encodingStyle=" http://schemas.xmlsoap.org/soap/encoding/" namespace=" http://elvis.os.lan/cgi-bin/WebObjects/CalDynamique.woa/-5000/ws/CalService" use="encoded"/>
      </wsdl:fault>
      </wsdl:operation>
      <wsdl:operation name="loadImages">
      <wsdlsoap:operation soapAction=""/>
      <wsdl:input name="loadImagesRequest">
      <wsdlsoap:body encodingStyle=" http://schemas.xmlsoap.org/soap/encoding/" namespace=" http://DefaultNamespace" use="encoded"/>
      </wsdl:input>
      <wsdl:output name="loadImagesResponse">
      <wsdlsoap:body encodingStyle=" http://schemas.xmlsoap.org/soap/encoding/" namespace=" http://elvis.os.lan/cgi-bin/WebObjects/CalDynamique.woa/-5000/ws/CalService" use="encoded"/>
      </wsdl:output>
      </wsdl:operation>
      </wsdl:binding>
      <wsdl:service name="CalService">
      <wsdl:port binding="impl:CalServiceSoapBinding" name="CalService">
      <wsdlsoap:address location=" http://elvis.os.lan/cgi-bin/WebObjects/CalDynamique.woa/-5000/ws/CalService"/>
      </wsdl:port>
      </wsdl:service>
      </wsdl:definitions>
        • 1. Re: WebService (SOAP)  and repeaters
          ntsiii Level 3
          Don't bind directly to last result, it is too hard to debug.

          Use resultFormat="e4x", the default is "object" and you do not want that.

          Use a custom component for the repeater. This way you can debug the data the repeater item has.

          Some code snippets below.
          Tracy

          When working with Repeater, I advise creating a custom component that you will repeat, and pass it the entire "currentItem", In the component, implement a "setter" function to receive the currentItem data.

          Now, in the component, you can code normally, binding to the data as you wish, without the hard to read currentItem references. You also avoid the binding warnings without the cast/conversion because the binding source is a true XML object.

          And, you can dispatch events normally. In the event handler, you can reference the component via the event.target property, and thus get a direct reference to the dataProvider item. This is easier to write and read than having to use getRepeaterItem().

          Here are some code snippets:

          In the main app or component (note how "clean" and readable this is):
          <mx:Application
          <mx:VBox ...>
          <mx:Repeater id="rp" dataProvider="{_xmlData}" ...>
          <mycomp:MyRepeatedComponent xmlItem="{rp.currentItem}" .../>
          </mx:Repeater
          </mx:VBox>

          And in the component, MyRepeatedComponent.mxml:
          <?xml version="1.0" encoding="utf-8"?>
          <mx:HBox ...
          <mx:Script><![CDATA[
          [Bindable]private var _xmlItem:XML;

          public function set xmlData(xml:XML):void
          {
          _xmlItem = xml;
          trace(_xmlItem.toXMLString());
          //do any special, non-bound ui stuff you want
          }//
          ]]></mx:Script>
          <!-- Now declare the Item UI -->
          <mx:Text id="lbDescription" text="{_xmlItem.@description}" width="100%" height="100%" />