[fusion-commits] r1954 - trunk/lib

svn_fusion at osgeo.org svn_fusion at osgeo.org
Tue Oct 27 16:42:33 EDT 2009


Author: chrisclaydon
Date: 2009-10-27 16:42:32 -0400 (Tue, 27 Oct 2009)
New Revision: 1954

Modified:
   trunk/lib/ApplicationDefinition.js
Log:
fix #305 - Using PHP API instead of HTTP API allows IE correctly to create a new session when the browser is refreshed.

Modified: trunk/lib/ApplicationDefinition.js
===================================================================
--- trunk/lib/ApplicationDefinition.js	2009-10-26 16:17:47 UTC (rev 1953)
+++ trunk/lib/ApplicationDefinition.js	2009-10-27 20:42:32 UTC (rev 1954)
@@ -33,13 +33,13 @@
 Fusion.Lib.ApplicationDefinition = OpenLayers.Class({
     /**
      * Property: mapGroups
-     * 
-     * array of map groups, parsed from ApplicationDefinition.  A MapGroup 
+     *
+     * array of map groups, parsed from ApplicationDefinition.  A MapGroup
      * consists of one or more Maps that can be combined into the same
      * OpenLayers Map object
      */
     mapGroups: null,
-    
+
     /**
      * Property: widgetSets
      *
@@ -47,7 +47,7 @@
      * from the ApplicationDefinition.
      */
     widgetSets: null,
-    
+
     /**
      * Property: {Object} oBroker
      *
@@ -55,21 +55,21 @@
      * in the case we are running against a MapGuide server
      */
     oBroker: null,
-    
+
     /**
      * Property: {Array} searchDefinitions
      *
      * An array of search definitions
      */
     searchDefinitions: null,
-    
+
     /**
      * Property: {Array} searchCategories
      *
      * An array of search categories
      */
     searchCategories: null,
-    
+
     /**
      * Constructor: ApplicationDefinition
      *
@@ -81,20 +81,20 @@
      * an optional session id to initialize the application with, passed to
      * the map widgets when they are created.
      */
-     
-    initialize: function(sessionId) {   
+
+    initialize: function(sessionId) {
         //console.log('ApplicationDefinition initialize');
         this.sessionId = sessionId;
         this.oBroker = Fusion.getBroker();
         this.applicationDefinition =  Fusion.getApplicationDefinitionURL();
-        
+
         this.widgetSets = [];
         this.mapGroups = {};
         this.searchDefinitions = [];
         this.searchCategories = [];
         this.parse();
     },
-    
+
     /**
      * Function: parse
      *
@@ -111,15 +111,15 @@
             //TODO: emit an error
             return null;
         }
-        /* if the application definition is not in the mapguide server, 
+        /* if the application definition is not in the mapguide server,
            just load the xml*/
-        
+
         if ( (this.applicationDefinition.match('Library://') == null) &&
              (this.applicationDefinition.match('Session:') == null) ) {
             if (Fusion.appDefJson) {
                 this.parseAppDef(Fusion.appDefJson);
             } else {
-                Fusion.getXmlAsJson(this.applicationDefinition, 
+                Fusion.getXmlAsJson(this.applicationDefinition,
                               OpenLayers.Function.bind(this.getAppDefCB, this));
             }
         } else {
@@ -135,27 +135,30 @@
         }
         return true;
     },
-    
+
     createSessionThenGetAppDef: function() {
-      var r = new Fusion.Lib.MGRequest.MGCreateSession();
-      this.oBroker.dispatchRequest(r, OpenLayers.Function.bind(this.createSessionThenGetAppDefCB, this));
+      var sl = Fusion.getScriptLanguage();
+      var scriptURL = 'layers/' + 'MapGuide' + '/' + sl + '/CreateSession.' + sl;
+      var options = {onSuccess: OpenLayers.Function.bind(this.createSessionThenGetAppDefCB, this)};
+      Fusion.ajaxRequest(scriptURL, options);
     },
-    
+
     createSessionThenGetAppDefCB : function(xhr) {
-      if (xhr && typeof(xhr) == "object" && xhr.responseText) { 
-        this.sessionId = xhr.responseText; 
-        Fusion.sessionId = this.sessionId; 
+      if (xhr && typeof(xhr) == "object" && xhr.responseText) {
+        var o;
+        eval("o="+xhr.responseText);
+        this.sessionId = o.sessionId;
+        Fusion.sessionId = this.sessionId;
       }
       this.getAppDef();
     },
-	
 
-    getAppDef: function(){ 
-      var r = new Fusion.Lib.MGRequest.MGGetResourceContent(this.applicationDefinition); 
-      r.parameters.session = this.sessionId; 
-      r.parameters.format = 'application/json'; 
-      this.oBroker.dispatchRequest(r, 
-              OpenLayers.Function.bind(this.getAppDefCB, this)); 
+    getAppDef: function(){
+      var r = new Fusion.Lib.MGRequest.MGGetResourceContent(this.applicationDefinition);
+      r.parameters.session = this.sessionId;
+      r.parameters.format = 'application/json';
+      this.oBroker.dispatchRequest(r,
+              OpenLayers.Function.bind(this.getAppDefCB, this));
     },
 
     getAppDefCB: function(xhr) {
@@ -193,10 +196,10 @@
                 }
             }
         } else {
-          Fusion.reportError(new Fusion.Error(Fusion.Error.FATAL, 
+          Fusion.reportError(new Fusion.Error(Fusion.Error.FATAL,
                         OpenLayers.i18n('appDefParseError')));
         }
-        
+
         /* process WIDGET sets */
         if (appDef.WidgetSet) {
             for (var i=0; i<appDef.WidgetSet.length; i++) {
@@ -204,10 +207,10 @@
                 this.widgetSets.push(widgetSet);
             }
         } else {
-          Fusion.reportError(new Fusion.Error(Fusion.Error.FATAL, 
+          Fusion.reportError(new Fusion.Error(Fusion.Error.FATAL,
                       OpenLayers.i18n('widgetSetParseError')));
         }
-        
+
         /* process extensions */
         if (appDef.Extension) {
             var extension = appDef.Extension[0];
@@ -233,10 +236,10 @@
                     }
                 }
             }
-            
+
         }
     },
-    
+
     /**
      * Function: create
      *
@@ -248,7 +251,7 @@
             this.widgetSets[i].create(this);
         }
     },
-    
+
     /**
      * Function: getMapByName
      *
@@ -270,7 +273,7 @@
         }
         return map;
     },
-    
+
     /**
      * Function: getMapById
      *
@@ -278,7 +281,7 @@
      *
      * Parameter: {String} id
      *
-     * The map id to return.  ID is distinct from map.name in that id is the 
+     * The map id to return.  ID is distinct from map.name in that id is the
      * id of the HTML tag where the map widget is inserted.
      *
      * Returns: {Object} a map object or null if not found.
@@ -293,7 +296,7 @@
         }
         return map;
     },
-    
+
     /**
      * Function: getMapByIndice
      *
@@ -312,7 +315,7 @@
          }
          return map;
      },
-     
+
     /**
      * Function: getMapGroup
      *
@@ -327,7 +330,7 @@
      getMapGroup : function(mapGroupId) {
          return this.mapGroups[mapGroupId];
      },
-     
+
      /**
       * Function getWidgetsByType
       *
@@ -358,7 +361,7 @@
 Fusion.Lib.ApplicationDefinition.MapGroup = OpenLayers.Class({
     initialView: null,
     maps: null,
-    
+
     initialize: function(jsonNode) {
         this.mapId = jsonNode['@id'][0];
         this.maps = [];
@@ -445,7 +448,7 @@
             //TODO: do we need a warning that there are no layers in this map?
         }
     },
-    
+
     parseMapEventSubBlock: function(block) {
         var a = [];
         if (block.Layer && block.Layer instanceof Array) {
@@ -458,15 +461,15 @@
             for (var i=0; i<block.Group.length; i++) {
                 var group = block.Group[i];
                 a.push({type: 'group', name:group.Name[0], enable: group.Enable[0] == 'true' ? true : false});
-            }            
+            }
         }
         return a;
     },
-    
+
     getInitialView: function() {
         return this.initialView;
     },
-    
+
     setInitialView: function(view) {
         this.initialView = view;
     }
@@ -496,7 +499,7 @@
             this.extension = {};
         }
         this.resourceId = this.extension.ResourceId ? this.extension.ResourceId[0] : '';
-        
+
         var tagOptions = this.extension.Options;
         this.layerOptions = {};
         if (tagOptions && tagOptions[0]) {
@@ -519,7 +522,7 @@
             this.layerParams[key] = tagParams[0][key][0];
           }
         }
-        
+
         switch (this.type) {
           case 'MapGuide':
           case 'MapServer':
@@ -566,7 +569,7 @@
                 this.mapId = jsonNode.MapWidget[i].MapId[0];
             }
         }
-        
+
         /* process widgets */
         if (jsonNode.Widget) {
             for (var i=0; i<jsonNode.Widget.length; i++) {
@@ -584,9 +587,9 @@
                 this.containersByName[container.name] = container;
             }
         }
-        
+
     },
-    
+
     /**
      * Function: addWidgetInstance
      *
@@ -599,7 +602,7 @@
     addWidgetInstance: function(widget) {
         this.widgetInstances.push(widget);
     },
-    
+
     /**
      * Function: getMapWidget
      *
@@ -610,14 +613,14 @@
     getMapWidget: function() {
         return this.mapWidget;
     },
-    
+
     /**
      * Function: create
      *
      * create all the things required by this widgetSet, including
      * containers and widgets.
      *
-     * Parameter: {<Fusion.Lib.ApplicationDefinition>} 
+     * Parameter: {<Fusion.Lib.ApplicationDefinition>}
      *
      * the application definition that this widgetSet is part of
      */
@@ -631,15 +634,15 @@
           if (mapGroup) {
             this.mapId = paramMapId;
           } else {
-            Fusion.reportError(new Fusion.Error(Fusion.Error.WARNING, 
+            Fusion.reportError(new Fusion.Error(Fusion.Error.WARNING,
               "can't find MapGroup: " + paramMapId + ' - reverting to default map'));
           }
         }
-        
+
         if (!mapGroup) {
           mapGroup = appDef.getMapGroup(this.mapId);
         }
-        
+
         //create the Map widget for this WidgetSet
         this.mapWidget = new Fusion.Widget.Map(this.mapWidgetTag,mapGroup,this);
         this.mapWidget.setMenu();
@@ -674,7 +677,7 @@
         }
         return map;
     },
-    
+
     /**
      * Function getWidgetsByType
      *
@@ -695,11 +698,11 @@
         }
         return widgets;
     },
-    
+
     getWidgetByName: function(name) {
         return this.widgetTagsByName[name];
     },
-    
+
     getContainerByName: function(name) {
         return this.containersByName[name];
     }
@@ -738,7 +741,7 @@
             //TODO: is this a problem if there are no items?
         }
     },
-    
+
     create: function(widgetSet) {
         var container;
         if (this.type == 'Toolbar' || this.type == 'Statusbar') {
@@ -761,13 +764,13 @@
             container.domObj.jxLayout.resize({forceResize: true});
         }
     },
-    
+
     createWidgets: function(widgetSet, container) {
         for (var i=0; i<this.items.length; i++) {
             this.items[i].create(widgetSet, container, this.name + '_' + i);
         }
     }
-    
+
 });
 
 /****************************************************************************
@@ -806,9 +809,9 @@
             this.label = jsonNode.Label ? jsonNode.Label[0] : '';
             this.label = OpenLayers.i18n(this.label);
             this.disabled = jsonNode.Disabled ? (jsonNode.Disabled[0].toLowerCase() == 'true' ? true : false) : false;
-            
+
             //console.log('Widget: ' + this.type + ', ' + this.name + ', ' + this.description);
-        
+
             if (jsonNode.Extension) {
                 this.extension = jsonNode.Extension[0];
             } else {
@@ -820,7 +823,7 @@
             }
         }
     },
-    
+
     getMapWidget: function() {
         if (this.widgetSet) {
             return this.widgetSet.getMapWidget();
@@ -828,7 +831,7 @@
             return null;
         }
     },
-    
+
     /**
      * Function: create
      *
@@ -908,11 +911,11 @@
             case 'Multi':
                 this.multi = new Fusion.Lib.ApplicationDefinition.Multi(jsonNode);
                 break;
-            case 'Separator':   
+            case 'Separator':
                 break;
         }
     },
-      
+
     create: function(widgetSet, container, idx) {
         switch(this.type) {
             case 'Widget':
@@ -931,7 +934,7 @@
                                 image: widgetTag.imageUrl,
                                 imageClass: widgetTag.imageClass,
                                 toggle: widget.isExclusive
-                            }));                            
+                            }));
                         }
                         container.add(widget.uiObj);
                         if (widget.uiObj.setEnabled) {
@@ -982,7 +985,7 @@
                         }
                     }
                 } else {
-                  Fusion.reportError(new Fusion.Error(Fusion.Error.WARNING, 
+                  Fusion.reportError(new Fusion.Error(Fusion.Error.WARNING,
                     "can't find widget: " + this.widgetName));
                  }
                 break;
@@ -997,14 +1000,14 @@
                 };
                 if (container instanceof Jx.Toolbar) {
                     menu = new Jx.Menu(opt);
-                } else if (container instanceof Jx.Menu || 
-                           container instanceof Jx.Menu.Context || 
+                } else if (container instanceof Jx.Menu ||
+                           container instanceof Jx.Menu.Context ||
                            container instanceof Jx.Menu.SubMenu) {
                     menu = new Jx.Menu.SubMenu(opt);
                 }
                 container.add(menu);
                 this.flyout.create(widgetSet, menu);
-                
+
                 break;
             case 'Multi':
                 var multi;
@@ -1018,11 +1021,11 @@
                 container.add(multi);
                 this.multi.create(widgetSet, multi);
                 break;
-                
+
             case 'Separator':
                 if (container instanceof Jx.Toolbar) {
                     container.add(new Jx.Toolbar.Separator());
-                } else if (container instanceof( Jx.Menu) || 
+                } else if (container instanceof( Jx.Menu) ||
                            container instanceof(Jx.Menu.SubMenu) ||
                            container instanceof(Jx.Menu.Context)) {
                     container.add(new Jx.Menu.Separator());
@@ -1045,7 +1048,7 @@
     description: null,
     imageUrl: null,
     items: null,
-    
+
     initialize: function(jsonNode) {
         this.label = jsonNode.Label ? jsonNode.Label[0] : '';
         this.tooltip = jsonNode.Tooltip ? jsonNode.Tooltip[0] : '';
@@ -1058,13 +1061,13 @@
             }
         }
     },
-    
+
     create: function(widgetSet, menu) {
         for (var i=0; i<this.items.length; i++) {
             this.items[i].create(widgetSet, menu);
         }
     }
-    
+
 });
 
 /****************************************************************************
@@ -1080,7 +1083,7 @@
     description: null,
     imageUrl: null,
     items: null,
-    
+
     initialize: function(jsonNode) {
         this.label = jsonNode.Label ? jsonNode.Label[0] : '';
         this.tooltip = jsonNode.Tooltip ? jsonNode.Tooltip[0] : '';
@@ -1093,13 +1096,13 @@
             }
         }
     },
-    
+
     create: function(widgetSet, multi) {
         for (var i=0; i<this.items.length; i++) {
             this.items[i].create(widgetSet, multi);
         }
     }
-    
+
 });
 
 /****************************************************************************
@@ -1116,7 +1119,7 @@
     parameters: null,
     join: null,
     rule: null,
-    
+
     initialize: function(json) {
         this.id = json['@id'];
         this.name = json['@name'];
@@ -1151,7 +1154,7 @@
             }
         }
     },
-    
+
     getJoinUrl: function(params) {
         if (this.join) {
             return '&joinlayer='+this.join.layer+'&joinpk='+this.join.primaryKey+'&joinfk='+this.join.foreignKey;
@@ -1159,7 +1162,7 @@
             return '';
         }
     },
-    
+
     getFilterUrl: function(params) {
         return '&filter='+encodeURIComponent(this.rule.toString(params));
     }
@@ -1197,11 +1200,11 @@
         this.type = type;
         this.conditions = [];
     },
-    
+
     add: function(condition) {
         this.conditions.push(condition);
     },
-    
+
     remove: function(condition) {
         for (var i=0; i<this.conditions.length; i++) {
             if (this.conditions[i] == condition) {
@@ -1210,7 +1213,7 @@
             }
         }
     },
-    
+
     toString: function(params) {
         var conditions = [];
         for (var i=0; i<this.conditions.length; i++) {



More information about the fusion-commits mailing list