In this post I will explain, how in a simple way you can use managed bean to perform a binding operation.
In case of using ADF for managing Human Task flows (BPM process), you sometimes want to perform post/pre actions to the native operation.
For example: you want the user to press the approve action, and in the background you want to call a Web service for some validations.
Here is how you do it:
- Create a bean method by double click the action button, or manually create a class with the required method:
to copy:
public String approveAction() { BindingContainer bindings = BindingContext.getCurrent().getCurrentBindingsEntry(); OperationBinding validateNameOP = bindings.getOperationBinding("validateName"); Object resultCommit = validateNameOP.execute(); if (!validateNameOP.getErrors().isEmpty()) { return null; } AttributeBinding status =(AttributeBinding)bindings.get("status"); if (status.getInputValue().toString().equalsIgnoreCase("Y")){ OperationBinding operationBinding = bindings.getOperationBinding("APPROVE"); Object result = operationBinding.execute(); if (!operationBinding.getErrors().isEmpty()) { System.out.println("inside error"); return null; } }else{ return null; } return "refreshTaskFlow";
- Declare the bean in the action listener property of the command button:
That’s it.
Just be sure, that both APPROVE & validateName operations are declared in the binding. Or else you will get nullPointerException.
Good Luck