title: "preRenderComponent" is ignored when "viewParam" is present in parent view
body: <p>I need a method to be executed whenever my component gets rendered, i.e. when it gets created for the first time and on every update.</p>
  
  <p>A way of doing it is using f:metadata and f:event for the event "preRenderComponent". It works perfectly well, unless I also have a f:metadata with f:viewParam in the view holding the component. If I have a f:viewParam in the parent view, f:event, in the component, gets ignored.</p>
  
  <p>How to solve this problem, why does it happen?</p>
  
  <p>Here's some code to reproduce the problem:</p>
  
  <p>The view (index.xhtml):</p>
  
  <pre><code>&lt;h:body&gt;
    &lt;f:metadata&gt;
      &lt;f:viewParam name="vparam" value="#{index.vparam}" /&gt;
    &lt;/f:metadata&gt;
  
    &lt;comp:component /&gt;
  &lt;/h:body&gt;
  </code></pre>
  
  <p>The managedBean (Index.java)</p>
  
  <pre><code>@ManagedBean(name="index")
  public class Index implements Serializable {
      private String vparam;
  
      public void setVparam(String vparam) {
          this.vparam = vparam;
      }
  
      public String getVparam() {
          return vparam;
      }
  }
  </code></pre>
  
  <p>The component view (component.xhtml):</p>
  
  <pre><code>&lt;h:body&gt;
      &lt;composite:interface componentType="component" /&gt;
      &lt;composite:implementation&gt;
          &lt;f:metadata&gt;
              &lt;f:event type="preRenderComponent" listener="#{cc.generateString}" /&gt;
          &lt;/f:metadata&gt;
          &lt;h:outputText value="#{cc.string}" /&gt;
      &lt;/composite:implementation&gt;
  &lt;/h:body&gt;
  </code></pre>
  
  <p>The component's java class (Component.java):</p>
  
  <pre><code>@FacesComponent(value="component")
  public class Component extends UINamingContainer implements Serializable {
      private String string;
  
      public void generateString(){
          System.out.println("*** PRE RENDERING COMPONENT...");
          System.out.flush();
          string = "It worked!";
      }
  
      public String getString(){
          return string;
      }
  }
  </code></pre>
  
  <p>The expected output of this code is: the string "It worked!" printed in the index page.
  The actual output is: nothing, since a null string is printed as "" by the h:outputText.</p>
  
  <p>In the log file, "<em>*</em>** PRE RENDERING COMPONENT..." is not printed, it's never executed.</p>
  
  <p>If I remove the following line from index.xhtml, everything works fine:</p>
  
  <pre><code>&lt;f:viewParam name="vparam" value="#{index.vparam}" /&gt;
  </code></pre>
  
  <p>Why does the presence of "viewParam" in the component's parent page makes JSF to ignore "f:event" in the component?</p>
  
  <p>Thanks in advance for any answer.</p>