Java Code Examples for javax.servlet.jsp.tagext.VariableInfo#AT_END

The following examples show how to use javax.servlet.jsp.tagext.VariableInfo#AT_END . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Node.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
public List<Object> getScriptingVars(int scope) {
    List<Object> vec = null;

    switch (scope) {
    case VariableInfo.AT_BEGIN:
        vec = this.atBeginScriptingVars;
        break;
    case VariableInfo.AT_END:
        vec = this.atEndScriptingVars;
        break;
    case VariableInfo.NESTED:
        vec = this.nestedScriptingVars;
        break;
    }

    return vec;
}
 
Example 2
Source File: JspContextWrapper.java    From packagedrone with Eclipse Public License 1.0 5 votes vote down vote up
/**
    * Copies the variables of the given scope from the virtual page scope of
    * this JSP context wrapper to the page scope of the invoking JSP context.
    *
    * @param scope variable scope (one of NESTED, AT_BEGIN, or AT_END)
    */
   private void copyTagToPageScope(int scope) {
Iterator<String> iter = null;

switch (scope) {
case VariableInfo.NESTED:
    if (nestedVars != null) {
	iter = nestedVars.iterator();
    }
    break;
case VariableInfo.AT_BEGIN:
    if (atBeginVars != null) {
	iter = atBeginVars.iterator();
    }
    break;
case VariableInfo.AT_END:
    if (atEndVars != null) {
	iter = atEndVars.iterator();
    }
    break;
}

while ((iter != null) && iter.hasNext()) {
    String varName = iter.next();
    Object obj = getAttribute(varName);
    varName = findAlias(varName);
    if (obj != null) {
	invokingJspCtxt.setAttribute(varName, obj);
    } else {
	invokingJspCtxt.removeAttribute(varName, PAGE_SCOPE);
    }
}
   }
 
Example 3
Source File: TldRuleSet.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
public void setScope(String scopeName) {
    switch (scopeName) {
        case "NESTED":
            scope = VariableInfo.NESTED;
            break;
        case "AT_BEGIN":
            scope = VariableInfo.AT_BEGIN;
            break;
        case "AT_END":
            scope = VariableInfo.AT_END;
            break;
    }
}
 
Example 4
Source File: PagerTagExtraInfo.java    From feilong-taglib with Apache License 2.0 5 votes vote down vote up
@Override
public VariableInfo[] getVariableInfo(TagData tagData){
    //如果不设置 使用 ${feilongPagerHtml1 } 是正常的
    //但是如果使用 <%=feilongPagerHtml1%> 会提示 feilongPagerHtml1 cannot be resolved to a variable

    String pagerHtmlAttributeName = defaultIfNullOrEmpty(
                    tagData.getAttributeString("pagerHtmlAttributeName"),
                    DEFAULT_PAGE_ATTRIBUTE_PAGER_HTML_NAME);

    VariableInfo variableInfo = new VariableInfo(pagerHtmlAttributeName, String.class.getName(), true, VariableInfo.AT_END);
    return ConvertUtil.toArray(variableInfo);
}
 
Example 5
Source File: Node.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
public void setScriptingVars(List<Object> vec, int scope) {
    switch (scope) {
    case VariableInfo.AT_BEGIN:
        this.atBeginScriptingVars = vec;
        break;
    case VariableInfo.AT_END:
        this.atEndScriptingVars = vec;
        break;
    case VariableInfo.NESTED:
        this.nestedScriptingVars = vec;
        break;
    }
}
 
Example 6
Source File: JspContextWrapper.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
/**
 * Copies the variables of the given scope from the virtual page scope of
 * this JSP context wrapper to the page scope of the invoking JSP context.
 * 
 * @param scope
 *            variable scope (one of NESTED, AT_BEGIN, or AT_END)
 */
private void copyTagToPageScope(int scope) {
    Iterator<String> iter = null;

    switch (scope) {
    case VariableInfo.NESTED:
        if (nestedVars != null) {
            iter = nestedVars.iterator();
        }
        break;
    case VariableInfo.AT_BEGIN:
        if (atBeginVars != null) {
            iter = atBeginVars.iterator();
        }
        break;
    case VariableInfo.AT_END:
        if (atEndVars != null) {
            iter = atEndVars.iterator();
        }
        break;
    }

    while ((iter != null) && iter.hasNext()) {
        String varName = iter.next();
        Object obj = getAttribute(varName);
        varName = findAlias(varName);
        if (obj != null) {
            invokingJspCtxt.setAttribute(varName, obj);
        } else {
            invokingJspCtxt.removeAttribute(varName, PAGE_SCOPE);
        }
    }
}
 
