1 23 24 package org.dbforms.taglib; 25 26 import org.dbforms.event.WebEvent; 27 import org.dbforms.event.eventtype.EventType; 28 29 import org.dbforms.util.Util; 30 31 import java.util.Vector ; 32 33 import javax.servlet.http.HttpServletRequest ; 34 import javax.servlet.jsp.JspException ; 35 36 37 38 44 public abstract class DbBaseInputTag extends DbBaseHandlerTag { 45 48 private String cols = null; 49 50 51 private java.lang.String hidden = "false"; 52 53 54 private String maxlength = null; 55 56 57 private java.lang.String overrideValue; 58 59 60 private String rows = null; 61 62 67 public void setCols(String cols) { 68 this.cols = cols; 69 } 70 71 72 74 79 public String getCols() { 80 return (this.cols); 81 } 82 83 84 90 public void setHidden(java.lang.String newHidden) { 91 hidden = newHidden; 92 } 93 94 95 100 public void setMaxlength(String maxlength) { 101 this.maxlength = maxlength; 102 } 103 104 105 110 public String getMaxlength() { 111 return (this.maxlength); 112 } 113 114 115 121 public void setOverrideValue(java.lang.String newOverrideValue) { 122 overrideValue = newOverrideValue; 123 } 124 125 126 132 public java.lang.String getOverrideValue() { 133 return overrideValue; 134 } 135 136 137 142 public void setRows(String rows) { 143 this.rows = rows; 144 } 145 146 147 152 public String getRows() { 153 return (this.rows); 154 } 155 156 157 162 public void setSize(String size) { 163 setCols(size); 164 } 165 166 167 172 public String getSize() { 173 return (getCols()); 174 } 175 176 177 184 public int doEndTag() throws JspException { 185 return EVAL_PAGE; 186 } 187 188 189 192 public void doFinally() { 193 cols = null; 194 maxlength = null; 195 rows = null; 196 super.doFinally(); 197 } 198 199 200 202 209 public int doStartTag() throws JspException { 210 if (hasReadOnlySet() || getParentForm() 211 .hasReadOnlySet()) { 212 String onFocus = (getOnFocus() != null) ? getOnFocus() 213 : ""; 214 215 if (onFocus.lastIndexOf(";") != (onFocus.length() - 1)) { 216 onFocus += ";"; } 218 219 setOnFocus(onFocus + "this.blur();"); 220 } 221 222 return EVAL_BODY_BUFFERED; 223 } 224 225 226 232 public boolean hasHiddenSet() { 233 return Util.getTrue(hidden); 234 } 235 236 237 242 protected String getFormFieldValue() { 243 String res; 244 245 248 HttpServletRequest request = (HttpServletRequest ) this.pageContext 249 .getRequest(); 250 Vector errors = (Vector ) request.getAttribute("errors"); 251 WebEvent we = getParentForm() 252 .getWebEvent(); 253 254 if ((this.getOverrideValue() != null) 255 && !((getParentForm() 256 .hasRedisplayFieldsOnErrorSet() 257 && (errors != null) && (errors.size() > 0)) 258 || ((we != null) 259 && (we.getType().equals(EventType.EVENT_NAVIGATION_RELOAD))))) { 260 res = getOverrideValue(); 261 } else { 263 res = super.getFormFieldValue(); 264 } 265 266 return res; 267 } 268 269 270 275 protected String prepareKeys() { 276 StringBuffer tagBuf = new StringBuffer (); 277 278 if (getAccessKey() != null) { 279 tagBuf.append(" accesskey=\""); 280 tagBuf.append(getAccessKey()); 281 tagBuf.append("\""); 282 } 283 284 if (getTabIndex() != null) { 285 tagBuf.append(" tabindex=\""); 286 tagBuf.append(getTabIndex()); 287 tagBuf.append("\""); 288 } 289 290 return tagBuf.toString(); 291 } 292 293 294 299 protected String prepareName() { 300 StringBuffer tagBuf = new StringBuffer (); 301 tagBuf.append("name=\""); 302 tagBuf.append(getFormFieldName()); 303 tagBuf.append("\""); 304 305 return tagBuf.toString(); 306 } 307 308 309 314 protected String prepareSize() { 315 StringBuffer tagBuf = new StringBuffer (); 316 317 if (getMaxlength() != null) { 318 tagBuf.append(" maxlength=\""); 319 tagBuf.append(getMaxlength()); 320 tagBuf.append("\""); 321 } 322 323 if (getCols() != null) { 324 tagBuf.append(" size=\""); 325 tagBuf.append(getCols()); 326 tagBuf.append("\""); 327 } 328 329 return tagBuf.toString(); 330 } 331 332 333 338 protected String prepareType() { 339 return hasHiddenSet() ? "type=\"hidden\" " 340 : "type=\"text\" "; 341 } 342 343 344 349 protected String prepareValue() { 350 StringBuffer tagBuf = new StringBuffer (); 351 tagBuf.append(" value=\""); 352 tagBuf.append(escapeHTML(getFormFieldValue())); 353 tagBuf.append("\" "); 354 355 return tagBuf.toString(); 356 } 357 358 359 362 protected void writeOutSpecialValues() throws JspException { 363 super.writeOutSpecialValues(); 364 365 try { 366 pageContext.getOut() 367 .write(renderPatternHtmlInputField()); 368 } catch (java.io.IOException ioe) { 369 throw new JspException ("IO Error: " + ioe.getMessage()); 370 } 371 } 372 } 373 | Popular Tags |