Skip to main content

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


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.

Comments

ak said…
Hi,

thank 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.
Jobinesh said…
Hi Andreas
Thanks for the comment.
Yes, the default is Optional.
Anonymous said…
ITSolusenz departments manage all components web application, software development including, Application Development Company, software development company india, Software Development Services.
Todd said…
Hi, thanks for this posting. It clarifies what those options mean.

On 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?
Jobinesh said…
Hi Todd
I 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
Vinod said…
Todd,

Check 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.
Stanley Guan said…
Hi,

Can 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
Jobinesh said…
Stanley
As 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.
Mukul said…
Hi Jobinesh,
Thanks 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
Kavin Kumar said…
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.

That said, since you have mentioned, were you able to find out any other significant difference between these two?

Popular posts from this blog

How to set Bind Variable Values at runtime ?

In this post I'm sharing a couple of approaches for programmatically setting bind variables values at run time. This post is an attempt to explain 'When to use what ?'[ In case if you are familiar with 'Bind Variables' in ADF BC, please refer Section 5.10, Working with Bind Variables in Fusion Developer's Guide ]

1. Set the Bind Variable value using RowSet::setNamedWhereClauseParam(...)

You can use use the setNamedWhereClauseParam(...) method on the ViewObject interface (which extends oracle.jbo.RowSet) to set the value for bind variables. Please note this sets the value on default RowSet. In other words, this doesn't have any effect on the secondary RowSets that you/system generates.
ViewObject vo = am.findViewObject("EmployeesView1"); vo.setNamedWhereClauseParam("bindVarDeptId", new Number(10)); vo.executeQuery();
2. Set the Bind Variable value using ViewObject's VariableValueManager::setVariableValue(...)

VariableValueManager Ma…

Happy New Year 2018 !

We can't go back and change the beginning, but we always can start where we are and change the ending. Believe in yourself and you will be unstoppable!

Wishing you and your family a very happy new year 2018 !!!