Requirement: There will be many requirement where we want to get the object of the ApplicationModule in the Managed Bean in Oracle ADF. Thus, in this post I will show you few approaches by which we can get an object of the ApplicationModule
Approach 1: We can get the object of applicationModuleImpl by writing the below line of Java code:
BindingContext bindingContext = BindingContext.getCurrent();
DCDataControl dc = bindingContext.findDataControl("AppModuleDataControl");// Name of application module in datacontrolBinding.cpx
AppModuleImpl appModule = (AppModuleImpl) dc.getDataProvider();Approach 2: We can also get the object of applicationModuleImpl by writing the below line of Java code:
AppModuleImpl am = (AppModuleImpl)resolvElDC("AppModuleDataControl");The Java code for the resolvElDC method is shown below:
public Object resolvElDC(String data) {
FacesContext fc = FacesContext.getCurrentInstance();
Application app = fc.getApplication();
ExpressionFactory elFactory = app.getExpressionFactory();
ELContext elContext = fc.getELContext();
ValueExpression valueExp =
elFactory.createValueExpression(elContext, "#{data." + data + ".dataProvider}", Object.class);
return valueExp.getValue(elContext);
}Hence, the solution to our requirement.
If you like the post please comment, share, and do join me on Facebook. Please subscribe to my YouTube Channel for video tutorials.
Thanks & Regards,
Susanto Paul
484 total views, 1 views today