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

后端 未结 7 1534
伪装坚强ぢ
伪装坚强ぢ 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:08

    If you are using remotecommand then you can do like this

    
    

    And my javascript:

    
    

    ServerSide action method:

    public String onPageLoadForNewTab(){
        HttpServletRequest req = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest(); String url = req.getRequestURL().toString();
            url=(url.substring(0, url.length() - req.getRequestURI().length()) + req.getContextPath() + "/"); url=url+navigationpagename+".jsf"; RequestContext.getCurrentInstance().
            execute("window.open('"+url+"','_blank')");** 
        return ""; }
    

提交回复
热议问题