Reputation: 2189
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?
Upvotes: 1
Views: 105
Reputation: 9741
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)
Upvotes: 3