To Display a page or servlet output in a popup window
Suppose that the page name is view.jsp
import org.apache.myfaces.trinidad.render.ExtendedRenderKitService;
import org.apache.myfaces.trinidad.util.Service;
FacesContext context = FacesContext.getCurrentInstance();
HttpServletRequest request = (HttpServletRequest) context.getExternalContext().getRequest();
String targetURL = request.getRequestURL().toString();
targetURL = targetURL.substring(0, targetURL.lastIndexOf("/") + 1) + "view.jsp";
System.out.println(targetURL);
ExtendedRenderKitService service = Service.getRenderKitService(context, ExtendedRenderKitService.class);
String script = "window.open('" + targetURL + "', '', 'location=0, status=0, resizable=1, scrollbars=0');";
service.addScript(FacesContext.getCurrentInstance(), script);
import org.apache.myfaces.trinidad.render.ExtendedRenderKitService;
import org.apache.myfaces.trinidad.util.Service;
FacesContext context = FacesContext.getCurrentInstance();
HttpServletRequest request = (HttpServletRequest) context.getExternalContext().getRequest();
String targetURL = request.getRequestURL().toString();
targetURL = targetURL.substring(0, targetURL.lastIndexOf("/") + 1) + "view.jsp";
System.out.println(targetURL);
ExtendedRenderKitService service = Service.getRenderKitService(context, ExtendedRenderKitService.class);
String script = "window.open('" + targetURL + "', '', 'location=0, status=0, resizable=1, scrollbars=0');";
service.addScript(FacesContext.getCurrentInstance(), script);
Comments