Thursday, September 26, 2013

ADF 11G : Check if VO is Dirty

ADF 11G : Check if VO is Dirty

Approach 1: Click 

Approach 2: 
    public String save() {
        System.out.println(isDirty()); //Call the method to check if VO is Dirty
        BindingContainer bindings = getBindings();
        OperationBinding operationBinding = bindings.getOperationBinding("Commit");
        Object result = operationBinding.execute();
        if (!operationBinding.getErrors().isEmpty()) {
            return null;
        }
        return null;
    }


    public boolean isDirty(){
    boolean dirty=false;
    BindingContext bindingCtx = BindingContext.getCurrent();
    DataControlFrame dataCtrlFrame = bindingCtx.findDataControlFrame(bindingCtx.getCurrentDataControlFrame());
    Collection dataCol = dataCtrlFrame.datacontrols();
    for (DCDataControl dcDaCtrl : dataCol) {
    if (!dcDaCtrl.getName().equals("NeelmaniAMDataControl1") && !dcDaCtrl.getName().equals("NeelmaniAMDataControl2"))
        dirty = (dcDaCtrl.isTransactionDirty()==true) ? true :false;
    }
    return dirty;
    }