title: includeViewParams=true doesn't work in templated pages
body: <p>Consider this template:</p>
  
  <pre class="lang-xhtml prettyprint-override"><code>&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"&gt;
      &lt;f:view contentType="text/html"&gt;
          &lt;ui:insert name="metadata"/&gt;
          &lt;h:head&gt;
              &lt;title&gt;&lt;/title&gt;
          &lt;/h:head&gt;
          &lt;h:body&gt;
              &lt;ui:insert name="content"/&gt;
          &lt;/h:body&gt;
      &lt;/f:view&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>this page that uses it (/pages/test.xhtml):</p>
  
  <pre class="lang-xhtml prettyprint-override"><code>&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"&gt;
      &lt;f:view contentType="text/html"&gt;
          &lt;h:head&gt;
              &lt;title&gt;&lt;/title&gt;
          &lt;/h:head&gt;
          &lt;h:body&gt;
              &lt;ui:composition template="/WEB-INF/templates/testLayout.xhtml"&gt;
                  &lt;ui:define name="metadata"&gt;
                      &lt;f:metadata&gt;
                          &lt;f:viewParam name="foobar" value="#{pageBean.foo}"/&gt;
                      &lt;/f:metadata&gt;
                  &lt;/ui:define&gt;
                  &lt;ui:define name="content"&gt;
                      &lt;h:form&gt;
                          &lt;h:commandLink value="Click"
                                         action="#{util.currentPageAction()}"/&gt;
                      &lt;/h:form&gt;
                  &lt;/ui:define&gt;
              &lt;/ui:composition&gt;
          &lt;/h:body&gt;
      &lt;/f:view&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>the page's bean:</p>
  
  <pre class="lang-java prettyprint-override"><code>@Named
  @RequestScoped
  public class PageBean implements Serializable
  {
      public String getFoo()
      {
          return foo;
      }
  
      public void setFoo(String foo)
      {
          this.foo = foo;
      }
  
      private String foo;
  }
  </code></pre>
  
  <p>and this bean:</p>
  
  <pre class="lang-java prettyprint-override"><code>@Named
  @ApplicationScoped
  public class Util implements Serializable
  {
      public String currentPageAction()
      {
          return FacesContext.getCurrentInstance().getViewRoot().getViewId() +
                     "?faces-redirect=true&amp;includeViewParams=true";
      }
  }
  </code></pre>
  
  <p>When I load <code>http://localhost:8080/faces/pages/test.xhtml?foo=bar</code> in the browser and click the <code>&lt;h:commandLink/&gt;</code>, the URL changes to <code>http://localhost:8080/faces/pages/test.xhtml</code>. That is, the view parameters are not included in the redirect URL.</p>
  
  <p>However, when I refactor the page such that it doesn't use a template, it behaves as expected. That is, the view parameters are included in the redirect URL.</p>
  
  <p>I understand that <code>&lt;f:metadata/&gt;</code> doesn't and isn't supposed to work when placed inside a facelets template. This is not what's happening here, so it's a different issue. There's nothing in the spec to say that this can't be done. Indeed, there would be no other way (to my knowledge) to create a template-based page with view parameters.</p>