X

The blog for hints & tips about Oracle Application Development Framework and Mobile Application Framework

  • ADFm
    November 23, 2010

#{data} - to use or not to use ?

Frank Nimphius
Master Principal Product Manager

The #{data} expression allows developers to access the ADF BindingContext object
that represents the content of the DataBindings.cpx file at runtime. In Oracle
JDeveloper 11g, the BindingContext
class has a static method getCurrent
that also allows developers to access the BindingContext object so there is no need to
use the #{data} expression anymore, at least not when access is required from
Java in a managed bean.

In Oracle JDeveloper 10.1.3, there exists no static getCurrent method and #{data} and
#{bindings} are the two options available to access the BindingContext at runtime. However,
the binding context is not a good starting point for developers to access page
bindings or invoke methods on a View Object or Application Module if you want
the UI to refresh in response to an operation.  For any business service access you want to perform
in the context of working with ADF, the recommendation - and best practice is -
to use the binding container #{bindings}. In JDeveloper 11g, to access the
current active binding container from Java, you use the following code:

BindingContext
bctx = BindingContext.getCurrent();

DCBindingContainer bindings =

                  (DCBindingContainer)
bctx.getCurrentBindingsEntry()

In summary: In JDeveloper 10.1.3, use #{data} only to
access DataControl data providers - like ADF Business Component Application
Modules - for method invocations that are not meant to cause any change in the
UI. For all other access to business services methods and attributes, use the
#{bindings} expression or the Java code shown above.

An interesting observation of mine while monitoring the OTN
forum is that many developers who use the BindingContext to invoke operations on
ApplicationModules and ViewObjects also tend to cast the access to "Impl"
classes, which also is not considered best practices in the context of ADF. Instead
casting should be done for the AM or VO interface class.

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.