Revision: 4533
          http://sourceforge.net/p/vexi/code/4533
Author:   mkpg2
Date:     2013-06-20 22:18:52 +0000 (Thu, 20 Jun 2013)
Log Message:
-----------
Ability to set $vars in script, as a means of having globally accessible vars 
in a template.

Modified Paths:
--------------
    branches/vexi3/org.vexi-core.main/src/main/java/org/vexi/core/VML.java
    
branches/vexi3/org.vexi-core.main/src/test/java/test/core/template/lang_subtemplate_ids.t

Modified: branches/vexi3/org.vexi-core.main/src/main/java/org/vexi/core/VML.java
===================================================================
--- branches/vexi3/org.vexi-core.main/src/main/java/org/vexi/core/VML.java      
2013-06-20 17:03:57 UTC (rev 4532)
+++ branches/vexi3/org.vexi-core.main/src/main/java/org/vexi/core/VML.java      
2013-06-20 22:18:52 UTC (rev 4533)
@@ -336,26 +336,34 @@
                 
                 void putDollar(String key, JS target) throws JSExn {
                     JS jskey = JSU.S("$" + key);
-                    idContext.putDollar(jskey, target);
+                    putDollar(jskey, target);
                 }
                 // JS:FIXME: ugly
-                private void putDollar(JS key, JS val) throws JSExn { 
-                    if (subComponents==null) { 
-                        subComponents = new JS.Obj();
-                        object.put(SC_subComponents, subComponents);
-                    }
-                    subComponents.put(key,val); 
+                private void putDollar(JS key, JS val) throws JSExn {
+                       if(this==idContext){
+                           if (subComponents==null) { 
+                               subComponents = new JS.Obj();
+                               object.put(SC_subComponents, subComponents);
+                           }
+                           subComponents.put(key,val);
+                       }else{
+                               idContext.putDollar(key, val);
+                       }
                 }
                 
                 public JS getDollar(JS key) throws JSExn{
-                    if (subComponents!=null){
-                       JS r = subComponents.get(key);
-                       if(r!=null) return r;
-                    }
-                    if(idContextParent!=null){
-                       return idContextParent.getDollar(key);
-                    }
-                    return null;
+                       if(this==idContext){
+                               if (subComponents!=null){
+                               JS r = subComponents.get(key);
+                               if(r!=null) return r;
+                        }
+                               if(idContextParent!=null){
+                               return idContextParent.getDollar(key);
+                        }
+                        return null;
+                       }else{
+                               return idContext.getDollar(key);
+                       }
                 }
                 
 
@@ -392,7 +400,12 @@
 
                 // FIXME should come from JSGlobalScope ... or something 
                 public void put(JS key, JS val) throws JSExn {
-                    Main.SCHEDULER.putAndTriggerTraps(object,key,val);
+                       String s = JSU.toString(key);
+                       if(s.startsWith("$")){
+                               putDollar(key, val);
+                       }else{
+                               
Main.SCHEDULER.putAndTriggerTraps(object,key,val);
+                       }
                 }
                 
                 public JS callMethod(JS this_, JS method, JS[] args) throws 
JSExn {

Modified: 
branches/vexi3/org.vexi-core.main/src/test/java/test/core/template/lang_subtemplate_ids.t
===================================================================
--- 
branches/vexi3/org.vexi-core.main/src/test/java/test/core/template/lang_subtemplate_ids.t
   2013-06-20 17:03:57 UTC (rev 4532)
+++ 
branches/vexi3/org.vexi-core.main/src/test/java/test/core/template/lang_subtemplate_ids.t
   2013-06-20 22:18:52 UTC (rev 4533)
@@ -3,14 +3,16 @@
         <ui:Box id="title" text="Ids Test"/>
         <ui:Box id="main" text="Moo">
             thisbox.path ++= function(){
-                return $outer.text+" / "+$title.text+" / "+text;
+                return $outer.text+" / "+$title.text+" / "+$nonxml.text+" / 
"+text;
             };
         </ui:Box>
         
+        $nonxml = { text: "boo" };
         
+        
         <ui:Box id="content"/>
     
-
+        
     
         <lang:subtemplate property="sub">
             <ui:Box>
@@ -18,7 +20,7 @@
                 $item.text = arguments[0];
                 
                 thisbox.path ++= function(){
-                    return $outer.text+" / "+$title.text +" / "+$item.text;
+                    return $outer.text+" / "+$title.text +" / "+ 
$nonxml.text+" / "+$item.text;
                 };
                     
             </ui:Box>
@@ -28,9 +30,9 @@
         thisbox.add(new sub("A"));
         thisbox.add(new sub("B"));
         
-        .util..assertEquals("Outer / Ids Test / Moo",$main.path);
-        .util..assertEquals("Outer / Ids Test / A",thisbox[0].path);
-        .util..assertEquals("Outer / Ids Test / B",thisbox[1].path);
+        .util..assertEquals("Outer / Ids Test / boo / Moo",$main.path);
+        .util..assertEquals("Outer / Ids Test / boo / A",thisbox[0].path);
+        .util..assertEquals("Outer / Ids Test / boo / B",thisbox[1].path);
 
     </ui:Box>
     

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
Vexi-svn mailing list
Vexi-svn@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/vexi-svn

Reply via email to