我想使用h:commandLink
发布到我的支持bean方法。之后我想从bean方法打开网站中的另一个页面。怎么做?
答案 0 :(得分:2)
使用h:commandLink绑定bean actionListener并从操作重定向,如下所示:
<强> XHTML:强>
<h:commandLink value="Redirect Link"
actionListener="#{yourBean.redirectLinkAction}">
<f:param name="param1" value="param1Value" />
</h:commandLink>
<强>豆:强>
public void showAddressBook(ActionEvent ae) {
try {
ExternalContext externalContext =
FacesContext.getCurrentInstance().getExternalContext();
Map<String, String> params = externalContext.getRequestParameterMap();
String param1 = (String) params.get("param1");
/* Do necessary action with parameter(s) here */
String redirectURL = "Your URL";
externalContext.redirect(redirectURL);
} catch (Exception e) {
// log error here
}
}