Java Action to detect browser wont compile on v7

0
I have a java action that detects the users browser that works fine on v5, however won't compile on v7. Can anyone help, either with a fix or an alternative for detecting the browser please? java action and compile error below. Many Thanks, Simon.   JAVA ACTION // This file was generated by Mendix Modeler. // // WARNING: Only the following code will be retained when actions are regenerated: // - the import list // - the code between BEGIN USER CODE and END USER CODE // - the code between BEGIN EXTRA CODE and END EXTRA CODE // Other code you write will be lost the next time you deploy the project. // Special characters, e.g., é, ö, à, etc. are supported in comments. package administration.actions; import net.sf.uadetector.ReadableUserAgent; import net.sf.uadetector.UserAgentStringParser; import net.sf.uadetector.service.UADetectorServiceFactory; import com.mendix.systemwideinterfaces.core.IContext; import com.mendix.webui.CustomJavaAction; /**  * Returns information about the Browser  */ public class GetBrowserInfo_Test extends CustomJavaAction<java.lang.String> {     public GetBrowserInfo_Test(IContext context)     {         super(context);     }     @Override     public java.lang.String executeAction() throws Exception     {         // BEGIN USER CODE         UserAgentStringParser parser = UADetectorServiceFactory.getResourceModuleParser();         ReadableUserAgent agent = parser.parse(request.getHeader("User-Agent"));         return agent.getName();         // END USER CODE     }     /**      * Returns a string representation of this action      */     @Override     public java.lang.String toString()     {         return "GetBrowserInfo_Test";     }     // BEGIN EXTRA CODE     // END EXTRA CODE }   COMPILE ERROR     [javac] Compiling 43 source files to C:\Scratch\Mendix\GetBrowserInfo_Test-main\deployment\run\bin     [javac] C:\Scratch\Mendix\GetBrowserInfo_Test-main\javasource\administration\actions\GetBrowserInfo_Test.java:34: error: cannot find symbol     [javac]         String userAgent = currentRequest.getHeader("User-Agent");     [javac]                            ^     [javac]   symbol:   variable currentRequest     [javac]   location: class GetBrowserInfo_Test     [javac] Note: Some input files use or override a deprecated API.     [javac] Note: Recompile with -Xlint:deprecation for details.     [javac] 1 error
asked
2 answers
0

I think that this GetBrowserInfo_Test java action is only a test and you can exclude it from you project.

 

Edit 1:

The browser is only known when a client connects to the server. Is there anything added in the index.html? Where do you use the browser info? Do you redirect to certain pages?

answered
0

As Chris said:

You don't recieve the http request, from which you can determine the browser, in a normal mendix java action. To be able to collect this information you need a request handler

 

It really depends on what point you need to know which browser the user is using. 

answered