【发布时间】:2016-07-25 06:01:06
【问题描述】:
我有一个p:datatable,在选择时我想导航到不同的页面。我可以通过<p:ajax event="rowSelect" listener="#{users.onUserSelect(userInformation.id)}"/> 做到这一点
public void onUserSelect(long id) {
System.out.println("user selected" + id);
try {
FacesContext.getCurrentInstance().getExternalContext().redirect("users/user.jsf?id=" + id);
FacesContext.getCurrentInstance().responseComplete();
} catch (IOException e) {
e.printStackTrace();
}
}
在结果页面中,我想使用该 ID 从 db 获取一些数据并显示它。那么,首先这种方法可以吗?如果是这样,我应该如何/在哪里使用请求参数在结果页面中获取该 ID?或者可能有其他一些最佳实践来实现我想要的?
【问题讨论】:
-
这是您要找的吗? stackoverflow.com/q/8459903
-
@BalusC 谢谢,这正是我想要的
标签: jsf primefaces navigation