Example usage for org.springframework.web.util TagUtils getScope

List of usage examples for org.springframework.web.util TagUtils getScope

Introduction

In this page you can find the example usage for org.springframework.web.util TagUtils getScope.

Prototype

public static int getScope(String scope) 

Source Link

Document

Determines the scope for a given input String .

Usage

From source file:com.googlecode.spring.appengine.taglib.ApplicationIdTag.java

/**
 * Set the scope to export the application identifier variable to.
 * This attribute has no meaning unless var is also defined.
 * Defaults to {@link PageContext#PAGE_SCOPE}.
 *//*w ww. ja  v  a 2  s  . c  om*/
public void setScope(String scope) {
    this.scope = TagUtils.getScope(scope);
}

From source file:se.softhouse.garden.orchid.spring.tags.OrchidMessageTag.java

@Override
public int doEndTag() throws JspException {

    // Resolve the unescaped message.
    String msg = resolveMessage();

    // HTML and/or JavaScript escape, if demanded.
    msg = isHtmlEscape() ? HtmlUtils.htmlEscape(msg) : msg;
    msg = this.javaScriptEscape ? JavaScriptUtils.javaScriptEscape(msg) : msg;

    // Expose as variable, if demanded, else write to the page.
    String resolvedVar = ExpressionEvaluationUtils.evaluateString("var", this.var, this.pageContext);
    if (resolvedVar != null) {
        String resolvedScope = ExpressionEvaluationUtils.evaluateString("scope", this.scope, this.pageContext);
        this.pageContext.setAttribute(resolvedVar, msg, TagUtils.getScope(resolvedScope));
    } else {/*w  ww.  j  ava 2  s. c  om*/
        writeMessage(msg);
    }

    return EVAL_PAGE;
}

From source file:com.seajas.search.utilities.tags.MessageTag.java

/**
 * Put the actual internal processing in here.
 * //from  w  ww . jav a 2  s .  c  om
 * @return
 * @throws JspException
 */
@Override
public int doEndTag() throws JspException {
    try {
        // Resolve the unescaped message.
        String msg = resolveMessage();

        // HTML and/or JavaScript escape, if demanded.
        msg = isHtmlEscape() ? HtmlUtils.htmlEscape(msg) : msg;
        msg = this.javaScriptEscape ? JavaScriptUtils.javaScriptEscape(msg) : msg;

        // Expose as variable, if demanded, else write to the page.
        String resolvedVar = ExpressionEvaluationUtils.evaluateString("var", this.var, pageContext);
        if (resolvedVar != null) {
            String resolvedScope = ExpressionEvaluationUtils.evaluateString("scope", this.scope, pageContext);
            pageContext.setAttribute(resolvedVar, msg, TagUtils.getScope(resolvedScope));
        } else {
            try {
                writeMessage(msg);
            } catch (IOException e) {
                throw new JspException(e);
            }
        }

        return super.doAfterBody();
    } catch (NoSuchMessageException ex) {
        throw new JspTagException(getNoSuchMessageExceptionDescription(ex));
    }
}

From source file:com.ei.itop.common.tag.MessageTag.java

/**
 * Resolves the message, escapes it if demanded,
 * and writes it to the page (or exposes it as variable).
 * @see #resolveMessage()//from  w  w  w .j a va  2s . co  m
 * @see org.springframework.web.util.HtmlUtils#htmlEscape(String)
 * @see org.springframework.web.util.JavaScriptUtils#javaScriptEscape(String)
 * @see #writeMessage(String)
 */
@Override
protected final int doStartTagInternal() throws JspException, IOException {
    try {
        // Resolve the unescaped message.
        String msg = resolveMessage();

        // HTML and/or JavaScript escape, if demanded.
        msg = isHtmlEscape() ? HtmlUtils.htmlEscape(msg) : msg;
        msg = this.javaScriptEscape ? JavaScriptUtils.javaScriptEscape(msg) : msg;

        // Expose as variable, if demanded, else write to the page.
        String resolvedVar = ExpressionEvaluationUtils.evaluateString("var", this.var, pageContext);
        if (resolvedVar != null) {
            String resolvedScope = ExpressionEvaluationUtils.evaluateString("scope", this.scope, pageContext);
            pageContext.setAttribute(resolvedVar, msg, TagUtils.getScope(resolvedScope));
        } else {
            writeMessage(msg);
        }

        return EVAL_BODY_INCLUDE;
    } catch (NoSuchMessageException ex) {
        throw new JspTagException(getNoSuchMessageExceptionDescription(ex));
    }
}

From source file:org.openmrs.web.taglib.OpenmrsMessageTag.java

/**
 * @see MessageTag#doStartTagInternal()//from  w  w w  .  j ava 2s.  c om
 * @should evaluate specified message resolvable
 * @should resolve message by code
 * @should resolve message in locale that different from default
 * @should return code if no message resolved
 * @should use body content as fallback if no message resolved
 * @should use text attribute as fallback if no message resolved
 * @should use body content in prior to text attribute as fallback if no message resolved
 * @should ignore fallbacks if tag locale differs from context locale
 */
@Override
protected int doEndTagInternal() throws JspException, IOException {
    try {
        // Resolve the unescaped message.
        String msg = resolveMessage();

        // HTML and/or JavaScript escape, if demanded.
        msg = isHtmlEscape() ? HtmlUtils.htmlEscape(msg) : msg;
        msg = this.javaScriptEscape ? JavaScriptUtils.javaScriptEscape(msg) : msg;

        // Expose as variable, if demanded, else write to the page.
        String resolvedVar = this.var;
        if (resolvedVar != null) {
            pageContext.setAttribute(resolvedVar, msg, TagUtils.getScope(this.scope));
        } else {
            writeMessage(msg);
        }

        return EVAL_PAGE;
    } catch (NoSuchMessageException ex) {
        throw new JspTagException(getNoSuchMessageExceptionDescription(ex));
    }
}

From source file:org.osaf.cosmo.ui.jsp.tag.SimpleVarSetterTag.java

/**
 *///from w w w.  jav  a  2s. c om
public void doTag() throws JspException, IOException {
    getJspContext().setAttribute(var, computeValue(), TagUtils.getScope(scope));
}