Author: jmorliaguet
Date: Sat Mar 18 16:31:40 2006
New Revision: 2654

Modified:
   cpsskins/branches/jmo-perspectives/ui/framework/cpsskins.js
Log:

- fixes: MVC components should only be instanciated once otherwise there is no
  way to store permanent information in the instances.



Modified: cpsskins/branches/jmo-perspectives/ui/framework/cpsskins.js
==============================================================================
--- cpsskins/branches/jmo-perspectives/ui/framework/cpsskins.js (original)
+++ cpsskins/branches/jmo-perspectives/ui/framework/cpsskins.js Sat Mar 18 
16:31:40 2006
@@ -272,22 +272,27 @@
       switch(classid) {
 
         case "controller": {
-          var controller_type = def.type || "command";
-          var factory = this.Controllers[controller_type];
-          if (factory) {
-            var controller = factory(node, def);
-            controller.setup();
-            this._controllers[id] = controller;
-            CPSSkins.notify("registered controller",
-              {'publisher': controller, 'scope': id}
-            );
+          var controller = this.getControllerById(id);
+          if (!controller) {
+            var controller_type = def.type || "command";
+            var factory = this.Controllers[controller_type];
+            if (factory) {
+              controller = factory(node, def);
+              this._controllers[id] = controller;
+            }
           }
+          CPSSkins.notify("registered controller",
+            {'publisher': controller, 'scope': id}
+          );
           break;
         }
 
         case "model": {
-          var model = new CPSSkins.Model(node, def);
-          this._models[id] = model;
+          var model = this.getModelById(id);
+          if (!model) {
+            model = new CPSSkins.Model(node, def);
+            this._models[id] = model;
+          }
           CPSSkins.notify("registered model",
             {'publisher': model, 'scope': id}
           );
@@ -295,7 +300,6 @@
         }
 
         case "view": {
-          var view;
           var widget_type;
 
           var template = def.widget.template;
@@ -322,9 +326,12 @@
             }
           }
 
-          factory = this.Widgets[widget_type];
-          view = factory(def);
-          this._views[id] = view;
+          var view = this.getViewById(id);
+          if (!view) {
+            factory = this.Widgets[widget_type];
+            view = factory(def);
+            this._views[id] = view;
+          }
 
           /* create the view */
           if (view) {
@@ -424,6 +431,7 @@
     this.node = node;
     this.def = def;
     this.views = new CPSSkins.Set();
+    this.setup();
   },
 
   hash: function() {
@@ -1899,7 +1907,7 @@
 
       var parts = url.split('?');
       if (parts.length == 2) {
-        var url = parts[0];
+        url = parts[0];
         options.parameters = parts[1];
       }
       new Ajax.Updater(widget, url, options);
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to