title: JSF index.xhtml and redirect to faces action
body: <p>I think its a good practice to have an index page (in my case index.xhtml).
  I want to pass some action on index page (for example in struts:<code>&lt;c:redirect url="list.do" /&gt;</code> and I go to struts action class without any links and buttons) I know if I want to use navigation I should use commandLink-s or buttons). I can write <code>&lt;h:commandButton&gt;</code> with onclick javascript function, but I don't feel this is the best option.</p>
  
  <p>I'm totally new to JSF (using JSF 2.0) and I need your advice. What are the best practices for redirecting from index page to an action in controller?</p>
  
  <p>///new version</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:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"&gt;
  &lt;f:view&gt;
  &lt;ui:insert name="metadata"/&gt;
      &lt;f:viewParam name="action" value="listItems.xtml"/&gt;
      &lt;f:event type="preRenderView" listener="#{yourBean.methodInManagedBean}" /&gt;
  &lt;h:body&gt;&lt;/h:body&gt;
  &lt;/f:view&gt;
  &lt;/html&gt;
  
  public class ForwardBean {
  
      private String action;
  
      // getter, setter
  
      public void navigate(PhaseEvent event) {
          FacesContext facesContext = FacesContext.getCurrentInstance();
          String outcome = action; 
          facesContext.getApplication().getNavigationHandler().handleNavigation(facesContext, null, outcome);
      }
  }
  </code></pre>