title: using f:viewParam with required attribute and commands
body: <p>I want to share my experience using primefaces, f:viewParam and p:commandButton, and ask a few questions.Take a look at this page:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!DOCTYPE html&gt;
  &lt;html 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:p="http://primefaces.org/ui"&gt;
    &lt;h:head&gt;&lt;/h:head&gt;
    &lt;h:body&gt;  
      &lt;f:metadata&gt;
        &lt;f:viewParam required="true" name="id_file" value="#{bean.idFile}" /&gt;
      &lt;/f:metadata&gt;
      &lt;h:form id="tableform" prependId="false"&gt;              
        &lt;p:commandButton actionListener="#{bean.myMethod())}" icon="ui-icon-search" title="View" /&gt;
      &lt;/h:form&gt;
      &lt;p:messages id="messages" showDetail="true" autoUpdate="true" closable="true" /&gt;      
    &lt;/h:body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>The backing bean have a "myMethod()" method that does nothing. When you enter the page it expects the "id_file" parameter and put it in the idFile property of the backing bean. Then you click the button and the myMethod is called. Then you click again and you get an obscure validation error and myMethod is never called:</p>
  
  <pre><code>j_idt1: Validation Error: Value is required.j_idt1: Validation Error: Value is required.
  </code></pre>
  
  <p>First of all, remember that without p:messages you can't see this message, you have to dig the XML that primefaces send on ajax calls. Secondly, after 4 hours of debugging I've tried to change the f:viewParam like this:</p>
  
  <pre><code>&lt;f:viewParam name="id_file" value="#{bean.idFile}" /&gt;
  </code></pre>
  
  <p>without "required": magically everything start working, I can click 1,2,3,etc and myMethod is called every time. So, the problem is that the ajax submit validate the parameter specified with f:viewParam, it sounds silly to me, but ok, I can live with it. </p>
  
  <p>My questions are:</p>
  
  <ul>
  <li><p>why this validation error doesn't appear the first time button is clicked? If you look at the ajax POSTs they are identical </p></li>
  <li><p>it is supposed to be ok to validate the view parameters (that, in my idea, belongs to the view) on a partial ajax call?</p></li>
  <li><p>is there a way to tell to primefaces not to validate on particular ajax request (process="@this" does not resolve)?</p></li>
  </ul>
  
  <p>Thank you, I hope that my experience will allow you to avoid spending hours doing debugging!</p>