Example 7
Source File: TestScriptingVariabler.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
/**
 * Return information about the scripting variables to be created.
 */
@Override
public VariableInfo[] getVariableInfo(TagData data) {
    return new VariableInfo[] {
        new VariableInfo("Test", "java.lang.String", true,
            VariableInfo.AT_END)
    };
}
 
Example 8
Source File: TestGenerator.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
@Override
public VariableInfo[] getVariableInfo(TagData data) {
    return new VariableInfo[] {
            new VariableInfo("now", Bean.class.getCanonicalName(),
                    true, VariableInfo.AT_END)
        };
}
 
Example 9
Source File: Node.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
public void setScriptingVars(List<Object> vec, int scope) {
    switch (scope) {
    case VariableInfo.AT_BEGIN:
        this.atBeginScriptingVars = vec;
        break;
    case VariableInfo.AT_END:
        this.atEndScriptingVars = vec;
        break;
    case VariableInfo.NESTED:
        this.nestedScriptingVars = vec;
        break;
    }
}
 
Example 10
Source File: JspContextWrapper.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
/**
 * Copies the variables of the given scope from the virtual page scope of
 * this JSP context wrapper to the page scope of the invoking JSP context.
 * 
 * @param scope
 *            variable scope (one of NESTED, AT_BEGIN, or AT_END)
 */
private void copyTagToPageScope(int scope) {
    Iterator<String> iter = null;

    switch (scope) {
    case VariableInfo.NESTED:
        if (nestedVars != null) {
            iter = nestedVars.iterator();
        }
        break;
    case VariableInfo.AT_BEGIN:
        if (atBeginVars != null) {
            iter = atBeginVars.iterator();
        }
        break;
    case VariableInfo.AT_END:
        if (atEndVars != null) {
            iter = atEndVars.iterator();
        }
        break;
    }

    while ((iter != null) && iter.hasNext()) {
        String varName = iter.next();
        Object obj = getAttribute(varName);
        varName = findAlias(varName);
        if (obj != null) {
            invokingJspCtxt.setAttribute(varName, obj);
        } else {
            invokingJspCtxt.removeAttribute(varName, PAGE_SCOPE);
        }
    }
}
 
Example 11
Source File: TestScriptingVariabler.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
/**
 * Return information about the scripting variables to be created.
 */
@Override
public VariableInfo[] getVariableInfo(TagData data) {
    return new VariableInfo[] {
        new VariableInfo("Test", "java.lang.String", true,
            VariableInfo.AT_END)
    };
}
 
Example 12
Source File: TestGenerator.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
@Override
public VariableInfo[] getVariableInfo(TagData data) {
    return new VariableInfo[] {
            new VariableInfo("now", Bean.class.getCanonicalName(),
                    true, VariableInfo.AT_END)
        };
}
 
Example 13
Source File: Node.java    From packagedrone with Eclipse Public License 1.0 5 votes vote down vote up
public ArrayList<Object> getScriptingVars(int scope) {
    switch (scope) {
    case VariableInfo.AT_BEGIN:
	return this.atBeginScriptingVars;
    case VariableInfo.AT_END:
	return this.atEndScriptingVars;
    case VariableInfo.NESTED:
	return this.nestedScriptingVars;
    }
    return null;
}
 
