从托管 bean 打开新的 window

Open new window from managed bean

我使用此代码在 JavaScript 中打开一个弹出窗口:

function showMyPage() { 
 window.open('./showMyPage.xhtml','mywindow', 'resizable=no,toolbar=no,scrollbars=yes,height=450,width=530,top=145,left=235');
 return true;

}

但是,我想从托管 Bean 执行此操作,这可能吗?

例如,我有以下条件,来自 p:dataTable:

<p:column >
                             <h:commandLink action="#{tableBean.list(ind)}" >  
                                <i class="cus-find"></i> 
                            </h:commandLink>  
                        </p:column>

我想调用一个托管 Bean 并通过它打开一个弹出窗口,可以吗?

public String list(InfoListVO ind){
        FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put("InfoListVO ", ind);

//here I want to return my page in a popud directly from a Managed Bean
    return "myPage";
}

提前致谢!

它不在托管 Bean 中,但我认为它可以达到您的目的。

   <p:commandLink action="#{tableBean.list(ind)}" oncomplete="showMyPage()">  
        <i class="cus-find"></i> 
   </p:commandLink> 

你可以在 action 调用的函数中做你想做的事情,javascript 之后执行,所以你可以向它发送 args。