title: Liferay Portlet and JSF : Redirect during Render Phase
body: <p>I have a problem to implement a simple HTTP redirection.</p>
  
  <p>I use Liferay 6.0.6, our <strong>portlets</strong> are build with <strong>JSF2.0</strong> / <a href="http://www.portletfaces.org/">PortletFaces</a>.</p>
  
  <p>I want to call a redirection <strong>when a view is loaded</strong> (and not when an action is triggered). Currently, my function is called by the PreRenderView listener.</p>
  
  <pre><code>&lt;f:metadata&gt;
    &lt;f:event listener="#{myControler.dispatch}" type="preRenderView" /&gt;
  &lt;/f:metadata&gt;
  </code></pre>
  
  <p>In this function, i can check the permissions, do other stuff, and in some cases I want to redirect the user to a new page (not another view).</p>
  
  <p>I tried several methods, unsuccessfully.
  Specifically, I thought that this method would work :</p>
  
  <pre><code>getFacesContext().getExternalContext().redirect(url);
  getFacesContext().responseComplete()
  // =&gt; Can only redirect during ACTION_PHASE
  </code></pre>
  
  <p>This error is logical, but is there a solution to <strong>force</strong> the redirection.<br /></p>
  
  <p>It could be realized in another function, called otherwise, I only need the Hibernate Session (set at the beginning of the Render Phase)</p>
  
  <p>Have you ideas to resolve this problem?<br />
  Thanks!</p>
  
  <p><em>ps : <code>&lt;redirect /&gt;</code> or <code>?faces-redirect</code> don't work with the portlets.</em></p>