Search in sources :

Example 1 with VariableInfo

use of jakarta.servlet.jsp.tagext.VariableInfo in project tomcat by apache.

the class Generator method declareTemporaryScriptingVars.

private void declareTemporaryScriptingVars(Node.Nodes page) throws JasperException {
    class ScriptingVarVisitor extends Node.Visitor {

        private final Vector<String> vars;

        ScriptingVarVisitor() {
            vars = new Vector<>();
        }

        @Override
        public void visit(Node.CustomTag n) throws JasperException {
            if (n.getCustomNestingLevel() > 0) {
                TagVariableInfo[] tagVarInfos = n.getTagVariableInfos();
                VariableInfo[] varInfos = n.getVariableInfos();
                if (varInfos.length > 0) {
                    for (VariableInfo varInfo : varInfos) {
                        String varName = varInfo.getVarName();
                        String tmpVarName = "_jspx_" + varName + "_" + n.getCustomNestingLevel();
                        if (!vars.contains(tmpVarName)) {
                            vars.add(tmpVarName);
                            out.printin(varInfo.getClassName());
                            out.print(" ");
                            out.print(tmpVarName);
                            out.print(" = ");
                            out.print(null);
                            out.println(";");
                        }
                    }
                } else {
                    for (TagVariableInfo tagVarInfo : tagVarInfos) {
                        String varName = tagVarInfo.getNameGiven();
                        if (varName == null) {
                            varName = n.getTagData().getAttributeString(tagVarInfo.getNameFromAttribute());
                        } else if (tagVarInfo.getNameFromAttribute() != null) {
                            // alias
                            continue;
                        }
                        String tmpVarName = "_jspx_" + varName + "_" + n.getCustomNestingLevel();
                        if (!vars.contains(tmpVarName)) {
                            vars.add(tmpVarName);
                            out.printin(tagVarInfo.getClassName());
                            out.print(" ");
                            out.print(tmpVarName);
                            out.print(" = ");
                            out.print(null);
                            out.println(";");
                        }
                    }
                }
            }
            visitBody(n);
        }
    }
    page.visit(new ScriptingVarVisitor());
}
Also used : TagVariableInfo(jakarta.servlet.jsp.tagext.TagVariableInfo) VariableInfo(jakarta.servlet.jsp.tagext.VariableInfo) TagVariableInfo(jakarta.servlet.jsp.tagext.TagVariableInfo) Vector(java.util.Vector)

Aggregations

TagVariableInfo (jakarta.servlet.jsp.tagext.TagVariableInfo)1 VariableInfo (jakarta.servlet.jsp.tagext.VariableInfo)1 Vector (java.util.Vector)1