If "event.target.lastResult.DATARESULTS.SEVEND_ALOWED" works, then just
change it to:
event.result.DATARESULTS.SEVEND_ALOWED;
Note, you must be passing event into the handler in your declaration:
result=" stationloadResult(event)"
or event will be null.
When you change resultFormat to e4x, you have to use xml expressions to
access it. One other thing I advised is: do not bind directly to last
result, it is too hard to debug. I am quite sure the reason you
bindings failed is because you were not clear on the structure of your
xml. I suspect you did not understand that event.result is alrady at
the root node so you would never use it in a binding expression.
If you are happy using the object tree results, then fine, but when you
start having to loop and recurse and so forth just to find your data,
remember it was your choice!
If you want to try again using xml then here is some sample code below.
Tracy
Sample code using HTTPService, e4x, handler function to populate a list
item.
Also shows usage of AsyncToken.
The DataGrid tag:
<mx:DataGrid id="dg" dataProvider="{_xlcMyListData}" .../>
The HTTPService tag:
<mx:HTTPService id="service" resultFormat="e4x" result="onResult(event)"
fault="..../>
Script block declaration:
import mx.rpc.Events.ResultEvent;
import mx.rpc.AsyncToken;
[Bindable]private var _xlcMyListData:XMLListCollection;
Invoke send:
var oRequest:Object = new Object();
oRequest.Arg1 = "value1";
var callToken:AsyncToken = service.send(oRequest);
callToken.callId = "myQuery1";
Result Handler function:
private function onResult(oEvent:ResultEvent):void {
var xmlResult:XML = XML(event.result); //converts
result Object to XML. can also use "as" operator
trace(xmlResult.toXMLString());
var xlMyListData:XMLList = xmlResult.myListData; //depends on xml
format, is row data
_xlcMyListData = new XMLListCollection(xlMyListData); //wrap the
XMLList in a collection
trace(_xlcMyListData.toXMLString()); //so you can see
exactly how to specify dataField or build labelFunction
var callToken:AsyncToken = oEvent.token;
var sCallId = callToken.callId; //"myQuery1"
switch(sCallId) { //Process the
result conditionally
case "myQuery1":
doQuery2(); //do whatever.
this example calls another data service query
break;
...
}
}//onResult
________________________________
From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Jason B
Sent: Monday, June 02, 2008 3:07 PM
To: [email protected]
Subject: [flexcoders] Re: working with resulthandler httpservice and
referencing lastresult?
Tracy thanks for answering so quickly...
let me answer these items for you.
> First, don't use lastResult except in bindings. Use event.result.
Ok i wont anymore try this...! but i know the below line
event.target.lastResult.DATARESULTS.SEVEND_ALOWED works great !
> you have that in the handler, why did you switch back to lastResult?
I could never get your example to work i asked you for a example but
setting resultformat to anything i get blank info returned? im lost on
that?
> Second, what is your resultFormat? I think we have been through
this once before.
heheh yes i tried the resultformat you suggested a while back but it
never would work it would destroy my entire bindings
example my current binding in a textinput is
<mx:TextArea x="20" y="187" height="135" width="178"
id="stationinfo_placeofbusiness"
text="{stationsearchgrid_click.lastResult.DATARESULTS.POB_ADDRESS}" />
> Third, what is: "DATARESULTS.SEVEND_ALOWED"? Is this part of the data
> that is being returned?
I return XML file from php
<DATARESULTS>
<STATION_ID>XYZ12345</STATION_ID>
</DATARESULTS>
> You first step needs to be verifying you have the data you expect
within
> the result handler.
I did this already i have logging enabled and can see the xml being
returned it is ok on the php side