Example 14
Source File: Generator.java    From Tomcat7.0.67 with Apache License 2.0 4 votes vote down vote up
private void generateSetJspContext(TagInfo tagInfo) {

        boolean nestedSeen = false;
        boolean atBeginSeen = false;
        boolean atEndSeen = false;

        // Determine if there are any aliases
        boolean aliasSeen = false;
        TagVariableInfo[] tagVars = tagInfo.getTagVariableInfos();
        for (int i = 0; i < tagVars.length; i++) {
            if (tagVars[i].getNameFromAttribute() != null
                    && tagVars[i].getNameGiven() != null) {
                aliasSeen = true;
                break;
            }
        }

        if (aliasSeen) {
            out.printil("public void setJspContext(javax.servlet.jsp.JspContext ctx, java.util.Map aliasMap) {");
        } else {
            out.printil("public void setJspContext(javax.servlet.jsp.JspContext ctx) {");
        }
        out.pushIndent();
        out.printil("super.setJspContext(ctx);");
        out.printil("java.util.ArrayList _jspx_nested = null;");
        out.printil("java.util.ArrayList _jspx_at_begin = null;");
        out.printil("java.util.ArrayList _jspx_at_end = null;");

        for (int i = 0; i < tagVars.length; i++) {

            switch (tagVars[i].getScope()) {
            case VariableInfo.NESTED:
                if (!nestedSeen) {
                    out.printil("_jspx_nested = new java.util.ArrayList();");
                    nestedSeen = true;
                }
                out.printin("_jspx_nested.add(");
                break;

            case VariableInfo.AT_BEGIN:
                if (!atBeginSeen) {
                    out.printil("_jspx_at_begin = new java.util.ArrayList();");
                    atBeginSeen = true;
                }
                out.printin("_jspx_at_begin.add(");
                break;

            case VariableInfo.AT_END:
                if (!atEndSeen) {
                    out.printil("_jspx_at_end = new java.util.ArrayList();");
                    atEndSeen = true;
                }
                out.printin("_jspx_at_end.add(");
                break;
            } // switch

            out.print(quote(tagVars[i].getNameGiven()));
            out.println(");");
        }
        if (aliasSeen) {
            out.printil("this.jspContext = new org.apache.jasper.runtime.JspContextWrapper(ctx, _jspx_nested, _jspx_at_begin, _jspx_at_end, aliasMap);");
        } else {
            out.printil("this.jspContext = new org.apache.jasper.runtime.JspContextWrapper(ctx, _jspx_nested, _jspx_at_begin, _jspx_at_end, null);");
        }
        out.popIndent();
        out.printil("}");
        out.println();
        out.printil("public javax.servlet.jsp.JspContext getJspContext() {");
        out.pushIndent();
        out.printil("return this.jspContext;");
        out.popIndent();
        out.printil("}");
    }
 
Example 15
Source File: TagFileProcessor.java    From Tomcat7.0.67 with Apache License 2.0 4 votes vote down vote up
@Override
public void visit(Node.VariableDirective n) throws JasperException {

    JspUtil.checkAttributes("Variable directive", n,
            variableDirectiveAttrs, err);

    String nameGiven = n.getAttributeValue("name-given");
    String nameFromAttribute = n
            .getAttributeValue("name-from-attribute");
    if (nameGiven == null && nameFromAttribute == null) {
        err.jspError("jsp.error.variable.either.name");
    }

    if (nameGiven != null && nameFromAttribute != null) {
        err.jspError("jsp.error.variable.both.name");
    }

    String alias = n.getAttributeValue("alias");
    if (nameFromAttribute != null && alias == null
            || nameFromAttribute == null && alias != null) {
        err.jspError("jsp.error.variable.alias");
    }

    String className = n.getAttributeValue("variable-class");
    if (className == null)
        className = "java.lang.String";

    String declareStr = n.getAttributeValue("declare");
    boolean declare = true;
    if (declareStr != null)
        declare = JspUtil.booleanValue(declareStr);

    int scope = VariableInfo.NESTED;
    String scopeStr = n.getAttributeValue("scope");
    if (scopeStr != null) {
        if ("NESTED".equals(scopeStr)) {
            // Already the default
        } else if ("AT_BEGIN".equals(scopeStr)) {
            scope = VariableInfo.AT_BEGIN;
        } else if ("AT_END".equals(scopeStr)) {
            scope = VariableInfo.AT_END;
        }
    }

    if (nameFromAttribute != null) {
        /*
         * An alias has been specified. We use 'nameGiven' to hold the
         * value of the alias, and 'nameFromAttribute' to hold the name
         * of the attribute whose value (at invocation-time) denotes the
         * name of the variable that is being aliased
         */
        nameGiven = alias;
        checkUniqueName(nameFromAttribute, VAR_NAME_FROM, n);
        checkUniqueName(alias, VAR_ALIAS, n);
    } else {
        // name-given specified
        checkUniqueName(nameGiven, VAR_NAME_GIVEN, n);
    }

    variableVector.addElement(new TagVariableInfo(nameGiven,
            nameFromAttribute, className, declare, scope));
}
 
