Oracle ADF – accessing BindingContext and DataControl in Servlets

October 29th, 2010 | Posted by in Oracle ADF | 3 Comments

This post shows how to access the Binding Context and the Data Control from a Servlet.

Sometimes we need Servlets for handling some POST HTTP requests directly, and a bookmark-able page cannot be used instead because the posted parameters are not available when its handling method is called. In this case it is more appropriate for the servlet’s request handling methods (doPost(), doGet()) to access the application model from the Data Control from the Binding Context instead of accessing the application model directly using the Configuration.createRootApplicationModule() method and later the Configuration.releaseRootApplicationModule() method.

In order to access the binding context the servlet must be filtered by the adfBidings filter already available in the WEB-INF/web.xml configuration file like in the following picture:

The code used in the Servlet’s methods looks like:

...
   // get the binding context
   BindingContext bc =  (BindingContext)ADFContext.getCurrent().
         getSessionScope().get("data");
   // get the data control based on its name
   DCDataControl dc = bc.findDataControl("<your data control name>");
   // get the data provider
   // if the data provider is an application module
   //     then cast it to ApplicationModule
   // else cast to your service's class/interface
   // here it is an ApplicationModule
   ApplicationModule am = (ApplicationModule)dc.getDataProvider();
...

Tags: , , , , ,

3 Responses to “Oracle ADF – accessing BindingContext and DataControl in Servlets”

  1. Amr Ismail says:

    thanx,it’s very nice topic

  2. Fazel says:

    i have a problem in bc.findDataControl(“”) method
    this method return null
    why findDatControl doesnt work?

    • Juan says:

      Hi Fazel.

      Did you find the solution? I don´t know why sometimes y get the instance and other times no…

      thanks

Leave a Reply