1 16 package com.blandware.atleap.webapp.taglib.core.html; 17 18 import org.apache.struts.taglib.TagUtils; 19 20 import javax.servlet.jsp.JspException ; 21 import javax.servlet.jsp.PageContext ; 22 import javax.servlet.jsp.tagext.JspFragment ; 23 import java.io.StringWriter ; 24 import java.io.IOException ; 25 26 import com.blandware.atleap.webapp.taglib.core.BaseHandlerTag; 27 28 29 64 public class SubmitTag extends BaseHandlerTag { 65 68 protected String property = null; 69 70 73 protected String value = null; 74 75 79 protected Boolean disableButtonOnSubmit = Boolean.FALSE; 80 81 90 public String getProperty() { 91 92 return (this.property); 93 94 } 95 96 101 public void setProperty(String property) { 102 103 this.property = property; 104 105 } 106 107 116 public String getValue() { 117 118 return (this.value); 119 120 } 121 122 127 public void setValue(String value) { 128 129 this.value = value; 130 131 } 132 133 142 public Boolean getDisableButtonOnSubmit() { 143 return disableButtonOnSubmit; 144 } 145 146 151 public void setDisableButtonOnSubmit(Boolean disableButtonOnSubmit) { 152 this.disableButtonOnSubmit = disableButtonOnSubmit; 153 } 154 155 161 public void doTag() throws JspException , IOException { 162 String text; 164 StringWriter writer = new StringWriter (); 165 JspFragment body = getJspBody(); 166 if (body != null) { 167 body.invoke(writer); 168 text = writer.toString().trim(); 169 } else { 170 text = null; 171 } 172 173 String label = value; 175 if ((label == null) && (text != null)) { 176 label = text; 177 } 178 if ((label == null) || (label.length() < 1)) { 179 label = "Submit"; 180 } 181 182 String disablingCode = "this.disabled = true;"; 184 if (disableButtonOnSubmit == null) { 185 disableButtonOnSubmit = Boolean.FALSE; 186 } 187 if (disableButtonOnSubmit.booleanValue()) { 188 if (onclick == null) { 189 onclick = disablingCode; 190 } else { 191 onclick = disablingCode + onclick; 192 } 193 } 194 195 StringBuffer results = new StringBuffer (); 197 results.append("<input type=\"submit\""); 198 if (property != null) { 199 results.append(" name=\""); 200 results.append(property); 201 results.append("\" "); 202 } 203 if (label != null) { 204 results.append(" value=\""); 205 results.append(label); 206 results.append("\" "); 207 } 208 results.append(prepareAttributes()); 209 results.append("/>"); 210 211 PageContext pageContext = (PageContext ) getJspContext(); 213 TagUtils.getInstance().write(pageContext, results.toString()); 214 } 215 } 216 | Popular Tags |