1 18 19 package org.apache.struts.taglib.html; 20 21 import javax.servlet.jsp.JspException ; 22 23 import org.apache.struts.taglib.TagUtils; 24 25 30 31 public abstract class BaseFieldTag extends BaseInputTag { 32 33 35 41 protected String accept = null; 42 43 public String getAccept() { 44 return (this.accept); 45 } 46 47 public void setAccept(String accept) { 48 this.accept = accept; 49 } 50 51 54 protected boolean redisplay = true; 55 56 public boolean getRedisplay() { 57 return (this.redisplay); 58 } 59 60 public void setRedisplay(boolean redisplay) { 61 this.redisplay = redisplay; 62 } 63 64 68 protected String type = null; 69 70 72 79 public int doStartTag() throws JspException { 80 81 TagUtils.getInstance().write(this.pageContext, this.renderInputElement()); 82 83 return (EVAL_BODY_TAG); 84 85 } 86 87 92 protected String renderInputElement() throws JspException { 93 StringBuffer results = new StringBuffer ("<input"); 94 95 prepareAttribute(results, "type", this.type); 96 prepareAttribute(results, "name", prepareName()); 97 prepareAttribute(results, "accesskey", getAccesskey()); 98 prepareAttribute(results, "accept", getAccept()); 99 prepareAttribute(results, "maxlength", getMaxlength()); 100 prepareAttribute(results, "size", getCols()); 101 prepareAttribute(results, "tabindex", getTabindex()); 102 prepareValue(results); 103 results.append(this.prepareEventHandlers()); 104 results.append(this.prepareStyles()); 105 prepareOtherAttributes(results); 106 results.append(this.getElementClose()); 107 return results.toString(); 108 } 109 110 114 protected void prepareValue(StringBuffer results) throws JspException { 115 116 results.append(" value=\""); 117 if (value != null) { 118 results.append(this.formatValue(value)); 119 120 } else if (redisplay || !"password".equals(type)) { 121 Object value = 122 TagUtils.getInstance().lookup(pageContext, name, property, null); 123 124 results.append(this.formatValue(value)); 125 } 126 127 results.append('"'); 128 129 } 130 131 142 protected String formatValue(Object value) throws JspException { 143 if (value == null) { 144 return ""; 145 } 146 147 return TagUtils.getInstance().filter(value.toString()); 148 } 149 150 153 public void release() { 154 155 super.release(); 156 accept = null; 157 name = Constants.BEAN_KEY; 158 redisplay = true; 159 160 } 161 162 } 163 | Popular Tags |