Wednesday, February 10, 2021

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

Ic.. so you are saying get the domain value via JavaScript and pass it to GWT, in that case anything that's written by user on the browser, becomes the domain name. 

Aha.. so in this case, basically GWT doesn't need to care what is the domain name. Hmm interesting. 

But in this case, this has to be at GWT EntryPoint? 

On Wed, Feb 10, 2021, 7:23 PM Ricardo Serathiuk <ricardo@serathiuk.com> wrote:
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 a topic in the Google Groups "GWT Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-web-toolkit/Cumty5Oge1U/unsubscribe.
To unsubscribe from this group and all its topics, 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.

--
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/CA%2B2UxCFh8S%3DcRCn4LWR5XYKdMetnkqye%2B%3DLfsBnru5uxFR_XWQ%40mail.gmail.com.

No comments:

Post a Comment