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