1 7 package org.ejtools.servlet.http.jsp.tagext.tree; 8 9 import javax.servlet.jsp.JspException ; 10 import javax.servlet.jsp.tagext.TagSupport ; 11 12 import org.apache.struts.util.RequestUtils; 13 import org.apache.struts.util.ResponseUtils; 14 15 16 24 public class TreeNameRendererTag extends TagSupport 25 { 26 27 protected String className = null; 28 29 protected String name = null; 30 31 protected String property = null; 32 33 protected String scope = null; 34 35 36 42 public int doStartTag() 43 throws JspException 44 { 45 String display = null; 46 Object o = null; 47 48 if (property != null) 49 { 50 o = RequestUtils.lookup(pageContext, name, property, scope); 51 } 52 else 53 { 54 o = RequestUtils.lookup(pageContext, name, scope); 55 } 56 57 if (o == null) 58 { 59 return (SKIP_BODY); 60 } 61 62 try 63 { 64 TreeRenderer renderer = (TreeRenderer) Class.forName(this.className).newInstance(); 65 66 display = renderer.getDisplayName(o); 67 } 68 catch (Exception e) 69 { 70 display = null; 71 } 72 if (display == null) 73 { 74 display = ""; 75 } 76 77 ResponseUtils.write(pageContext, display); 78 79 return (SKIP_BODY); 81 } 82 83 84 90 public String getName() 91 { 92 return (this.name); 93 } 94 95 96 102 public String getProperty() 103 { 104 return (this.property); 105 } 106 107 108 114 public String getRenderer() 115 { 116 return (this.className); 117 } 118 119 120 126 public String getScope() 127 { 128 return (this.scope); 129 } 130 131 132 133 134 public void release() 135 { 136 super.release(); 137 scope = null; 138 className = null; 139 property = null; 140 name = null; 141 } 142 143 144 149 public void setName(String name) 150 { 151 this.name = name; 152 } 153 154 155 160 public void setProperty(String property) 161 { 162 this.property = property; 163 } 164 165 166 171 public void setRenderer(String className) 172 { 173 this.className = className; 174 } 175 176 177 182 public void setScope(String scope) 183 { 184 this.scope = scope; 185 } 186 } 187 | Popular Tags |