When running a GWT application in hosted mode one usually needs to add the location of the code server in a query string parameter, for example instead of index.html
one may need to open index.html?gwt.codesvr=127.0.0.1:9997
. The problem is that gwt.codesvr
is not usually included in hyperlinks, so it has to be added manually. Adding it to all links in your application does not seem a good idea as it will interfere with the final GWT-compiled version. Another option is for index.html
to introspect itself by JavaScript and append a default gwt.codesvr
to window.location
, but this should be done only after the application is sure that it has not been compiled, that is after the GWT module may need to be (re)compiled
alert.
The ideal solution, I believe, would be for GWT to allow customization of the action it does after it finds no permutations to select from. The default action is to show the alert warning just mentioned, but unfortunately this is not customizable.
So my question is this: what is the best way to automatically open the current page with a default gwt.codesvr
when there is no compiled permutations.
Since I'm dealing with 'Places' all the time now I updated the bookmarklet to deal with '#' too.
javascript:(function(){h="localhost";p="9997";l="gwt.codesvr="+h+":"+p;s=false;if(document.location.href.indexOf("gwt.codesvr")<0){q=document.location.href.indexOf("?");if(q<0){q=document.location.href.indexOf("#");if(q>0){q=q-1}s=true}if(q<0&&!s){document.location.href=document.location.href+"?"+l}else%20if(q>=0&&!s){b=document.location.href.substr(0,q+1);e=document.location.href.substr(q+1);document.location.href=b+l+"&"+e}else{b=document.location.href.substr(0,q+1);if(q<0){e=""}else{e=document.location.href.substr(q+1)}document.location.href=b+"?"+l+e}}})();
Update 2/7/2017- There had been a typo in the script. Corrected it.