Thursday, December 17, 2015

Rollback before navigation between pages is done

When you want to rollback any transaction before navigate to another page:
1- Create class that extends class called NavigationHandler then
    override method called handleNavigation as follows:


public class CustomNavigationHandler  extends NavigationHandler{
  
    private NavigationHandler navHandler=null;
  
    public CustomNavigationHandler(NavigationHandler navHandler)
    {
        super();
        this.navHandler=navHandler;
      
    }
    public void handleNavigation(FacesContext ctx,String action,String outcome){
        if (outcome !=null){
            ADFUtils.getAppImpl("AppModuleAM").getDBTransaction().rollback();
        }
        navHandler.handleNavigation(ctx,action,outcome);
    }   
}

2- Register the class at the faces-config.xml file as follows:

No comments:

Post a Comment

java - fill distinct objects in ArrayList

If you have a list that contains some objects that it is considered as duplication when two or three fields of these objects are equal. How ...