GWT RequestBuilder is based on XmlHttpRequest, which has to honour
same origin policy for security reasons.

I haven't tried this, but technically it should work.
a) Create a FormPanel, and set the action to the URL that you want.
Set the method to "get".
b) Add a SubmitCompleteHandler to the FormPanel, and implement the
onSubmitComplete(SubmitCompleteEvent event) method
c) Use event.getResults() method to get the contents of the URL.

Note that this approach doesn't have the equivalent of onFailure
method. If there is a backend exception, a 404 or any other problem,
you will just get the raw HTML explaining the problem. Any other
approach you adopt will have the same problems though.

--sri


On Sep 7, 9:33 am, palomer <rathere...@gmail.com> wrote:
> Dear gwt group,
> I'd like to fetch the contents of a url located in another domain and
> print it on the screen. I've pasted code that tries to achieve this
> using RequestBuilder. The code throws a security exception since you
> can't grab urls from other domains using RequestBuilder. How do I go
> about doing what I want to do?
> cheers
> --Jacques
>
> class LabelInclude extends Label {
>   public LabelInclude(final String url) {
>     super();
>     final LabelInclude widget = this;
>     try {
>       new RequestBuilder(RequestBuilder.GET, url).sendRequest("",
>           new RequestCallback() {
>             public void onError(Request request, Throwable exception)
> {
>                 widget.setText("failed");
>             }
>             public void onResponseReceived(Request request, Response
> response) {
>               if (response.getStatusCode() == 200) {
>                 widget.setText(response.getText());
>               } else {
>                   widget.setText("failed");
>               }
>             }
>           });
>     } catch (RequestException e) {
>         widget.setText("failed because of:" + e.toString());
>
>     }
>   }
>
> }
--~--~---------~--~----~------------~-------~--~----~
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 
google-web-toolkit+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to