Example 16
Source File: TagFileProcessor.java    From Tomcat8-Source-Read with MIT License 4 votes vote down vote up
@Override
public void visit(Node.VariableDirective n) throws JasperException {

    JspUtil.checkAttributes("Variable directive", n,
            variableDirectiveAttrs, err);

    String nameGiven = n.getAttributeValue("name-given");
    String nameFromAttribute = n
            .getAttributeValue("name-from-attribute");
    if (nameGiven == null && nameFromAttribute == null) {
        err.jspError("jsp.error.variable.either.name");
    }

    if (nameGiven != null && nameFromAttribute != null) {
        err.jspError("jsp.error.variable.both.name");
    }

    String alias = n.getAttributeValue("alias");
    if (nameFromAttribute != null && alias == null
            || nameFromAttribute == null && alias != null) {
        err.jspError("jsp.error.variable.alias");
    }

    String className = n.getAttributeValue("variable-class");
    if (className == null)
        className = "java.lang.String";

    String declareStr = n.getAttributeValue("declare");
    boolean declare = true;
    if (declareStr != null)
        declare = JspUtil.booleanValue(declareStr);

    int scope = VariableInfo.NESTED;
    String scopeStr = n.getAttributeValue("scope");
    if (scopeStr != null) {
        if ("NESTED".equals(scopeStr)) {
            // Already the default
        } else if ("AT_BEGIN".equals(scopeStr)) {
            scope = VariableInfo.AT_BEGIN;
        } else if ("AT_END".equals(scopeStr)) {
            scope = VariableInfo.AT_END;
        }
    }

    if (nameFromAttribute != null) {
        /*
         * An alias has been specified. We use 'nameGiven' to hold the
         * value of the alias, and 'nameFromAttribute' to hold the name
         * of the attribute whose value (at invocation-time) denotes the
         * name of the variable that is being aliased
         */
        nameGiven = alias;
        checkUniqueName(nameFromAttribute, VAR_NAME_FROM, n);
        checkUniqueName(alias, VAR_ALIAS, n);
    } else {
        // name-given specified
        checkUniqueName(nameGiven, VAR_NAME_GIVEN, n);
    }

    variableVector.addElement(new TagVariableInfo(nameGiven,
            nameFromAttribute, className, declare, scope));
}
 
Example 17
Source File: Generator.java    From Tomcat8-Source-Read with MIT License 4 votes vote down vote up
private void generateSetJspContext(TagInfo tagInfo) {

        boolean nestedSeen = false;
        boolean atBeginSeen = false;
        boolean atEndSeen = false;

        // Determine if there are any aliases
        boolean aliasSeen = false;
        TagVariableInfo[] tagVars = tagInfo.getTagVariableInfos();
        for (int i = 0; i < tagVars.length; i++) {
            if (tagVars[i].getNameFromAttribute() != null
                    && tagVars[i].getNameGiven() != null) {
                aliasSeen = true;
                break;
            }
        }

        if (aliasSeen) {
            out.printil("public void setJspContext(javax.servlet.jsp.JspContext ctx, java.util.Map aliasMap) {");
        } else {
            out.printil("public void setJspContext(javax.servlet.jsp.JspContext ctx) {");
        }
        out.pushIndent();
        out.printil("super.setJspContext(ctx);");
        out.printil("java.util.ArrayList _jspx_nested = null;");
        out.printil("java.util.ArrayList _jspx_at_begin = null;");
        out.printil("java.util.ArrayList _jspx_at_end = null;");

        for (int i = 0; i < tagVars.length; i++) {

            switch (tagVars[i].getScope()) {
            case VariableInfo.NESTED:
                if (!nestedSeen) {
                    out.printil("_jspx_nested = new java.util.ArrayList();");
                    nestedSeen = true;
                }
                out.printin("_jspx_nested.add(");
                break;

            case VariableInfo.AT_BEGIN:
                if (!atBeginSeen) {
                    out.printil("_jspx_at_begin = new java.util.ArrayList();");
                    atBeginSeen = true;
                }
                out.printin("_jspx_at_begin.add(");
                break;

            case VariableInfo.AT_END:
                if (!atEndSeen) {
                    out.printil("_jspx_at_end = new java.util.ArrayList();");
                    atEndSeen = true;
                }
                out.printin("_jspx_at_end.add(");
                break;
            } // switch

            out.print(quote(tagVars[i].getNameGiven()));
            out.println(");");
        }
        if (aliasSeen) {
            out.printil("this.jspContext = new org.apache.jasper.runtime.JspContextWrapper(this, ctx, _jspx_nested, _jspx_at_begin, _jspx_at_end, aliasMap);");
        } else {
            out.printil("this.jspContext = new org.apache.jasper.runtime.JspContextWrapper(this, ctx, _jspx_nested, _jspx_at_begin, _jspx_at_end, null);");
        }
        out.popIndent();
        out.printil("}");
        out.println();
        out.printil("public javax.servlet.jsp.JspContext getJspContext() {");
        out.pushIndent();
        out.printil("return this.jspContext;");
        out.popIndent();
        out.printil("}");
    }
 
