Wednesday, December 23, 2015

Fixing the Issue where getBindings() returns Null

Problem Statement:

Suppose we have a jspx page having a bounded task flow as region.


The taskflow starts with method activity as shown in the figure


If the method tries to access the some method binding using the getBinding() method, where get binding is defined as:

    public BindingContainer getBindings() {
        return BindingContext.getCurrent().getCurrentBindingsEntry();
    }

some binding method accessed as:
        OperationBinding op =
            (OperationBinding)getBindings().get("someMethodInAppModImpl");
        Object result = op.execute();

in this case, the BindingContext.getCurrent() would return the BindingContext but when trying to access getCurrentBindingsEntry(), this method would return null and as result the
 OperationBinding op =
            (OperationBinding)getBindings().get("someMethodInAppModImpl");

would throw null pointer exception

Solution:

Since the page starts with method having no pagedef difination the CurrentBindingsEntry always return null.

Make Sure you create binding for the default method as:


also the binding defined for the method shall have the method binding for the someMethodInAppModImpl you wish to access during execution.

Once page defination is defined, you can see the small little sign at the right bottom of the methodas


Please reach out in case of any further issues


Tuesday, July 14, 2015

Externalized Resource Bundle for ADF Application

Often we have to use resource bundle for our project which is a part of the project war.
Issue with this approach is when the war is specific to environment, for eg, if you need to provide different url for dev,prod,st and qa in your application, you need to create environment specific artifact and the same artifact can not be implemented across all the environment.

Solution to this approach is to externalize the resource bundle. The resource bundle would be the part of environment and the application would point to the location of the resource bundle instead of resource bundle being a part of the Application.

steps to implement the same:

1. create the property file with content(content is specific to this demo):

button_value=this text comes from property file
butoon_message=this message will be displayed on button click which comes from property file

and save it as TestMessage.properties in the local folder for eg:

C:\test\TestMessage.properties

while deploying the application in weblogic the path can be:
/web/TestMessage.properties

2. Mention the path's name in weblogic's start parameter.
I would define a system variable as TESTPROP_PATH and assign it the location as C:\test\TestMessage.properties for the example

To achieve this i have made an entry in
setDomainEnv file present in <UserFolder>\AppData\Roaming\JDeveloper\system11.1.1.7.40.64.93\DefaultDomain\bin

as:
set EXTRA_JAVA_PROPERTIES=-Djps.app.credential.overwrite.allowed=true -DTESTPROP_PATH=/test/TestMessage.properties %EXTRA_JAVA_PROPERTIES%

once set, this variable can be accessed from application as:

System.getProperty("AIMSPROP_PATH")

***please check with Environment team how to perform the step 2 for the environment


3. Now in your application you need to create a java class which would extend ListResourceBundle and fetch all the entries from the file as:

4. Make an entry for this class as <resource-bundle> in faces-config.xml

5. To access the resource bundle in jspx or jsff and entry has to be made in for f:loadBundle and can be used as:
6. Similarly, to use the resource bundle in java class can be used as:

the link to the demo application can be found here

steps 1 & 2 has to be performed individually to run the downloaded application


Please put in your comments in case of any doubts or suggestion to improvise this entry

Wednesday, February 4, 2015

Integrate your jdeveloper with FindBug Utility

FindBugs is an useful open source program which looks for bugs in Java code.It uses static analysis to identify hundreds of different potential types of errors in Java programs.Reports from find bug comes very handy when trying to sanitize your application code before moving to a production like environment. I took the help from link to use it as tool within my local jdeveloper. I will explain the same as step by step integration.

1. Download find bug zip from mentioned link, unzip it and place it in your local
2. Write the following xml file to use as ant build file  later

<?xml version="1.0" encoding="windows-1252" ?>
<project xmlns="antlib:org.apache.tools.ant" default="init">
<taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask"/>
  <target name="init">
    <tstamp/>
  </target>
  <property name="findbugs.home" value="C:/HPP/findbugs-3.0.0/findbugs-3.0.0" />
  <target name="findbugs">
    <findbugs home="${findbugs.home}" output="text">    
      <sourcePath path="${basedir}/src/java" />
      <class location="${basedir}/classes" />
    </findbugs>
  </target>

</project>

for this example saving the file as findbug.xml 

3. Now lets start with creating an external tool in jdeveloper. Go to Jdeveloper -- > Tool -- >External tool --> New
4. Select Apache Ant as Tool Type

5. Select the findbug.xml saved in step to as Ant buildfile

6. select findbugs as available target 

7. As mentioned in the build file, it expects a parameter named basedir which has to be added as project directory in this case


8 go with default options for options and process step


9. Make sure you point to findbug-ant.jar(available as<findbug_home/lib/findbug-ant.jar>) as class path entry


10. I am selecting it as Tool Menu in this case and making the availability as always


11. Select your project (either model or view, one at a time) and select FindBug from one of the option in Tool menu to generate the report


Please comment in case of any issues

Edit #1 : Findbugs 3.0 will work only with JDK 1.7. Choose the same in step 8