tags:

views:

36

answers:

1

I am doing coding from beggining blackberry by Anthony Rizk. I am stuck with this code as it is showing error again and again... private void getURL() { HttpRequestDispatcher dispatcher = new HttpRequestDispatcher(urlField.getText(), "GET", this); dispatcher.start(); }

Can anyone explain me why we are passing this as parameter and why actually this code is doing...

+1  A: 

"this" refers to the main screen you passed to the class so you can alert the requestFailed string. Check the run method on page 170. You'll see screen.requestFailed("Unexpected...").

As for your error - I suggest adding this line: System.out.println(" ----------------- HTTPREQUESTDISPATCHER ---------- " + urlField.getText());

right before your dispatcher.start(); line and then compile in debug mode to see what your console says. Just to make sure your URL to request is a valid web URL.

Additionally, make sure your simulator has MDS enabled. You need that to make web calls. In eclipse it is under Run->run configurations-> simulator tab -> general -> checkbox for Mobile Data System. I don't know where it is in the RIM package. If you're not using eclipse, you might want to switch over to it. It will highlight errors and try to help you resolve them.

fleces
Hi fleces...Thankxxx for replying...that surely helped me out....
Narendra