I don't have time to review the commit history right now. If the change was made during the refactoring, then I agree there is a regression.

Adrian Crum
Sandglass Software
www.sandglass-software.com

On 9/26/2014 8:31 AM, Jacopo Cappellato wrote:
I may be wrong but... this syntax used to work before.
In fact there is still code in OFBiz, older than the refactoring, that uses 
this syntax and was probably broken by the change.
And in the other thread "Error when result-name contains a ${} expression" you 
confirmed that the code should actually work as below

Jacopo Cappellato wrote:
<set field="total" value="10" type="BigDecimal"/>
<set field="result1" value="totalOrders"/>
<field-to-result field="total" result-name="${result1}"/>

I would expect that the above returns: expression == "totalOrders"
Is it correct assumption?
Adrian Crum wrote:
Yes, that it the way it should work.

Jacopo



On Sep 26, 2014, at 9:24 AM, Adrian Crum <[email protected]> 
wrote:

Yes, that is what I am saying. Please see the Attribute Types section in the 
grammar:

https://cwiki.apache.org/confluence/display/OFBADMIN/Mini-language+%28minilang%29+Reference

Adrian Crum
Sandglass Software
www.sandglass-software.com

On 9/26/2014 8:21 AM, Jacopo Cappellato wrote:
I am confused... are you saying that the syntax:

<field-to-result field="val" result-name="${key}"/>

is not supported?

Jacopo



On Sep 26, 2014, at 9:02 AM, Adrian Crum <[email protected]> 
wrote:

The element is behaving as specified in the schema:

<xs:documentation>
                        The name of the result field to set. The target of the 
assignment.
                        Defaults to the value of the field attribute.

                        Optional. Attribute type: expression.
                    </xs:documentation>


Adrian Crum
Sandglass Software
www.sandglass-software.com

On 9/26/2014 7:56 AM, [email protected] wrote:
Author: jacopoc
Date: Fri Sep 26 06:56:27 2014
New Revision: 1627718

URL: http://svn.apache.org/r1627718
Log:
JUnit test to prove that field-to-result doesn't work properly when result-name 
contains the a ${} field.

Modified:
     
ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/test/MiniLangTests.java

Modified: 
ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/test/MiniLangTests.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/test/MiniLangTests.java?rev=1627718&r1=1627717&r2=1627718&view=diff
==============================================================================
--- 
ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/test/MiniLangTests.java 
(original)
+++ 
ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/test/MiniLangTests.java 
Fri Sep 26 06:56:27 2014
@@ -91,4 +91,18 @@ public class MiniLangTests extends OFBiz
          assertTrue("<assert> error message text", 
errorMessage.startsWith("Assertion failed:"));
      }

+    public void testFieldToResultOperation() throws Exception {
+        String simpleMethodXml = "<simple-method name=\"testFieldToResult\">" +
+                                 "  <set field=\"resultValue\" 
value=\"someResultValue\"/>" +
+                                 "  <set field=\"result1\" 
value=\"dynamicResultName\"/>" +
+                                 "  <field-to-result field=\"resultValue\" 
result-name=\"constantResultName\"/>" +
+                                 "  <field-to-result field=\"resultValue\" 
result-name=\"${result1}\"/>" +
+                                 "</simple-method>";
+        SimpleMethod methodToTest = createSimpleMethod(simpleMethodXml);
+        MethodContext context = createServiceMethodContext();
+        String result = methodToTest.exec(context);
+        assertEquals("testFieldToResult success result", 
methodToTest.getDefaultSuccessCode(), result);
+        assertEquals("Constant result name set", "someResultValue", 
context.getResult("constantResultName"));
+        //assertEquals("Dynamic result name set", "someResultValue", 
context.getResult("dynamicResultName")); This one fails!
+    }
  }




Reply via email to