The blog for hints & tips about Oracle Application Development Framework and Mobile Application Framework

  • ADFm
    February 28, 2012

Best practice invoking business services methods from JSF beans

Frank Nimphius
Master Principal Product Manager

Recently there was an increasing interest on OTN in best practices for invoking methods exposed on the ADF Business Components client interface. There exist two options to access methods exposed on ADF Business Components application modules and view objects from a managed bean through ADF.

  • Call findDataControl(String) on the BindingContext and access the application module to invoke a method exposed on the Application Module or View Object client interface.

  • Create a method binding on a PageDef level that binds to a method exposed on the Application Module or View Object client interface

Speaking of best practices, it’s the second option  to use a method binding on the PageDef file that I recommend for the following reasons

  • ADF is about abstracting the view and controller layer from the business service implementation details. A method binding instead exposes an ID (the name o the binding) to the JSF developer, which they use to access the binding from a managed bean using the OperationBinding API. Signature or name changes of a method exposed on the business service thus don't require a change in the managed bean(s) referencing it. All changes would be applied in metadata.

  • ADF provides the OperationBinding class as an abstraction for business services methods. Configuring business service method access on the PageDef file using method bindings exposes a single and consistent API to application developers.

  • Programmatic access to a method exposed on the business service require more lines of code than accessing the same method through the binding layer

  • Direct business service access violates the recommendation to always work through the ADF binding layer and not to bypass it.

To access a method binding from a managed bean, use the following code

  BindingContext bctx = BindingContext.getCurrent();
BindingContainer bindings = bctx.getCurrentBindingsEntry();
OperationBinding operationBinding =
//invoke method
if (!operationBinding.getErrors().isEmpty()) {
     //check errors
     List errors = operationBinding.getErrors();
Object methodReturnValue = operationBinding.getResult();

Join the discussion

Comments ( 2 )
  • Mostafa Maged Wednesday, February 14, 2018
    Hi Frank,
    i wonder how the second option is the best practice.
    this technique has an issue if the method parameters change in any way (order, type, number), in this case only run time exception will be thrown and you will never be able to discover this at development time.
    what do you think?
    in my opinion, first option is the best to avoid such problem
  • Frank Nimphius Thursday, February 15, 2018
    Not sure which of the four arguments did not convince you. If you look at the code


    then whenever the signature changes, you only need to change the two lines speaking to the map.
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.