Monday, June 13, 2011

Accessing ADF ViewObject's property in Groovy

Use this to access any field in ViewObject


Wednesday, March 2, 2011

Getting context path in serlvets

if (servletContext.getMajorVersion() == 2
&& servletContext.getMinorVersion() <= 4) {
return servletContext.getServletContextName();
} else {
return servletContext.getContextPath();

Getting objects created in current java thread

There are two ways to resolve object dependency in java e.g. objects created in one method will be needed in other method in the same thread request. One way of resolving this dependency is that you pass newly created objects as parameter to method but this approach has drawback e.g. if you have created an object in one method, then that method is calling another which is calling another method and that method requires object created in first method then using first approach you will have to pass object in the parameter of second method and then second method will pass it to third method as parameter. As second method does not require it but we will have to pass it to resolve dependency of third method.
Second and most efficient approach is using ThreadLocal class. You can set object in first method to this class by this:
Now in third method you can get this object using this:
Usually this approach is used with objects which are current request's context related e.g. FacesContext object is the key object in JSF and is required to use it anywhere in the request. so JSF creates instance of FacesContext in each request and set it to ThreadLocal. and then later on returns it from ThreadLocal.

Tuesday, March 1, 2011

Getting java web classloader

J2EE 1.3 (and later) containers are required to make the web application class loader visible through the context class loader of the current thread. You can access it like this:
ClassLoader cl = Thread.currentThread().getContextClassLoader();

Monday, February 14, 2011

Changing Context Root of application during deployment in Weblogic

Configuring Applications for Production Deployment: "You cannot use a deployment plan to change the context-root in an application.xml file. However, if an application is deployed as a library, you can either change the context-root through an weblogic-application.xml file or use the deployment plan to change the context-root in an weblogic-application.xml file."

Wednesday, February 9, 2011

Using request Parameters in ADF Taskflow router

In order to use request parameters or parameters which are appended as query string in URL invoked ADF Taskflow, you will have to do two steps:
  • Define a new parameter in "Input Parameter Definition" of taskflow and assign to it value of request parameter by


    Actually ADF fetches request parameters and places in pageFlowScope when you call a Taskflow from URL
  • Now use this newly defined parameter anywhere you want like in a condition of router by this

    #{pageFlowScope.parameterName == 'some conditional value'}
If you want to access this value in model layer e.g. after condition you want to execute a method, you can pass it as parameter or you can also access it programmatically by this: