Why are you converting the e4x XML into the legacy XMLDocument?  And if you
really are satisfied working with dynamic Object instead of XML, then use
resultFormat="object" and skip all that decdoing stuff.  Flex will do that
for you.  But that is the worst of both worlds; you lose the power of e4x
and suffer the diminished access performance of a dynamic object.

 

I suggest you use XML and XMLListCollection instead.

 

  _____  

From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On
Behalf Of anitha2324
Sent: Sunday, March 08, 2009 3:20 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: how to call dynamic servlet

 

Hi Thanks alot for your reply,

I have removed the binding variables, replaced xml by e4x , and setted the
url before the service.send but am still unable to get the successful result


here is my modified code

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe. <http://www.adobe.com/2006/mxml>
com/2006/mxml" layout="absolute" creationComplete="init()">
<mx:Script>
<![CDATA[
import flash.net.sendToURL;
import mx.controls.Alert;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
import mx.rpc.xml.SimpleXMLDecoder;
import mx.controls.Button;
import mx.controls.Label;
import mx.collections.ArrayCollection;

[Bindable]
public var expenses:ArrayCollection;

public var userId:int;

public var servletURL:String;

private function init():void{
userId = 12;
servletURL="http://localhost:
<http://localhost:8080/Application/topSenderServlet?TYPE=4&amp;USER_ID=>
8080/Application/topSenderServlet?TYPE=4&amp;USER_ID="+userId;
Alert.show(servletURL);
topSenders.url=servletURL;
topSenders.send();
}
private function serv_result(evt:ResultEvent):void {
/* Convert XMLNode to XMLDocument. */
var xmlStr:String = evt.result.toString();
var xmlDoc:XMLDocument = new XMLDocument(xmlStr);
var decoder:SimpleXMLDecoder = new SimpleXMLDecoder(true);
var resultObj:Object = decoder.decodeXML(xmlDoc);
/* Assign the values... */

expenses = new ArrayCollection();
for(var i:int=0;i<resultObj.top.sender.length;i++){
Alert.show(resultObj.top.sender[i].phone);

}
}

]]>
</mx:Script>

<!--<mx:HTTPService id="topSenders" useProxy="false" resultFormat="xml"
method="POST" url="http://localhost:
<http://localhost:8080/Application/topSenderServlet?TYPE=4&amp;USER_ID=12>
8080/Application/topSenderServlet?TYPE=4&amp;USER_ID=12"
result="serv_result(event);"/>-->

<mx:HTTPService id="topSenders" useProxy="false" resultFormat="e4x"
method="POST" 
result="serv_result(event);"/>

</mx:Application>

thanking you in Advance



Reply via email to