1

We are required to support only IE8 and IE9 and no other browsers. When using Chrome or Firefox all I get is a blank page (the host page). Is there a way to detect or be informed that no js file was found for that browser? Or do I have to look at the user agent myself in the host page and show message if the browser is not IE8 or IE9?

1 Answer 1

3

There are different ways to solve this problem, but the usual gwt way is using Deferred-Binding

Just create a class for loading the app code and instantiate it using GWT.create() in your onModuleLoad. Then you can have different implementations of the class for each permutation.

  package mynamespace.client;
  ...

  public class MyEntryPoint implements EntryPoint {

    public void onModuleLoad() {
      // create the appropriate implementation of the App class
      App app = GWT.create(App.class);
      // call the method to load the application.
      app.onLoad();
    }

    // Default implementation
    public static class App {
      public void onLoad() {
        Window.alert("This App is only supported in IE");
      }
    }

    // Implementation for IE
    public static class AppIE extends App {
      public void onLoad() {
        Window.alert("This is a supported Browser");
      }
    }
  }

Define which implementation use per each user-agent in your .gwt.xml file:

  <replace-with class="mynamespace.client.MyEntryPoint.AppIE">
    <when-type-is class="mynamespace.client.MyEntryPoint.App"/>
    <any>
         <when-property-is name="user.agent" value="ie6"/>
         <when-property-is name="user.agent" value="ie8"/>
         <when-property-is name="user.agent" value="ie9"/>
    </any>
  </replace-with>

IMO, I think the nocache.js bootstrap script should have a mechanism to alert the user when there is no permutation for a specific browser. Maybe calling the gwt:onLoadErrorFn (see my comment at gwt issue#8135)

Sign up to request clarification or add additional context in comments.

2 Comments

Agree, it would be nice to get a callback from bootstrap script if no permuation was found. But in your solution above I still have to create permutations for all browsers, right?
Yes that is the problem. But one advantage is that you can show to the user a customized screen informing about the issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.