Eggsy,

To get it to work you need to get the plumbing right, and it's not
quite the same way as calling from code - btw, the example on that
page is aimed at client side not server side.  The server is any
language you want as long as it returns a well-formed JavaScript
segment of the form:

mycallback({....some json content....})

So your servlet would work as long as it returns something like the
above.

In this approach you don't call the servlet in the normal way from the
program code, rather it gets called as a consequence of adding a
<script> tag to the DOM - this is what the addScript() method in the
example code does.  Once the script is added to the DOM the browser
accesses the defined url of your service and expects a response.  As
the response is a JavaScript function, it will get evaluated in the
browser.

If you also define a function in the DOM with the same name you expect
back in the server response, e.g. mycallback, and that function calls
the GWT handle() function then the loop is closed.  The example code
adds such a function using the setUp() method.

The example code reserves a new function name for each "call" made to
the server, adds that new function to the DOM and then the <script>
tag.

Where things usually go wrong are if the server returns a function
name not set up, or the response is not a valid javascript expression.

Hope that helps in some small way!

//Adam


this then gets evaluated in the browser

On 6 Okt, 17:02, eggsy84 <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> Taking the informative article by Dan Morrill at GWT
>
> Link:http://code.google.com/support/bin/answer.py?answer=65632&topic=11368
>
> It explains how to code for Server side mashups so that you can
> perform cross site JSONP calls.
>
> In the article he uses the handle method (Shown below) to handle the
> return from the server side:
>
> public void handle(JavaScriptObject jso) {
>     JSONObject json = new JSONObject(jso);
>     JSONArray ary =
> json.get("feed").isObject().get("entry").isArray();
>     for (int i = 0; i < ary.size(); ++i) {
>       RootPanel.get().add(new
> Label(ary.get(i).isObject().get("title").isObject().get("$t").toString()));
>     }
>   }
>
> I have tried writing my own basic Java Servlet GET/POST we all know
> the score and I can successfully call into my servlet but I never get
> back to my client side, in this case after the servlet has done its
> stuff, I never go back to the handle method to perform some whizz bang
> GWT stuff - is there something specific you are required to do on the
> server side? Such as extends RemoteServiceServlet as you would do in a
> normal GWT AsyncCallback call? Anyone got any ideas?
>
> Thanks all
>
> eggsy
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to Google-Web-Toolkit@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to