Re: [flexcoders] multiple http requests

2007-09-28 Thread Randy Troppmann
AsyncToken, thats very cool. What part of the HTTP header does it use
to match up asyncronous calls?

Randy

On 9/27/07, Tracy Spratt <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
>
> Use a single HTTPService instance, and a single result handler.
>
>  When you invoke send(), it returns an AsyncToken. This is a dynamic object
> to which you can add almost any property. I usually add a callid string
> property.
>
>  Then in the result handler, I can access the callid property value, and
> process the result data accordingly.
>
>  Tracy
>
>  Snippets:
>
>  Sample code using HTTPService, e4x, handler function to populate a list
> item.
>  Also shows usage of AsyncToken.
>
>  The DataGrid tag:
>  
>
>  The HTTPService tag:
>   fault="/>
>
>  Script block declaration:
>  import mx.rpc.Events.ResultEvent;
>  [Bindable]private var _xlcMyListData:XMLListCollection;
>
>  Invoke send:
>  var oRequest:Object = new Object();
>  oRequest.Arg1 = "value1";
>  var callToken:AsyncToken = service.send(oRequest);
>  token.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
>  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) {
>  case "myQuery1":
>  doQuery2();
>  break;
>  ...
>  }
>  }//onResult
>
>  ____
>  From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
> Behalf Of Mansour Raad
>  Sent: Thursday, September 27, 2007 3:32 PM
>  To: flexcoders@yahoogroups.com
>  Subject: Re: [flexcoders] multiple http requests
>
>  the player is limited by the number concurrent http to the _same_ domain of
> the browser (typically 2)
>  If u target multiple domains at once - then u should be ok - so - create
> www.host[abcde...].com
>
>  Mansour
>  http://thunderheadxpler.blogspot.com
>  :-)
>
>  On Sep 27, 2007, at 11:35 AM, Randy Troppmann wrote:
>
>  My application sometimes needs to make a flurry of http requests to a
>  web service to populate some values. So it may send out 10 in a row
>  quickly. Although the responses always come back in the order that
>  they were requested, I am pretty sure that I cannot rely on this
>  always being so. So I cache the calls and send them out one at a time
>  and only when the previous response has been recieved. But this makes
>  the mechanism pretty slow. Is there a better way or a pattern I should
>  look at?
>
>  - Randy
>
>  --
>  Flexcoders Mailing List
>  FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
>  Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
>  Yahoo! Groups Links
>
>  Mansour
>  http://thunderheadxpler.blogspot.com
>  :-)
>
>  


RE: [flexcoders] multiple http requests

2007-09-27 Thread Tracy Spratt
Use a single HTTPService instance, and a single result handler.

When you invoke send(), it returns an AsyncToken.  This is a dynamic object to 
which you can add almost any property.  I usually add a callid string property.

Then in the result handler, I can access the callid property value, and process 
the result data accordingly.

Tracy

Snippets:

Sample code using HTTPService, e4x, handler function to populate a list item.  
Also shows usage of AsyncToken.

The DataGrid tag:



The HTTPService tag:
mailto:[EMAIL PROTECTED] On Behalf Of Mansour 
Raad
Sent: Thursday, September 27, 2007 3:32 PM
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders] multiple http requests

the player is limited by the number concurrent http to the _same_ domain of the 
browser (typically 2)
If u target multiple domains at once - then u should be ok - so - create 
www.host[abcde...].comĀ 

Mansour
http://thunderheadxpler.blogspot.com
:-)



On Sep 27, 2007, at 11:35 AM, Randy Troppmann wrote:


My application sometimes needs to make a flurry of http requests to a
web service to populate some values. So it may send out 10 in a row
quickly. Although the responses always come back in the order that
they were requested, I am pretty sure that I cannot rely on this
always being so. So I cache the calls and send them out one at a time
and only when the previous response has been recieved. But this makes
the mechanism pretty slow. Is there a better way or a pattern I should
look at?

- Randy


--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.comĀ 
Yahoo! Groups Links





Mansour
http://thunderheadxpler.blogspot.com
:-)




 



Re: [flexcoders] multiple http requests

2007-09-27 Thread Mansour Raad
the player is limited by the number concurrent http to the _same_  
domain of the browser (typically 2)
If u target multiple domains at once - then u should be ok - so -  
create www.host[abcde...].com


Mansour
http://thunderheadxpler.blogspot.com
:-)



On Sep 27, 2007, at 11:35 AM, Randy Troppmann wrote:


My application sometimes needs to make a flurry of http requests to a
web service to populate some values. So it may send out 10 in a row
quickly. Although the responses always come back in the order that
they were requested, I am pretty sure that I cannot rely on this
always being so. So I cache the calls and send them out one at a time
and only when the previous response has been recieved. But this makes
the mechanism pretty slow. Is there a better way or a pattern I should
look at?

- Randy


--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders% 
40yahoogroups.com

Yahoo! Groups Links






Mansour
http://thunderheadxpler.blogspot.com
:-)





[flexcoders] multiple http requests

2007-09-27 Thread Randy Troppmann
My application sometimes needs to make a flurry of http requests to a
web service to populate some values. So it may send out 10 in a row
quickly. Although the responses always come back in the order that
they were requested, I am pretty sure that I cannot rely on this
always being so. So I cache the calls and send them out one at a time
and only when the previous response has been recieved. But this makes
the mechanism pretty slow. Is there a better way or a pattern I should
look at?

- Randy


RE: [flexcoders] multiple HTTP Requests

2006-12-18 Thread Peter Farland
As with other RPC services, an instance of AsyncToken is returned when
you call myService.myOperationName().
 
 



From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Steve Kellogg @ Project SOC
Sent: Monday, December 18, 2006 1:06 PM
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] multiple HTTP Requests



Tracy,

I've been wondering about AsyncToken...  Is there any way to use it with
WebService objects that are defined in mxml?

I currently define the WebService, and then call
"myService.myOperationName();", but I haven't figured out any way to
inject an AsyncToken into that procedure.

Thanks in Advance for any advice.

Steve


RE: [flexcoders] multiple HTTP Requests

2006-12-18 Thread Steve Kellogg @ Project SOC
Tracy,

 

I've been wondering about AsyncToken.  Is there any way to use it with
WebService objects that are defined in mxml?

 

 

I currently define the WebService, and then call
"myService.myOperationName();", but I haven't figured out any way to inject
an AsyncToken into that procedure.

 

 

Thanks in Advance for any advice.

 

 

Steve

 

  _  

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Tracy Spratt
Sent: Monday, December 18, 2006 11:00 AM
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] multiple HTTP Requests

 

First, don't use URLLoader, HTTPService is easier.

 

Second, you *can't* use the result in the same function in which you invoke
send(), you must do that work in the handler function.

 

Third, use the AsyncToken. You can assign a identifier to each query when
you send it, and use that identifier in a switch statement in a handler
function to determine how to handle the result.  Or you can directly assign
a handler function to the AsyncToken.

 

Tracy

 

  _  

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Sudha Hariharan
Sent: Monday, December 18, 2006 1:50 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] multiple HTTP Requests

 

hi,

I am rather new to flex and this is one of my amateur attempts at building
RIAs. My application at present includes a tree menu, items of which when
dropped onto a canvas opens up window components. Each window sends a http
request that gets the appropriate data onto the display of the window. 
when i include multiple http requests at a given time, the data relevent to
the most recent request is only being displayed. How do I display data from
other http requests simulatenously?
a portion of my code is here
http://localhost/mydoc.php "
useProxy="false" method="POST" result="sHandler(event)">
  
  
   
 http://localhost/mydoc1.php "
useProxy="false" method="POST" result="sHandler(event)">
  
  
   

  public function onDragDrop(event:DragEvent):void{

var myWindow:ResizableTitleWindow = new ResizableTitleWindow();
var myTextArea:Text = new Text();
var ds:DragSource = event.dragSource ;
if( !ds.hasFormat("treeItems") ) return; // no useful data
var items:Array = ds.dataForFormat("treeItems") as Array;
for(var i:Number=0; i < items.length; i++) {
var item:XML = XML(items[i]);
if( [EMAIL PROTECTED] == "ms"){

userRequest.send();
myTextArea.text= userRequest.lastResult.slk;

}
else if([EMAIL PROTECTED] == "hr"){
userRequest1.send();
myTextArea.text = userRequest1.lastResult.slk;
}
}
myWindow.label = "New Window";
myWindow.x = xvalue;
myWindow.y = yvalue;
myWindow.addChild(myTextArea);
home1.addChild (myWindow);
}
public function sHandler(event:ResultEvent):void
{

myTextArea.text = event.result.slk ;

}

A friend of mine suggested to your URLLoader instead of HTTPRequest...how do
I go about with that?..Please help me

Thanks in Advance,
Sudha Hariharan. 

 Send free SMS to your Friends on Mobile from your Yahoo! Messenger.
Download Now! http://messenger.yahoo.com/download.php

 