Example 18
Source File: Generator.java    From packagedrone with Eclipse Public License 1.0 4 votes vote down vote up
private void generateSetJspContext(TagInfo tagInfo) {

        boolean nestedSeen = false;
        boolean atBeginSeen = false;
        boolean atEndSeen = false;

        // Determine if there are any aliases
        boolean aliasSeen = false;
        TagVariableInfo[] tagVars = tagInfo.getTagVariableInfos();
        for (int i = 0; i < tagVars.length; i++) {
            if (tagVars[i].getNameFromAttribute() != null
                && tagVars[i].getNameGiven() != null) {
                aliasSeen = true;
                break;
            }
        }

        if (aliasSeen) {
            out.printil(
                "public void setJspContext(JspContext ctx, java.util.Map aliasMap) {");
        } else {
            out.printil("public void setJspContext(JspContext ctx) {");
        }
        out.pushIndent();
        out.printil("super.setJspContext(ctx);");
        out.printil("java.util.ArrayList<String> _jspx_nested = null;");
        out.printil("java.util.ArrayList<String> _jspx_at_begin = null;");
        out.printil("java.util.ArrayList<String> _jspx_at_end = null;");

        for (int i = 0; i < tagVars.length; i++) {

            switch (tagVars[i].getScope()) {
                case VariableInfo.NESTED :
                    if (!nestedSeen) {
                        out.printil(
                            "_jspx_nested = new java.util.ArrayList<String>();");
                        nestedSeen = true;
                    }
                    out.printin("_jspx_nested.add(");
                    break;

                case VariableInfo.AT_BEGIN :
                    if (!atBeginSeen) {
                        out.printil(
                            "_jspx_at_begin = new java.util.ArrayList<String>();");
                        atBeginSeen = true;
                    }
                    out.printin("_jspx_at_begin.add(");
                    break;

                case VariableInfo.AT_END :
                    if (!atEndSeen) {
                        out.printil(
                            "_jspx_at_end = new java.util.ArrayList<String>();");
                        atEndSeen = true;
                    }
                    out.printin("_jspx_at_end.add(");
                    break;
            } // switch

            out.print(quote(tagVars[i].getNameGiven()));
            out.println(");");
        }
        if (aliasSeen) {
            out.printil(
                "this.jspContext = new org.apache.jasper.runtime.JspContextWrapper(ctx, _jspx_nested, _jspx_at_begin, _jspx_at_end, aliasMap);");
        } else {
            out.printil(
                "this.jspContext = new org.apache.jasper.runtime.JspContextWrapper(ctx, _jspx_nested, _jspx_at_begin, _jspx_at_end, null);");
        }
        out.popIndent();
        out.printil("}");
        out.println();
        out.printil("public JspContext getJspContext() {");
        out.pushIndent();
        out.printil("return this.jspContext;");
        out.popIndent();
        out.printil("}");
    }
 
Example 19
Source File: CollectionTagExtraInfo.java    From fenixedu-academic with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public VariableInfo[] getVariableInfo(TagData arg0) {
    return new VariableInfo[] { new VariableInfo("id", "java.util.Collection", true, VariableInfo.AT_END) };

}
 
Example 20
Source File: EnumDescriptionTagExtraInfo.java    From fenixedu-academic with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public VariableInfo[] getVariableInfo(TagData arg0) {
    return new VariableInfo[] { new VariableInfo("id", "java.lang.String", true, VariableInfo.AT_END) };

}