title: f:viewAction in ui:composition
body: <p>I've found a strange behaviour while using <code>f:viewAction</code> in <code>ui:composition</code>.</p>
  
  <p>I've a main page that includes a composition.
  In both pages I've defined an f:viewAction, but when loading page, only the one in the main page is fired.</p>
  
  <p>This is an example of the code I used:</p>
  
  <p><strong>Main.xhtml</strong></p>
  
  <p>
      
      
          
      </p>
  
  <pre><code>&lt;h:head&gt;
      &lt;h:outputLabel value="Test page*******" /&gt;
  &lt;/h:head&gt;
  &lt;h:body&gt;
      &lt;ui:include src="/pages/include.xhtml" /&gt;
  &lt;/h:body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>include.xhtml</strong></p>
  
  <pre><code>&lt;ui:composition xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://xmlns.jcp.org/jsf/core"
      xmlns:h="http://xmlns.jcp.org/jsf/html"&gt;
  
      &lt;f:metadata&gt;
          &lt;f:viewAction action="#{sample.actionTest2}" /&gt;
      &lt;/f:metadata&gt;
  
      &lt;h:outputLabel value="Include" /&gt;
  
  &lt;/ui:composition&gt;
  </code></pre>
  
  <p><strong>Sample bean</strong></p>
  
  <pre><code>import java.io.Serializable;
  
  import javax.faces.bean.ManagedBean;
  import javax.faces.bean.SessionScoped;
  
  @ManagedBean(name = "sample")
  @SessionScoped
  public class SampleBean implements Serializable {
  
      /**
       * 
       */
      private static final long serialVersionUID = 2458168772774828175L;
  
      public void actionTest1() {
          System.out.println("Test1");
      }
  
      public void actionTest2() {
          System.out.println("Test2");
      }
  }
  </code></pre>
  
  <p>Only <strong>sample.actionTest1</strong> is invoked.</p>
  
  <p><strong>The JSF version is Mojarra 2.2.8-02</strong></p>
  
  <p>I'm editing my question to explain in details my scenario.
  In the previous question I omitted, for simplicity's sake, the fact that I need to render only the content section.</p>
  
  <p>The modified main page is:</p>
  
  <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://xmlns.jcp.org/jsf/core"
      xmlns:h="http://xmlns.jcp.org/jsf/html"&gt;
  &lt;f:metadata&gt;
      &lt;f:viewAction action="#{sample.actionTest1}" /&gt;
  &lt;/f:metadata&gt;
  
  &lt;h:head&gt;
      &lt;h:outputLabel value="Test page*******" /&gt;
      &lt;h:form&gt;
          &lt;h:commandLink value="Refresh content"&gt;
              &lt;f:ajax render=":content" /&gt;
          &lt;/h:commandLink&gt;
      &lt;/h:form&gt;
  &lt;/h:head&gt;
  &lt;h:body&gt;
      &lt;h:panelGroup id="content"&gt;
          &lt;ui:include src="/pages/include.xhtml" /&gt;
      &lt;/h:panelGroup&gt;
  &lt;/h:body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>As you can see, when command link in clicked, only content must be rendered.
  Is there any possibility to use <code>f:viewAction</code> to execute some action before rendering in this scenario?
  Now I'm using <code>f:event</code> and it works pefectly.</p>