diff --git a/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/tags/form/AbstractFormTag.java b/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/tags/form/AbstractFormTag.java
index 9dbfd3d5ce8cb1fd388effc2f76fec9b6b00c43d..7e898f8be9144971805df97006853101808c3197 100644
--- a/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/tags/form/AbstractFormTag.java
+++ b/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/tags/form/AbstractFormTag.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2007 the original author or authors.
+ * Copyright 2002-2010 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.form;
import java.beans.PropertyEditor;
-
import javax.servlet.jsp.JspException;
import org.springframework.util.ObjectUtils;
@@ -55,6 +54,18 @@ public abstract class AbstractFormTag extends HtmlEscapingAwareTag {
}
}
+ /**
+ * Evaluate the supplied value for the supplied attribute name. If the supplied value
+ * is null
then false
is returned, otherwise evaluation is
+ * handled using {@link ExpressionEvaluationUtils#evaluate(String, String, javax.servlet.jsp.PageContext)},
+ * with subsequent matching against Boolean.TRUE
and 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)));
+ }
+
/**
* Optionally writes the supplied value under the supplied attribute name into the supplied
* {@link TagWriter}. In this case, the supplied value is {@link #evaluate evaluated} first
diff --git a/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/tags/form/AbstractHtmlInputElementTag.java b/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/tags/form/AbstractHtmlInputElementTag.java
index d58634c703e3de1a1a4c6cd9f5ae7ea4a82f8851..c5a3d549ae282e7e45facce3a5412b84ff4d37ea 100644
--- a/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/tags/form/AbstractHtmlInputElementTag.java
+++ b/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/tags/form/AbstractHtmlInputElementTag.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2007 the original author or authors.
+ * Copyright 2002-2010 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.
@@ -192,7 +192,7 @@ public abstract class AbstractHtmlInputElementTag extends AbstractHtmlElementTag
* Is the current HTML tag disabled?
*/
protected boolean isDisabled() throws JspException {
- return "true".equals(evaluate(DISABLED_ATTRIBUTE, getDisabled()));
+ return evaluateBoolean(DISABLED_ATTRIBUTE, getDisabled());
}
/**
@@ -202,7 +202,7 @@ public abstract class AbstractHtmlInputElementTag extends AbstractHtmlElementTag
* not affected by them since their values don't change (only their status does.)
*/
protected boolean isReadonly() throws JspException {
- return "true".equals(evaluate(READONLY_ATTRIBUTE, getReadonly()));
+ return evaluateBoolean(READONLY_ATTRIBUTE, getReadonly());
}
}
diff --git a/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/tags/form/OptionTag.java b/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/tags/form/OptionTag.java
index 619004c2593675aed2575f02bc6fa6e22d71913e..16398f1d2cea24579d7dd318deedba6fb651e9b0 100644
--- a/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/tags/form/OptionTag.java
+++ b/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/tags/form/OptionTag.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2008 the original author or authors.
+ * Copyright 2002-2010 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.
@@ -126,8 +126,8 @@ public class OptionTag extends AbstractHtmlElementBodyTag implements BodyTag {
* Is the current HTML tag disabled?
* @return true
if this tag is disabled
*/
- protected boolean isDisabled() {
- return "true".equals(getDisabled());
+ protected boolean isDisabled() throws JspException {
+ return evaluateBoolean(DISABLED_ATTRIBUTE, getDisabled());
}
/**
diff --git a/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/tags/form/OptionWriter.java b/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/tags/form/OptionWriter.java
index 3b3b6e521445a05a2e50aa000b89eee1c0096835..4d60c834957d0890882d88c85b9c670ea0e70607 100644
--- a/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/tags/form/OptionWriter.java
+++ b/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/tags/form/OptionWriter.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2008 the original author or authors.
+ * Copyright 2002-2010 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.
@@ -19,7 +19,6 @@ package org.springframework.web.servlet.tags.form;
import java.util.Collection;
import java.util.Iterator;
import java.util.Map;
-
import javax.servlet.jsp.JspException;
import org.springframework.beans.BeanWrapper;
@@ -258,7 +257,7 @@ class OptionWriter {
/**
* Determine whether the option fields should be disabled.
*/
- protected boolean isOptionDisabled() {
+ protected boolean isOptionDisabled() throws JspException {
return false;
}
diff --git a/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/tags/form/OptionsTag.java b/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/tags/form/OptionsTag.java
index 2017fdfd10e6ba8c75599559b98baea74e114bf4..c24ecf4fa64fba4830da6707a545d001a3082b91 100644
--- a/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/tags/form/OptionsTag.java
+++ b/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/tags/form/OptionsTag.java
@@ -138,8 +138,8 @@ public class OptionsTag extends AbstractHtmlElementTag {
* Is the current HTML tag disabled?
* @return true
if this tag is disabled
*/
- protected boolean isDisabled() {
- return "true".equals(getDisabled());
+ protected boolean isDisabled() throws JspException {
+ return evaluateBoolean("disabled", getDisabled());
}
@@ -149,7 +149,7 @@ public class OptionsTag extends AbstractHtmlElementTag {
Object items = getItems();
Object itemsObject = null;
if (items != null) {
- itemsObject = (items instanceof String ? evaluate("items", (String) items) : items);
+ itemsObject = (items instanceof String ? evaluate("items", items) : items);
} else {
Class> selectTagBoundType = ((SelectTag) findAncestorWithClass(this, SelectTag.class))
.getBindStatus().getValueType();
@@ -204,7 +204,7 @@ public class OptionsTag extends AbstractHtmlElementTag {
}
@Override
- protected boolean isOptionDisabled() {
+ protected boolean isOptionDisabled() throws JspException {
return isDisabled();
}
diff --git a/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/tags/form/SelectTag.java b/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/tags/form/SelectTag.java
index 9c86e86b2380ce0b782f102ec85eb9ca9ebb14e0..906acefd36d855da2ba73bded97aa6855d0b07e6 100644
--- a/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/tags/form/SelectTag.java
+++ b/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/tags/form/SelectTag.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2008 the original author or authors.
+ * Copyright 2002-2010 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.form;
import java.util.Collection;
import java.util.Map;
-
import javax.servlet.jsp.JspException;
import org.springframework.util.ObjectUtils;
@@ -247,12 +246,11 @@ public class SelectTag extends AbstractHtmlInputElementTag {
private boolean isMultiple() throws JspException {
Object multiple = getMultiple();
- if (Boolean.TRUE.equals(multiple) || "true".equals(multiple) || "multiple".equals(multiple)) {
+ if (Boolean.TRUE.equals(multiple) || "multiple".equals(multiple)) {
return true;
}
else if (this.multiple instanceof String) {
- Object evaluatedValue = evaluate("multiple", multiple);
- return Boolean.TRUE.equals(evaluatedValue);
+ return evaluateBoolean("multiple", (String) multiple);
}
return forceMultiple();
}