Example usage for javax.servlet.jsp PageContext getSession

List of usage examples for javax.servlet.jsp PageContext getSession

Introduction

In this page you can find the example usage for javax.servlet.jsp PageContext getSession.

Prototype


abstract public HttpSession getSession();

Source Link

Document

The current value of the session object (an HttpSession).

Usage

From source file:org.mifos.framework.components.customTableTag.Column.java

private String getLabelText(PageContext pageContext, String key, String bundle) {

    UserContext userContext = (UserContext) pageContext.getSession().getAttribute(Constants.USER_CONTEXT_KEY);
    LabelTagUtils labelTagUtils = LabelTagUtils.getInstance();
    String labelText = null;/* w  w  w  .j  a va  2 s.co m*/
    try {
        labelText = labelTagUtils.getLabel(pageContext, bundle, userContext.getPreferredLocale(), key, null);
    } catch (Exception e) {
    }
    if (StringUtils.isBlank(labelText)) {
        labelText = ApplicationContextProvider.getBean(MessageLookup.class).lookup(key);
    }
    if (StringUtils.isBlank(labelText)) {
        try {
            char[] charArray = bundle.toCharArray();
            charArray[0] = Character.toUpperCase(charArray[0]);
            String newBundle = new String(charArray);
            labelText = labelTagUtils.getLabel(pageContext, newBundle, userContext.getPreferredLocale(), key,
                    null);

        } catch (Exception e) {
            labelText = key;

        }
    }
    return labelText;
}

From source file:org.mifos.framework.util.helpers.LabelTagUtils.java

@SuppressWarnings("unchecked")
public boolean isConfigurableMandatory(String key, PageContext pageContext) {
    // TODO get is mandatory or not from the cache.
    Map mandatoryMap = (Map) pageContext.getSession().getAttribute("ConfigurableMandatory");
    if (mandatoryMap == null) {
        return false;
    }//from  w  w  w  . ja va  2s . co m
    return mandatoryMap.containsKey(key);
}

From source file:org.mifos.framework.util.helpers.LabelTagUtils.java

@SuppressWarnings("unchecked")
public boolean isHidden(String key, PageContext pageContext) {
    // TODO get is hidden or not from the cache.
    Map hiddenMap = (Map) pageContext.getSession().getAttribute("Hidden");
    if (hiddenMap == null) {
        return false;
    }//from ww w  .ja v a  2 s. c  o m
    return hiddenMap.containsKey(key);
}

From source file:org.mifos.framework.util.helpers.LabelTagUtils.java

@SuppressWarnings("unchecked")
public boolean isConfidential(String key, PageContext pageContext) {
    // TODO get is confidential or not from the cache.
    Map confidentialMap = (Map) pageContext.getSession().getAttribute("Confidential");
    if (confidentialMap == null) {
        return false;
    }/*from ww w.  j a  v a  2 s.co  m*/
    return confidentialMap.containsKey(key);
}

From source file:org.silverpeas.core.web.util.viewgenerator.html.arraypanes.AbstractArrayPane.java

@Override
public void init(String name, PageContext pageContext) {
    init(name, pageContext.getRequest(), pageContext.getSession());
}

From source file:org.squale.welcom.outils.Access.java

/**
 * Retourne le droit merge entre le pageAccess, et l'accs du tag
 * //w ww . jav  a2  s. c  om
 * @param overridePageAccess si on autorise la surcharge
 * @param pageAccess l'acces de la page
 * @param accessKey du tag courant
 * @param pageContext page context
 * @return Retourne le droit merge entre le pageAccess, et l'accs du tag
 */
