How to detect browser type and version from ADF Faces
Posted
by Frank Nimphius
on Oracle Blogs
See other posts from Oracle Blogs
or by Frank Nimphius
Published on Fri, 25 Nov 2011 07:36:49 -0600
Indexed on
2011/11/25
17:57 UTC
Read the original article
Hit count: 297
/Oracle/ADFv
Sometimes ADF applications need to know about the user browser type and version. For this, assuming you need this information in Java, you can use the Trinidad RequestContext object. You could also use the AdfFacesContext object for the same, but since the ADF Faces Agent class is marked as deprecated, using the equivalent Trinidad classes is the better choice.
The source code below prints the user browser information to the Oracle JDeveloper message window
import
org.apache.myfaces.trinidad.context.Agent;
import org.apache.myfaces.trinidad.context.RequestContext;
…
RequestContext requestCtx = RequestContext.getCurrentInstance();
Agent agent = requestCtx.getAgent();
String version = agent.getAgentVersion();
String browser = agent.getAgentName();
String platform = agent.getPlatformName();
String platformVersion = agent.getPlatformVersion();
System.out.println("==================");
System.out.println("Your browser information: ");
System.out.println("Browser: "+browser);
System.out.println("Browser Version : "+version);
System.out.println("Browser Platform: "+platform);
System.out.println("Browser Platform Version:
"+platformVersion);
System.out.println("==================");
© Oracle Blogs or respective owner