Monday, May 10, 2010

Action Bindings and Method Bindings in Oracle ADF 11g

PageDef.xml is the page definition XML file. It associates web page UI components with data, or data controls. Oracle JDeveloper creates this file each time you design a new web page using the Data Controls Panel or Structure window. These XML files contain the meta data used to create the bindings that populate the data in the web page’s UI components. For every web page that refers to an ADF binding, there must be a corresponding page definition file with binding definitions.

In the overview editor for any page definition’s Bindings and Executables tab, click the Add icon in the Bindings section. From the Insert Item dialog, you're allowed to choose either action or methodAction binding object to create as shown below:
The description for the action item is "Binding for Action." So, it is named action binding. The description for the methodAction item is "Method binding for the Control." It is also known as method binding. In this article, we'll examine what're the differences and similarities of these two binding objects.

Acronyms

  1. ADFm: ADF Model layer
  2. ADFc: ADF Controller
  3. ADFv: ADF View layer
  4. EL: Expression Language

Action Binding

Action binding object can be used to bind command components, such as buttons or links, to built-in data control operations (such as Commit or Rollback) or to built-in collection-level operations (such as Create, Delete, Next, Previous, or ExecuteWithParams).

Action binding is defined in the page definition using the following attributes:




































Attributes
Attribute
Description
Action

Fully qualified package name. Identifies the class for which the data control is created. In the case of the EJB session facade, this is the session bean.

BindingClass

This is for backward compatibility to indicate which class implements the runtime for this binding definition. This is used by earlier versions of
JDeveloper.

DataControl

Name of the DataControl usage in the bindingContext (.cpx) which this iteratorBinding or actionBinding is associated with.

Execute

Used by default when you drop an operation from the Data Controls Panel in the automatically configured ActionListener property. It results in executing the action binding's operation at runtime.

InstanceName

Specifies the instance name for the action.

IterBinding

Specifies the iteratorBinding instance in this bindingContainer to which this binding is associated.

Outcome

Use if you want to use the result of a method action binding (once converted to a String) as a JSF navigation outcome name.


For example, ExecuteWithParams (i.e., a built-in collection-level operation) is defined in a page definition file as:
<bindings>
<action IterBinding="TestTrendIterator" id="ExecuteWithParams"
RequiresUpdateModel="true" Action="executeWithParams">
<NamedData NDName="TSBegin" NDType="java.sql.Date"
NDValue="${bindings.ExecuteWithParams_TSBegin}"/>
<NamedData NDName="TSEnd" NDType="java.sql.Date"
NDValue="${bindings.ExecuteWithParams_TSEnd}"/>
</action>
</bindings>

Note that ExecuteWithParams on our view object (not shown here) takes two parameters:
  1. TSBegin
  2. TSEnd
These two parameters are defined to be optional (i.e., NDOption="optional") by default. This means that if you didn't provide new values programmatically at runtime, their values will be taken from meta data (i.e., ${bindings.ExecuteWithParams_TSXxx}) as provided in the action binding. See this article, for the descriptions of binding model parameter options (i.e., NDOption).

Method Binding

Method bindings are similar to action bindings. But, they are used to bind to methods defined in an ADF BC application, view object, or view row client interfaces.

Method binding is defined in the page definition using the following attributes:

























































Attributes
Attribute
Description
Action

Fully qualified package name. Identifies the class for which the data control is created. In the case of the EJB session facade, this is the session bean.

BindingClass

This is for backward compatibility to indicate which class implements the runtime for this binding definition. This is used by earlier versions of
JDeveloper.

ClassName

This is the class to which the method being invoked belongs.

DataControl

Name of the DataControl usage in the bindingContext (.cpx) which this methodAction is associated with.

DefClass

Used internally by ADF.

id

Unique identifier. May be referenced by any ADF action binding.

InstanceName

A dot-separated EL path to a Java object instance on which the associated method is to be invoked.

IsLocalObjectReference

Set to true if the instanceName contains an EL path relative to this bindingContainer.

IsViewObjectMethod

Set to true if the instanceName contains an instance path relative to the associated data control's application module.

MethodNameIndicates the name of the operation on the given instance or class that needs to be invoked for this methodActionBinding.
RequiresUpdateModelWhether this action requires that the model be updated
before the action is to be invoked.
ReturnNameThe EL path of the result returned by the associated method.

For example, myCustomMethod defined in an ADF BC application is defined to be:
<bindings>
<methodAction id="myCustomMethod"
InstanceName="SelTestPortalAMDataControl.dataProvider"
DataControl="SelTestPortalAMDataControl"
RequiresUpdateModel="true" Action="invokeMethod"
MethodName="refreshTotalComments" IsViewObjectMethod="false"/>
</bindings>

How to Access Action/Method Bindings in an Fusion Web Application

When working with Fusion web applications using the ADF Model layer for data binding, JDeveloper configures a servlet filter in your user interface project called the ADFBindingFilter. It orchestrates the automatic acquisition and release of an appropriate application module instance based on declarative binding metadata, and ensures that the service is available to be looked up as a data control using a known action binding or iterator binding, specified by any page definition file in the user interface project.

