Removed Spring’s own JSP expression support (in favor of JSP 2.0+)

This commit is contained in:
Juergen Hoeller
2013-03-19 16:30:46 +01:00
parent f19f55a59b
commit 20fb418785
37 changed files with 207 additions and 1129 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,7 +21,6 @@ import javax.servlet.jsp.JspException;
import javax.servlet.jsp.PageContext;
import org.springframework.validation.Errors;
import org.springframework.web.util.ExpressionEvaluationUtils;
/**
* JSP tag that evaluates content if there are binding errors
@@ -61,9 +60,7 @@ public class BindErrorsTag extends HtmlEscapingAwareTag {
@Override
protected final int doStartTagInternal() throws ServletException, JspException {
String resolvedName = ExpressionEvaluationUtils.evaluateString("name", this.name, pageContext);
this.errors = getRequestContext().getErrors(resolvedName, isHtmlEscape());
this.errors = getRequestContext().getErrors(this.name, isHtmlEscape());
if (this.errors != null && this.errors.hasErrors()) {
this.pageContext.setAttribute(ERRORS_VARIABLE_NAME, this.errors, PageContext.REQUEST_SCOPE);
return EVAL_BODY_INCLUDE;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,13 +17,11 @@
package org.springframework.web.servlet.tags;
import java.beans.PropertyEditor;
import javax.servlet.jsp.JspTagException;
import javax.servlet.jsp.PageContext;
import org.springframework.validation.Errors;
import org.springframework.web.servlet.support.BindStatus;
import org.springframework.web.util.ExpressionEvaluationUtils;
/**
* Bind tag, supporting evaluation of binding errors for a certain
@@ -104,8 +102,7 @@ public class BindTag extends HtmlEscapingAwareTag implements EditorAwareTag {
@Override
protected final int doStartTagInternal() throws Exception {
String resolvedPath = ExpressionEvaluationUtils.evaluateString("path", getPath(), pageContext);
String resolvedPath = getPath();
if (!isIgnoreNestedPath()) {
String nestedPath = (String) pageContext.getAttribute(
NestedPathTag.NESTED_PATH_VARIABLE_NAME, PageContext.REQUEST_SCOPE);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,12 +17,10 @@
package org.springframework.web.servlet.tags;
import java.io.IOException;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.BodyContent;
import javax.servlet.jsp.tagext.BodyTag;
import org.springframework.web.util.ExpressionEvaluationUtils;
import org.springframework.web.util.HtmlUtils;
import org.springframework.web.util.JavaScriptUtils;
@@ -55,9 +53,8 @@ public class EscapeBodyTag extends HtmlEscapingAwareTag implements BodyTag {
* Set JavaScript escaping for this tag, as boolean value.
* Default is "false".
*/
public void setJavaScriptEscape(String javaScriptEscape) throws JspException {
this.javaScriptEscape =
ExpressionEvaluationUtils.evaluateBoolean("javaScriptEscape", javaScriptEscape, pageContext);
public void setJavaScriptEscape(boolean javaScriptEscape) throws JspException {
this.javaScriptEscape = javaScriptEscape;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,7 +17,6 @@
package org.springframework.web.servlet.tags;
import java.io.IOException;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.el.VariableResolver;
@@ -36,7 +35,6 @@ import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.expression.spel.support.StandardEvaluationContext;
import org.springframework.expression.spel.support.StandardTypeConverter;
import org.springframework.util.ObjectUtils;
import org.springframework.web.util.ExpressionEvaluationUtils;
import org.springframework.web.util.HtmlUtils;
import org.springframework.web.util.JavaScriptUtils;
import org.springframework.web.util.TagUtils;
@@ -98,9 +96,8 @@ public class EvalTag extends HtmlEscapingAwareTag {
* Set JavaScript escaping for this tag, as boolean value.
* Default is "false".
*/
public void setJavaScriptEscape(String javaScriptEscape) throws JspException {
this.javaScriptEscape =
ExpressionEvaluationUtils.evaluateBoolean("javaScriptEscape", javaScriptEscape, this.pageContext);
public void setJavaScriptEscape(boolean javaScriptEscape) throws JspException {
this.javaScriptEscape = javaScriptEscape;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,8 +18,6 @@ package org.springframework.web.servlet.tags;
import javax.servlet.jsp.JspException;
import org.springframework.web.util.ExpressionEvaluationUtils;
/**
* Sets default HTML escape value for the current page. The actual value
* can be overridden by escaping-aware tags. The default is "false".
@@ -34,23 +32,21 @@ import org.springframework.web.util.ExpressionEvaluationUtils;
@SuppressWarnings("serial")
public class HtmlEscapeTag extends RequestContextAwareTag {
private String defaultHtmlEscape;
private boolean defaultHtmlEscape;
/**
* Set the default value for HTML escaping,
* to be put into the current PageContext.
*/
public void setDefaultHtmlEscape(String defaultHtmlEscape) {
public void setDefaultHtmlEscape(boolean defaultHtmlEscape) {
this.defaultHtmlEscape = defaultHtmlEscape;
}
@Override
protected int doStartTagInternal() throws JspException {
boolean resolvedDefaultHtmlEscape =
ExpressionEvaluationUtils.evaluateBoolean("defaultHtmlEscape", this.defaultHtmlEscape, pageContext);
getRequestContext().setDefaultHtmlEscape(resolvedDefaultHtmlEscape);
getRequestContext().setDefaultHtmlEscape(this.defaultHtmlEscape);
return EVAL_BODY_INCLUDE;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,8 +18,6 @@ package org.springframework.web.servlet.tags;
import javax.servlet.jsp.JspException;
import org.springframework.web.util.ExpressionEvaluationUtils;
/**
* Superclass for tags that output content that might get HTML-escaped.
*
@@ -46,8 +44,8 @@ public abstract class HtmlEscapingAwareTag extends RequestContextAwareTag {
* Overrides the default HTML escaping setting for the current page.
* @see HtmlEscapeTag#setDefaultHtmlEscape
*/
public void setHtmlEscape(String htmlEscape) throws JspException {
this.htmlEscape = ExpressionEvaluationUtils.evaluateBoolean("htmlEscape", htmlEscape, pageContext);
public void setHtmlEscape(boolean htmlEscape) throws JspException {
this.htmlEscape = htmlEscape;
}
/**

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,7 +18,6 @@ package org.springframework.web.servlet.tags;
import java.io.IOException;
import java.util.Collection;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspTagException;
@@ -27,7 +26,6 @@ import org.springframework.context.MessageSourceResolvable;
import org.springframework.context.NoSuchMessageException;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.util.ExpressionEvaluationUtils;
import org.springframework.web.util.HtmlUtils;
import org.springframework.web.util.JavaScriptUtils;
import org.springframework.web.util.TagUtils;
@@ -60,7 +58,7 @@ public class MessageTag extends HtmlEscapingAwareTag {
public static final String DEFAULT_ARGUMENT_SEPARATOR = ",";
private Object message;
private MessageSourceResolvable message;
private String code;
@@ -79,12 +77,10 @@ public class MessageTag extends HtmlEscapingAwareTag {
/**
* Set the MessageSourceResolvable for this tag.
* Accepts a direct MessageSourceResolvable instance as well as a JSP
* expression language String that points to a MessageSourceResolvable.
* <p>If a MessageSourceResolvable is specified, it effectively overrides
* any code, arguments or text specified on this tag.
*/
public void setMessage(Object message) {
public void setMessage(MessageSourceResolvable message) {
this.message = message;
}
@@ -145,9 +141,8 @@ public class MessageTag extends HtmlEscapingAwareTag {
* Set JavaScript escaping for this tag, as boolean value.
* Default is "false".
*/
public void setJavaScriptEscape(String javaScriptEscape) throws JspException {
this.javaScriptEscape =
ExpressionEvaluationUtils.evaluateBoolean("javaScriptEscape", javaScriptEscape, pageContext);
public void setJavaScriptEscape(boolean javaScriptEscape) throws JspException {
this.javaScriptEscape = javaScriptEscape;
}
@@ -170,10 +165,8 @@ public class MessageTag extends HtmlEscapingAwareTag {
msg = this.javaScriptEscape ? JavaScriptUtils.javaScriptEscape(msg) : msg;
// Expose as variable, if demanded, else write to the page.
String resolvedVar = ExpressionEvaluationUtils.evaluateString("var", this.var, pageContext);
if (resolvedVar != null) {
String resolvedScope = ExpressionEvaluationUtils.evaluateString("scope", this.scope, pageContext);
pageContext.setAttribute(resolvedVar, msg, TagUtils.getScope(resolvedScope));
if (this.var != null) {
pageContext.setAttribute(this.var, msg, TagUtils.getScope(this.scope));
}
else {
writeMessage(msg);
@@ -197,41 +190,28 @@ public class MessageTag extends HtmlEscapingAwareTag {
}
// Evaluate the specified MessageSourceResolvable, if any.
MessageSourceResolvable resolvedMessage = null;
if (this.message instanceof MessageSourceResolvable) {
resolvedMessage = (MessageSourceResolvable) this.message;
}
else if (this.message != null) {
String expr = this.message.toString();
resolvedMessage = (MessageSourceResolvable)
ExpressionEvaluationUtils.evaluate("message", expr, MessageSourceResolvable.class, pageContext);
}
if (resolvedMessage != null) {
if (this.message != null) {
// We have a given MessageSourceResolvable.
return messageSource.getMessage(resolvedMessage, getRequestContext().getLocale());
return messageSource.getMessage(this.message, getRequestContext().getLocale());
}
String resolvedCode = ExpressionEvaluationUtils.evaluateString("code", this.code, pageContext);
String resolvedText = ExpressionEvaluationUtils.evaluateString("text", this.text, pageContext);
if (resolvedCode != null || resolvedText != null) {
if (this.code != null || this.text != null) {
// We have a code or default text that we need to resolve.
Object[] argumentsArray = resolveArguments(this.arguments);
if (resolvedText != null) {
if (this.text != null) {
// We have a fallback text to consider.
return messageSource.getMessage(
resolvedCode, argumentsArray, resolvedText, getRequestContext().getLocale());
this.code, argumentsArray, this.text, getRequestContext().getLocale());
}
else {
// We have no fallback text to consider.
return messageSource.getMessage(
resolvedCode, argumentsArray, getRequestContext().getLocale());
this.code, argumentsArray, getRequestContext().getLocale());
}
}
// All we have is a specified literal text.
return resolvedText;
return this.text;
}
/**
@@ -246,7 +226,7 @@ public class MessageTag extends HtmlEscapingAwareTag {
String[] stringArray =
StringUtils.delimitedListToStringArray((String) arguments, this.argumentSeparator);
if (stringArray.length == 1) {
Object argument = ExpressionEvaluationUtils.evaluate("argument", stringArray[0], pageContext);
Object argument = stringArray[0];
if (argument != null && argument.getClass().isArray()) {
return ObjectUtils.toObjectArray(argument);
}
@@ -255,12 +235,7 @@ public class MessageTag extends HtmlEscapingAwareTag {
}
}
else {
Object[] argumentsArray = new Object[stringArray.length];
for (int i = 0; i < stringArray.length; i++) {
argumentsArray[i] =
ExpressionEvaluationUtils.evaluate("argument[" + i + "]", stringArray[i], pageContext);
}
return argumentsArray;
return stringArray;
}
}
else if (arguments instanceof Object[]) {

View File

@@ -22,7 +22,6 @@ import javax.servlet.jsp.tagext.TagSupport;
import javax.servlet.jsp.tagext.TryCatchFinally;
import org.springframework.beans.PropertyAccessor;
import org.springframework.web.util.ExpressionEvaluationUtils;
/**
* <p>Nested-path tag, to support and assist with nested beans or bean properties
@@ -81,14 +80,12 @@ public class NestedPathTag extends TagSupport implements TryCatchFinally {
@Override
public int doStartTag() throws JspException {
String resolvedPath = ExpressionEvaluationUtils.evaluateString("path", getPath(), pageContext);
// Save previous nestedPath value, build and expose current nestedPath value.
// Use request scope to expose nestedPath to included pages too.
this.previousNestedPath =
(String) pageContext.getAttribute(NESTED_PATH_VARIABLE_NAME, PageContext.REQUEST_SCOPE);
String nestedPath =
(this.previousNestedPath != null ? this.previousNestedPath + resolvedPath : resolvedPath);
(this.previousNestedPath != null ? this.previousNestedPath + getPath() : getPath());
pageContext.setAttribute(NESTED_PATH_VARIABLE_NAME, nestedPath, PageContext.REQUEST_SCOPE);
return EVAL_BODY_INCLUDE;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,11 +18,9 @@ package org.springframework.web.servlet.tags;
import java.beans.PropertyEditor;
import java.io.IOException;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;
import org.springframework.web.util.ExpressionEvaluationUtils;
import org.springframework.web.util.HtmlUtils;
import org.springframework.web.util.TagUtils;
@@ -32,7 +30,7 @@ import org.springframework.web.util.TagUtils;
* form element tag from Spring's form tag library).
*
* <p>The BindTag has a PropertyEditor that it uses to transform properties of
* a bean to a String, useable in HTML forms. This tag uses that PropertyEditor
* a bean to a String, usable in HTML forms. This tag uses that PropertyEditor
* to transform objects passed into this tag.
*
* @author Alef Arendsen
@@ -59,11 +57,6 @@ public class TransformTag extends HtmlEscapingAwareTag {
* <p>The value can either be a plain value to transform (a hard-coded String
* value in a JSP or a JSP expression), or a JSP EL expression to be evaluated
* (transforming the result of the expression).
* <p>Like all of Spring's JSP tags, this tag is capable of parsing EL expressions
* itself, on any JSP version. Note, however, that EL expressions in a JSP 2.0 page
* will be evaluated by the JSP container, with the result getting passed in here.
* For this reason, the type of this property is Object (accepting any result
* object from a pre-evaluated expression) rather than String.
*/
public void setValue(Object value) {
this.value = value;
@@ -93,13 +86,7 @@ public class TransformTag extends HtmlEscapingAwareTag {
@Override
protected final int doStartTagInternal() throws JspException {
Object resolvedValue = this.value;
if (this.value instanceof String) {
String strValue = (String) this.value;
resolvedValue = ExpressionEvaluationUtils.evaluate("value", strValue, pageContext);
}
if (resolvedValue != null) {
if (this.value != null) {
// Find the containing EditorAwareTag (e.g. BindTag), if applicable.
EditorAwareTag tag = (EditorAwareTag) TagSupport.findAncestorWithClass(this, EditorAwareTag.class);
if (tag == null) {
@@ -111,18 +98,16 @@ public class TransformTag extends HtmlEscapingAwareTag {
PropertyEditor editor = tag.getEditor();
if (editor != null) {
// If an editor was found, edit the value.
editor.setValue(resolvedValue);
editor.setValue(this.value);
result = editor.getAsText();
}
else {
// Else, just do a toString.
result = resolvedValue.toString();
result = this.value.toString();
}
result = isHtmlEscape() ? HtmlUtils.htmlEscape(result) : result;
String resolvedVar = ExpressionEvaluationUtils.evaluateString("var", this.var, pageContext);
if (resolvedVar != null) {
String resolvedScope = ExpressionEvaluationUtils.evaluateString("scope", this.scope, pageContext);
pageContext.setAttribute(resolvedVar, result, TagUtils.getScope(resolvedScope));
if (this.var != null) {
pageContext.setAttribute(this.var, result, TagUtils.getScope(this.scope));
}
else {
try {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,7 +22,6 @@ import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import javax.servlet.ServletRequest;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -31,7 +30,6 @@ import javax.servlet.jsp.PageContext;
import org.springframework.util.StringUtils;
import org.springframework.web.servlet.support.RequestDataValueProcessor;
import org.springframework.web.util.ExpressionEvaluationUtils;
import org.springframework.web.util.HtmlUtils;
import org.springframework.web.util.JavaScriptUtils;
import org.springframework.web.util.TagUtils;
@@ -152,9 +150,8 @@ public class UrlTag extends HtmlEscapingAwareTag implements ParamAware {
* Set JavaScript escaping for this tag, as boolean value.
* Default is "false".
*/
public void setJavaScriptEscape(String javaScriptEscape) throws JspException {
this.javaScriptEscape =
ExpressionEvaluationUtils.evaluateBoolean("javaScriptEscape", javaScriptEscape, pageContext);
public void setJavaScriptEscape(boolean javaScriptEscape) throws JspException {
this.javaScriptEscape = javaScriptEscape;
}
public void addParam(Param param) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,7 +21,6 @@ import javax.servlet.jsp.JspException;
import org.springframework.util.ObjectUtils;
import org.springframework.web.servlet.tags.HtmlEscapingAwareTag;
import org.springframework.web.util.ExpressionEvaluationUtils;
/**
* Base class for all JSP form tags. Provides utility methods for
@@ -42,29 +41,11 @@ import org.springframework.web.util.ExpressionEvaluationUtils;
public abstract class AbstractFormTag extends HtmlEscapingAwareTag {
/**
* Evaluate the supplied value for the supplied attribute name. If the supplied value
* is {@code null} then {@code null} is returned, otherwise evaluation is
* handled using {@link ExpressionEvaluationUtils#evaluate(String, String, javax.servlet.jsp.PageContext)}.
* Evaluate the supplied value for the supplied attribute name.
* <p>The default implementation simply returns the given value as-is.
*/
protected Object evaluate(String attributeName, Object value) throws JspException {
if (value instanceof String) {
return ExpressionEvaluationUtils.evaluate(attributeName, (String) value, this.pageContext);
}
else {
return value;
}
}
/**
* Evaluate the supplied value for the supplied attribute name. If the supplied value
* is {@code null} then {@code false} is returned, otherwise evaluation is
* handled using {@link ExpressionEvaluationUtils#evaluate(String, String, javax.servlet.jsp.PageContext)},
* with subsequent matching against {@code Boolean.TRUE} and {@code Boolean.valueOf}.
*/
protected boolean evaluateBoolean(String attributeName, String value) throws JspException {
Object evaluated = ExpressionEvaluationUtils.evaluate(attributeName, value, this.pageContext);
return (Boolean.TRUE.equals(evaluated) ||
(evaluated instanceof String && Boolean.valueOf((String) evaluated)));
return value;
}
/**

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -71,9 +71,9 @@ public abstract class AbstractHtmlInputElementTag extends AbstractHtmlElementTag
private String accesskey;
private String disabled;
private boolean disabled;
private String readonly;
private boolean readonly;
/**
@@ -138,34 +138,29 @@ public abstract class AbstractHtmlInputElementTag extends AbstractHtmlElementTag
/**
* Set the value of the '{@code disabled}' attribute.
* May be a runtime expression.
*/
public void setDisabled(String disabled) {
public void setDisabled(boolean disabled) {
this.disabled = disabled;
}
/**
* Get the value of the '{@code disabled}' attribute.
*/
protected String getDisabled() {
protected boolean isDisabled() {
return this.disabled;
}
/**
* Sets the value of the '{@code readonly}' attribute.
* May be a runtime expression.
* @see #isReadonly()
*/
public void setReadonly(String readonly) {
public void setReadonly(boolean readonly) {
this.readonly = readonly;
}
/**
* Gets the value of the '{@code readonly}' attribute.
* May be a runtime expression.
* @see #isReadonly()
*/
protected String getReadonly() {
protected boolean isReadonly() {
return this.readonly;
}
@@ -189,21 +184,4 @@ public abstract class AbstractHtmlInputElementTag extends AbstractHtmlElementTag
}
}
/**
* Is the current HTML tag disabled?
*/
protected boolean isDisabled() throws JspException {
return evaluateBoolean(DISABLED_ATTRIBUTE, getDisabled());
}
/**
* Is the current HTML tag readonly?
* <p>Note: some {@link AbstractHtmlInputElementTag} subclasses (such a those
* for checkboxes and radiobuttons) may contain readonly attributes, but are
* not affected by them since their values don't change (only their status does.)
*/
protected boolean isReadonly() throws JspException {
return evaluateBoolean(READONLY_ATTRIBUTE, getReadonly());
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -35,20 +35,15 @@ public class ButtonTag extends AbstractHtmlElementTag {
*/
public static final String DISABLED_ATTRIBUTE = "disabled";
private TagWriter tagWriter;
private String name;
private String value;
private String disabled;
private boolean disabled;
/**
* Set the value of the '{@code name}' attribute.
*/
public String getName() {
return name;
}
/**
* Get the value of the '{@code name}' attribute.
@@ -58,10 +53,10 @@ public class ButtonTag extends AbstractHtmlElementTag {
}
/**
* Get the value of the '{@code value}' attribute.
* Set the value of the '{@code name}' attribute.
*/
public String getValue() {
return this.value;
public String getName() {
return name;
}
/**
@@ -72,20 +67,27 @@ public class ButtonTag extends AbstractHtmlElementTag {
}
/**
* Get the value of the '{@code disabled}' attribute.
* Get the value of the '{@code value}' attribute.
*/
public String getDisabled() {
return this.disabled;
public String getValue() {
return this.value;
}
/**
* Set the value of the '{@code disabled}' attribute.
* May be a runtime expression.
*/
public void setDisabled(String disabled) {
public void setDisabled(boolean disabled) {
this.disabled = disabled;
}
/**
* Get the value of the '{@code disabled}' attribute.
*/
public boolean isDisabled() {
return this.disabled;
}
@Override
protected int writeTagContent(TagWriter tagWriter) throws JspException {
tagWriter.startTag("button");
@@ -100,13 +102,6 @@ public class ButtonTag extends AbstractHtmlElementTag {
return EVAL_BODY_INCLUDE;
}
/**
* Is the current HTML tag disabled?
*/
protected boolean isDisabled() throws JspException {
return evaluateBoolean(DISABLED_ATTRIBUTE, getDisabled());
}
/**
* Writes the '{@code value}' attribute to the supplied {@link TagWriter}.
* Subclasses may choose to override this implementation to control exactly
@@ -119,7 +114,6 @@ public class ButtonTag extends AbstractHtmlElementTag {
/**
* Return the default value.
*
* @return The default value if none supplied.
*/
protected String getDefaultValue() {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -40,23 +40,25 @@ public class HiddenInputTag extends AbstractHtmlElementTag {
*/
public static final String DISABLED_ATTRIBUTE = "disabled";
private String disabled;
private boolean disabled;
/**
* Get the value of the '{@code disabled}' attribute.
*/
public String getDisabled() {
return this.disabled;
}
/**
* Set the value of the '{@code disabled}' attribute.
* May be a runtime expression.
*/
public void setDisabled(String disabled) {
public void setDisabled(boolean disabled) {
this.disabled = disabled;
}
/**
* Get the value of the '{@code disabled}' attribute.
*/
public boolean isDisabled() {
return this.disabled;
}
/**
* Flags "type" as an illegal dynamic attribute.
*/
@@ -85,11 +87,4 @@ public class HiddenInputTag extends AbstractHtmlElementTag {
return SKIP_BODY;
}
/**
* Is the current HTML tag disabled?
*/
protected boolean isDisabled() throws JspException {
return evaluateBoolean(DISABLED_ATTRIBUTE, getDisabled());
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -89,12 +89,11 @@ public class OptionTag extends AbstractHtmlElementBodyTag implements BodyTag {
private Object oldDisplayValue;
private String disabled;
private boolean disabled;
/**
* Set the 'value' attribute of the rendered HTML {@code &lt;option&gt;} tag.
* <p>May be a runtime expression.
*/
public void setValue(Object value) {
this.value = value;
@@ -109,28 +108,18 @@ public class OptionTag extends AbstractHtmlElementBodyTag implements BodyTag {
/**
* Set the value of the '{@code disabled}' attribute.
* <p>May be a runtime expression.
* @param disabled the value of the '{@code disabled}' attribute
*/
public void setDisabled(String disabled) {
public void setDisabled(boolean disabled) {
this.disabled = disabled;
}
/**
* Get the value of the '{@code disabled}' attribute.
*/
protected String getDisabled() {
protected boolean isDisabled() {
return this.disabled;
}
/**
* Is the current HTML tag disabled?
* @return {@code true} if this tag is disabled
*/
protected boolean isDisabled() throws JspException {
return evaluateBoolean(DISABLED_ATTRIBUTE, getDisabled());
}
/**
* Set the text body of the rendered HTML {@code &lt;option&gt;} tag.
* <p>May be a runtime expression.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -56,7 +56,7 @@ public class OptionsTag extends AbstractHtmlElementTag {
*/
private String itemLabel;
private String disabled;
private boolean disabled;
/**
@@ -84,7 +84,6 @@ public class OptionsTag extends AbstractHtmlElementTag {
* attribute of the '{@code option}' tag.
* <p>Required when wishing to render '{@code option}' tags from
* an array or {@link java.util.Collection}.
* <p>May be a runtime expression.
*/
public void setItemValue(String itemValue) {
Assert.hasText(itemValue, "'itemValue' must not be empty");
@@ -102,7 +101,6 @@ public class OptionsTag extends AbstractHtmlElementTag {
/**
* Set the name of the property mapped to the label (inner text) of the
* '{@code option}' tag.
* <p>May be a runtime expression.
*/
public void setItemLabel(String itemLabel) {
Assert.hasText(itemLabel, "'itemLabel' must not be empty");
@@ -112,7 +110,6 @@ public class OptionsTag extends AbstractHtmlElementTag {
/**
* Get the name of the property mapped to the label (inner text) of the
* '{@code option}' tag.
* <p>May be a runtime expression.
*/
protected String getItemLabel() {
return this.itemLabel;
@@ -120,28 +117,18 @@ public class OptionsTag extends AbstractHtmlElementTag {
/**
* Set the value of the '{@code disabled}' attribute.
* <p>May be a runtime expression.
* @param disabled the value of the '{@code disabled}' attribute
*/
public void setDisabled(String disabled) {
public void setDisabled(boolean disabled) {
this.disabled = disabled;
}
/**
* Get the value of the '{@code disabled}' attribute.
*/
protected String getDisabled() {
protected boolean isDisabled() {
return this.disabled;
}
/**
* Is the current HTML tag disabled?
* @return {@code true} if this tag is disabled
*/
protected boolean isDisabled() throws JspException {
return evaluateBoolean("disabled", getDisabled());
}
@Override
protected int writeTagContent(TagWriter tagWriter) throws JspException {

View File

@@ -18,7 +18,6 @@ package org.springframework.web.servlet.tags.form;
import java.util.Collection;
import java.util.Map;
import javax.servlet.jsp.JspException;
import org.springframework.util.ObjectUtils;
@@ -153,8 +152,6 @@ public class SelectTag extends AbstractHtmlInputElementTag {
/**
* Set the value of the HTML '{@code size}' attribute rendered
* on the final '{@code select}' element.
* <p>May be a runtime expression.
* @param size the desired value of the '{@code size}' attribute
*/
public void setSize(String size) {
this.size = size;
@@ -162,7 +159,6 @@ public class SelectTag extends AbstractHtmlInputElementTag {
/**
* Get the value of the '{@code size}' attribute.
* <p>May be a runtime expression.
*/
protected String getSize() {
return this.size;
@@ -171,7 +167,6 @@ public class SelectTag extends AbstractHtmlInputElementTag {
/**
* Set the value of the HTML '{@code multiple}' attribute rendered
* on the final '{@code select}' element.
* <p>May be a runtime expression.
*/
public void setMultiple(Object multiple) {
this.multiple = multiple;
@@ -180,7 +175,6 @@ public class SelectTag extends AbstractHtmlInputElementTag {
/**
* Get the value of the HTML '{@code multiple}' attribute rendered
* on the final '{@code select}' element.
* <p>May be a runtime expression.
*/
protected Object getMultiple() {
return this.multiple;
@@ -257,9 +251,6 @@ public class SelectTag extends AbstractHtmlInputElementTag {
if (Boolean.TRUE.equals(multiple) || "multiple".equals(multiple)) {
return true;
}
else if (this.multiple instanceof String) {
return evaluateBoolean("multiple", (String) multiple);
}
return forceMultiple();
}