Revision: 345
Author:   tfenne
Date:     2006-07-08 10:31:10 -0700 (Sat, 08 Jul 2006)
ViewCVS:  http://svn.sourceforge.net/stripes/?rev=345&view=rev

Log Message:
-----------
Fix for STS-208: option tag is not well behaved well value attribute is not 
supplied.

Modified Paths:
--------------
    trunk/stripes/src/net/sourceforge/stripes/tag/InputOptionTag.java
Modified: trunk/stripes/src/net/sourceforge/stripes/tag/InputOptionTag.java
===================================================================
--- trunk/stripes/src/net/sourceforge/stripes/tag/InputOptionTag.java   
2006-07-08 13:22:41 UTC (rev 344)
+++ trunk/stripes/src/net/sourceforge/stripes/tag/InputOptionTag.java   
2006-07-08 17:31:10 UTC (rev 345)
@@ -102,19 +102,29 @@
                     ("Option tags must always be contained inside a select 
tag.");
         }
 
-        if ( selectTag.isOptionSelected(getValue(), (this.selected != null)) ) 
{
+        // Decide if the label will come from the body of the option, of the 
label attr
+        String actualLabel = getBodyContentAsString();
+        if (actualLabel == null) {
+            actualLabel = this.label;
+        }
+
+        // If no explicit value attribute set, use the tag label as the value
+        Object actualValue;
+        if (this.value == null) {
+            actualValue = actualLabel;
+        }
+        else {
+            actualValue = this.value;
+        }
+        getAttributes().put("value", format(actualValue));
+
+       // Determine if the option should be selected
+        if (selectTag.isOptionSelected(actualValue, (this.selected != null))) {
             getAttributes().put("selected", "selected");
         }
 
-        getAttributes().put("value", format(this.value));
-
+        // And finally write the tag out to the page
         try {
-            String actualLabel = getBodyContentAsString();
-
-            if (actualLabel == null) {
-                actualLabel = this.label;
-            }
-
             writeOpenTag(getPageContext().getOut(), "option");
             if (actualLabel != null) {
                 getPageContext().getOut().write(actualLabel);


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Stripes-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-development

Reply via email to