The following example explains , how to call the server side methods (Backing Bean / Managed Bean methods) from Java Script.
Sample requirement is :
When we call the JavaScript for validation / Java Script values after that we want to pass the control to service side methods with arguments or with out.
here we can define the code .
In UI (jsff/ jspx pages)
define the client listener and server listener tag for any component it supports in ADF 11g like:
the logic works like , first it will call the JavaScript method , once it completes all the code it will navigate to server listener.
JavaScript Method defintion:
function sampleJSMethod(evt) {
AdfCustomEvent.queue(evt.getSource(), "sampleServerSideMethod",
{argumentName: argumentValueFromJS},true);
evt.cancel();
}
ServerSide Method Defintion:
public void sampleMethod(ClientEvent clientEvent) {
Object value = (Object)clientEvent.getParameters().get("argumentName");
}
This facility we can use in real time , whenever we have to pass some values to Java Script functions , after depending on that return values if we need to run Service Side Method.
Sample requirement is :
When we call the JavaScript for validation / Java Script values after that we want to pass the control to service side methods with arguments or with out.
here we can define the code .
In UI (jsff/ jspx pages)
define the client listener and server listener tag for any component it supports in ADF 11g like:
the logic works like , first it will call the JavaScript method , once it completes all the code it will navigate to server listener.
JavaScript Method defintion:
function sampleJSMethod(evt) {
AdfCustomEvent.queue(evt.getSource(), "sampleServerSideMethod",
{argumentName: argumentValueFromJS},true);
evt.cancel();
}
ServerSide Method Defintion:
public void sampleMethod(ClientEvent clientEvent) {
Object value = (Object)clientEvent.getParameters().get("argumentName");
}
This facility we can use in real time , whenever we have to pass some values to Java Script functions , after depending on that return values if we need to run Service Side Method.
Hi Srini,
ReplyDeleteI was looking for the same and found your blog over google.
Very useful post.
I am going to use the same technique find the mobile device agents.
Keep blogging.
Thanks,
Arun