Tuesday, March 19, 2013

JSF : How to Add Javascript from Bean in JSF ?

JSF : How to Add Javascript from Bean in JSF ?












    public String callJS() {
               FacesContext facesContext = FacesContext.getCurrentInstance();

        org.apache.myfaces.trinidad.render.ExtendedRenderKitService service =
            org.apache.myfaces.trinidad.util.Service.getRenderKitService(facesContext, ExtendedRenderKitService.class);

        service.addScript(facesContext, "alert('Hi');window.close();");
        return null;
    }