On Sep 26, 2014, at 5:02 PM, Adrian Crum <[email protected]>
wrote:
> The change should be self-explanatory. If the attribute contains a nested
> expression, then use FSE to expand the nested expression before using FMA to
> retrieve the value.
Like this:
<field-to-result field="total" result-name="${result}"/>
?
>
> Adrian Crum
> Sandglass Software
> www.sandglass-software.com
>
> On 9/26/2014 1:11 PM, Jacopo Cappellato wrote:
>> Adrian,
>>
>> this is still related to the issue related to the field-to-result operation
>> with an ${} value in the result name.
>> This is the modification you did a couple of years ago trying to fix the
>> issue I reported at that time.
>> Could you help me to understand what is the effect of this enhancement? An
>> example of intended usage of the <field-to-result/> element would be enough.
>>
>> Jacopo
>>
>>
>>
>> On May 14, 2012, at 10:49 PM, [email protected] wrote:
>>
>>> Author: adrianc
>>> Date: Mon May 14 20:49:01 2012
>>> New Revision: 1338394
>>>
>>> URL: http://svn.apache.org/viewvc?rev=1338394&view=rev
>>> Log:
>>> Fixed a bug in Mini-language <field-to-result> element where nested
>>> expressions were not evaluated correctly.
>>>
>>> Modified:
>>>
>>> ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/serviceops/FieldToResult.java
>>>
>>> Modified:
>>> ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/serviceops/FieldToResult.java
>>> URL:
>>> http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/serviceops/FieldToResult.java?rev=1338394&r1=1338393&r2=1338394&view=diff
>>> ==============================================================================
>>> ---
>>> ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/serviceops/FieldToResult.java
>>> (original)
>>> +++
>>> ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/serviceops/FieldToResult.java
>>> Mon May 14 20:49:01 2012
>>> @@ -28,7 +28,7 @@ import org.ofbiz.minilang.method.MethodO
>>> import org.w3c.dom.Element;
>>>
>>> /**
>>> - * Copies a field to a service OUT attribute.
>>> + * Copies a field to the simple-method result Map.
>>> */
>>> public final class FieldToResult extends MethodOperation {
>>>
>>> @@ -58,9 +58,13 @@ public final class FieldToResult extends
>>> public boolean exec(MethodContext methodContext) throws
>>> MiniLangException {
>>> Object fieldVal = this.fieldFma.get(methodContext.getEnvMap());
>>> if (fieldVal != null) {
>>> - // FIXME: Needs special handling for nested expressions.
>>> - // The result attribute might contain a reference to an
>>> environment (not result Map) variable.
>>> - this.resultFma.put(methodContext.getResults(), fieldVal);
>>> + if (this.resultFma.containsNestedExpression()) {
>>> + String expression = (String)
>>> this.resultFma.get(methodContext.getEnvMap());
>>> + FlexibleMapAccessor<Object> resultFma =
>>> FlexibleMapAccessor.getInstance(expression);
>>> + resultFma.put(methodContext.getResults(), fieldVal);
>>> + } else {
>>> + this.resultFma.put(methodContext.getResults(), fieldVal);
>>> + }
>>> }
>>> return true;
>>> }
>>>
>>>
>>