dgraham 2003/09/25 23:28:05
Modified: src/share/org/apache/struts/taglib/html CheckboxTag.java
Log:
Refactored the checked logic into a new isChecked()
method.
Revision Changes Path
1.21 +32 -21
jakarta-struts/src/share/org/apache/struts/taglib/html/CheckboxTag.java
Index: CheckboxTag.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/CheckboxTag.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- CheckboxTag.java 26 Sep 2003 06:22:05 -0000 1.20
+++ CheckboxTag.java 26 Sep 2003 06:28:05 -0000 1.21
@@ -194,24 +194,10 @@
}
results.append("\"");
-
- Object result =
- TagUtils.getInstance().lookup(pageContext, name, property, null);
-
- if (result == null) {
- result = "";
- }
-
- result = result.toString();
- String checked = (String) result;
- if (checked.equalsIgnoreCase(value)
- || checked.equalsIgnoreCase("true")
- || checked.equalsIgnoreCase("yes")
- || checked.equalsIgnoreCase("on")) {
-
- results.append(" checked=\"checked\"");
- }
+ if (this.isChecked()) {
+ results.append(" checked=\"checked\"");
+ }
results.append(prepareEventHandlers());
results.append(prepareStyles());
@@ -225,6 +211,31 @@
return (EVAL_BODY_TAG);
}
+
+ /**
+ * Determines if the checkbox should be checked.
+ * @return true if checked="checked" should be rendered.
+ * @throws JspException
+ * @since Struts 1.2
+ */
+ protected boolean isChecked() throws JspException {
+ Object result =
+ TagUtils.getInstance().lookup(pageContext, name, property,
null);
+
+ if (result == null) {
+ result = "";
+ }
+
+ result = result.toString();
+
+ String checked = (String) result;
+ return (
+ checked.equalsIgnoreCase(this.value)
+ || checked.equalsIgnoreCase("true")
+ || checked.equalsIgnoreCase("yes")
+ || checked.equalsIgnoreCase("on"));
+
+ }
/**
* Save the associated label from the body content.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]