// 1. Create a value binding
// 2. Access the binding container
// 3. Find the data control using #data binding.
// 4. Access the data control's application module data provider
ValueBinding vb=fctx.getApplication().createValueBinding();
BindingContext bc = (BindingContext)vb.getValue(fctx);
DCDataControl dc = bc.findDataControl("#{data}");
ApplicationModule am =(ApplicationModule)dc.getDataProvider();
Method 2 : (Typically used in a managed bean)
Configuration.createRootApplicationModule(MyAMDefn,AMConfig);
Configuration.releaseRootApplicationModule(
Method 3 : (Typically used in a backing bean based on page iterators)
// 1. Access the binding container
// 2. Find a named iterator binding
// 3. Get the data control from the iterator binding
// 4. Access the data control's application module data provider
DCBindingContainer bc = (DCBindingContainer)getBindings();
DCIteratorBinding iter = bc.findIteratorBinding("MyVOIterator");
DCDataControl dc = iter.getDataControl();
ApplicationModule am = (ApplicationModule)dc.getDataProvider();
Method 4 : (Typically used in a backing bean based on action binding)
// 1. Access the binding container
// 3. Get the data control from the iterator binding (or method binding)
// 4. Access the data control's application module data provider
DCBindingContainer bc = (DCBindingContainer)getBindings();
JUCtrlActionBinding action = (JUCtrlActionBinding)bc.findCtrlBinding("MyActionMethod");
DCDataControl dc = action.getDataControl();
ApplicationModule am = (ApplicationModule)dc.getDataProvider();
Method 5 :
// 1. Access the binding context
// 2. Find data control by name
// 3. Access the data control's application module data provider
FacesContext fctx = FacesContext.getCurrentInstance();
BindingContext bindingContext = BindingContext.getCurrent();
DCDataControl dc = bindingContext.findDataControl("MyModuleDataControl");
MyAMImpl am = (MyAMImpl)dc.getDataProvider();
Method 6 :
//Using Value Expression.
FacesContext fc = FacesContext.getCurrentInstance();
Application app = fc.getApplication();
ExpressionFactory elFactory = app.getExpressionFactory();
ELContext elContext = fc.getELContext();
ValueExpression valueExp =elFactory.createValueExpression(elContext, "#{data.MyDataControl.dataProvider}",Object.class);
MyAMImpl am = (AmImpl)valueExp.getValue(elContext);