title: p:commandLink not working in p:datatable with pagination after page 1
body: <p>I am using PrimeFaces 5.1 in my JSF application. On the listing page of this application I am using Primefaces Datatable with pagination. Values for one of the column in the table is a primefaces commandLink that on click is defined to call action method defined in a JSF ManagedBean class that has SessionScope. This datatable itself is defined in an XHTML page that uses template XHTML that has h:form defined. Thus this datatable is nested in that h:form.</p>
  
  <p>The problem I am facing is that the method defined in ManagedBean is only getting invoked from commandLinks rendered on the first page of the datatable, whereas from commandLinks on subsequent pages action method is not getting invoked. What I also noticed is that as the total records are less than 100 so when I set the value for 'rows' attribute of the datatable in XHTML to 100 rows per page, only a single page gets rendered and then when I select 10 or 50 rows per page option from the pagination drop down list in the listing page multiple pages show up but the link works fine. However, from the code, if I set the rows value to 50 or 10 rows per page in the XHTML code the issue seems to happen.</p>
  
  <p>I checked firebug JS as well as Chrome JS console and there are no errors nor does the tomcat log file shows any log error even though I have set the <code>javax.faces.PROJECT_STAGE</code> context-param in <code>web.xml</code> to <code>Development</code>. What could be the reason for this behavior and how can I resolve this?</p>
  
  <p>Below is my JSF snippet for the datatable:</p>
  
  <pre><code>&lt;p:dataTable id="data" widgetVar="dataTable" var="customer" value="#{customerServicePortaltBacking.customers}"
           paginator="true"
           rows="50"
           paginatorTemplate="{RowsPerPageDropdown} {FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}"
           rowsPerPageTemplate="10,50,100"&gt;
  &lt;p:column style="width: 14%"&gt;
      &lt;f:facet name="header"&gt;
          &lt;p:outputLabel value="#{msg['customerId']}" styleClass="covFont"/&gt;
      &lt;/f:facet&gt;
      &lt;h:outputText value="#{customer.customerId}" styleClass="covFont"/&gt;
  &lt;/p:column&gt;
  &lt;p:column style="width: 66%"&gt;
      &lt;f:facet name="header"&gt;
          &lt;p:outputLabel value="#{msg['name']}" styleClass="covFont"/&gt;
      &lt;/f:facet&gt;
      &lt;h:outputText value="#{customer.name}" styleClass="covFont"/&gt;
  &lt;/p:column&gt;
  &lt;p:column style="width: 10%"&gt;
      &lt;f:facet name="header"&gt;
          &lt;p:outputLabel value="#{msg['deptId']}" styleClass="covFont"/&gt;
      &lt;/f:facet&gt;
      &lt;h:outputText value="#{customer.deptId}" styleClass="covFont"/&gt;
  &lt;/p:column&gt;
  &lt;p:column style="width: 10%"&gt;
      &lt;f:facet name="header"&gt;
          &lt;p:outputLabel value="#{msg['view']}" styleClass="covFont"/&gt;
      &lt;/f:facet&gt;
      &lt;p:commandLink id="invoiceButton" value="#{msg['customers.invoices']}" action="#{customerServicePortaltBacking.goInvoiceCategories(customer)}"
      &gt;&lt;/p:commandLink&gt;
  &lt;/p:column&gt;
  
  &lt;/p:dataTable&gt;
  </code></pre>
  
  <p>Below is the code from Managed Bean class:</p>
  
  <pre><code>package com.assetworks.csportal;
  
  import com.assetworks.csportal.orm.*;
  import org.apache.commons.lang.StringUtils;
  import org.primefaces.component.datatable.DataTable;
  import org.primefaces.event.SelectEvent;
  import org.primefaces.event.UnselectEvent;
  
  import javax.faces.bean.ManagedBean;
  import javax.faces.bean.SessionScoped;
  import javax.faces.context.FacesContext;
  import javax.servlet.ServletOutputStream;
  import javax.servlet.http.HttpServletResponse;
  import java.io.FileInputStream;
  import java.text.MessageFormat;
  import java.util.*;
  import java.util.logging.Logger;
  
  @ManagedBean
  @SessionScoped
  public class CustomerServicePortaltBacking {
  
  private static final Logger LOGGER = 
  Logger.getLogger(CustomerServicePortaltBacking.class.getName());
  
  private List&lt;Customer&gt; customers = null;
  private Stack&lt;Screens&gt; screensStack = new Stack&lt;&gt;();
  //Screen
  private Screens screen = Screens.CustomerBrowse;
  
  private String customerName;
  
  private Customer customer;
  
  public String getCustomerName() {
      if(customerName == null){
  
          String name = new DataAccess().getCustomerName(getContactId());
          if(name == null)
              name = "";
          customerName = name;
      }
      return customerName;
  }
  
  public void setCustomerName(String customerName) {
      this.customerName = customerName;
  }
  
  public List&lt;Customer&gt; getCustomers() {
      if(customers == null){
          customers = new DataAccess().getCustomers(getContactId());
      }
      List&lt;Customer&gt; filteredCustomers = new LinkedList&lt;&gt;();
      if(hasValue(this.getSearch())) {
          String search = getSearch().toUpperCase();
          for (Customer customer : customers) {
              if(customer.getCustomerId().indexOf(search) != -1 ||     customer.getName().toUpperCase().indexOf(search) != -1 || customer.getDeptId().indexOf(search) != -1){
                  filteredCustomers.add(customer);
              }
          }
      }
      else{
          filteredCustomers = customers;
      }
      return filteredCustomers;
  }
  
  public String goCusomerList(){
      screensStack.clear();
      DataTable dataTable = (DataTable) FacesContext.getCurrentInstance().getViewRoot().findComponent("form:data");
      if(dataTable != null) {
          dataTable.resetValue();
          dataTable.processUpdates(FacesContext.getCurrentInstance());
      }
      setScreen(Screens.CustomerBrowse);
      return Screens.CustomerBrowse.getId();
  }
  
  public String goHome(){
      search = null;
      return goCusomerList();
  }
  
  public String goInvoiceCategories(Customer customer){
      categories = null;
      this.customer = customer;
      this.setScreen(Screens.CustomerServiceCategory);
      return Screens.CustomerServiceCategory.getId();
  }
  
  public String goBack() {
      this.screen = screensStack.pop();
      return getScreen().getId();
  }
  
  public boolean hasValue(String str){
      return str != null &amp;&amp; str.length() &gt; 0;
  }
  
  public void setCustomer(Customer customer) {
      this.customer = customer;
  }
  
  public String authenticateUser() {
      isUserAuthenticated = true;
      return goCusomerList();
  }
  
  public void setScreen(Screens screen) {
      screensStack.push(getScreen());
      this.screen = screen;
  }
  
  public Screens getScreen() {
      return this.screen;
  }
  
  public String getMessage(String key, Object[] args){
      String result = "[Key " + key + " not found in messages.properties]";
      try {
          FacesContext context = FacesContext.getCurrentInstance();
          ResourceBundle bundle =
            ResourceBundle.getBundle("messages",
              context.getViewRoot().getLocale());
          result = new MessageFormat(bundle.getString(key)).format(args);
      } catch (Exception e) {
          e.printStackTrace();
      }
  
      return result;
  }
  
  
  public String getVersion(){
      return Application.VERSION;
  }
  
  public String getScreenlabel() {
      return getMessage(screen.getId(), new Object[0]);
  }
  
  public Customer getCustomer() {
      return customer;
  }
  
  public void setCustomers(List&lt;Customer&gt; customers) {
      this.customers = customers;
  }
  
  public boolean isCustomerExternal(){
      return customer.getDeptId().toUpperCase().startsWith("UFL");
  }
  }
  </code></pre>