Wicket: Get Browser Information

1.9k Views Asked by At

How do I get information about the browser in a Java/Wicket/Maven Project?

Greetings

3

There are 3 best solutions below

2
On BEST ANSWER

You can capture the browser information using the following code

getApplication().getRequestCycleSettings().setGatherExtendedBrowserInfo(true);

WebClientInfo w = (WebClientInfo)getWebRequestCycle().getClientInfo(); ClientProperties cp = w.getProperties();

// do something with the data cp.getNavigatorAppName();
cp.getNavigatorAppCodeName();
cp.getNavigatorAppVersion();
cp.getBrowserVersionMajor();
cp.getBrowserVersionMinor();

Exerpt taken from WICKET Documentation

EDIT Updated from comments.
The above code is for Wicket 1.4.x. For newer versions of Wicket replace getWebRequestCycle() with getRequestCycle()

0
On

Wicket 6.x also provides org.apache.wicket.ajax.AjaxClientInfoBehavior. A demo of it can be seen at: http://www.wicket-library.com/wicket-examples-6.0.x/ajaxhellobrowser/

0
On

If there is no getClientInfo() on getRequestCycle() (like there wasn't for me either), you could try the answer to this question:

Checking User Agent in Wicket

WebSession.get().getClientInfo();

It worked for me.