Requirement-In ADF application we often come across requirement where we want to call JavaScript method or java Method on page load or after load o of .JSPX or .JSF page.
Solution:
First step is to add clientListener onBodyLoad method which gets called
on load of page as below
<af:clientListener
method="onBodyLoad"
type="load"></af:clientListener>
Java script method as below
Above you can notice I am firing the click event by finding component “main” which is panel group layout as below.
Since there is af:clientListener added inside af:panelGroupLayout onMainClick method get called.
public void onTemplateLoad(ClientEvent
clientEvent) {
// Add event code here...
String osType = (String)
clientEvent.getParameters().get("osType");
System.out.println("Os
type-"+osType);
ADFContext.getCurrent().getSessionScope().put("OSTYPE",
osType);
AdfFacesContext.getCurrentInstance().addPartialTarget(panelGroupBinding);
}
When you run
page it shows first the alert as below
No comments:
Post a Comment