RE: [flexcoders] multiple HTTP Requests

2006-12-18 Thread Tracy Spratt
First, don't use URLLoader, HTTPService is easier.

 

Second, you *can't* use the result in the same function in which you
invoke send(), you must do that work in the handler function.

 

Third, use the AsyncToken. You can assign a identifier to each query
when you send it, and use that identifier in a switch statement in a
handler function to determine how to handle the result.  Or you can
directly assign a handler function to the AsyncToken.

 

Tracy

 



From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Sudha Hariharan
Sent: Monday, December 18, 2006 1:50 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] multiple HTTP Requests

 

hi,

I am rather new to flex and this is one of my amateur attempts at
building RIAs. My application at present includes a tree menu, items of
which when dropped onto a canvas opens up window components. Each window
sends a http request that gets the appropriate data onto the display of
the window. 
when i include multiple http requests at a given time, the data relevent
to the most recent request is only being displayed. How do I display
data from other http requests simulatenously?
a portion of my code is here
http://localhost/mydoc.php "
useProxy="false" method="POST" result="sHandler(event)">
  
  
   
 http://localhost/mydoc1.php
" useProxy="false" method="POST" result="sHandler(event)">
  
  
   

  public function onDragDrop(event:DragEvent):void{

var myWindow:ResizableTitleWindow = new ResizableTitleWindow();
var myTextArea:Text = new Text();
var ds:DragSource = event.dragSource ;
if( !ds.hasFormat("treeItems") ) return; // no useful data
var items:Array = ds.dataForFormat("treeItems") as Array;
for(var i:Number=0; i < items.length; i++) {
var item:XML = XML(items[i]);
if( [EMAIL PROTECTED] == "ms"){

userRequest.send();
myTextArea.text= userRequest.lastResult.slk;

}
else if([EMAIL PROTECTED] == "hr"){
userRequest1.send();
myTextArea.text = userRequest1.lastResult.slk;
}
}
myWindow.label = "New Window";
myWindow.x = xvalue;
myWindow.y = yvalue;
myWindow.addChild(myTextArea);
home1.addChild (myWindow);
}
public function sHandler(event:ResultEvent):void
{

myTextArea.text = event.result.slk ;

}

A friend of mine suggested to your URLLoader instead of
HTTPRequest...how do I go about with that?..Please help me

Thanks in Advance,
Sudha Hariharan. 

 Send free SMS to your Friends on Mobile from your Yahoo! Messenger.
Download Now! http://messenger.yahoo.com/download.php

 



[flexcoders] multiple HTTP Requests

2006-12-18 Thread Sudha Hariharan
hi,

I am rather new to flex and this is one of my amateur attempts at building 
RIAs. My application at present includes a tree menu, items of which when 
dropped onto a canvas opens up window components. Each window sends a http 
request that gets the appropriate data onto the display of the window. 
when i include multiple http requests at a given time, the data relevent to the 
most recent request is only being displayed. How do I display data from other 
http requests simulatenously?
a portion of my code is here
http://localhost/mydoc.php " 
useProxy="false" method="POST" result="sHandler(event)">
  
  
   
 http://localhost/mydoc1.php " 
useProxy="false" method="POST" result="sHandler(event)">
  
  
   

  public function onDragDrop(event:DragEvent):void{

var myWindow:ResizableTitleWindow = new ResizableTitleWindow();
var myTextArea:Text = new Text();
var ds:DragSource = event.dragSource ;
if( !ds.hasFormat("treeItems") ) return; // no useful data
var items:Array = ds.dataForFormat("treeItems") as Array;
for(var i:Number=0; i < items.length; i++) {
var item:XML = XML(items[i]);
if( [EMAIL PROTECTED] == "ms"){

userRequest.send();
myTextArea.text= userRequest.lastResult.slk;

}
else if([EMAIL PROTECTED] == "hr"){
userRequest1.send();
myTextArea.text = userRequest1.lastResult.slk;
}
}
myWindow.label = "New Window";
myWindow.x = xvalue;
myWindow.y = yvalue;
myWindow.addChild(myTextArea);
home1.addChild (myWindow);
}
public function sHandler(event:ResultEvent):void
{

myTextArea.text = event.result.slk ;

}

A friend of mine suggested to your URLLoader instead of HTTPRequest...how do I 
go about with that?..Please help me

Thanks in Advance,
Sudha Hariharan. 

 Send free SMS to your Friends on Mobile from your Yahoo! Messenger. Download 
Now! http://messenger.yahoo.com/download.php