how to detect browser type in itmill application??

hello,

I am trying to use itmill toolkit and my application is now showing well in firefox all versions, but ugly in IE 6 and 7.

Now I want to show message to users who doesnt use FF, that…my site can be viewed best in FF.

Help please.

tookit fan

Ugly?

The Window has function getTerminal:
http://toolkit.itmill.com/demo/doc/api/com/itmill/toolkit/ui/Window.html

You have to cast it before use:

WebBrowser browser = (WebBrowser) myApplication.getMainWindow().getTerminal();

From there you can find the function you are looking for:

http://toolkit.itmill.com/demo/doc/api/com/itmill/toolkit/terminal/gwt/server/WebBrowser.html#getBrowserApplication()

Point of correction, Ugly as in my application…am learning…so not a pro in css and styling and cross browsing stuff.

But the toolkit, Is a top notch…totaly cool.

and thanks for replay.

I am registering in a minute.

Hi all,
Was just wondering whether vaadin has a way of doing browser detection and redirecting to a view that displays the content for a mobile browser using say TouchKit, such that a web browser and an xhtml browser can view the page but with some modifications made to the markup so thats its viewable from a mobile device, say an Iphone.Is such functionality available ?

You can detect browser from the WebBrowser object, see
an on-line example
.

Notice that you can only do redirection from a Vaadin application once it has started, which may be too late for redirection for lighter pages such as for mobile browsers. You might instead want to do the redirection with JavaScript from a loader page that first checks the browser and then loads the client-side engine of Vaadin. See the Book on
embedding Vaadin applications
(the section is slightly outdated).

I am trying to determine the browser that my application is running in, but the examples here do not seem to work. Are there more current examples?

Most of the examples in this thread are 4-5 years old, back when Vaadin was still called It Mill Toolkit.
For an example for the current version have a look at the sampler here
http://demo.vaadin.com/sampler/#foundation/browser-information
and click on the Source icon in the top right.

Just noticed that they didn’t include the code for actually getting the Browser name + version… so here is my short coded version to explain it a bit:

//get the Webbrowser object
WebBrowser browser = UI.getCurrent().getPage().getWebBrowser();

//returns the user agent string. not that descriptive in some cases
browser.getBrowserApplication(); 

//get the Version of the Browser
browser.getBrowserMajorVersion();
browser.getBrowserMinorVersion();

//Detecting the browser this way often brings better results then using the user agent
String browserText = "";
if(browser.isChrome())
    browserText = "Google Chrome";
else if (browser.isFirefox())    
    browserText = "Mozilla Firefox";
else if (browser.isIE())    
    browserText = "Internet Explorer";
....

Thank you for the help.

I encouter this issue also, fine in Chrome, ugly in IE8, have you figure out this? css or sass need some specific setting?