On the datable I click on commandLink and that link navigates to destination page. I need to get the parameter ('id' in this case) on that destination page.
It works fine with link but not with commandLink. I get the parameter as null. And I must solve this with commandLink.
source page
<p:dataTable value="#{orderBean.orders}" var="order" id="orderDTable" rowKey="#{order.id}">
<p:column id="editButtonsId" >
<p:commandLink value="Edit" action="orderInsert" >
<f:param name="id" value="#{order.id}"/>
</p:commandLink>
<!-- works fine with this link -->
<p:link value="Edit" outcome="orderInsert" >
<f:param name="id" value="#{order.id}" />
</p:link>
</p:column>
</p:dataTable>
destination page
<ui:composition template="templates/layout.xhtml"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:components="http://java.sun.com/jsf/composite/components"
xmlns:fn="http://java.sun.com/jsp/jstl/functions"
xmlns:p="http://primefaces.org/ui">
<f:metadata>
<f:viewParam name="id" value="#{orderInsertBean.id}" />
<f:event listener="#{orderInsertBean.init}" type="preRenderView" />
</f:metadata>
</ui:composition>
@Component("orderInsertBean")
@ManagedBean
@RequestScoped
public class OrderInsertBean implements Serializable {
private String id;
public void init() {
// the parameter id is null here when the page is navigated by the commandLink
FacesMessage msg = new FacesMessage(id, null);
FacesContext.getCurrentInstance().addMessage(null, msg);
}
public String getId() { return id; }
public void setId(String id) { this.id = id; }
}