Tuesday, February 21, 2012

ADF - Programmatically intercede before a Commit ( or other DB operation)

// Below is an action button method which does an operation before a commit.
//-----------------------------------------------------------------------------------------
   public String saveAll_action() {

    BindingContainer bindings = getBindings();

      // some operation that needs to run before the commit
      // Reset is RowImpl Java code done in a Transient Attribute 
        OperationBinding operation = bindings.getOperationBinding("Reset");

        operation.execute();
 
       // Do the Commit!
        operation = bindings.getOperationBinding("Commit");

        Object result = operation.execute();

        return null;
    }

//------------------------------------------------------------------

    public BindingContainer getBindings() {
        return BindingContext.getCurrent().getCurrentBindingsEntry();
    }