Feeds:
Posts
Comments

Posts Tagged ‘bean’

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:

  1. Create a bean method by double click the action button, or manually create a class with the required method:beanto 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";
    
  2. Declare the bean in the action listener property of the command button:approve-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

Read Full Post »

Let’s say you want to call a a taskFlow activity, for example, a “back” activity, but declarative within your java code:

Navigation

Use the below code in a bean in order to call a task flow navigation within your ADF application:

 

import javax.faces.application.NavigationHandler;
import javax.faces.context.FacesContext;

....

NavigationHandler backHnd =
FacesContext.getCurrentInstance().getApplication().getNavigationHandler();
backHnd.handleNavigation(FacesContext.getCurrentInstance(), null,"back");

 

Good Luck!

Read Full Post »