Published

Tue 20 September 2011

←Home

ADF 11g using same view object in different taskflows

You might face a scenario where you have to reuse the same view object in different task flows. But the issue you will encounter if you are not using separate View Object instances is that changes made to view objects in one task flow will reflect in the view object in the other task flow. If you are not using separate view object instances you can either call clearCache on the view object when the region renders or call ApplicationModuleImpl clearVOCaches method.  The former method will clear cache for both transient and entity based view object instances and the latter can be used to clear the cache on all the entity based view objects. If you are using dynamic regions you can use use the either of the following fragments for clearing the cache which solves your re-usability scenario as clicking on the command link will clear the view object cache's and hence you will get consistent results.

1
2
3
4
DCBindingContainer container=(DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
TestAMImpl amImpl=(TestAMImpl) container.findDataControl("TestAMDataControl").getDataProvider();
//clear the all entity caches and do it recursively.
amImpl.clearVOCaches(null, true);

or

1
2
3
4
DCBindingContainer container=(DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
   TestAMImpl amImpl=(TestAMImpl) container.findDataControl("TestAMDataControl").getDataProvider();
   String [] viewObjectName=amImpl.getViewObjectNames();
   for (int i=0;i<viewobjectname.length;i++){ amimpl.findviewobject(viewobjectname[i]).clearcache();}

Note: This is only a workaround and not a best practice, though if you want to reuse the view object in many places this will suffice.

Go Top
comments powered by Disqus