No matter what a binding object is (i.e., action binding or method binding), they are retrieved and invoked in the same way when accessed from Fusion Web Applications:
  • Retrieve them from the DCBindingContainer (i.e., the runtime object that embodies the meta data defined in the page definition) by naming an action binding or method binding.
Method bindings such as myCustomMethod, or action bindings such as Next, Previous or ExectureWithParams, exposed on a view object are instance of JUCtrlActionBinding that can be cast to the OperationBinding interface when accessed from Java:
BindingContext context = BindingContext.getCurrent();
DCBindingContainer bindingContainer = (DCBindingContainer) context.getCurrentBindingsEntry();
OperationBinding oper = bindingContainer.getOperationBinding("openSubTask");
...
oper.execute();

FacesCtrlAttrsBinding


Internally JUCtrlActionBinding is an FacesCtrlActionBinding, which is the class that connects ADFv[1] command components to ADFc[2]/ADFm[3]. Like other ADFv binding classes, this is a sub-class of an ADFm class. And like other ADFm bindings there is an entry in the pageDef.xml file for this binding (i.e., action or method binding). If the method has either parameters or a return, there will be additional attribute bindings corresponding to the parameter and return values. These attribute bindings will correspond to a FacesCtrlAttrsBinding class and be in the pageDef.xml file.

The ADFv command components that use this class are:
  • commandLink
  • commandButton,
  • commandMenuItem
  • commandToobarButton
  • commandImageLink.
and they are linked to this class via EL[4] on the component, typically the actionListener attribute.

Learn More
  1. Implement Contextual Events
  2. Oracle ADF Model In Depth
  3. Oracle ADF BindingContext and BindingContainer
  4. Open Source sample applications for Oracle Fusion Middleware technology
  5. How-To Access ADF application module with ADF faces (see Steve Muench's comments)

32 comments:

劉KarolR_Sundquis said...

路過--你好嗎..很棒的BLOG..............................................

DennisPick麗珠 said...

當身處逆境時,要能忍一時之氣,吃一時之苦,並及早確立自己的目標,總有一天,你會嘗到那甘美的果實。.............................................

韋于倫成 said...

成功招引朋友,挫敗可考驗朋友........................................

文辰 said...

Undertake no more than you can perform. ............................................................

ElisaCe慈佐lestin0708 said...

樂觀進取,勇往直前,持之以恒,是克服困難的妙方。 ............................................................

batesda said...

人有兩眼一舌,是為了觀察倍於說話的緣故。............................................................

慈佐 said...

能猜得出女人真實年齡的男人也許耳聰目明,但肯定毫無大腦。哈哈!..................................................................

黃佳伸 said...

要持續更新下去喲!!祝你心情愉快.................................................................

陳隆 said...

Poverty is stranger to industry.....................................................................

常映 said...

知識可以傳授,智慧卻不行。每個人必須成為他自己。.................................................................

KrisMcmillen07星美 said...

成熟,就是有能力適應生活中的模糊。.................................................................

吳婷婷 said...

人生是故事的創造與遺忘。............................................................

吳婷婷 said...

thx rfor you sharing~~learn it by heart..................................................................

有年 said...

A bird in hand is worth two in the bush. ..................................................................

俊杰 said...

很喜歡看看別人的生活故事,謝謝您的分享哦~~............................................................

佑英佑英 said...

永遠不要躊躇伸出你的手。也永遠不要躊躇接受別人伸出的手。.................................................................

芸茂芸茂 said...

人要學習健忘,把所有不如意忘掉,才會快樂。..................................................

宜欣宜欣 said...

forgive others but not yourself...................................................

王美妹 said...

GOOD IDEA~thanks............................................................

bur蔡ge佳ssal郁berto said...

做好事,不需要給人知道,雖然只是一件微不足道的事,但我相信,這會帶給我快樂。..................................................

佩劉俊宇劉璇 said...

聰明人之所以不會成功,是因為他們缺乏了堅忍的毅力。.......................................................

陳陳昀人良喬 said...

快樂,是享受工作過程的結果..................................................

文王廷 said...

逛BLOG逛上癮了,一天不來會不習慣了耶!!............................................................

邱思吳佳順翰 said...

人不能像動物一樣活著,而應該追求知識和美德............................................................

偉曹琬 said...

生存乃是不斷地在內心與靈魂交戰;寫作是坐著審判自己。. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

胡曹哲維佳玲 said...

一個人的價值,應該看他貢獻了什麼,而不是他取得了什麼......................................... ........................

佳張張張張燕張張張張張 said...

從來愛都不知它的深度,非得等到別離的時候.....................................................................

麗王王珠 said...

No pains, no gains.......................................................................

怡靜怡靜怡靜怡雯 said...

要在憂患恥辱的環境裡,創造我們自力更生的新生活。..................................................

怡靜怡靜怡靜怡雯 said...

很棒的分享~祝福你............................................................

Blogger said...

If you want your ex-girlfriend or ex-boyfriend to come crawling back to you on their knees (even if they're dating somebody else now) you gotta watch this video
right away...

(VIDEO) Have your ex CRAWLING back to you...?

Blogger said...

QUANTUM BINARY SIGNALS

Get professional trading signals delivered to your cell phone every day.

Start following our signals right now and gain up to 270% per day.