Thursday, November 4, 2010

How to access Application Module from UI Layer

Application module is in the business service layer and is separated from user interface layer. The first thing to do is to get the bridge to business service from user interface - BindingContext.

BindingContext bctx = BindingContext.getCurrentInstance();

And then;

BindingContainer bc = bctx.getCurrentBindingEntry();

The method is get ApplicationModule is through "DCDataControl" by method: getApplicationModule (for any non-bc4j application, this method returns null).

To get DCDataControl, you could use DBBindingContainer by "getDataControl". But look at the API instructions, "*** For internal framework use only *** Returns the DCApplciation object to which this form binding belongs." So this method is for Oracle internal developers only.

The workaround on this is to use EL to reference the ApplicationModule bound to the UI page and use EL resolving to cast to application module type.

To find the Data Control Name:


    public static DCDataControl findDataControl(String dataCtlName)
    {
       return BindingContext.getCurrent().findDataControl(dataCtlName);
    }

To get the application Module data control by name:


  public static ApplicationModule getApplicationModuleForDataControl(String name)
  {
    return (ApplicationModule)JSFUtils.resolveExpression("#{data." +
                                                          name +
                                                          ".dataProvider}");
  }

JSFUtils.resolveExpression method can be found from Frank and Steve's ADF JSFUtils class.

1 comment:

Daniel Valdivia said...

but what is the findDataControl for if the getApplicationModule function returns you the application module?