X

The blog for hints & tips about Oracle Application Development Framework and Mobile Application Framework

  • ADFv
    November 25, 2011

How to detect browser type and version from ADF Faces

Frank Nimphius
Master Principal Product Manager

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("==================");


Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.