How to check whether particular View Object’s data is modified or not?

How to check whether particular View Object’s data is modified or not?

In my previous post I had explained, “how to check whether table row is modified or not with the help of isDirty() method”. This method work on transaction level, in other word if your application module contain more than one view object and user modify any one view object ,isDirty() method will return true.
Therefore in this post I will explain how to check, specific view object is modified or not.Following are steps-.

  1. Create following method in ViewImpl class of your view object.

    public boolean isdirty()
    boolean flag=false;
    DepartmentsViewRowImpl crow =(DepartmentsViewRowImpl)this.getCurrentRow();
    EntityImpl entity= crow.getDepartments();
    byte state=entity.getEntityState();
    return flag;

As you can see we can get entity state using EntityImpl instant, if status is not unmodified that means some modification was done on view object. And above method will return “true” if particular view object is dirty.

  1. Expose isdirty() method as client Interface.
  2. Add method to page binding as MethodAction

4. Then in managed bean execute isdirty method using operation binding as follows

public void checkDirty(ActionEvent actionEvent) {
BindingContext bindingctx=BindingContext.getCurrent();
BindingContainer binding=bindingctx.getCurrentBindingsEntry();
DCBindingContainer bindingsImpl = (DCBindingContainer) binding;
DCIteratorBinding dciter = bindingsImpl.findIteratorBinding("DepartmentsView1Iterator");
ViewObject vo=dciter.getViewObject();
long cnt=vo.getEstimatedRowCount();
Row row=null;
for(int i=0;i<cnt;i++)
OperationBinding isdirty =binding.getOperationBinding("isdirty");
List li= isdirty.getErrors();
boolean flag=(Boolean) isdirty.getResult();
this.showMsg("Row is modified.");

About Manish Pandey

Manish is a Project Leader at Jagran Prakashan Ltd, focused on Jdeveloper Fusion Web Application(specifically Oracle ADF). He shares his knowledge through the OTN Jdev/ADF Forum. He has written more than 50 article about Oracle ADF and Jdeveloper.

Leave a Reply