XComponent - tweaking failure conditions.
authorAlan Knowles <alan@akbkhome.com>
Thu, 4 Aug 2011 04:39:54 +0000 (04:39 +0000)
committerAlan Knowles <alan@akbkhome.com>
Wed, 7 Sep 2011 02:27:21 +0000 (10:27 +0800)
Roo/XComponent.js
roojs-all.js
roojs-debug.js
roojs-ui-debug.js
roojs-ui.js

index 060df50..37b7bda 100644 (file)
@@ -256,7 +256,12 @@ Roo.apply(Roo.XComponent, {
         var rt, o;
         rt = ar.shift();
             /** eval:var:o */
-        eval('if (typeof ' + rt + ' == "undefined"){ o = false;} o = ' + rt + ';');
+        try {
+            eval('if (typeof ' + rt + ' == "undefined"){ o = false;} o = ' + rt + ';');
+        } catch (e) {
+            throw "Module not found : " + str;
+        }
+        
         if (o === false) {
             throw "Module not found : " + str;
         }
@@ -282,7 +287,12 @@ Roo.apply(Roo.XComponent, {
         Roo.each(this.modules , function (obj)
         {
             var opar = obj.parent;
-            obj.parent = this.toObject(opar);
+            try { 
+                obj.parent = this.toObject(opar);
+            } catch(e) {
+                Roo.log(e.toString());
+                return;
+            }
             
             if (!obj.parent) {
                 this.topModule = obj;
index ac07c51..361cb2a 100644 (file)
@@ -958,9 +958,9 @@ D.push({id:id,target:G,exec:F,test:fn,body:m[1]||''});s=s.replace(m[0],'{xtpl'+i
 this.master=D[D.length-1];this.tpls=D;};Roo.extend(Roo.XTemplate,Roo.Template,{re:/\{([\w-\.]+)(?:\:([\w\.]*)(?:\((.*?)?\))?)?\}/g,applySubTemplate:function(id,A,B){var t=this.tpls[id];if(t.test&&!t.test.call(this,A,B)){return '';}if(t.exec&&t.exec.call(this,A,B)){return '';}var vs=t.target?t.target.call(this,A,B):A;B=t.target?A:B;if(t.target&&vs instanceof Array){var C=[];for(var i=0,D=vs.length;i<D;i++){C[C.length]=t.compiled.call(this,vs[i],B);}return C.join('');}return t.compiled.call(this,vs,B);},compileTpl:function(A){var fm=Roo.util.Format;var B=this.disableFormats!==true;var C=Roo.isGecko?"+":",";var fn=function(m,E,F,G){if(E.substr(0,4)=='xtpl'){return "'"+C+'this.applySubTemplate('+E.substr(4)+', values, parent)'+C+"'";}var v;if(E.indexOf('.')!=-1){v=E;}else {v="values['"+E+"']";}if(F&&B){G=G?','+G:"";if(F.substr(0,5)!="this."){F="fm."+F+'(';}else {F='this.call("'+F.substr(5)+'", ';G=", values";}}else {G='';F="("+v+" === undefined ? '' : ";}return "'"+C+F+v+G+")"+C+"'";};var D;if(Roo.isGecko){D="tpl.compiled = function(values, parent){ return '"+A.body.replace(/(\r\n|\n)/g,'\\n').replace(/'/g,"\\'").replace(this.re,fn)+"';};";}else {D=["tpl.compiled = function(values, parent){ return ['"];D.push(A.body.replace(/(\r\n|\n)/g,'\\n').replace(/'/g,"\\'").replace(this.re,fn));D.push("'].join('');};");D=D.join('');}eval(D);return this;},applyTemplate:function(A){return this.master.compiled.call(this,A,{});var s=this.subs;},apply:function(){return this.applyTemplate.apply(this,arguments);},compile:function(){return this;}});Roo.XTemplate.from=function(el){el=Roo.getDom(el);return new Roo.XTemplate(el.value||el.innerHTML);};
 Roo.XComponent=function(A){Roo.apply(this,A);this.addEvents({'built':true,'buildcomplete':true});this.region=this.region||'center';Roo.XComponent.register(this);this.modules=false;this.el=false;}
 Roo.extend(Roo.XComponent,Roo.util.Observable,{el:false,panel:false,layout:false,disabled:false,parent:false,order:false,name:false,region:'center',items:false,render:function(el){el=el||false;var hp=this.parent?1:0;if(!el&&typeof(this.parent)=='string'&&this.parent[0]=='#'){var A=this.parent.substr(1)
-this.parent=false;el=Roo.get(A);if(!el){Roo.log("Warning - element can not be found :#"+A);return;}}if(!this.parent){el=el?Roo.get(el):false;this.parent={el:new Roo.BorderLayout(el||document.body,{center:{titlebar:false,autoScroll:false,closeOnTab:true,tabPosition:'top',alwaysShowTabs:el&&hp?false:true,hideTabs:el||!hp?true:false,minTabWidth:140}})}}var B=this.tree();B.region=B.region||this.region;this.el=this.parent.el.addxtype(B);this.fireEvent('built',this);this.panel=this.el;this.layout=this.panel.layout;}});Roo.apply(Roo.XComponent,{buildCompleted:false,topModule:false,modules:[],elmodules:[],register:function(A){this.modules.push(A);},toObject:function(A){if(!A||typeof(A)=='object'){return A;}if(A[0]=='#'){return A;}var ar=A.split('.');var rt,o;rt=ar.shift();eval('if (typeof '+rt+' == "undefined"){ o = false;} o = '+rt+';');if(o===false){throw "Module not found : "+A;}
-Roo.each(ar,function(e){if(typeof(o[e])=='undefined'){throw "Module not found : "+A;}
-o=o[e];});return o;},preBuild:function(){var _t=this;Roo.each(this.modules,function(A){var B=A.parent;A.parent=this.toObject(B);if(!A.parent){this.topModule=A;return;}if(typeof(A.parent)=='string'){this.elmodules.push(A);return;}if(A.parent.constructor!=Roo.XComponent){Roo.log("Object Parent is not instance of XComponent:"+A.name)}if(!A.parent.modules){A.parent.modules=new Roo.util.MixedCollection(false,function(o){return o.order+''});}
+this.parent=false;el=Roo.get(A);if(!el){Roo.log("Warning - element can not be found :#"+A);return;}}if(!this.parent){el=el?Roo.get(el):false;this.parent={el:new Roo.BorderLayout(el||document.body,{center:{titlebar:false,autoScroll:false,closeOnTab:true,tabPosition:'top',alwaysShowTabs:el&&hp?false:true,hideTabs:el||!hp?true:false,minTabWidth:140}})}}var B=this.tree();B.region=B.region||this.region;this.el=this.parent.el.addxtype(B);this.fireEvent('built',this);this.panel=this.el;this.layout=this.panel.layout;}});Roo.apply(Roo.XComponent,{buildCompleted:false,topModule:false,modules:[],elmodules:[],register:function(A){this.modules.push(A);},toObject:function(str){if(!str||typeof(str)=='object'){return str;}if(str[0]=='#'){return str;}var ar=str.split('.');var rt,o;rt=ar.shift();try{eval('if (typeof '+rt+' == "undefined"){ o = false;} o = '+rt+';');}catch(e){throw "Module not found : "+str;}if(o===false){throw "Module not found : "+str;}
+Roo.each(ar,function(e){if(typeof(o[e])=='undefined'){throw "Module not found : "+str;}
+o=o[e];});return o;},preBuild:function(){var _t=this;Roo.each(this.modules,function(A){var B=A.parent;try{A.parent=this.toObject(B);}catch(e){Roo.log(e.toString());return;}if(!A.parent){this.topModule=A;return;}if(typeof(A.parent)=='string'){this.elmodules.push(A);return;}if(A.parent.constructor!=Roo.XComponent){Roo.log("Object Parent is not instance of XComponent:"+A.name)}if(!A.parent.modules){A.parent.modules=new Roo.util.MixedCollection(false,function(o){return o.order+''});}
 A.parent.modules.add(A);},this);},buildOrder:function(){var A=this;var B=function(a,b){return String(a).toUpperCase()>String(b).toUpperCase()?1:-1;};if((!this.topModule||!this.topModule.modules)&&!this.elmodules.length){throw "No top level modules to build";}var C=this.topModule?[this.topModule]:[];Roo.each(this.elmodules,function(e){C.push(e)});var D=function(m){C.push(m);if(m.modules){m.modules.keySort('ASC',B);m.modules.each(D);}if(m.finalize){m.finalize.name=m.name+" (clean up) ";C.push(m.finalize);}};if(this.topModule){this.topModule.modules.keySort('ASC',B);this.topModule.modules.each(D);}return C;},build:function(){this.preBuild();var A=this.buildOrder();if(!A.length){throw "NO modules!!!";}
 Roo.MessageBox.show({title:'loading'});Roo.MessageBox.show({title:"Please wait...",msg:"Building Interface...",width:450,progress:true,closable:false,modal:false});var B=A.length;var C=this;var D=function(){if(!A.length){Roo.debug&&Roo.log('hide?');Roo.MessageBox.hide();if(C.topModule){C.topModule.fireEvent('buildcomplete',C.topModule);}return false;}var m=A.shift();Roo.debug&&Roo.log(m);if(typeof(m)=='function'){m.call(this);return D.defer(10,C);}Roo.MessageBox.updateProgress((B-A.length)/B,"Building Interface "+(B-A.length)+" of "+B+(m.name?(' - '+m.name):''));var E=(typeof(m.disabled)=='function')?m.disabled.call(m.module.disabled):m.disabled;if(E){return D();}
 m.render();return D.defer(10,C);}
index b8ee0ef..c9e0eed 100644 (file)
@@ -23671,6 +23671,8 @@ Roo.View = function(config, depreciated_tpl, depreciated_config){
          * Fires on every row to render, to allow you to change the data.
          * @param {Roo.View} this
          * @param {Object} data to be rendered (change this)
+         * @param {Number} row being rendered
+         * @param {Roo.data.Record} record being rendered.
          */
           "preparedata" : true
         });
@@ -51572,7 +51574,12 @@ Roo.apply(Roo.XComponent, {
         var rt, o;
         rt = ar.shift();
             /** eval:var:o */
-        eval('if (typeof ' + rt + ' == "undefined"){ o = false;} o = ' + rt + ';');
+        try {
+            eval('if (typeof ' + rt + ' == "undefined"){ o = false;} o = ' + rt + ';');
+        } catch (e) {
+            throw "Module not found : " + str;
+        }
+        
         if (o === false) {
             throw "Module not found : " + str;
         }
@@ -51598,7 +51605,12 @@ Roo.apply(Roo.XComponent, {
         Roo.each(this.modules , function (obj)
         {
             var opar = obj.parent;
-            obj.parent = this.toObject(opar);
+            try { 
+                obj.parent = this.toObject(opar);
+            } catch(e) {
+                Roo.log(e.toString());
+                return;
+            }
             
             if (!obj.parent) {
                 this.topModule = obj;
index 4b05276..bcba846 100644 (file)
@@ -9211,6 +9211,8 @@ Roo.View = function(config, depreciated_tpl, depreciated_config){
          * Fires on every row to render, to allow you to change the data.
          * @param {Roo.View} this
          * @param {Object} data to be rendered (change this)
+         * @param {Number} row being rendered
+         * @param {Roo.data.Record} record being rendered.
          */
           "preparedata" : true
         });
@@ -37112,7 +37114,12 @@ Roo.apply(Roo.XComponent, {
         var rt, o;
         rt = ar.shift();
             /** eval:var:o */
-        eval('if (typeof ' + rt + ' == "undefined"){ o = false;} o = ' + rt + ';');
+        try {
+            eval('if (typeof ' + rt + ' == "undefined"){ o = false;} o = ' + rt + ';');
+        } catch (e) {
+            throw "Module not found : " + str;
+        }
+        
         if (o === false) {
             throw "Module not found : " + str;
         }
@@ -37138,7 +37145,12 @@ Roo.apply(Roo.XComponent, {
         Roo.each(this.modules , function (obj)
         {
             var opar = obj.parent;
-            obj.parent = this.toObject(opar);
+            try { 
+                obj.parent = this.toObject(opar);
+            } catch(e) {
+                Roo.log(e.toString());
+                return;
+            }
             
             if (!obj.parent) {
                 this.topModule = obj;
index 2e4d769..4917e52 100644 (file)
@@ -714,9 +714,9 @@ D.push({id:id,target:G,exec:F,test:fn,body:m[1]||''});s=s.replace(m[0],'{xtpl'+i
 this.master=D[D.length-1];this.tpls=D;};Roo.extend(Roo.XTemplate,Roo.Template,{re:/\{([\w-\.]+)(?:\:([\w\.]*)(?:\((.*?)?\))?)?\}/g,applySubTemplate:function(id,A,B){var t=this.tpls[id];if(t.test&&!t.test.call(this,A,B)){return '';}if(t.exec&&t.exec.call(this,A,B)){return '';}var vs=t.target?t.target.call(this,A,B):A;B=t.target?A:B;if(t.target&&vs instanceof Array){var C=[];for(var i=0,D=vs.length;i<D;i++){C[C.length]=t.compiled.call(this,vs[i],B);}return C.join('');}return t.compiled.call(this,vs,B);},compileTpl:function(A){var fm=Roo.util.Format;var B=this.disableFormats!==true;var C=Roo.isGecko?"+":",";var fn=function(m,E,F,G){if(E.substr(0,4)=='xtpl'){return "'"+C+'this.applySubTemplate('+E.substr(4)+', values, parent)'+C+"'";}var v;if(E.indexOf('.')!=-1){v=E;}else {v="values['"+E+"']";}if(F&&B){G=G?','+G:"";if(F.substr(0,5)!="this."){F="fm."+F+'(';}else {F='this.call("'+F.substr(5)+'", ';G=", values";}}else {G='';F="("+v+" === undefined ? '' : ";}return "'"+C+F+v+G+")"+C+"'";};var D;if(Roo.isGecko){D="tpl.compiled = function(values, parent){ return '"+A.body.replace(/(\r\n|\n)/g,'\\n').replace(/'/g,"\\'").replace(this.re,fn)+"';};";}else {D=["tpl.compiled = function(values, parent){ return ['"];D.push(A.body.replace(/(\r\n|\n)/g,'\\n').replace(/'/g,"\\'").replace(this.re,fn));D.push("'].join('');};");D=D.join('');}eval(D);return this;},applyTemplate:function(A){return this.master.compiled.call(this,A,{});var s=this.subs;},apply:function(){return this.applyTemplate.apply(this,arguments);},compile:function(){return this;}});Roo.XTemplate.from=function(el){el=Roo.getDom(el);return new Roo.XTemplate(el.value||el.innerHTML);};
 Roo.XComponent=function(A){Roo.apply(this,A);this.addEvents({'built':true,'buildcomplete':true});this.region=this.region||'center';Roo.XComponent.register(this);this.modules=false;this.el=false;}
 Roo.extend(Roo.XComponent,Roo.util.Observable,{el:false,panel:false,layout:false,disabled:false,parent:false,order:false,name:false,region:'center',items:false,render:function(el){el=el||false;var hp=this.parent?1:0;if(!el&&typeof(this.parent)=='string'&&this.parent[0]=='#'){var A=this.parent.substr(1)
-this.parent=false;el=Roo.get(A);if(!el){Roo.log("Warning - element can not be found :#"+A);return;}}if(!this.parent){el=el?Roo.get(el):false;this.parent={el:new Roo.BorderLayout(el||document.body,{center:{titlebar:false,autoScroll:false,closeOnTab:true,tabPosition:'top',alwaysShowTabs:el&&hp?false:true,hideTabs:el||!hp?true:false,minTabWidth:140}})}}var B=this.tree();B.region=B.region||this.region;this.el=this.parent.el.addxtype(B);this.fireEvent('built',this);this.panel=this.el;this.layout=this.panel.layout;}});Roo.apply(Roo.XComponent,{buildCompleted:false,topModule:false,modules:[],elmodules:[],register:function(A){this.modules.push(A);},toObject:function(A){if(!A||typeof(A)=='object'){return A;}if(A[0]=='#'){return A;}var ar=A.split('.');var rt,o;rt=ar.shift();eval('if (typeof '+rt+' == "undefined"){ o = false;} o = '+rt+';');if(o===false){throw "Module not found : "+A;}
-Roo.each(ar,function(e){if(typeof(o[e])=='undefined'){throw "Module not found : "+A;}
-o=o[e];});return o;},preBuild:function(){var _t=this;Roo.each(this.modules,function(A){var B=A.parent;A.parent=this.toObject(B);if(!A.parent){this.topModule=A;return;}if(typeof(A.parent)=='string'){this.elmodules.push(A);return;}if(A.parent.constructor!=Roo.XComponent){Roo.log("Object Parent is not instance of XComponent:"+A.name)}if(!A.parent.modules){A.parent.modules=new Roo.util.MixedCollection(false,function(o){return o.order+''});}
+this.parent=false;el=Roo.get(A);if(!el){Roo.log("Warning - element can not be found :#"+A);return;}}if(!this.parent){el=el?Roo.get(el):false;this.parent={el:new Roo.BorderLayout(el||document.body,{center:{titlebar:false,autoScroll:false,closeOnTab:true,tabPosition:'top',alwaysShowTabs:el&&hp?false:true,hideTabs:el||!hp?true:false,minTabWidth:140}})}}var B=this.tree();B.region=B.region||this.region;this.el=this.parent.el.addxtype(B);this.fireEvent('built',this);this.panel=this.el;this.layout=this.panel.layout;}});Roo.apply(Roo.XComponent,{buildCompleted:false,topModule:false,modules:[],elmodules:[],register:function(A){this.modules.push(A);},toObject:function(str){if(!str||typeof(str)=='object'){return str;}if(str[0]=='#'){return str;}var ar=str.split('.');var rt,o;rt=ar.shift();try{eval('if (typeof '+rt+' == "undefined"){ o = false;} o = '+rt+';');}catch(e){throw "Module not found : "+str;}if(o===false){throw "Module not found : "+str;}
+Roo.each(ar,function(e){if(typeof(o[e])=='undefined'){throw "Module not found : "+str;}
+o=o[e];});return o;},preBuild:function(){var _t=this;Roo.each(this.modules,function(A){var B=A.parent;try{A.parent=this.toObject(B);}catch(e){Roo.log(e.toString());return;}if(!A.parent){this.topModule=A;return;}if(typeof(A.parent)=='string'){this.elmodules.push(A);return;}if(A.parent.constructor!=Roo.XComponent){Roo.log("Object Parent is not instance of XComponent:"+A.name)}if(!A.parent.modules){A.parent.modules=new Roo.util.MixedCollection(false,function(o){return o.order+''});}
 A.parent.modules.add(A);},this);},buildOrder:function(){var A=this;var B=function(a,b){return String(a).toUpperCase()>String(b).toUpperCase()?1:-1;};if((!this.topModule||!this.topModule.modules)&&!this.elmodules.length){throw "No top level modules to build";}var C=this.topModule?[this.topModule]:[];Roo.each(this.elmodules,function(e){C.push(e)});var D=function(m){C.push(m);if(m.modules){m.modules.keySort('ASC',B);m.modules.each(D);}if(m.finalize){m.finalize.name=m.name+" (clean up) ";C.push(m.finalize);}};if(this.topModule){this.topModule.modules.keySort('ASC',B);this.topModule.modules.each(D);}return C;},build:function(){this.preBuild();var A=this.buildOrder();if(!A.length){throw "NO modules!!!";}
 Roo.MessageBox.show({title:'loading'});Roo.MessageBox.show({title:"Please wait...",msg:"Building Interface...",width:450,progress:true,closable:false,modal:false});var B=A.length;var C=this;var D=function(){if(!A.length){Roo.debug&&Roo.log('hide?');Roo.MessageBox.hide();if(C.topModule){C.topModule.fireEvent('buildcomplete',C.topModule);}return false;}var m=A.shift();Roo.debug&&Roo.log(m);if(typeof(m)=='function'){m.call(this);return D.defer(10,C);}Roo.MessageBox.updateProgress((B-A.length)/B,"Building Interface "+(B-A.length)+" of "+B+(m.name?(' - '+m.name):''));var E=(typeof(m.disabled)=='function')?m.disabled.call(m.module.disabled):m.disabled;if(E){return D();}
 m.render();return D.defer(10,C);}