I am struggling to get commandLink to work in a dataTable, I tried both h:commandLink and p:commandLink but they are both not working, they are either not executable or keep invoking the same page returning an empty table. I also tried request scope and session scope but none of them seems to work. This is my jsf page code
<h:form>
        <p:dataTable value="#{forSaleController.forSalePropList}" var="bk" >
            <p:column>
                <f:facet name="header">
                    <h:outputText value="ID"/>
                </f:facet>         
                <h:outputText value="#{bk.pid}" id="pId" />
            </p:column>
            <p:column>
                <f:facet name="header">
                    <h:outputText value="Type"/>
                </f:facet>
                <h:outputText value="#{bk.propertyType}"/>
            </p:column>
            <p:column>
                <f:facet name="header">
                    <h:outputText value="Location"/>
                </f:facet>
                <h:outputText value="#{bk.location}"/>
            </p:column>
            <p:column>      
                <f:facet name="header">
                    <h:outputText value="Action"/>
                </f:facet>
                <p:commandLink process="@this" value="View Details" action="#{forSaleController.fsDetails(2)}"></p:commandLink>
            </p:column>
        </p:dataTable>
    </h:form>
And this is the code of my bean
 public String fsDetails(Long pId){    
    forsale = forSalePropEJB.searchForSale(pId);       
    returnDetails();       
    return "salePropertyDetails.xhtml";
}
And this is my code from EJB class
public ForSale searchForSale(Long pId){
    TypedQuery<ForSale> query = em.createNamedQuery("searchForSaleQuery",ForSale.class);
    query.setParameter("pId", pId);
    return query.getSingleResult();
}
I have been reading some solutions from other posts but it does not seem to be a solution for me! I would very appreciate it if someone can give me some idea on how to fix this, thank you so much
 
    