1 2 3 27 28 package org.apache.jasper.tagplugins.jstl; 29 30 import org.apache.jasper.compiler.tagplugin.*; 31 32 public final class If implements TagPlugin { 33 34 public void doTag(TagPluginContext ctxt) { 35 String condV = ctxt.getTemporaryVariableName(); 36 ctxt.generateJavaSource("boolean " + condV + "="); 37 ctxt.generateAttribute("test"); 38 ctxt.generateJavaSource(";"); 39 if (ctxt.isAttributeSpecified("var")) { 40 String scope = "PageContext.PAGE_SCOPE"; 41 if (ctxt.isAttributeSpecified("scope")) { 42 String scopeStr = ctxt.getConstantAttribute("scope"); 43 if ("request".equals(scopeStr)) { 44 scope = "PageContext.REQUEST_SCOPE"; 45 } else if ("session".equals(scopeStr)) { 46 scope = "PageContext.SESSION_SCOPE"; 47 } else if ("application".equals(scopeStr)) { 48 scope = "PageContext.APPLICATION_SCOPE"; 49 } 50 } 51 ctxt.generateJavaSource("_jspx_page_context.setAttribute("); 52 ctxt.generateAttribute("var"); 53 ctxt.generateJavaSource(", new Boolean(" + condV + ")," + scope + ");"); 54 } 55 ctxt.generateJavaSource("if (" + condV + "){"); 56 ctxt.generateBody(); 57 ctxt.generateJavaSource("}"); 58 } 59 } 60 | Popular Tags |