Wednesday, February 10, 2021

Re: How do we make GWT accept dynamic domain name?

You can try to create a hidden element on the HTML file with the server name. Example:

<input type="hidden" name="server-name" id="server-name" value="SERVER NAME HERE">

And you can get the value in GWT with:
InputElement input = (InputElement) Document.get().getElementById("server-name");
String serverName = input.getValue();

Another way is creating in the HTML file, a Javascript global variable via script tag or script file and load this via GWT using JSNI or JSInterop (the example is with JSNI):
<script>
window.SERVER_NAME = [SERVER_NAME_HERE];
</script>

In GWT:
public class ServerNameUtil {
public static native String getServerName() /*-{
   return $wnd.SERVER_NAME;
}-*/;
}

You can improve these ideas for your solution. IT is some ideas to help you to think of the best solution for your scenario. :)

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit/CALVte5y6DcMON1BM4xpJ4FXWdSh-sEF5rG7Gtfavbjc9nwbBtg%40mail.gmail.com.

No comments:

Post a Comment