You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by sm...@apache.org on 2012/08/08 14:51:55 UTC

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

Author: smartini
Date: Wed Aug  8 12:51:54 2012
New Revision: 1370749

URL: http://svn.apache.org/viewvc?rev=1370749&view=rev
Log:
add the ability to use a (JavaScript) variable (defined for example inside the bxml file) to use as a src for the include of another bxml file, as here:
var baseURL  = ...
var frameURL = ...
...
        <bxml:include bxml:id="testRemoteFrame" src="$frameURL"/>

A sample usage of this will be in the JavaScript Console Test, under tests.

Modified:
    pivot/branches/2.0.x/core/src/org/apache/pivot/beans/BXMLSerializer.java

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=1370749&r1=1370748&r2=1370749&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 Wed Aug  8 12:51:54 2012
@@ -823,6 +823,16 @@ public class BXMLSerializer implements S
             }
 
             String src = element.properties.get(INCLUDE_SRC_ATTRIBUTE);
+            if (src.charAt(0) == OBJECT_REFERENCE_PREFIX) {
+                src = src.substring(1);
+                if (src.length() > 0) {
+                    if (!JSON.containsKey(namespace, src)) {
+                        throw new SerializationException("Value \"" + src + "\" is not defined.");
+                    }
+                    String variableValue = JSON.get(namespace, src);
+                    src = variableValue;
+                }
+            }
 
             Resources resourcesLocal = this.resources;
             if (element.properties.containsKey(INCLUDE_RESOURCES_ATTRIBUTE)) {