Saturday, October 10, 2015

Clear ADF Form after Commit a new record


In this example I'll show you how to clear ADF form after Commite a new Row


Let us start :

1- Create new VO from DepartmentEO  (DepartmentInsertOnly)
2- Open Tuning  tab from VO and check option No Rows (Inserting new Rows Only)



3- Create new VO from DepartmentEO to preview Data (DepartmentReadOnly)
4- Shuttle these two VOs as instances in Data Model 


5- Create new JSF page (InsertDepartmentpage)
6- Drag DepartmentInsertOnly from Data control panel into page as adf Form .
7- Drag Commit and CreateInsert Operations into page .
8- Drag DepartmentReadOnly  from Data control as read only adf table.
9- Double click on commit button to create custom method inside a managed bean , to commit new row and refresh view object after clear cache.





10- Add this code under this method


 public String commitAction() {     
   BindingContainer bindings = getBindings();
        OperationBinding operationBinding = bindings.getOperationBinding("Commit");
        Object result = operationBinding.execute();
        refreshVO("DepartmentsViewInsertOnly"); // Iterator Name
        
         if (!operationBinding.getErrors().isEmpty()) {
            return null;
        }
        
        return null;
    }

   // refresh View Object
    private void refreshVO(String vo){

            DCIteratorBinding irt = (DCIteratorBinding)getBindings().get(vo);
            ViewObjectImpl view = (ViewObjectImpl)irt.getViewObject();
            view.clearCache();
            view.executeQuery();

        }



- Now please run and test

       As you see ADF Form still blank with now data , becuase it is for insert new row only






      Enter you data and press commit button



      ADF will clear VO Cache and re-execute . 




No comments:

O racle  SQL WITH Clause         subquery factoring     or         Materializing   subqueries                                 (Sim...