private static String getAccessTagMergeWithPageAccess(PageContext pageContext, boolean overridePageAccess,
        String pageAccess, final String accessKey) {
    String accessTag = null;

    // recherche le logonbean
    final Object o = pageContext.getSession().getAttribute(WConstants.USER_KEY);

    if (o != null) {
        // Verifie qi on est en mode scuris
        if (o instanceof WILogonBeanSecurity) {
            final WILogonBeanSecurity lb = (WILogonBeanSecurity) o;
            final String computedAccessTag = Access.getMultipleSecurityPage(lb, accessKey);
            if (overridePageAccess) {
                accessTag = computedAccessTag;
            } else
            // si mis a false explicitement
            if (Util.isEquals(pageAccess, Access.READONLY)
                    && Util.isEquals(computedAccessTag, Access.READWRITE)) {
                accessTag = Access.READONLY;
            } else {
                accessTag = computedAccessTag;
            }
        }
    }
    return accessTag;
}

From source file:org.squale.welcom.struts.util.WRequestUtils.java

/**
 * Look up and return a message string, based on the specified parameters.
 * /*from   w  w w  .j  ava  2  s . c o  m*/
 * @param pageContext The PageContext associated with this request
 * @param key Message key to be looked up and returned
 * @param args Replacement parameters for this message
 * @return message string saved in the request already)
 */
public static String message(final PageContext pageContext, final String key, final Object args[]) {
    try {
        logger.debug("Message : "
                + RequestUtils.message(pageContext, Globals.MESSAGES_KEY, Globals.LOCALE_KEY, key, args));
        logger.debug("Message locale : " + pageContext.getSession().getAttribute(Globals.LOCALE_KEY));
        return RequestUtils.message(pageContext, Globals.MESSAGES_KEY, Globals.LOCALE_KEY, key, args);
    } catch (final JspException e) {
        return "";
    }
}

From source file:org.squale.welcom.taglib.canvas.CanvasTag.java

/**
 * surcharge du on load//from www .j  a v a  2 s.  c om
 * 
 * @param pageContext contexte
 * @param oldOnLoad ancien onload su body
 * @return le onload formatte
 */
public static String addMessagePopupOnOnLoad(final PageContext pageContext, final String oldOnLoad) {
    // on gere un 2eme stringbuffer au cas ou on aurait pas besoin de onload
    final StringBuffer sbOnload = new StringBuffer();

    final Object logonBean = (pageContext.getSession().getAttribute(WConstants.USER_KEY));
    final String msg = WResultAction.readMessage(pageContext.getRequest());
    if (!GenericValidator.isBlankOrNull(msg)) {

        sbOnload.append("javascript:alert(\'" + Util.formatJavaScript(msg) + "\');");

        // message afficher, suppression du message
        WResultAction.resetMessage(pageContext.getRequest());
    }

    if (!GenericValidator.isBlankOrNull(oldOnLoad)) {
        sbOnload.append(ResponseUtils.filter(oldOnLoad) + ";");
    }

    return sbOnload.toString();

}

From source file:org.vulpe.view.struts.tags.StrutsFunctions.java

/**
 *
 * @param pageContext//  ww  w  .  j  av  a2s .co  m
 * @param pagingName
 * @param pageSize
 * @param fullList
 * @return
 */
public static SessionPaging findPaging(final PageContext pageContext, final String pagingName,
        final Long pageSize, final List fullList) {
    SessionPaging paging = (SessionPaging) pageContext.getSession().getAttribute(pagingName);
    if (paging == null && fullList != null) {
        paging = new SessionPaging(pageSize.intValue(), fullList);
        pageContext.getSession().setAttribute(pagingName, paging);
    }
    return paging;
}

From source file:org.vulpe.view.tags.Functions.java

/**
 *
 * @return//w  w w . j av  a 2  s  . c o  m
 */
public static Boolean isAuthenticated(final PageContext pageContext) {
    final Object springSecurity = pageContext.getSession().getAttribute(Security.SPRING_SECURITY_CONTEXT);
    if (springSecurity == null) {
        return false;
    }
    final Object springSecurityAutentication = VulpeReflectUtil.getFieldValue(springSecurity, "authentication");
    final Boolean authenticated = VulpeReflectUtil.getFieldValue(springSecurityAutentication, "authenticated");
    if (authenticated != null && authenticated.booleanValue()) {
        return true;
    }
    return ((HttpServletRequest) pageContext.getRequest()).getUserPrincipal() != null;
}