struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lukaszlen...@apache.org
Subject [1/5] struts git commit: WW-4427 - Converters are no longer applied to values coming from the context - fix and UT
Date Tue, 23 Dec 2014 15:10:47 GMT
Repository: struts
Updated Branches:
  refs/heads/develop 40822d67f -> 60db1aadb


WW-4427 - Converters are no longer applied to values coming from the context - fix and UT


Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/6834b78f
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/6834b78f
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/6834b78f

Branch: refs/heads/develop
Commit: 6834b78fe9ec33e90530686e9c5101358750a854
Parents: 5f2898e
Author: Przemek Bruski <pbruski@atlassian.com>
Authored: Tue Dec 9 17:17:15 2014 +0100
Committer: Przemek Bruski <pbruski@atlassian.com>
Committed: Tue Dec 9 17:17:15 2014 +0100

----------------------------------------------------------------------
 .../com/opensymphony/xwork2/ognl/OgnlValueStack.java     |  2 ++
 .../com/opensymphony/xwork2/ognl/OgnlValueStackTest.java | 11 +++++++++++
 2 files changed, 13 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/struts/blob/6834b78f/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/OgnlValueStack.java
----------------------------------------------------------------------
diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/OgnlValueStack.java b/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/OgnlValueStack.java
index 90b1a54..ce273b1 100644
--- a/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/OgnlValueStack.java
+++ b/xwork-core/src/main/java/com/opensymphony/xwork2/ognl/OgnlValueStack.java
@@ -351,6 +351,8 @@ public class OgnlValueStack implements Serializable, ValueStack, ClearableValueS
             value = getValue(expr, asType);
             if (value == null) {
                 value = findInContext(expr);
+                final XWorkConverter conv = ((Container)getContext().get(ActionContext.CONTAINER)).getInstance(XWorkConverter.class);
+                return conv.convertValue(getContext(), value, asType);
             }
         } finally {
             context.remove(THROW_EXCEPTION_ON_FAILURE);

http://git-wip-us.apache.org/repos/asf/struts/blob/6834b78f/xwork-core/src/test/java/com/opensymphony/xwork2/ognl/OgnlValueStackTest.java
----------------------------------------------------------------------
diff --git a/xwork-core/src/test/java/com/opensymphony/xwork2/ognl/OgnlValueStackTest.java
b/xwork-core/src/test/java/com/opensymphony/xwork2/ognl/OgnlValueStackTest.java
index e0e949c..769fcf7 100644
--- a/xwork-core/src/test/java/com/opensymphony/xwork2/ognl/OgnlValueStackTest.java
+++ b/xwork-core/src/test/java/com/opensymphony/xwork2/ognl/OgnlValueStackTest.java
@@ -93,6 +93,17 @@ public class OgnlValueStackTest extends XWorkTestCase {
         assertEquals("1, 2", vs.findValue("childAges", String.class));
     }
 
+    public void testValuesFromContextAreConverted() {
+        final OgnlValueStack vs = createValueStack();
+        vs.getContext().put(ActionContext.CONTAINER, container);
+
+        final String propertyName = "dogName";
+        final String propertyValue = "Rover";
+        vs.getContext().put(propertyName, new String[]{propertyValue});
+
+        assertEquals(propertyValue, vs.findValue(propertyName, String.class));
+    }
+
     public void testFailOnException() {
         OgnlValueStack vs = createValueStack();
 


Mime
View raw message