Reputation: 35276
Hi I have this code in my gwt app which purpose is to chage to URL as follows:
public void goToSignUpPage(boolean isDeployed) {
String url = (isDeployed == true ? "signup.html" : "signup.html?gwt.codesvr=127.0.0.1:9997");
Window.Location.replace(url);
However what happens it redirects into this URL:
http://127.0.0.1:8888/mygwtapp/signup.html?gwt.codesvr=127.0.0.1:9997
Where the working URL is this:
http://127.0.0.1:8888/signup.html?gwt.codesvr=127.0.0.1:9997
BTW, mygwtapp is the gwt module named defined in MyGwtApp.gwt.xml
<module rename-to='mygwtapp'>
Any ideas why the URL is appended by the gwt module name? Any way to fix this?
Upvotes: 1
Views: 4090
Reputation: 19857
All you needed was to add in GWT.getHostPageBaseURL() to get the full URL for your web application without it appending to the module name.
Try this out:
public void goToSignUpPage() {
String url = GWT.getHostPageBaseURL() + "signup.html";
if(!GWT.isProdMode()) {
Window.alert("We are in development mode!");
url += "?gwt.codesvr=127.0.0.1:9997";
}
Window.Location.replace(url);
}
I've also removed your parameter "isDeployed" and replaced it with GWT.isProdMode() within the method to check if you're in production or development mode.
With a paramater:
public void goToSignUpPage(Boolean isDeployed) {
String url = GWT.getHostPageBaseURL() + "signup.html";
if(!isDeployed) {
url += "?gwt.codesvr=127.0.0.1:9997";
}
Window.Location.replace(url);
}
Hope this helps!
Upvotes: 1