开发者

Why GWT doesn´t work without ?gwt.codesvr=127.0.0.1:9997

I would like to know why GWT doesn´t work without the argument ?gwt.codesvr=127.0.0.1:9997 in the url, I´m redirecting between modules hardcoding the url´s and I have to set this line not to be shown the message: Module XXX Must be (re) compile.

I hope not to have to change this urls in the future when I would change from host mode to we mode...

So is there any better way to link from a module to the other one? I´m doing with:

GWT.getHostPageBaseURL() + "UserRegistration.h开发者_运维知识库tml ?gwt.codesvr=127.0.0.1:9997 "

Thanks in advance.


That query-string argument is looked at by the *.nocache.js to trigger loading the dev mode plugin you installed in your browser, so it connects back to the designated DevMode app.

When you have to redirect between pages and you want them to all run either in dev mode or web mode, the easiest is to condition the argument (if possible with the value taken from the existing one, rather than hard-coded) to !GWT.isProdMode():

if (!GWT.isProdModode()) {
   // assumes 'url' doesn't contain a query-string yet
   url += "?gwt.codesvr=" + Window.Location.getParameter("gwt.codesvr");
}

If you don't use a query-string yourself, so it's only expected to ever exist with the gwt.codesvr parameter or be absent, you can make it even simpler using a UrlBuilder:

UrlBuilder builder = Window.Location.createUrlBuilder();
builder.setPath(GWT.getHostPageBaseURL() + "UserRegistration.html")
//don't pass the history token around:
builder.setHash(null);
// builder.toString() will then keep the same query string.

and it's not even conditioned to the current "mode" the app is run in, as it just, unconditionally, copies the query-string around.


That parameter is just for development mode. Be warned that if you are hard coding the url's with that parameter, well that is wrong for sure.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