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>
How do we access the client attributes on server side ?
ReplyDeleteThanks for sharing this great article! That is very interesting I love reading and I am always searching for informative articles like this.
ReplyDeleteStruts Training in Chennai
Struts Training Chennai
Best Struts Training in Chennai
WordPress course
Wordpress Training institute in Chennai
Struts Training in Adyar
struts Training in Anna Nagar