Note that there are some explanatory texts on larger screens.

plurals
  1. POJSF 2.0. Unable to get POST parameters and cookies in preRenderView event handler
    primarykey
    data
    text
    <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>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload