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


5 comments:

  1. Thanks alot. It realy helped me

    ReplyDelete
  2. Hi there, I have a case where I am calling a operation A and it works fine, then I call operation B and it also works fine, but then I try calling A again and it returns null.
    Can you help try pointing me in some direction, I am new to ADF and I've been having lots of trouble with things that fail inconsistently or with no apparent reason.

    ReplyDelete
    Replies
    1. BTW I'm working with JDeveloper 11g Release 2

      Delete
    2. Can you please share a bit more on the issue?
      like code details etc?

      Delete