BalusC shows here that in order to do the navigation we can use
<h:column>
<h:link value="Edit" outcome="/products/edit">
<f:param name="id" value="#{product.id}" />
</h:link>
</h:column>
which is fine, but how to do the same if I don't want an additional column as a navigation - I want to do it onclicking the row.
What I've tried. The list.xhtml:
<p:dataTable id="datalist" ....>
<p:ajax event="rowSelect" listener="#{listController.onRowSelect}" />
Which goes to bean:
public void onRowSelect(SelectEvent event) throws IOException {
FacesContext.getCurrentInstance().getExternalContext().redirect("edit.xhtml?faces-redirect=true&id=" + listItem.getId());
}
and this in fact navigates me to new page after clicking a row in a datatable, the url is:
http://localhost/app/faces/edit.xhtml?faces-redirect=true&id=1686
so id of a row on datatable is appended. What happens is of course the NULL:
javax.el.PropertyNotFoundException: /edit.xhtml @18,84 value="#{listController.item.id}": Target Unreachable, 'null' returned null
The 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>
Obviously I am doing sth wrong.