Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Adobe AIR Development

Posts: 12
Registered: ‎03-25-2011
My Device: 9800
My Carrier: Unknown

Making HTTPRequest and getting response

Im trying to make a HTTP Request as follows:


var pSmiley TongueersonSearchController = new PersonSearchController();

navigator.pushView(views.PersonSearchResults, +p.getResp());
So basically, before the search we get a "Searching..." AlertDialog box, once the search is complete, the dialog box disappears and the results screen is pushed onto the screen...
Here is the search method:
function search{
var requestSender:URLLoader= new URLLoader();

dispatcher.addEventListener(Event.COMPLETE, completeHandler);

var urlRequest :URLRequest = new URLRequest("http://airpoint05:8888/MPS2/PersonSearch");

var msgSmiley Frustratedtring = "blah";
/* Setup HTTP Request */
urlRequest.data = msg;
urlRequest.contentType = "application/x-www-form-urlencoded";
urlRequest.method = URLRequestMethod.POST;
And here is the completeHandler function:
/* URL has completed and got a response */
private function completeHandler(event:Event):void
 var response:URLLoader = URLLoader(event.target);
 this.res = URLLoader(event.target).data;
When this line is called: navigator.pushView(views.PersonSearchResults, +p.getResp());
p.getResp() is nothing as the response hasn't came back yet. I want the program to basically block until the HTTPResponse is received so I can process the results. At the moment the Popup appear and disappears quickly, and in the background the search goes off and makes the request... I get the response but only after the results screen has been pushed out. How can I make the popup block until we have a HTTPresponse?



Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: Making HTTPRequest and getting response

When you allocate the Alert window, maintain that as a private attribute and when the callback occurs from the website, then close the alert window.


You should also manage errors from the URLLoader request in case the user is not connected to the Internet.


Also, it is helpful to others here that you post code using the [C] icon in the toolbar.  It makes the code more readable and you will likely get a better answer.