title: Problems understanding JSF Phases
body: <p>I have a problem understanding the JSF Phases. I have the followed problem.</p>
  
  <p>On my main page i create a panelGroup, and includes a xhtml dynamicaly.</p>
  
  <pre><code>    &lt;h:panelGroup id="padding"&gt;
          &lt;ui:include src="#{navigationHandler.currentPage}" /&gt;
      &lt;/h:panelGroup&gt;
  </code></pre>
  
  <p>In my menubar i have some code like this:</p>
  
  <pre><code>    &lt;p:submenu label="#{translator.menuentry_insured}"&gt;
          &lt;p:menuitem value="#{translator.menuentry_add_insured}"    actionListener="#{navigationHandler.addInsured}"    update=":padding" /&gt;
          &lt;p:menuitem value="#{translator.menuentry_search_insured}" actionListener="#{navigationHandler.searchInsured}" update=":padding"/&gt;
      &lt;/p:submenu&gt;
  </code></pre>
  
  <p>When I click on the menuitem, first the "currentPage" method is called, returning the page currently active. After that, the actionListener is called, setting the page to the new page. If I click again on the same link, then the correct page is shown.</p>
  
  <p>I know the problem is in the JSF lifecycle ("restore view" phase before "invoke application" phase), but I don't know how to solve this.</p>
  
  <p>Here is a output from my own PhaseListener, just for debugging purpose:</p>
  
  <pre><code>BEFORE: RESTORE_VIEW 1
      Using current page: addInsured.xhtml
  AFTER: RESTORE_VIEW 1
  BEFORE: APPLY_REQUEST_VALUES 2
  AFTER: APPLY_REQUEST_VALUES 2
  BEFORE: PROCESS_VALIDATIONS 3
  AFTER: PROCESS_VALIDATIONS 3
  BEFORE: UPDATE_MODEL_VALUES 4
  AFTER: UPDATE_MODEL_VALUES 4
  BEFORE: INVOKE_APPLICATION 5
      Setting current page to searchInsured.xhtml
  AFTER: INVOKE_APPLICATION 5
  BEFORE: RENDER_RESPONSE 6
  AFTER: RENDER_RESPONSE 6
  </code></pre>
  
  <p>Is there any solution? What I am doing wrong?</p>