In ADF framework you can execute Javascript code from Java code using the below method
Import the following classes
You can call previous method from anywhere from your code
For example I will display alert using javascript
Thanks
public static void runJavaScriptCode(String javascriptCode) {
FacesContext facesCtx = FacesContext.getCurrentInstance();
ExtendedRenderKitService service = Service.getRenderKitService(facesCtx, ExtendedRenderKitService.class);
service.addScript(facesCtx, javascriptCode);
}
Import the following classes
import javax.faces.context.FacesContext;
import org.apache.myfaces.trinidad.render.ExtendedRenderKitService;
import org.apache.myfaces.trinidad.util.Service;
You can call previous method from anywhere from your code
For example I will display alert using javascript
runJavaScriptCode("alert(\"My name is Mahmoud\");");
Thanks
No comments:
Post a Comment