Example usage for javax.servlet.jsp PageContext PAGE_SCOPE

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

Introduction

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

Prototype

int PAGE_SCOPE

To view the source code for javax.servlet.jsp PageContext PAGE_SCOPE.

Click Source Link

Document

Page scope: (this is the default) the named reference remains available in this PageContext until the return from the current Servlet.service() invocation.

Usage

From source file:org.sakaiproject.metaobj.security.control.tag.AuthZMapTag.java

public void setScope(String scope) {
    if (scope.equalsIgnoreCase("page")) {
        this.scope = PageContext.PAGE_SCOPE;
    } else if (scope.equalsIgnoreCase("request")) {
        this.scope = PageContext.REQUEST_SCOPE;
    } else if (scope.equalsIgnoreCase("session")) {
        this.scope = PageContext.SESSION_SCOPE;
    } else if (scope.equalsIgnoreCase("application")) {
        this.scope = PageContext.APPLICATION_SCOPE;
    }//from  ww  w.j  a  v  a  2s .c o m

    // TODO: Add error handling?  Needs direction from spec.
}

From source file:org.sakaiproject.metaobj.security.control.tag.AuthZMapTag.java

protected void init() {
    var = "can";
    scope = PageContext.PAGE_SCOPE;
    qualifier = null;
    setUseSite(false);
}

From source file:org.sakaiproject.metaobj.shared.control.tag.Message.java

public void release() {
    localScope = PageContext.PAGE_SCOPE;
    text = null;
    localVar = null;
    super.release();
}

From source file:org.springframework.security.taglibs.authz.AccessControlListTag.java

private int skipBody() {
    if (var != null) {
        pageContext.setAttribute(var, Boolean.FALSE, PageContext.PAGE_SCOPE);
    }/* w w w .  j  a v  a  2s. c om*/
    return TagLibConfig.evalOrSkip(false);
}

From source file:org.springframework.security.taglibs.authz.AccessControlListTag.java

private int evalBody() {
    if (var != null) {
        pageContext.setAttribute(var, Boolean.TRUE, PageContext.PAGE_SCOPE);
    }// www . ja va2 s . c  o m
    return TagLibConfig.evalOrSkip(true);
}

From source file:org.squale.welcom.taglib.table.ColsTag.java

/**
 * @see javax.servlet.jsp.tagext.BodyTagSupport#doInitBody()
 *///from ww w . ja v  a2 s  . c  o m
public void doInitBody() throws JspException {
    final TrimStringBuffer sb = new TrimStringBuffer();

    String nom = tableTag.getName();

    if (!GenericValidator.isBlankOrNull(tableTag.getProperty())) {
        nom += ("." + tableTag.getProperty());
    }

    if (tableTag.getScrollHeight() != 0) {
        sb.append(render.drawTableStart(null, tableTag.getWidth()));
    } else {
        sb.append(render.drawTableStart(getTableName(), tableTag.getWidth()));
    }

    ResponseUtils.write(pageContext, sb.toString());

    if (!(collectionForMemory instanceof HTMLTable)) {
        idCount = 0;
    } else {
        idCount = ((HTMLTable) collectionForMemory).getFrom();
    }

    // Charge le tableau associatif des Object d'afficagae avec les object Memoire
    initRelationDisplayIdMemory();

    Object o = null;

    // Si la collection n'est pas vide alors passes l'object sinon il est null
    if (!collectionForDisplay.isEmpty()) {
        o = collectionForDisplay.elementAt(idCount);
        pageContext.setAttribute(getId(), o, PageContext.PAGE_SCOPE);
        pageContext.setAttribute(getIdIndex(), (Integer) relationDisplayIdMemory.get(o),
                PageContext.PAGE_SCOPE);
    }
}

From source file:org.squale.welcom.taglib.table.ColsTag.java

/**
 * @see javax.servlet.jsp.tagext.BodyTagSupport#doAfterBody()
 *//*from  w  ww. java2 s . co  m*/
