title: JSF 2.0. Unable to get POST parameters and cookies in preRenderView event handler
body: <p>I am trying to develop a service.</p>
  
  <p>The point is that my index.xhtml should get parameters (either POST and GET) and cookies from HTTP Request. </p>
  
  <p>I tried combination with <code>&lt;f:metadata&gt;</code> and <code>&lt;f:event type="preRenderView"&gt;</code> like this:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;f:metadata&gt;  
      &lt;f:event type="preRenderView" listener="#{deConversation.start}"/&gt;  
  &lt;/f:metadata&gt;
  </code></pre>
  
  <p>Code for deConversation.start:</p>
  
  <pre class="lang-java prettyprint-override"><code>public void start(ComponentSystemEvent event) {
      System.out.println("checkLogin");
      HttpServletRequest request = SsoHelper.getRequest();
      String requestSessId = SsoHelper.getRequestSessionId(request);
      String requestRedirect = SsoHelper.getRequestRedirect(request);
  
      System.out.println("sessId " + requestSessId);
  
      if (requestRedirect == null || requestRedirect.isEmpty()) {
          requestRedirect = "self";
      }
  
      if (requestSessId != null) {
          trySessId(requestSessId, requestRedirect);
      }
  
      externalResourcesHandler.setExternalRedirect(requestRedirect);
      tryToBeginConversation();
  
      if (!isAuthorized()) {
          SsoHelper.performNavigation("auth");
      }
  }
  </code></pre>
  
  <p>SsoHelper just provides api like this:</p>
  
  <pre class="lang-java prettyprint-override"><code>public static String getRequestSessionId(HttpServletRequest request) {
      Map&lt;String, Object&gt; cookieMap = FacesContext.getCurrentInstance().getExternalContext().getRequestCookieMap();
      String requestDeSessionId = null;
      if (cookieMap.containsKey("de_session_id")) {
          requestDeSessionId = ((Cookie) cookieMap.get("de_session_id")).getValue();
      }
      return requestDeSessionId;
  }
  
  public static String getRequestRedirect(HttpServletRequest request) {
      return getRequestParam(request, "redirect", "self");
  }
  
  public static String getRequestExternalCss(HttpServletRequest request) {
      return getRequestParam(request, "externalcss", null);
  }
  
  public static String getRequestParam(HttpServletRequest request, String name, String defaultValue) {
      String[] paramValues = HttpServletRequestHelper.getParamValues(request, name);
      String paramValue = null;
      if (paramValues != null &amp;&amp; paramValues.length != 0) {
          paramValue = paramValues[0];
      }
      if(paramValue == null){
          paramValue = defaultValue;
      }
      return paramValue;
  }
  
  public static HttpServletRequest getRequest() {
      return (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
  }
  
  public static void performNavigation(String destination) {
      FacesContext context = FacesContext.getCurrentInstance();
      ConfigurableNavigationHandler handler = (ConfigurableNavigationHandler) context.getApplication().getNavigationHandler();
      handler.performNavigation(destination);
  }
  </code></pre>
  
  <p>The point is that I could not get any POST parameters or cookie in method start(). I can get only GET parameters.</p>
  
  <p>Is there any possibilty to read cookies and POST parameters using <code>&lt;f:event type="preRenderView"&gt;</code>?</p>