1 7 package com.inversoft.verge.mvc.view.jsp.html; 8 9 10 import java.io.IOException ; 11 import java.util.HashMap ; 12 import java.util.Map ; 13 14 import javax.servlet.jsp.JspException ; 15 16 import com.inversoft.verge.mvc.view.HtmlConstants; 17 import com.inversoft.verge.mvc.view.HtmlViewToolkit; 18 import com.inversoft.verge.mvc.view.jsp.JspTools; 19 20 21 26 public class FormTag extends ContextBasedTag { 27 28 private String action; 29 protected String localAction; 30 private String method; 31 protected String localMethod; 32 private String onsubmit; 33 protected String localOnsubmit; 34 private String onreset; 35 protected String localOnreset; 36 private Map childParams = new HashMap (); 37 38 39 44 public String getAction() { 45 return action; 46 } 47 48 53 public void setAction(String action) { 54 this.action = action; 55 } 56 57 62 public String getMethod() { 63 return method; 64 } 65 66 71 public void setMethod(String method) { 72 this.method = method; 73 } 74 75 80 public String getOnsubmit() { 81 return onsubmit; 82 } 83 84 89 public void setOnsubmit(String onsubmit) { 90 this.onsubmit = onsubmit; 91 } 92 93 98 public String getOnreset() { 99 return onreset; 100 } 101 102 107 public void setOnreset(String onreset) { 108 this.onreset = onreset; 109 } 110 111 118 public Object getAttribute(String key) { 119 return childParams.get(key); 120 } 121 122 129 public void setAttribute(String key, Object value) { 130 childParams.put(key, value); 131 } 132 133 138 protected void initialize() throws JspException { 139 super.initialize(); 140 141 localAction = action; 142 localMethod = method; 143 localOnsubmit = onsubmit; 144 localOnreset = onreset; 145 146 if (!JspTools.JSP_20) { 148 localAction = (String ) JspTools.expand("action", action, String .class, 149 this, pageContext); 150 localMethod = (String ) JspTools.expand("method", method, String .class, 151 this, pageContext); 152 localOnsubmit = (String ) JspTools.expand("onsubmit", onsubmit, 153 String .class, this, pageContext); 154 localOnreset = (String ) JspTools.expand("onreset", onreset, 155 String .class, this, pageContext); 156 } 157 158 attributes.put(HtmlConstants.ON_SUBMIT, localOnsubmit); 159 attributes.put(HtmlConstants.ON_RESET, localOnreset); 160 } 161 162 169 public int doStartTag() throws JspException { 170 initialize(); 171 172 StringBuffer buf = new StringBuffer (); 173 createForm(buf, getId(), localName, localAction, localMethod); 174 175 try { 176 pageContext.getOut().print(buf.toString()); 177 } catch (IOException ioe) { 178 throw new JspException (ioe); 179 } 180 181 return EVAL_BODY_INCLUDE; 182 } 183 184 194 protected void createForm(StringBuffer buf, String id, String name, String url, 195 String method) 196 throws JspException { 197 if (url != null) { 198 StringBuffer localBuf = new StringBuffer (); 199 appendContextPlusURL(localBuf, url); 200 url = localBuf.toString(); 201 } 202 203 HtmlViewToolkit.createFormStartTag(buf, url, id, name, method, 204 attributes, singleAttrs); 205 } 206 207 212 public int doEndTag() throws JspException { 213 try { 214 pageContext.getOut().print(HtmlConstants.FORM_END_TAG); 215 } catch (IOException ioe) { 216 throw new JspException (ioe.toString()); 217 } 218 219 childParams.clear(); 221 222 return EVAL_PAGE; 223 } 224 } | Popular Tags |