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