You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by cr...@locus.apache.org on 2000/07/17 18:54:11 UTC
cvs commit: jakarta-struts/src/share/org/apache/struts/taglib SelectTag.java
craigmcc 00/07/17 09:54:11
Modified: src/share/org/apache/struts/taglib SelectTag.java
Log:
Enhance the <struts:select> tag to support two new attributes:
* The "multiple" attribute causes the rendered <select> element to include
the "multiple" modifier. (See below for important information on this.)
* The "size" attribute lets you define how many available options are
displayed. If not specified, the browser default (typically 1) is used.
NOTE: JSP custom tags must conform to the syntax requirements of XML, which
does not allow the HTML technique of "attribute minimization" (specifying an
attribute name with no value). Thus, you must specify a value for the
"multiple" attribute, even though it is not used, like this:
<struts:select name="serverType" multiple="multiple" size="3" ...>
... available options as before ...
</struts:select>
This enhancement is based on a suggestion by Jen Hsien Huang
<u5...@ncnu.edu.tw>, but is implemented slightly differently than what
was proposed (I made the two attributes independent of each other).
Revision Changes Path
1.9 +44 -4 jakarta-struts/src/share/org/apache/struts/taglib/SelectTag.java
Index: SelectTag.java
===================================================================
RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/SelectTag.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- SelectTag.java 2000/07/17 16:37:51 1.8
+++ SelectTag.java 2000/07/17 16:54:11 1.9
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/SelectTag.java,v 1.8 2000/07/17 16:37:51 craigmcc Exp $
- * $Revision: 1.8 $
- * $Date: 2000/07/17 16:37:51 $
+ * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/SelectTag.java,v 1.9 2000/07/17 16:54:11 craigmcc Exp $
+ * $Revision: 1.9 $
+ * $Date: 2000/07/17 16:54:11 $
*
* ====================================================================
*
@@ -78,7 +78,7 @@
* inside a form tag.
*
* @author Craig R. McClanahan
- * @version $Revision: 1.8 $ $Date: 2000/07/17 16:37:51 $
+ * @version $Revision: 1.9 $ $Date: 2000/07/17 16:54:11 $
*/
public final class SelectTag extends BaseHandlerTag {
@@ -102,6 +102,21 @@
/**
+ * Should multiple selections be allowed? Any non-null value will
+ * trigger rendering this.
+ */
+ private String multiple = null;
+
+ public String getMultiple() {
+ return (this.multiple);
+ }
+
+ public void setMultiple(String multiple) {
+ this.multiple = multiple;
+ }
+
+
+ /**
* The name of the bean containing our underlying property.
*/
private String name = Constants.BEAN_KEY;
@@ -122,6 +137,21 @@
/**
+ * How many available options should be displayed when this element
+ * is rendered?
+ */
+ private String size = null;
+
+ public String getSize() {
+ return (this.size);
+ }
+
+ public void setSize(String size) {
+ this.size = size;
+ }
+
+
+ /**
* The value to compare with for marking an option selected.
*/
private String value = null;
@@ -204,6 +234,14 @@
results.append(accessKey);
results.append("\"");
}
+ if (multiple != null) {
+ results.append(" multiple");
+ }
+ if (size != null) {
+ results.append(" size=\"");
+ results.append(size);
+ results.append("\"");
+ }
if (tabIndex != null) {
results.append(" tabindex=\"");
results.append(tabIndex);
@@ -292,8 +330,10 @@
super.release();
match = null;
+ multiple = null;
name = Constants.BEAN_KEY;
property = null;
+ size = null;
value = null;
}