Friday, April 9, 2010

Bit #8 - Executing an operation binding programmatically from a backing bean

To access an OperationBinding in a backing bean, call getOperationBinding() on the DCBindingContainer - the data control binding container - and specify the operation binding identifier that you assigned to the operation during the declarative binding process. Once you have the OperationBinding call its execute() method to execute it. If you need to pass any arguments to the operation, call getParamsMap() to get the operation parameters map and put() on the map the specific argument. Call getResult() after the call to execute() to retrieve the result of the execution. Here is an example.


Example:

        // in the context of a backing bean

         OperationBinding operation = bindings.getOperationBinding("operation_name");

         operation.getParamsMap().put("parameter_name", parameterValue);

         operation.execute();

         if (operation.getResult() != null) {
                  Boolean result = (Boolean) operation.getResult(); // cast to the expected result type
        }


Context:

Backing Bean


11 comments:

  1. Whats a point in this, if you can get same info from Developer Guide?

    ReplyDelete
  2. Hi there. Can you point me to where in the Developer Guide there is a single paragraph regarding this topic? Anyway, the topics listed here have a personal documentation usage. If they can be of help to anybody else this is added bonus as far as I concern.

    ReplyDelete
  3. Thanks for this Nick.

    It may well be in the developer's guide but I found this before I was able to find it in the developer's guide.

    ReplyDelete
  4. Thanks very much. This is a very useful tip. I have bookmarked your blog for reference!

    ReplyDelete
  5. Hi,

    OperationBinding is available in two packages.. bu this bit never said to use ftom which package..

    Anyways Thanks for the help :)

    ReplyDelete
  6. It should be OperationBinding interface from the the oracle.binding package.

    ReplyDelete
  7. Very helpful tip. Thank you.

    ReplyDelete
  8. Do you know if there's a difference between what's returned by the execute method and what's returned by getResult? Normally they seem to return the same, but once in a while it seem like only getResult works. A bit confused ;)

    ReplyDelete
  9. Excellent post!! very helpful :)

    ReplyDelete
  10. HI,

    Is there a way to retrieve the name of Iterator related to that OperationBinding programmatically ?

    Thanks

    ReplyDelete

Related Posts Plugin for WordPress, Blogger...