Revision: 1452
          http://stripes.svn.sourceforge.net/stripes/?rev=1452&view=rev
Author:   bengunter
Date:     2011-12-02 17:03:07 +0000 (Fri, 02 Dec 2011)
Log Message:
-----------
Fixed STS-853: Invalid <optgroup> HTML markup generated

Modified Paths:
--------------
    
branches/1.5.x/stripes/src/net/sourceforge/stripes/tag/InputOptionsCollectionTag.java

Modified: 
branches/1.5.x/stripes/src/net/sourceforge/stripes/tag/InputOptionsCollectionTag.java
===================================================================
--- 
branches/1.5.x/stripes/src/net/sourceforge/stripes/tag/InputOptionsCollectionTag.java
       2011-12-01 22:05:36 UTC (rev 1451)
+++ 
branches/1.5.x/stripes/src/net/sourceforge/stripes/tag/InputOptionsCollectionTag.java
       2011-12-02 17:03:07 UTC (rev 1452)
@@ -89,6 +89,19 @@
  * @author Tim Fennell
  */
 public class InputOptionsCollectionTag extends HtmlTagSupport {
+    /** A helper for writing HTML &lt;optgroup&gt; tags. */
+    private final HtmlTagSupport optgroupSupport = new HtmlTagSupport() {
+        @Override
+        public int doStartTag() throws JspException {
+            return 0;
+        }
+
+        @Override
+        public int doEndTag() throws JspException {
+            return 0;
+        }
+    };
+
     private Collection<? extends Object> collection;
     private String value;
     private String label;
@@ -301,6 +314,7 @@
         
         Object lastGroup = null;
 
+        JspWriter out = getPageContext().getOut();
         for (Entry entry : sortedEntries) {
             // Set properties common to all options
             tag.getAttributes().putAll(getAttributes());
@@ -311,11 +325,12 @@
             try {
                 if (entry.group != null && !entry.group.equals(lastGroup))
                 {
-                    JspWriter out = getPageContext().getOut();
-                    out.write("<optgroup label=\"");
-                    out.write(String.valueOf(entry.group).replaceAll("\"", 
"&quot;"));
-                    out.write(isXmlTags() ? "\" />" : "\">");
-                    
+                    if (lastGroup != null)
+                        optgroupSupport.writeCloseTag(out, "optgroup");
+
+                    optgroupSupport.set("label", String.valueOf(entry.group));
+                    optgroupSupport.writeOpenTag(out, "optgroup");
+
                     lastGroup = entry.group;
                 }
               
@@ -338,6 +353,9 @@
             }
         }
 
+        if (lastGroup != null)
+            optgroupSupport.writeCloseTag(out, "optgroup");
+
         // Clean up any temporary state
         this.entries.clear();
 

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


------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure 
contains a definitive record of customers, application performance, 
security threats, fraudulent activity, and more. Splunk takes this 
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
_______________________________________________
Stripes-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-development

Reply via email to