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

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.

Comments:

Post a Comment:
Comments are closed for this entry.
About

The Oracle JDeveloper forum ranks in the Top 5 of the most active forums on the Oracle Technology Network (OTN).



The OTN Harvest blog is a summary of selected topics posted on the OTN Oracle JDeveloper forum.



It is an effort to turn knowledge exchange into an interesting read for developers who enjoy little nuggets of wisdom





Frank Nimphius

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today