Also, I advise against using lastResult.  This property is intended for
use in binding expressions, and you cannot depend on its value when you
access it in AS code (though it usually works).  Instead, use
event.result:

...

var xmlResult:XML = XML(event.result);

trace(xmlResult.toXMLString());  //So you know how to write the xmllist
expression

var xlJobs:XMLList = xmlResult.job;

trace(xlJobs.length());  //is this number what you expect?

datagrid.dataProvider = xlJobs;

 

Note that if you ever decide to use binding instead of directly
assigning the dataProvider, do not use XMLList because it is not
bindable.  Wrapt that in an XMLListCollection instead.

 

Tracy

 

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Clinton D. Judy
Sent: Tuesday, May 20, 2008 9:26 AM
To: [email protected]
Subject: RE: [flexcoders] Re: Grr, HTTPService doesn't work when it
should

 

Hey, that was it. Thanks a bunch! :-D 

 

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of twcrone70
Sent: Tuesday, May 20, 2008 9:04 AM
To: [email protected]
Subject: [flexcoders] Re: Grr, HTTPService doesn't work when it should

 

On the contrary to an earlier response, I believe you need to change

checkJobs.lastResult.jobs.job

to

checkJobs.lastResult.job

It's been a while since I interacted with XML based responses but I
think the root tag is essentially ignored and you specify the level
past that.

- Todd

