Skip to main content

Passing dynamic parameters to the Java Script method in a Fusion Web Application

In this post, I'm sharing some tips to pass dynamic parameters values to a Java Script method. The idea is inspired by an example from Frank Nimphius. Solution is to use <af:clientAttribute> to associate the parameter and value with the component which triggers the event. When using af:clientAttribute the parameter can be accessed on the client through AdfUIComponent.getProperty("ParameterName"). The rich client framework takes care of marshaling the attribute value to the client. Also, the below code uses 'closure' in the JavaScript method to ease the coding.

 <af:resource type="javascript">  
  function someMethod(arg) {  
    return function (evt) {  
       var finalArg = evt.getSource().getProperty('SomeDynamicArg') + ' : ' + arg;  
       alert(finalArg);  
       evt.cancel();  
    }  
  }  
 </af:resource>  
 <af:commandButton text="SomeActionBtn" id="cb1">  
  <af:clientListener type="click"  
            method="someMethod('SomeStaticArg')"/>  
  <af:clientAttribute name="SomeDynamicArg"  
            value="#{bindings.DepartmentName.inputValue}"/>  
 </af:commandButton>  

Comments

Anonymous said…
How do we access the client attributes on server side ?

Popular posts from this blog

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 !!!

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…