且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何从链接调用JSF bean操作?

更新时间:2023-02-19 11:08:58

带有 target ="_ blank" 属性的< h:commandLink/> 怎么样:

<h:commandLink action="#{bean.action}" target="_blank" value="Open document"/>

在您的bean中:

public void action() {
   try {
       FacesContext.getCurrentInstance().getExternalContext()
            .redirect("page2.xhtml");
   } catch (IOException ex) {
       // do something here
   }
}

用目标网址替换 page2.xhtml .