--- In [email protected] <mailto:flexcoders%40yahoogroups.com>
, "Clinton D. Judy" <[EMAIL PROTECTED]> wrote:
>
> Sorry about not being descriptive enough. What I meant was, my browser
> would crash, and Flex Builder would bring up the httpservice source
code
> where the error happened. That's not happening anymore, but it's still
> not populating my datagrid.
> 
> 
> 
> This is my current source code:
> 
> 
> 
> <?xml version="1.0" encoding="utf-8"?>
> 
> <mx:Application
> 
> xmlns:mx="http://www.adobe.com/2006/mxml
<http://www.adobe.com/2006/mxml> "
> 
> layout="vertical" horizontalAlign="center" verticalAlign="top"
> 
> width="100%" height="100%" creationComplete="checkJobs.send()">
> 
> <mx:Script>
> 
> <![CDATA[
> 
> import mx.controls.Alert;
> 
> import mx.rpc.events.ResultEvent;
> 
> 
> 
> private function
> getResultOk(r:Number,event:Event):void{
> 
> if(!r){
> 
> Alert.show('Error sending data!!');
> 
> return;
> 
> }
> 
> 
> datagrid.dataProvider=checkJobs.lastResult.jobs.job;
> 
> Alert.show( String(this.checkJobs.lastResult) );
> 
> }
> 
> ]]>
> 
> </mx:Script>
> 
> <mx:HTTPService id="checkJobs"
> url="http://localhost:3001/jobs.xml <http://localhost:3001/jobs.xml> "
> 
> contentType="application/x-www-form-urlencoded"
> 
> method="POST" resultFormat="e4x" useProxy="false"
> 
> result="getResultOk(1,event)"
> 
> fault="getResultOk(0,event)" />
> 
> <mx:DataGrid id="datagrid" width="100%" height="60%">
> 
> <mx:columns>
> 
> <mx:DataGridColumn headerText="Name" dataField="name"
> />
> 
> <mx:DataGridColumn headerText="ECMS" dataField="ecms"
> />
> 
> </mx:columns>
> 
> </mx:DataGrid>
> 
> <mx:Button label="check jobs"
> click="blah.text='';checkJobs.send()" />
> 
> <mx:TextArea id="blah" text="{checkJobs.lastResult}" />
> 
> </mx:Application>
> 
> 
> 
> The XML is still the same from earlier. I tried both jobs and jobs.job
> to no avail. Any thoughts?
> 
> 
> 
> From: [email protected] <mailto:flexcoders%40yahoogroups.com>
[mailto:[email protected] <mailto:flexcoders%40yahoogroups.com>
] On
> Behalf Of Beau Scott
> Sent: Monday, May 19, 2008 6:08 PM
> To: [email protected] <mailto:flexcoders%40yahoogroups.com> 
> Subject: RE: [flexcoders] Grr, HTTPService doesn't work when it should
> 
> 
> 
> A little more information on the fault than "shuts down hard" would be
> helpful.
> 
> In any case, some webservers won't let you POST to an XML document,
try
> changing the HTTPService method to "GET".
> 
> 
> 
> Beau
> 
> 
> 
> 
> 
> From: [email protected] <mailto:flexcoders%40yahoogroups.com>
[mailto:[email protected] <mailto:flexcoders%40yahoogroups.com>
] On
> Behalf Of Clinton D. Judy
> Sent: Monday, May 19, 2008 2:23 PM
> To: [email protected] <mailto:flexcoders%40yahoogroups.com> 
> Subject: RE: [flexcoders] Grr, HTTPService doesn't work when it should
> 
> 
> 
> I tried Charles, and discovered I was sending this to Rails:
> 
> 
> 
> <> 
> 
> 
> 
> This doesn't seem right, and sure enough, Rails is throwing errors
when
> it receives that. So it's gotta be my HTTPService, but I don't know
> where to begin fixing it.
> 
> 
> 
> From: [email protected] <mailto:flexcoders%40yahoogroups.com>
[mailto:[email protected] <mailto:flexcoders%40yahoogroups.com>
] On
> Behalf Of Clinton D. Judy
> Sent: Monday, May 19, 2008 4:13 PM
> To: [email protected] <mailto:flexcoders%40yahoogroups.com> 
> Subject: RE: [flexcoders] Grr, HTTPService doesn't work when it should
> 
> 
> 
> I tried this, it didn't work. I thought you still referred to the
first
> element in an array in Flex, not its parent class. Are you sure my
> HTTPService is fine?
> 
> 
> 
> From: [email protected] <mailto:flexcoders%40yahoogroups.com>
[mailto:[email protected] <mailto:flexcoders%40yahoogroups.com>
] On
> Behalf Of Jeff Vroom
> Sent: Monday, May 19, 2008 3:59 PM
> To: [email protected] <mailto:flexcoders%40yahoogroups.com> 
> Subject: RE: [flexcoders] Grr, HTTPService doesn't work when it should
> 
> 
> 
> I think at least you need to change:
> 
> 
> 
> checkJobs.lastResult.jobs.job
> 
> 
> 
> to:
> 
> 
> 
> checkJobs.lastResult.jobs
> 
> 
> 
> the DataGrid is expecting a list of jobs, not just a single job. 
> 
> 
> 
> Jeff
> 
> 
> 
> ________________________________
> 
> From: [email protected] <mailto:flexcoders%40yahoogroups.com>
[mailto:[email protected] <mailto:flexcoders%40yahoogroups.com>
] On
> Behalf Of Clinton D. Judy
> Sent: Monday, May 19, 2008 12:52 PM
> To: [email protected] <mailto:flexcoders%40yahoogroups.com> 
> Subject: [flexcoders] Grr, HTTPService doesn't work when it should
> 
> 
> 
> This may be a simple problem, but Flex shuts down hard when I try this
> code:
> 
> 
> 
> 
> 
> <?xml version="1.0" encoding="utf-8"?>
> 
> <mx:Application
> 
> xmlns:mx="http://www.adobe.com/2006/mxml
<http://www.adobe.com/2006/mxml> "
> 
> layout="vertical" horizontalAlign="center" verticalAlign="top"
> 
> width="100%" height="100%" creationComplete="checkJobs.send()">
> 
> <mx:Script>
> 
> <![CDATA[
> 
> import mx.controls.Alert;
> 
> import mx.rpc.events.ResultEvent;
> 
> ]]>
> 
> </mx:Script>
> 
> <mx:HTTPService id="checkJobs"
> url="http://127.0.0.1:3001/jobs.xml <http://127.0.0.1:3001/jobs.xml> "
useProxy="false"
> contentType="application/xml" method="POST" />
> 
> <mx:DataGrid id="jobs" width="100%" height="60%"
> dataProvider="{checkJobs.lastResult.jobs.job}">
> 
> <mx:columns>
> 
> <mx:DataGridColumn headerText="Name" dataField="name"
> />
> 
> <mx:DataGridColumn headerText="ECMS" dataField="ecms"
> />
> 
> </mx:columns>
> 
> </mx:DataGrid>
> 
> <mx:Button label="check jobs" click="checkJobs.send()" />
> 
> </mx:Application>
> 
> 
> 
> 
> 
> And the accompanying XML file:
> 
> 
> 
> 
> 
> <jobs type="array">
> 
> <job>
> 
> <created-at type="datetime">2008-05-19T10:35:48-04:00</created-at>
> 
> <display-order type="integer" nil="true"/>
> 
> <ecms>1923</ecms>
> 
> <id type="integer">1</id>
> 
> <job-id nil="true"/>
> 
> <name>199238GAME</name>
> 
> <updated-at type="datetime">2008-05-19T10:35:48-04:00</updated-at>
> 
> </job>
> 
> <job>
> 
> <created-at type="datetime">2008-05-19T14:20:52-04:00</created-at>
> 
> <display-order type="integer" nil="true"/>
> 
> <ecms>1553</ecms>
> 
> <id type="integer">2</id>
> 
> <job-id nil="true"/>
> 
> <name>asdgggd</name>
> 
> <updated-at type="datetime">2008-05-19T14:20:52-04:00</updated-at>
> 
> </job>
> 
> </jobs>
> 
> 
> 
> 
> 
> Why isn't the datagrid being populated?
> 
> 
> 
> Clinton Judy
> 
> Web Developer
> 
> Glenn O. Hawbaker, Inc.
> 
> 
> 
> 
> 
> No virus found in this incoming message.
> Checked by AVG.
> Version: 7.5.524 / Virus Database: 269.23.21/1454 - Release Date:
> 5/19/2008 7:44 AM
> 
> 
> 
> No virus found in this outgoing message.
> Checked by AVG.
> Version: 7.5.524 / Virus Database: 269.23.21/1454 - Release Date:
> 5/19/2008 7:44 AM
>

 

Reply via email to