【发布时间】:2019-04-15 13:34:48
【问题描述】:
BalusC 显示 here 我们可以使用导航来进行导航
<h:column>
<h:link value="Edit" outcome="/products/edit">
<f:param name="id" value="#{product.id}" />
</h:link>
</h:column>
这很好,但是如果我不想要一个额外的列作为导航,如何做同样的事情 - 我想在点击行时这样做。
我尝试过的。 list.xhtml:
<p:dataTable id="datalist" ....>
<p:ajax event="rowSelect" listener="#{listController.onRowSelect}" />
哪个去豆:
public void onRowSelect(SelectEvent event) throws IOException {
FacesContext.getCurrentInstance().getExternalContext().redirect("edit.xhtml?faces-redirect=true&id=" + listItem.getId());
}
这实际上是在单击数据表中的一行后将我导航到新页面,网址是:
http://localhost/app/faces/edit.xhtml?faces-redirect=true&id=1686
附加数据表上一行的id。 发生的当然是NULL:
javax.el.PropertyNotFoundException: /edit.xhtml @18,84 value="#{listController.item.id}": Target Unreachable, 'null' returned null
edit.xhtml:
<ui:composition template="/template.xhtml">
<ui:define name="body">
<h:form id="itemForm">
<f:metadata>
<f:viewParam name="id" value="#{listController.item.id}" />
</f:metadata>
显然我做错了什么。
【问题讨论】:
-
FacesContext.getCurrentInstance().getExternalContext().redirect("edit.xhtml?faces-redirect=true&id=" + listItem.getId()); }是“重复”。faces-redirect=true是多余的。并且该错误意味着很可能未找到(已解决)列表控制器 -
或者
ListController.getItem()返回null?
标签: ajax jsf navigation