p:commandLink fails to open page in new window/tab

后端 未结 7 1443
伪装坚强ぢ
伪装坚强ぢ 2020-12-17 09:42

I\'m trying to create a link to open a new page in a different window/tab and display some msg from backing bean but fail to do it, wonder know why?

here is my xhtml

相关标签:
7条回答
  • 2020-12-17 10:17

    Try this in your controller code, it worked for me perfectly.

    HttpServletResponse res = (HttpServletResponse) FacesContext.getCurrentInstance().getExternalContext().getResponse();
                HttpServletRequest req = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
                String uri = req.getRequestURI();
                res.getWriter().println("<script>window.open('" + myUrl + "','_blank', 'location=yes,height=600,width=800,scrollbars=yes,status=yes'); window.parent.location.href= '"+uri+"';</script>");
                FacesContext.getCurrentInstance().responseComplete();   
    
    0 讨论(0)
提交回复
热议问题