Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GWT Browser distinction in Client

I try to find the current Browser for an specific Hack in GWT.

like: (View-class)

if( GWT.getBrowserName().contains("IE") ) {
    // DOM.setElementPropertyBoolean( ...  Hack
}else {
    // normal stuff
}
like image 237
oliholz Avatar asked Oct 10 '22 06:10

oliholz


1 Answers

I found a ugly solution:

Creating a class for each bowser and mapping it in the gwt.xml

public class BrowserIE6 extends Browser {
    public boolean isIE6() { return true; }
    public boolean isIE7() { return false; }
    ...
}

<replace-with class="com.project.client.style.BrowserIE6">
    <when-type-is class="com.project.client.style.Browser" />
    <when-property-is name="user.agent" value="ie6" />
</replace-with>

<replace-with class="com.project.client.style.BrowserIE7">
    <when-type-is class="com.project.client.style.Browser" />
    <when-property-is name="user.agent" value="ie7" />
</replace-with>

...

But is there an easy way to do this?

like image 144
oliholz Avatar answered Oct 17 '22 22:10

oliholz