A detailed look at Binding Model Parameter Options (NDOption)
ADF binding layer has been always a pleasant surprise for me. I have not seen such a 'rich glue layer' in any other frameworks. While wiring the business service methods with UI Components , developers can opt for specific 'Parameter Options'. These options would decide how the binding container should assign the value to the parameter(s) at runtime. This article discusses the significance of the Binding Model Parameters Options and their proper usage. Please note that Binding Model Parameters Option is termed as NDOption in your page definition file.
Where can I see Binding Model Parameter Options?
To answer this question let us start building an application and see where we really use this in real life.
Follow the steps given below.
1. Here, I assume that you already have one Fusion Web Application in place, with Application Module defined. Please refer Fusion Developer's Guide for Oracle Application Development Framework in case you are not familiar with building Fusion Web Application.
2. Now generate java files for your Application Module.
3. Go to the generated ApplicationModule implemenetation file(<YourApplicationModuleName>Impl.java) and define a method which takes atleast one parameter as argument. Let it be, public void doSomething(String someArg){}
4. Generate the Java Cleint Interface for this, so that this method can be wired with a web page (jspx, jsp or jsff) using DataControl.
5. Now, select the ViewController project, then create a jspx file.
OK, so far so good. Now let us try defining the binding for this Application Module method.
Please refer 11 Using Oracle ADF Model in a Fusion Web Application if you are not familiar with data binding.
6. Select the binding tab for the jspx, click on '+', this would display Insert Item dialog. Now select methodAction clik OK. 'Create Action Binding' dialog appears as shown below.
Lower half of the dialog displays a Parameter (Binding Model Parameter) table, where the details of method parameters can be found. All columns in the table are self explanatory, except the last two. Value column can have either binding expression or literal values such as constants. In the last column 'Option', you can find a drop down with options as Final, Mandatory and Optional.
Curious to know the significance of the Binding Model Parameter Options? Let me try explaining this with an example
Final, Mandatory, Otional
Below scenarios describe possible parameter options and their influence on the parameter value being passed at runtime.
Final
Final implies that value for parameter can be retrieved by evaluating the specified binding expression, no need to look anywhere else. This indicates that parameter value cannot be set explicitly set by a caller.
The binding model parameter is configured as shown below in the picture
Assume that backing bean code invokes this method action in response to some user action. The method invocation part may look like as below
What would be the Input to the method at runtime with the above configuration?
In this case final value being passed for parameter would be the 'evaluated value' of this Expression Language (EL) #{SomeBean.someParam}.
Mandatory
Binding Model Parameter value has to be set by the caller, always. EL or literal value specified in the binding definition will never be considered if the parameter option specified is Mandatory.
The binding model parameter is configured as shown below in the picture
The method invocation part from the backing bean may look like as below
What would be the Input to the method at runtime with the above configuration?
Value of parameter would be 'someValue' supplied by caller, won't consider value defined in your binding definition
Optional
Binding definition's value is used only if the caller does not specifically set the parameter. Parameter value defined in your BindingDefinition (pagedef file) is with least precedence here, just opposite to Final.
The binding model parameter is configured as shown below in the picture
The method invokation part from the backing bean may look like as below
What would be the Input to the method at runtime with the above configuration?
Value of parameter would be 'someValue' supplied by caller.
Where can I see Binding Model Parameter Options?
To answer this question let us start building an application and see where we really use this in real life.
Follow the steps given below.
1. Here, I assume that you already have one Fusion Web Application in place, with Application Module defined. Please refer Fusion Developer's Guide for Oracle Application Development Framework in case you are not familiar with building Fusion Web Application.
2. Now generate java files for your Application Module.
3. Go to the generated ApplicationModule implemenetation file(<YourApplicationModuleName>Impl.java) and define a method which takes atleast one parameter as argument. Let it be, public void doSomething(String someArg){}
4. Generate the Java Cleint Interface for this, so that this method can be wired with a web page (jspx, jsp or jsff) using DataControl.
5. Now, select the ViewController project, then create a jspx file.
OK, so far so good. Now let us try defining the binding for this Application Module method.
Please refer 11 Using Oracle ADF Model in a Fusion Web Application if you are not familiar with data binding.
6. Select the binding tab for the jspx, click on '+', this would display Insert Item dialog. Now select methodAction clik OK. 'Create Action Binding' dialog appears as shown below.
Lower half of the dialog displays a Parameter (Binding Model Parameter) table, where the details of method parameters can be found. All columns in the table are self explanatory, except the last two. Value column can have either binding expression or literal values such as constants. In the last column 'Option', you can find a drop down with options as Final, Mandatory and Optional.
Curious to know the significance of the Binding Model Parameter Options? Let me try explaining this with an example
Final, Mandatory, Otional
Below scenarios describe possible parameter options and their influence on the parameter value being passed at runtime.
Final
Final implies that value for parameter can be retrieved by evaluating the specified binding expression, no need to look anywhere else. This indicates that parameter value cannot be set explicitly set by a caller.
The binding model parameter is configured as shown below in the picture
Assume that backing bean code invokes this method action in response to some user action. The method invocation part may look like as below
DCBindingContainer bc = (DCBindingContainer)bcx.getCurrentBindingsEntry();
OperationBinding opb = (OperationBinding)bc.getOperationBinding("someMethod");
// someMethod is with signature public void someMethod(String someArg)
opb.getParamsMap().put("someArg", "someValue");
opb.invoke();
What would be the Input to the method at runtime with the above configuration?
In this case final value being passed for parameter would be the 'evaluated value' of this Expression Language (EL) #{SomeBean.someParam}.
Mandatory
Binding Model Parameter value has to be set by the caller, always. EL or literal value specified in the binding definition will never be considered if the parameter option specified is Mandatory.
The binding model parameter is configured as shown below in the picture
The method invocation part from the backing bean may look like as below
DCBindingContainer bc = (DCBindingContainer)bcx.getCurrentBindingsEntry();
OperationBinding opb = (OperationBinding)bc.getOperationBinding("someMethod");
// someMethod is with signature public void someMethod(String someArg)
opb.getParamsMap().put("someArg", "someValue");
opb.invoke();
What would be the Input to the method at runtime with the above configuration?
Value of parameter would be 'someValue' supplied by caller, won't consider value defined in your binding definition
Optional
Binding definition's value is used only if the caller does not specifically set the parameter. Parameter value defined in your BindingDefinition (pagedef file) is with least precedence here, just opposite to Final.
The binding model parameter is configured as shown below in the picture
The method invokation part from the backing bean may look like as below
DCBindingContainer bc = (DCBindingContainer)bcx.getCurrentBindingsEntry();
OperationBinding opb = (OperationBinding)bc.getOperationBinding("someMethod");
// someMethod is with signature public void someMethod(String someArg)
opb.getParamsMap().put("someArg", "someValue");
opb.invoke();
What would be the Input to the method at runtime with the above configuration?
Value of parameter would be 'someValue' supplied by caller.
Hi,
ReplyDeletethank you so much for clarifying this option. I am using ADF for quite some time now and was always unsure about that option.
The default is hopefully "Optional", isn't it?
Andreas.
Hi Andreas
ReplyDeleteThanks for the comment.
Yes, the default is Optional.
Hi, thanks for this posting. It clarifies what those options mean.
ReplyDeleteOn a similar topic, and one that I'm trying to understand, is the difference between how parameters are passed to an operation vs. a method call activity (in a task flow).
I've been reading the Nimphius/Munsinger book and on page 113, there is a discussion about method call activities and how you can pass parameters to methods through the controller layer.
I think what it is saying is that an ADF Method Binding (a custom method on an AppModuleImpl, for example) can be called with params from the method call activity, but an operation binding (one of the built-in operations on an ADF BC object) can't be. Rather, in the case of the operation binding, parameters can be set on the binding metadata as you describe here.
Is that your take on this too?
Hi Todd
ReplyDeleteI havn't got chance to go through the book you are refering here, very much interested to see though.
However, to answer your question, I guess you should be able to create method activity using both the options- 'built in' or 'custom' methods. If method call activity takes parameter, you may get an 'Edit Action' window where values can be keyed in.
In case I misunderstood your question, please detail the same with an example
Todd,
ReplyDeleteCheck this page for using the built-in operations of backend objects as a method action binding.
http://www.oracle.com/technology/products/jdev/tips/fnimphius/createWithParameters/createWithParameters.html
In case you are dragging and dropping a built-in operation of backend object, then a pagedef is created with that name. In the pagedef you can add the named data as mentioned in the link above.
Hi,
ReplyDeleteCan you summarize the differences between method bindings and action bindings? Besides one is built-in and another is custom, why you need two kind of bindings?
Thanks,
-Stanley
Stanley
ReplyDeleteAs you mentioned, methodAction is mapped to custom method whereas action is built in to the DataControl/iterator/accessorIterator's specific method with predefined signature. At run time, evaluation of 'action' will always looks at DC/iterator to see the mapped action method. Apart from this, I'm not able to see any other significant difference between these two. Will update this thread for sure, if I come across anything in future.
Hi Jobinesh,
ReplyDeleteThanks for this fantastic article , I recently started with ADF 11g and by mistake in a taskflow, selected an AM method paramater as mandatory(I thought mandatory means if this parameter is passed as null, framework will throw an error), and mapped the AM method parameter to a variable in pageFlowScope.
I struggled for 2 hours , but could not understand y null value is passing to the AM method, until I saw ur blog entry, which clearly says in case of "mandatory", the EL expression is ignored.
Cheers~
Mukul
Hi Jobinesh, This is such a fantastic article. Once I read this article, I had a question - what is the difference between methodAction and action bindings. I see that the same question has been asked and you have answered that as well. That is in sync with the explanation that I had on my mind so far.
ReplyDeleteThat said, since you have mentioned, were you able to find out any other significant difference between these two?