You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by rw...@apache.org on 2016/04/22 19:20:35 UTC

svn commit: r1740574 - in /pivot/branches/2.0.x: ./ core/src/org/apache/pivot/beans/BXMLSerializer.java

Author: rwhitcomb
Date: Fri Apr 22 17:20:35 2016
New Revision: 1740574

URL: http://svn.apache.org/viewvc?rev=1740574&view=rev
Log:
PIVOT-987:  Address the different handling of script return values
from attributes versus elements.

The script return value was being ignored in AttributeInvocationHandler
and the default values were always being used.  But in the similar
code in ElementInvocationHandler the script result was being used
and the defaults only used if the script method returns nothing.

Bring the code for attributes in line with that for elements.

This is a merge of revision r1740570 from trunk to branches/2.0.x.

Note: the merge includes the minor change also from trunk that
changes the return value in the Boolean case from "false" to
Boolean.FALSE.  I believe this was found by a "lint" check of
the code.


Modified:
    pivot/branches/2.0.x/   (props changed)
    pivot/branches/2.0.x/core/src/org/apache/pivot/beans/BXMLSerializer.java

Propchange: pivot/branches/2.0.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Apr 22 17:20:35 2016
@@ -1 +1 @@
-/pivot/trunk:1346574,1347051,1394847,1394858,1398511,1399331,1401781,1405882,1407585,1409081,1410536,1410555,1417081,1417258,1428056,1428650,1435351,1436707,1438126,1438659,1444260,1444910,1502657,1510821,1516518,1519859,1522078,1523205,1523736,1523776,1525982,1526005,1536829,1537222,1604238,1610563,1611829,1614462,1624381,1675204,1675517,1678238,1678251,1687873-1687874,1688306,1688484,1688523,1691618,1712175,1717360,1727931,1728247,1729480,1729493,1730100,1730108
+/pivot/trunk:1346574,1347051,1394847,1394858,1398511,1399331,1401781,1405882,1407585,1409081,1410536,1410555,1417081,1417258,1428056,1428650,1435351,1436707,1438126,1438659,1444260,1444910,1502657,1510821,1516518,1519859,1522078,1523205,1523736,1523776,1525982,1526005,1536829,1537222,1604238,1610563,1611829,1614462,1624381,1675204,1675517,1678238,1678251,1687873-1687874,1688306,1688484,1688523,1691618,1712175,1717360,1727931,1728247,1729480,1729493,1730100,1730108,1740570

Modified: pivot/branches/2.0.x/core/src/org/apache/pivot/beans/BXMLSerializer.java
URL: http://svn.apache.org/viewvc/pivot/branches/2.0.x/core/src/org/apache/pivot/beans/BXMLSerializer.java?rev=1740574&r1=1740573&r2=1740574&view=diff
==============================================================================
--- pivot/branches/2.0.x/core/src/org/apache/pivot/beans/BXMLSerializer.java (original)
+++ pivot/branches/2.0.x/core/src/org/apache/pivot/beans/BXMLSerializer.java Fri Apr 22 17:20:35 2016
@@ -153,18 +153,20 @@ public class BXMLSerializer implements S
                     bindings.put(ARGUMENTS_KEY, args);
                     scriptEngine.setBindings(bindings, ScriptContext.ENGINE_SCOPE);
                     scriptEngine.eval(NASHORN_COMPAT_SCRIPT);
-                    scriptEngine.eval(script);
+                    result = scriptEngine.eval(script);
                 } catch (ScriptException exception) {
                     reportException(exception, script);
                 }
             }
 
             // If the function didn't return a value, return the default
-            Class<?> returnType = method.getReturnType();
-            if (returnType == Vote.class) {
-                result = Vote.APPROVE;
-            } else if (returnType == Boolean.TYPE) {
-                result = false;
+            if (result == null) {
+                Class<?> returnType = method.getReturnType();
+                if (returnType == Vote.class) {
+                    result = Vote.APPROVE;
+                } else if (returnType == Boolean.TYPE) {
+                    result = Boolean.FALSE;
+                }
             }
 
             return result;