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 import org.apache.struts.util.MessageResources; 25 26 31 public class SubmitTag extends BaseHandlerTag { 32 33 34 36 37 40 protected static MessageResources messages = 41 MessageResources.getMessageResources(Constants.Package + ".LocalStrings"); 42 43 44 47 protected String property = null; 48 49 50 53 protected String text = null; 54 55 56 59 protected String value = null; 60 61 62 64 65 68 public String getProperty() { 69 70 return (this.property); 71 72 } 73 74 75 80 public void setProperty(String property) { 81 82 this.property = property; 83 84 } 85 86 87 90 public String getValue() { 91 92 return (this.value); 93 94 } 95 96 97 102 public void setValue(String value) { 103 104 this.value = value; 105 106 } 107 108 109 111 112 117 public int doStartTag() throws JspException { 118 119 this.text = null; 121 return (EVAL_BODY_TAG); 122 123 } 124 125 126 127 132 public int doAfterBody() throws JspException { 133 134 if (bodyContent != null) { 135 String value = bodyContent.getString().trim(); 136 if (value.length() > 0) { 137 text = value; 138 } 139 } 140 return (SKIP_BODY); 141 142 } 143 144 145 152 public int doEndTag() throws JspException { 153 154 StringBuffer results = new StringBuffer (); 156 results.append(getElementOpen()); 157 prepareAttribute(results, "name", prepareName()); 158 prepareButtonAttributes(results); 159 results.append(prepareEventHandlers()); 160 results.append(prepareStyles()); 161 prepareOtherAttributes(results); 162 results.append(getElementClose()); 163 164 TagUtils.getInstance().write(pageContext, results.toString()); 165 166 return (EVAL_PAGE); 167 168 } 169 170 175 protected String getElementOpen() { 176 return "<input type=\"submit\""; 177 } 178 179 180 184 protected String prepareName() throws JspException { 185 186 if (property == null) { 187 return null; 188 } 189 190 if(indexed) { 192 StringBuffer results = new StringBuffer (); 193 results.append(property); 194 prepareIndex(results, null); 195 return results.toString(); 196 } 197 198 return property; 199 200 } 201 202 206 protected void prepareButtonAttributes(StringBuffer results) 207 throws JspException { 208 prepareAttribute(results, "accesskey", getAccesskey()); 209 prepareAttribute(results, "tabindex", getTabindex()); 210 prepareValue(results); 211 } 212 213 217 protected void prepareValue(StringBuffer results) { 218 219 String label = value; 221 if ((label == null) && (text != null)) 222 label = text; 223 if ((label == null) || (label.length() < 1)) 224 label = getDefaultValue(); 225 226 prepareAttribute(results, "value", label); 227 228 } 229 230 235 protected String getDefaultValue() { 236 return "Submit"; 237 } 238 239 242 public void release() { 243 244 super.release(); 245 property = null; 246 text = null; 247 value = null; 248 249 } 250 251 252 } 253 | Popular Tags |