Thursday, December 13, 2012

How to obtain AM instance & Bindings from a backing/managed bean?

Some times we may need to access the Application Module instance from the backing bean. E.g. when we want to invoke some custom method in AM from a event listener in the backing bean.

DCBindingContainer bindings = (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();

TestAMImpl am = (TestAMImpl)bindings.getDataControl().getDataProvider();

With the am reference we can invoke any of its public method.

The BindingContext here corresponds to DataBindings.cpx file in the ADF application. That file contains mappings of all the pages and their page definitions within the application.

The  DCBindingContainer here corresponds to the pageDefintion (nothing but bindings)of the current page/pagefragment. So we can read not only the AM instance being referred through the datacontrol but also the iterators, the actions, etc from it.

No comments:

Post a Comment