public int doAfterBody() throws JspException {
    boolean autoDescription = false;

    // Blindage
    if (currentLine == null) {
        // Vide les colonnes car le retourve a chaque fois
        currentLine = new Cols();
    }

    // Genere tout les columns
    if (currentLine.isEmpty()) {
        currentLine.genAllCols(collectionForDisplay.elementAt(0).getClass());
        autoDescription = true;
    }

    if (firstIterate) {
        if (((collectionForMemory != null) && !collectionForMemory.isEmpty()) || ((collectionForMemory != null)
                && collectionForMemory.isEmpty() && !GenericValidator.isBlankOrNull(emptyKey))) {
            if (tableTag.isDisplayHeader()) {
                ResponseUtils.write(pageContext, tableTitre());
            }

            // Cherche pour l'inclusion de table
            if (tableTag.getScrollHeight() != 0) {
                if (!(collectionForDisplay.isEmpty())
                        || (collectionForDisplay.isEmpty() && !GenericValidator.isBlankOrNull(emptyKey))) {
                    ResponseUtils.write(pageContext, "</table>");
                    ResponseUtils.write(pageContext,
                            "<div style=\"height:" + tableTag.getScrollHeight() + "px;overflow:auto;\">");

                    ResponseUtils.write(pageContext,
                            render.drawTableStart(getTableName(), tableTag.getWidth()));

                    tableTag.setDisplayHeader(false);
                }
            }

            if (autoDescription) {
                idCount = 0;
                // Vide les colonnes car le retourve a chaque fois
                currentLine = new Cols();
                initCurrentLine();
                firstIterate = false;

                return EVAL_BODY_AGAIN;
            }
        }

        firstIterate = false;
    }

    final TrimStringBuffer sb = new TrimStringBuffer();

    // Si la table est vide affiche la ligne et part
    if (collectionForMemory.isEmpty() && !GenericValidator.isBlankOrNull(emptyKey)) {
        final String myClassLignePaire = WelcomConfigurator
                .getMessage(WelcomConfigurator.getCharte().getWelcomConfigFullPrefix() + ".cols.even");
        sb.append("<tr class=\"" + myClassLignePaire + "\">");

        if ((isSelectTr() || isSelectCheckBox())) {
            sb.append("<td></td>");
        }

        sb.append("<td colspan=\"" + currentLine.size() + "\">");

        final String emptyMessage = resources.getMessage(localeRequest, emptyKey);

        if (emptyMessage != null) {
            sb.append(ResponseUtils.filter(emptyMessage));
        } else {
            sb.append(ResponseUtils.filter(emptyKey));
        }

        sb.append("</tr>");
        ResponseUtils.write(pageContext, sb.toString());

        return EVAL_PAGE;
    }

    initCurrentLine();
    sb.append(currentLine.tabletrCorps(idCount, collectionForDisplay.elementAt(idCount),
            (Integer) relationDisplayIdMemory.get(collectionForDisplay.elementAt(idCount))));
    ResponseUtils.write(pageContext, sb.toString());

    // Suppresion de l'aobjet courant
    pageContext.removeAttribute(getId());
    pageContext.removeAttribute(getIdIndex());
    currentLine = new Cols(); // Vide les colonnes car le retourve a chaque fois

    idCount++;

    if (!(collectionForMemory instanceof HTMLTable)) {
        if (collectionForDisplay.size() > idCount) {
            final Object o = collectionForDisplay.elementAt(idCount);
            pageContext.setAttribute(getId(), o, PageContext.PAGE_SCOPE);
            pageContext.setAttribute(getIdIndex(), (Integer) relationDisplayIdMemory.get(o),
                    PageContext.PAGE_SCOPE);

            return EVAL_BODY_AGAIN;
        }
    } else {
        if ((collectionForDisplay.size() > idCount) && (idCount < (((HTMLTable) collectionForMemory).getLength()
                + ((HTMLTable) collectionForMemory).getFrom()))) {
            final Object o = collectionForDisplay.elementAt(idCount);
            pageContext.setAttribute(getId(), o, PageContext.PAGE_SCOPE);
            pageContext.setAttribute(getIdIndex(), (Integer) relationDisplayIdMemory.get(o),
                    PageContext.PAGE_SCOPE);

            return EVAL_BODY_AGAIN;
        }
    }

    return EVAL_PAGE;

    // ResponseUtils.write(pageContext,sb.toString());
}

From source file:org.theospi.portfolio.security.control.tag.AuthZMapTag.java

public void setScope(String scope) {
    if (scope.equalsIgnoreCase("page"))
        this.scope = PageContext.PAGE_SCOPE;
    else if (scope.equalsIgnoreCase("request"))
        this.scope = PageContext.REQUEST_SCOPE;
    else if (scope.equalsIgnoreCase("session"))
        this.scope = PageContext.SESSION_SCOPE;
    else if (scope.equalsIgnoreCase("application"))
        this.scope = PageContext.APPLICATION_SCOPE;

    // TODO: Add error handling?  Needs direction from spec.
}

From source file:ubic.gemma.web.taglib.ConstantsTag.java

@Override
public int doStartTag() throws JspException {
    // Using reflection, get the available field names in the class
    Class<?> c;/*from w  w  w . j  a v  a2s .c o m*/
    int toScope = PageContext.PAGE_SCOPE;

    if (scope != null) {
        toScope = getScope(scope);
    }

    try {
        c = Class.forName(clazz);
    } catch (ClassNotFoundException cnf) {
        log.error("ClassNotFound - maybe a typo?");
        throw new JspException(cnf.getMessage());
    }

    try {
        // if var is null, expose all variables
        if (var == null) {
            Field[] fields = c.getDeclaredFields();

            AccessibleObject.setAccessible(fields, true);

            for (Field field : fields) {
                /*
                 * if (log.isDebugEnabled()) { log.debug("putting '" + fields[i].getName() + "=" +
                 * fields[i].get(this) + "' into " + scope + " scope"); }
                 */
                pageContext.setAttribute(field.getName(), field.get(this), toScope);
            }
        } else {
            try {
                String value = (String) c.getField(var).get(this);
                pageContext.setAttribute(c.getField(var).getName(), value, toScope);
            } catch (NoSuchFieldException nsf) {
                log.error(nsf.getMessage());
                throw new JspException(nsf);
            }
        }
    } catch (IllegalAccessException iae) {
        log.error("Illegal Access Exception - maybe a classloader issue?");
        throw new JspException(iae);
    }

    // Continue processing this page
    return (SKIP_BODY);
}