/******************************************************************************************************************************** * Licensed Materials - Property of IBM * * * * IBM Cognos Products: AGS * * * * (C) Copyright IBM Corp. 2005, 2008 * * * * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. * *********************************************************************************************************************************/ function XHTTPDispatcher(callBackFunc, arguments) { this.callBackFunc = callBackFunc; this.request_url = this.processRequest(arguments); } XHTTPDispatcher.prototype.dispatch = function() { // send off the request sendDispatcherRequestWithXMLTextResponse(this.request_url, this.callBackFunc); } // utility function XHTTPDispatcher.prototype.processRequest = function(arguments) { var sURL = ""; var clk = "cl"; var plk = "pl"; var b_action = "b_action"; var locales = getLocales(clk, plk); // have to add b_action in by hand - URIEncode always prepends a '&' to it if (arguments[b_action]) { sURL = b_action + "=" + encodeURIComponent(arguments[b_action]); delete arguments[b_action]; } else { sURL = b_action + "=xts.run"; } // add some values into the URL if they don't exist in the arguments sURL += this.addDefaultValue(clk, locales[clk], arguments); sURL += this.addDefaultValue(plk, locales[plk], arguments); // add in all the other arguments - NB - arguments for the defaults // above won't be added again - if they existed in the argument array // they were removed in the addDefaultValue function. for (i in arguments) { // arguments i might be an array in which case we add all the contents of the array var values = makeArray(arguments[i]); for (var value in values) { sURL += URIEncode(i,values[value]); } } // add a cafContextId if there is one if (cafContextId != "") { sURL += URIEncode("cafcontextid",cafContextId); } // return the request return sURL; } // build a URIEncoded argument pair from the name/value passed in. If the // name is in the argument array - use that in preference XHTTPDispatcher.prototype.addDefaultValue = function(sName, sValue, arguments) { var sURL = ""; if (arguments[sName]) { sURL += URIEncode(sName, arguments[sName]); // remove it delete arguments[sName]; } else { sURL += URIEncode(sName, sValue); } return sURL; }