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.
- Did I choose the correct approach for the browser's difference?
- 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
Post a Comment