/** * @return true if the logout button should be printed. */ public boolean isPrintLogout() { if (!printLoginLogoutButtons) { return false; } return ContextUtils.isServlet() && getCurrentUser() != null; }
/** * @return true if the login button should be printed. */ public boolean isPrintLogin() { if (!printLoginLogoutButtons) { return false; } return ContextUtils.isServlet() && getCurrentUser() == null; }
/** * @return true if the logout button should be printed. */ public boolean isPrintLogout() { if (!printLoginLogoutButtons) { return false; } return ContextUtils.isServlet() && getCurrentUser() != null; }
/** * @return true if the login button should be printed. */ public boolean isPrintLogin() { if (!printLoginLogoutButtons) { return false; } return ContextUtils.isServlet() && getCurrentUser() == null; }
/** * @return The current HttpServletRequest. */ public static HttpServletRequest getHttpServletRequest() { if (ContextUtils.isServlet()) { return ((ServletRequestAttributes) ContextUtils.getContextAttributes()).getRequest(); } PortletRequest portletRequest = ((PortletRequestAttributes) ContextUtils.getContextAttributes()).getRequest(); return ContextUtils.getHttpServletRequestFromPortletRequest(portletRequest); }
@Override public void beforePhaseInternal(final PhaseEvent event) { FacesContext facesContext = event.getFacesContext(); ExternalContext externalContext = facesContext.getExternalContext(); if (event.getPhaseId() != PhaseId.RENDER_RESPONSE) { return; } // Implement POST-REDIRECT-GET pattern if (!"POST".equals(getMethod(externalContext))) { return; } if (!ContextUtils.isServlet()) { return; } String nextViewID = facesContext.getViewRoot().getViewId(); String nextViewURL = facesContext.getApplication().getViewHandler() .getActionURL(facesContext, nextViewID); if (logger.isDebugEnabled()) { logger.debug("Redirecting to " + nextViewURL); } try { event.getFacesContext().getExternalContext().redirect(nextViewURL); } catch (Throwable t) { logger.error("EXCEPTION: " + t.getMessage()); } }
/** * @return The request attributes, as a set of strings. */ public static Set<String> getRequestAttributesStrings() { if (!isWeb()) { return new TreeSet<String>(); } if (isServlet()) { return getAttributesStrings(getRequestAttributes( ((ServletRequestAttributes) getContextAttributes()).getRequest())); } return getAttributesStrings(getRequestAttributes( ((PortletRequestAttributes) getContextAttributes()).getRequest())); }
/** * @return The session attributes, as a set of strings. */ public static Set<String> getSessionAttributesStrings() { if (!isWeb()) { return new TreeSet<String>(); } if (isServlet()) { return getAttributesStrings(getSessionAttributes( ((ServletRequestAttributes) getContextAttributes()).getRequest())); } return getAttributesStrings(getSessionAttributes( ((PortletRequestAttributes) getContextAttributes()).getRequest())); }
/** * @return The global session attributes, as a set of strings. */ public static Set<String> getGlobalSessionAttributesStrings() { if (!isWeb()) { return new TreeSet<String>(); } if (isServlet()) { HttpServletRequest servletRequest = ((ServletRequestAttributes) getContextAttributes()).getRequest(); return getAttributesStrings(getGlobalSessionAttributes(servletRequest)); } PortletRequest portletRequest = ((PortletRequestAttributes) getContextAttributes()).getRequest(); return getAttributesStrings(getGlobalSessionAttributes(portletRequest)); }
@Override public void beforePhaseInternal(final PhaseEvent event) { FacesContext facesContext = event.getFacesContext(); ExternalContext externalContext = facesContext.getExternalContext(); if (event.getPhaseId() != PhaseId.RENDER_RESPONSE) { return; } // Implement POST-REDIRECT-GET pattern if (!"POST".equals(getMethod(externalContext))) { return; } if (!ContextUtils.isServlet()) { return; } String nextViewID = facesContext.getViewRoot().getViewId(); String nextViewURL = facesContext.getApplication().getViewHandler() .getActionURL(facesContext, nextViewID); if (logger.isDebugEnabled()) { logger.debug("Redirecting to " + nextViewURL); } try { event.getFacesContext().getExternalContext().redirect(nextViewURL); } catch (Throwable t) { logger.error("EXCEPTION: " + t.getMessage()); } }