1 16 17 package org.springframework.web.servlet.tags.form; 18 19 import java.beans.PropertyEditor ; 20 21 import javax.servlet.jsp.JspException ; 22 23 import org.springframework.util.ObjectUtils; 24 import org.springframework.web.servlet.tags.HtmlEscapingAwareTag; 25 import org.springframework.web.util.ExpressionEvaluationUtils; 26 27 41 public abstract class AbstractFormTag extends HtmlEscapingAwareTag { 42 43 46 private final ValueFormatter valueFormatter = new ValueFormatter(); 47 48 53 protected Object evaluate(String attributeName, Object value) throws JspException { 54 if (value instanceof String ) { 55 return ExpressionEvaluationUtils.evaluate(attributeName, (String )value, this.pageContext); 56 } 57 else { 58 return value; 59 } 60 } 61 62 70 protected final void writeOptionalAttribute(TagWriter tagWriter, String attributeName, String value) throws JspException { 71 tagWriter.writeOptionalAttributeValue(attributeName, getDisplayString(evaluate(attributeName, value))); 72 } 73 74 80 protected TagWriter createTagWriter() { 81 return new TagWriter(this.pageContext.getOut()); 82 } 83 84 89 protected final int doStartTagInternal() throws Exception { 90 return writeTagContent(createTagWriter()); 91 } 92 93 97 protected String getDisplayString(Object value) { 98 return this.valueFormatter.getDisplayString(value, isHtmlEscape()); 99 } 100 101 107 protected String getDisplayString(Object value, PropertyEditor propertyEditor) { 108 return this.valueFormatter.getDisplayString(value, propertyEditor, isHtmlEscape()); 109 } 110 111 115 protected abstract int writeTagContent(TagWriter tagWriter) throws JspException ; 116 117 } 118 | Popular Tags |