1 7 package org.ejtools.servlet.http.jsp.tagext; 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 29 public class HiddenObjectTag extends TagSupport 30 { 31 32 protected String id = null; 33 34 protected String name = null; 35 36 protected String property = null; 37 38 protected String scope = null; 39 40 41 47 public int doStartTag() 48 throws JspException 49 { 50 Object object = null; 51 52 if (property != null) 54 { 55 object = RequestUtils.lookup(pageContext, this.name, this.property, this.scope); 56 } 57 else 58 { 59 object = RequestUtils.lookup(pageContext, this.name, this.scope); 60 } 61 62 if (object == null) 63 { 64 throw new JspException ("Unable to find bean " + this.name + " or its property " + this.property); 65 } 66 67 StringBuffer output = new StringBuffer (); 69 output.append("<input type=\"hidden\" name=\""); 70 output.append(this.id); 71 output.append("\" value=\""); 72 output.append(ResponseUtils.filter(object.toString())); 73 output.append("\"/>"); 74 75 ResponseUtils.write(pageContext, output.toString()); 76 77 return (SKIP_BODY); 79 } 80 81 82 90 public String getId() 91 { 92 return this.id; 93 } 94 95 96 104 public String getName() 105 { 106 return this.name; 107 } 108 109 110 118 public String getProperty() 119 { 120 return this.property; 121 } 122 123 124 132 public String getScope() 133 { 134 return this.scope; 135 } 136 137 138 139 public void release() 140 { 141 super.release(); 142 this.id = null; 143 this.name = null; 144 this.property = null; 145 this.scope = null; 146 } 147 148 149 154 public void setId(String id) 155 { 156 this.id = id; 157 } 158 159 160 165 public void setName(String name) 166 { 167 this.name = name; 168 } 169 170 171 176 public void setProperty(String property) 177 { 178 this.property = property; 179 } 180 181 182 187 public void setScope(String scope) 188 { 189 this.scope = scope; 190 } 191 } 192 193 | Popular Tags |