1 Reply Latest reply on Sep 24, 2006 6:52 PM by peterent

    XML Response from an Action

    dougtpham
      Hi All,
      Hopefully, I will have a little better luck with this question. I call a basic Webwork/Struts action which response back in an XML.. I cannot get my data grid populated, what am I doing wrong?

      <mx:Application
      xmlns:mx=" http://www.adobe.com/2006/mxml"
      layout="absolute"
      initialize="documentationService.send()">

      <mx:HTTPService
      id="documentationService"
      resultFormat="e4x"
      url="/myApp/flex/viewInfo.do" />
      .
      .
      .
      <mx:DataGrid id="dgrd_PeopleGrid" enabled="true"
      dataProvider="{ documentationService.lastResult.staffs }" right="0" left="0" height="100%" y="79">
      <mx:columns>
      <mx:DataGridColumn headerText="First Name" dataField="firstName"/>
      <mx:DataGridColumn headerText="Last Name" dataField="lastName"/>
      <mx:DataGridColumn headerText="Internet ID" dataField="internetId"/>
      </mx:columns>
      </mx:DataGrid>
      .
      .
      .
      </mx:Application>

      My XML response looks something like this.


      <staffs>
      <staff>
      <firstName>John</firstName><lastName>Davidson</lastName><internetId>david01</internetId></ staff>
      <staff>
      <firstName>Jack</firstName><lastName>Davidson</lastName><internetId>david02</internetId></ staff>
      <staff>
      <firstName>Joe</firstName><lastName>Davidson</lastName><internetId>david03</internetId></s taff>
      <staff>
      <firstName>System</firstName><lastName>Administrator</lastName><internetId>system</interne tId></staff>
      </staffs>

      Thanks
      Doug
        • 1. Re: XML Response from an Action
          peterent Level 2
          From your example, documentationService.lastResult is the XML document response. Specifically, it is the root tag which is, from your example, <staffs>. What you want to pass to the DataGrid is a repeating element, which is <staff>, the immedidate children of <staffs> so your dataProvider should read

          dataProvider="{documentationService.lastResult.staff}"