home *** CD-ROM | disk | FTP | other *** search
/ One Click 21 (Special) / OC021.iso / Interface / it.dig / scripts / __Packages / mx / data / components / XMLConnector.as
Encoding:
Text File  |  2006-07-04  |  3.1 KB  |  86 lines

  1. class mx.data.components.XMLConnector extends mx.data.components.connclasses.RPCCall
  2. {
  3.    var direction;
  4.    var params;
  5.    var ignoreWhite;
  6.    var needData;
  7.    var xmlconnector;
  8.    var parseXML;
  9.    var status;
  10.    var URL;
  11.    function XMLConnector()
  12.    {
  13.       super();
  14.    }
  15.    function trigger()
  16.    {
  17.       _global.__dataLogger.logData(this,"XMLConnector Triggered, <URL>",this);
  18.       _global.__dataLogger.nestLevel = _global.__dataLogger.nestLevel + 1;
  19.       if(this.triggerSetup(this.direction != "receive"))
  20.       {
  21.          if(this.params != null)
  22.          {
  23.             if(this.direction == "receive")
  24.             {
  25.                _global.__dataLogger.logData(this,"Warning: direction is \'receive\', but params are non-null: <params>",this,mx.data.binding.Log.WARNING);
  26.             }
  27.             else
  28.             {
  29.                if(!(this.params instanceof XML))
  30.                {
  31.                   this.notifyStatus("Fault",{faultcode:"XMLConnector.Not.XML",faultstring:"params is not an XML object"});
  32.                   return undefined;
  33.                }
  34.                if(this.params.status != 0)
  35.                {
  36.                   this.notifyStatus("Fault",{faultcode:"XMLConnector.Parse.Error",faultstring:"params had XML parsing error " + this.params.status});
  37.                   return undefined;
  38.                }
  39.             }
  40.          }
  41.          else if(this.direction != "receive")
  42.          {
  43.             this.notifyStatus("Fault",{faultcode:"XMLConnector.Params.Missing",faultstring:"Direction is \'send\' or \'send/receive\', but params are null"});
  44.             return undefined;
  45.          }
  46.          var _loc4_ = this.params;
  47.          if(_loc4_ == null || this.direction == "receive")
  48.          {
  49.             _loc4_ = new XML();
  50.          }
  51.          var _loc3_ = new XML();
  52.          _loc3_.ignoreWhite = this.ignoreWhite;
  53.          _loc3_.xmlconnector = this;
  54.          _loc3_.needData = this.direction != "send";
  55.          _loc3_.onData = function(data)
  56.          {
  57.             if(this.needData)
  58.             {
  59.                if(data == undefined)
  60.                {
  61.                   this.xmlconnector.notifyStatus("Fault",{faultcode:"XMLConnector.No.Data.Received",faultstring:"Was expecting data from the server, but none was received"});
  62.                }
  63.                else
  64.                {
  65.                   this.parseXML(data);
  66.                   if(this.status != 0)
  67.                   {
  68.                      this.xmlconnector.notifyStatus("Fault",{faultcode:"XMLConnector.Results.Parse.Error",faultstring:"received data had an XML parsing error " + this.status});
  69.                   }
  70.                   else
  71.                   {
  72.                      this.xmlconnector.setResult(this);
  73.                   }
  74.                }
  75.             }
  76.             this.xmlconnector.bumpCallsInProgress(-1);
  77.          };
  78.          _global.__dataLogger.logData(this,"Invoking XMLConnector <me.URL>(<params>)",{me:this,params:_loc4_});
  79.          _loc4_.contentType = "text/xml";
  80.          _loc4_.sendAndLoad(this.URL,_loc3_);
  81.          this.bumpCallsInProgress(1);
  82.       }
  83.       _global.__dataLogger.nestLevel--;
  84.    }
  85. }
  86.