1 17 18 19 package org.apache.jasper.tagplugins.jstl.core; 20 21 import org.apache.jasper.compiler.tagplugin.*; 22 23 public final class If implements TagPlugin { 24 25 public void doTag(TagPluginContext ctxt) { 26 String condV = ctxt.getTemporaryVariableName(); 27 ctxt.generateJavaSource("boolean " + condV + "="); 28 ctxt.generateAttribute("test"); 29 ctxt.generateJavaSource(";"); 30 if (ctxt.isAttributeSpecified("var")) { 31 String scope = "PageContext.PAGE_SCOPE"; 32 if (ctxt.isAttributeSpecified("scope")) { 33 String scopeStr = ctxt.getConstantAttribute("scope"); 34 if ("request".equals(scopeStr)) { 35 scope = "PageContext.REQUEST_SCOPE"; 36 } else if ("session".equals(scopeStr)) { 37 scope = "PageContext.SESSION_SCOPE"; 38 } else if ("application".equals(scopeStr)) { 39 scope = "PageContext.APPLICATION_SCOPE"; 40 } 41 } 42 ctxt.generateJavaSource("_jspx_page_context.setAttribute("); 43 ctxt.generateAttribute("var"); 44 ctxt.generateJavaSource(", new Boolean(" + condV + ")," + scope + ");"); 45 } 46 ctxt.generateJavaSource("if (" + condV + "){"); 47 ctxt.generateBody(); 48 ctxt.generateJavaSource("}"); 49 } 50 } 51 | Popular Tags |