get object of ApplicationModule in managed bean in ADF | Techartifact

Requirment- Need an object of Application module in managed bean

Sometime we required to get an object of ApplicationModule in managed bean.May be we want to play with some VO object which we can get from
ApplicationModuleImpl Object only.

There are two ways.

First way-

        FacesContext context = FacesContext.getCurrentInstance();
        BindingContext bindingContext = BindingContext.getCurrent();
        DCDataControl dc  = bindingContext.findDataControl("AppModuleAMDataControl"); // Name of application module in datacontrolBinding.cpx
        AppModuleAMImpl appM = (AppModuleAMImpl)dc.getDataProvider();
     

Above AppModuleAMDataControl is name of application module in datacontrolBinding.cpx,open datacontrol and check the ID in tag. See below for reference.

 <BC4JDataControl id="AppModuleAMDataControl" Package="oper.model.module"
                     FactoryClass="oracle.adf.model.bc4j.DataControlFactoryImpl" SupportsTransactions="true"
                     SupportsFindMode="true" SupportsRangesize="true" SupportsResetState="true"
                     SupportsSortCollection="true" Configuration="AppModuleAMLocalWeb" syncMode="Immediate"
                     xmlns="http://xmlns.oracle.com/adfm/datacontrol"/>

Now you got the application module you can get the object of any ViewObjectImpl.

Second Way-

You can get the object of applicationModuleImpl by writing this line-

AppModuleAMImpl am = (AppModuleAMImpl)resolvElDC(AppModuleAMDataControl)

resolvElDC method is described below


private 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);
    }

Happy coding with Techartifact . 🙂

Vinay

I am an Oracle ACE in Oracle ADF/Webcenter. Sr Java Consultant-working on Java/J2EE/Oracle ADF/Webcenter Portal/ content and Hibernate for several years. I'm an active member of the OTN JDeveloper/Webcenter forum. Passionate about learning new technologies. I am here to share my knowledge. Give your views and suggestion on [email protected] .

More Posts - Website

Follow Me:
TwitterLinkedInGoogle PlusYouTube