On 17 déc, 14:15, dduck <[email protected]> wrote:
> Hi,
>
> I am debugging a piece of code that GETting a request to a server that
> isn't localhost. The code looks like this:
>
> public void recieveRequest(final ServerResponseRecipient
> callbackOnCompletion) {
> this.callback = callbackOnCompletion;
> final RequestBuilder rb = new RequestBuilder(
> RequestBuilder.GET,
> URL.encode(
>
> "http://my.server:9080/myShopInstall/DownloadReport.do?
> content=dq_candidate_matches&format=excel_csv"
> ));
>
> rb.setHeader("Content-Type", "application/x-www-form-
> urlencoded");
>
> rb.setRequestData("");
> rb.setCallback(this);
> try {
> rb.send();
> } catch (final RequestException e) {
> throw new RuntimeException(e);
> }
> }
>
> Is the ANY way that I can make hosted mode on my development machine
> allow this request despite the single-origin policy? If not, I have to
> live with at much slowed down build/test cycle...
Depends if you're also using GWT-RPC and/or change static resources
too (CSS, images, ImageBundles). If not then you can launch the
GWTShell in -noserver mode, passing the full URL to your deployed app;
and the GWTShell will load your local client code (in Java) instead of
launching the deployed GWT application.
For other cases (in my case, when I need to tweak the CSS and/or want
to check the result in browsers outside the GWTShell), I use a "proxy
servlet" that I'm mapping from within the tomcat/webapps/ROOT/WEB-INF/
web.xml (added to SVN so I'm sure that even if GWT overwrites it --
when I switch version-- I can get back my changes as easily as a "svn
revert"):
<servlet>
<servlet-name>proxy</servlet-name>
<servlet-class>my.very.own.server.ProxyServlet</servlet-class>
<init-param>
<param-name>hostname</param-name>
<param-value>otherserver</param-value>
</init-param>
<init-param>
<param-name>port</param-name>
<param-value>8080</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>proxy</servlet-name>
<url-pattern>/alfresco/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>shell</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
That way, my code is the same when developping as when compiling for
deployment:
new RequestBuilder(RequestBuilder.GET, "/alfresco/s/foo/bar");
Search in the archives for other discussions on the subject.
Also note that this will change a bit in GWT 1.6 as the web.xml will
be your own, not something controlled by GWT (so GWT won't ever
overwrite it and adding the servlet and servlet-mapping as above will
be the blessed way to configure a servlet; as opposed to GWT 1.4 and
1.5 way of mapping them from your *.gwt.xml, which doesn't support
wildcard mappings).
And in GWT 2.0, you'll be able to launch hosted mode not only from
your deployed app (similar to today's -noserver mode) but moreover
from any browser (no more embedded browser in the GWTShell), thanks to
OOPHM (out-of-process hosted mode)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---