Gate: get information about the browser

How do I get browser information in a Java / Wicket / Maven project?

Hello

+3


source to share


3 answers


You can grab 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 ();



Excerpt from WICKET Documentation

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

+3


source


If getRequestCycle()

not getClientInfo()

(for example, it wasn't for me either), you can try to answer this question:

User agent validation in Wicket



WebSession.get().getClientInfo();

      

This worked for me.

+2


source


Wicket 6.x also provides org.apache.wicket.ajax.AjaxClientInfoBehavior

. A demo of this can be seen at: http://www.wicket-library.com/wicket-examples-6.0.x/ajaxhellobrowser/

+1


source







All Articles