Client Browser detection in Vaadin -


Depending on the user agent, I want to set different topics in my Vaidini app. In particular, I want to differentiate between at least the mobile device (iPhone, Android, ...) and desktop web browser.

Waden's API reveals two interesting sections:

BrowserInfo works perfectly for my needs, but fails at instancing via its fetch - method:

  SEVERE: Javax.servlet.ServletException: ... done by: java.lang.UnisfiedLinkError: com.vaadin.terminal.gwt.client.BrowserInfo.getBrowserString () Ljava / lang / string;  

There was no way to access WebBrowser from within my app.

  1. Did I choose the correct approach for the browser's difference?
  2. Why does BrowserInfo fail?

As @Quinnnellisis pointed out, you are separate from client / server-side components Should be aware of being.

To obtain a user agent string on the server-side, the following code snippet works:

  ApplicationContext reference = this.getContext (); If (WebApplicationContext for reference example) {string useragent = ((WebApplicationContext) this.getContext ()). . GetBrowser () getBrowserApplication (); }  

Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -