Commits

mbogaert  committed cd4e4a5

Small spacing fix for select.vm. Added test for WW-455.

git-svn-id: http://svn.opensymphony.com/svn/webwork/trunk@613573baa09-0c28-0410-bef9-dab3c582ae83

  • Participants
  • Parent commits 5632fa7

Comments (0)

Files changed (6)

File src/java/template/simple/select.vm

         #end
 
         #if( $parameters.listValue )
-            #set( $itemValue  = $stack.findValue($parameters.listValue) )
+            #set( $itemValue = $stack.findValue($parameters.listValue) )
         #else
             #set( $itemValue = $item )
         #end
 
-        <option value="$!webwork.htmlEncode($itemKey)" #if( $tag.contains($parameters.nameValue, $itemKey) )selected="selected"#end>$!webwork.htmlEncode($itemValue)</option>
+        <option value="$!webwork.htmlEncode($itemKey)"#if( $tag.contains($parameters.nameValue, $itemKey) ) selected="selected"#end>$!webwork.htmlEncode($itemValue)</option>
 
         #set ($trash = $stack.pop())
     #end

File src/test/com/opensymphony/webwork/TestAction.java

 
 import java.util.Collection;
 import java.util.Map;
+import java.util.List;
 
 
 /**
     private User user;
     private String[] array;
     private String[][] list;
+    private List list2;
 
     //~ Methods ////////////////////////////////////////////////////////////////
 
         return list;
     }
 
+    public List getList2() {
+        return list2;
+    }
+
+    public void setList2(List list2) {
+        this.list2 = list2;
+    }
+
     public void setMap(Map map) {
         this.map = map;
     }

File src/test/com/opensymphony/webwork/views/jsp/ui/Select-1.txt

             <option value="headerKey">headerValue</option>
             <option value=""></option>
             <option value="hello" selected="selected">world</option>
-            <option value="foo" >bar</option>
+            <option value="foo">bar</option>
         </select></td>
 </tr>

File src/test/com/opensymphony/webwork/views/jsp/ui/Select-2.txt

     <td><select name="collection" multiple="multiple" onmousedown="alert('onmousedown');" onmouseup="alert('onmouseup');" onmouseover="alert('onmouseover');" onmousemove="alert('onmousemove');" onmouseout="alert('onmouseout');" >
             <option value="hello" selected="selected">world</option>
             <option value="foo" selected="selected">bar</option>
-            <option value="cat" >dog</option>
+            <option value="cat">dog</option>
         </select></td>
 </tr>

File src/test/com/opensymphony/webwork/views/jsp/ui/Select-3.txt

+<tr>
+    <td align="right" valign="top"><label class="label">mylabel:</label></td>
+    <td><select name="collection" multiple="multiple" onmousedown="alert('onmousedown');" onmouseup="alert('onmouseup');" onmouseover="alert('onmouseover');" onmousemove="alert('onmousemove');" onmouseout="alert('onmouseout');" >
+            <option value="hello" selected="selected">1</option>
+            <option value="foo" selected="selected">2</option>
+            <option value="&lt;cat&gt;">1.5</option>
+        </select></td>
+</tr>

File src/test/com/opensymphony/webwork/views/jsp/ui/SelectTest.java

 import com.opensymphony.webwork.TestAction;
 import com.opensymphony.webwork.views.jsp.AbstractUITagTest;
 
+import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.List;
 
 
 /**
 public class SelectTest extends AbstractUITagTest {
     //~ Methods ////////////////////////////////////////////////////////////////
 
+    /** Tests WW-455: Select tag template does not work properly for Object like BigDecimal. */
+    public void testBigDecimal() throws Exception {
+        BigDecimalObject hello = new BigDecimalObject("hello", new BigDecimal(1));
+        BigDecimalObject foo = new BigDecimalObject("foo", new BigDecimal(2));
+
+        TestAction testAction = (TestAction) action;
+
+        Collection collection = new ArrayList(2);
+        // expect strings to be returned, we're still dealing with HTTP here!
+        collection.add("hello");
+        collection.add("foo");
+        testAction.setCollection(collection);
+
+        List list2 = new ArrayList();
+        list2.add(hello);
+        list2.add(foo);
+        list2.add(new BigDecimalObject("<cat>", new BigDecimal(1.500)));
+        testAction.setList2(list2);
+
+        SelectTag tag = new SelectTag();
+        tag.setPageContext(pageContext);
+        tag.setLabel("'mylabel'");
+        tag.setName("'collection'");
+        tag.setList("list2");
+        tag.setListKey("name");
+        tag.setListValue("bigDecimal");
+        tag.setMultiple("true");
+        tag.setOnmousedown("'alert(\\'onmousedown\\');'");
+        tag.setOnmousemove("'alert(\\'onmousemove\\');'");
+        tag.setOnmouseout("'alert(\\'onmouseout\\');'");
+        tag.setOnmouseover("'alert(\\'onmouseover\\');'");
+        tag.setOnmouseup("'alert(\\'onmouseup\\');'");
+
+        int result = tag.doEndTag();
+
+        verify(SelectTag.class.getResource("Select-3.txt"));
+    }
+
+    public class BigDecimalObject {
+        private String name;
+        private BigDecimal bigDecimal;
+
+        public BigDecimalObject(String name, BigDecimal bigDecimal) {
+            this.name = name;
+            this.bigDecimal = bigDecimal;
+        }
+
+        public String getName() {
+            return name;
+        }
+
+        public BigDecimal getBigDecimal() {
+            return bigDecimal;
+        }
+    }
+
     public void testMultiple() throws Exception {
         TestAction testAction = (TestAction) action;
         Collection collection = new ArrayList(2);