lunes, 29 de junio de 2015

Llamada función JS desde managed bean

Para realizar una llamda a una función JS desde un managed bean (por ejemplo, cuando se inicialice el constructor de la clase), hay que proceder de la siguiente manera:

import javax.faces.context.FacesContext;
import org.apache.myfaces.trinidad.render.ExtendedRenderKitService;
import org.apache.myfaces.trinidad.util.Service;

FacesContext context = FacesContext.getCurrentInstance();
ExtendedRenderKitService service = Service.getRenderKitService(context, ExtendedRenderKitService.class);
service.addScript(context, "var popup = AdfPage.PAGE.findComponent('idPopup'); popup.show();");

No hay comentarios:

Publicar un comentario