123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538 |
- function DispatcherEntry(oCV)
- {
- this.m_oCV = oCV;
- this.m_requestKey = null;
- this.m_canBeQueued = false;
- this.m_originalFormFields = null;
- this.m_bUsePageRequest = false;
- if (oCV) {
- if (!this.m_request) {
- this.m_request = new XmlHttpObject();
- this.m_request.init("POST", this.m_oCV.getGateway(), "", true);
- }
- if (!this.m_requestHandler) {
- this.setRequestHandler(new BaseRequestHandler(oCV));
- }
- DispatcherEntry.prototype.setDefaultFormFields.call(this);
- this.setCallbacks( {
- "entryComplete" : {"object":this, "method":this.onEntryComplete},
- "entryFault" : {"object":this, "method":this.onEntryFault},
- "newRequest" : {"object":this, "method": this.onNewRequest},
- "fault" : {"object" : this, "method" : this.onFault},
- "error" : {"object" : this, "method" : this.onError},
- "passportTimeout" : {"object" : this, "method" : this.onPassportTimeout},
- "working" : {"object" : this, "method" : this.onWorking },
- "prompting" : {"object" : this, "method" : this.onPrompting},
- "preHttpRequest" : {"object" : this, "method" : this.onPreHttpRequest},
- "postHttpRequest" : {"object" : this, "method" : this.onPostHttpRequest},
- "postEntryComplete" : { "object" : this, 'method' : this.onPostEntryComplete}
- });
- }
- }
- DispatcherEntry.prototype.setHeaders = function(headers) {
- this.m_request.setHeaders(headers);
- };
- DispatcherEntry.prototype.getHeaders = function() {
- return this.m_request.getHeaders();
- };
- DispatcherEntry.prototype.setOriginalFormFields = function(formFields) {
- this.m_originalFormFields = formFields;
- };
- DispatcherEntry.prototype.getOriginalFormFields = function() {
- return this.m_originalFormFields;
- };
- DispatcherEntry.prototype.setRequestHandler = function(handler) {
-
- handler.addCallbackHooks();
- this.m_requestHandler = handler;
- };
- DispatcherEntry.prototype.getRequestHandler = function() {
- return this.m_requestHandler;
- };
- DispatcherEntry.prototype.setWorkingDialog = function(workingDialog) {
- if (this.getRequestHandler()) {
- this.m_requestHandler.setWorkingDialog(workingDialog);
- }
- };
- DispatcherEntry.prototype.setRequestIndicator = function(requestIndicator) {
- if (this.getRequestHandler()) {
- this.getRequestHandler().setRequestIndicator(requestIndicator);
- }
- };
- DispatcherEntry.prototype.forceSynchronous = function() {
- this.getRequest().forceSynchronous();
- };
- DispatcherEntry.prototype.setUsePageRequest = function(bUsePageRequest) {
- this.m_bUsePageRequest = bUsePageRequest;
- };
- DispatcherEntry.prototype.getUsePageRequest = function() {
- return this.m_bUsePageRequest;
- };
- DispatcherEntry.prototype.setDefaultFormFields = function() {
- var envParams = this.getViewer().envParams;
- this.addFormField("b_action", "cognosViewer");
- this.addFormField("cv.catchLogOnFault", "true");
- this.addDefinedNonNullFormField("protectParameters", envParams["protectParameters"]);
- this.addDefinedNonNullFormField("ui.routingServerGroup", envParams["ui.routingServerGroup"]);
- this.addDefinedNonNullFormField("cv.debugDirectory", envParams["cv.debugDirectory"]);
- this.addDefinedNonNullFormField("cv.showFaultPage", envParams["cv.showFaultPage"]);
- this.addDefinedNonNullFormField("cv.useRAPDrill", envParams["cv.useRAPDrill"]);
- this.addDefinedNonNullFormField("container", envParams["container"]);
- this.addNonEmptyStringFormField("cv.objectPermissions", envParams["cv.objectPermissions"]);
- };
- DispatcherEntry.prototype.getViewer = function() {
- return this.m_oCV;
- };
- DispatcherEntry.prototype.prepareRequest = function()
- {
-
- };
- DispatcherEntry.addWidgetInfoToFormFields = function(oWidget/*ViewerIWdiget Object*/, oDispatcherEntry/*DispatcherEntry Object*/){
- if(oWidget){
- var sBUXRTStateInfo = oWidget.getBUXRTStateInfoMap();
- if(sBUXRTStateInfo){
- oDispatcherEntry.addFormField("cv.buxRTStateInfo",sBUXRTStateInfo);
- }
- var sDisplayName = oWidget.getDisplayName();
- if(sDisplayName && sDisplayName.length >0){
- oDispatcherEntry.addFormField("displayTitle", sDisplayName);
- }
- }
- };
- DispatcherEntry.prototype.canBeQueued = function() {
- return this.m_canBeQueued;
- };
- DispatcherEntry.prototype.setCanBeQueued = function(canBeQueued) {
- this.m_canBeQueued = canBeQueued;
- };
- DispatcherEntry.prototype.getKey = function() {
- return this.m_requestKey;
- };
- DispatcherEntry.prototype.setKey = function(key) {
- this.m_requestKey = key;
- };
- DispatcherEntry.prototype.setRequest = function(request) {
- this.m_request = request;
- };
- DispatcherEntry.prototype.getRequest = function() {
- return this.m_request;
- };
- DispatcherEntry.prototype.setCallbacks = function(callbacks) {
- this.getRequest().setCallbacks(callbacks);
- };
- DispatcherEntry.prototype.getCallbacks = function() {
- return this.getRequest().getCallbacks();
- };
- DispatcherEntry.prototype.sendRequest = function() {
- this.prepareRequest();
-
- var formFields = this.getRequest().getFormFields();
- var formFieldNames = formFields.keys();
- if (!this.m_originalFormFields) {
- this.m_originalFormFields = new CDictionary();
- for (var index = 0; index < formFieldNames.length; index++) {
- this.m_originalFormFields.add(formFieldNames[index], formFields.get(formFieldNames[index]));
- }
- }
- this.getRequest().sendRequest();
- };
- DispatcherEntry.prototype.onNewRequest = function(request) {
- this.setRequest(request);
- };
- DispatcherEntry.prototype.retryRequest = function() {
- var oCV = this.getViewer();
- oCV.setRetryDispatcherEntry(null);
- var request = this.getRequest().newRequest();
- request.setHeaders(null);
- this.setRequest(request);
- var formFieldNames = this.m_originalFormFields.keys();
- for (var index = 0; index < formFieldNames.length; index++) {
- var formField = formFieldNames[index];
- var formFieldValue = this.m_originalFormFields.get(formField);
- if (formField == "cv.responseFormat" && formFieldValue == "iWidget") {
- this.addFormField("cv.responseFormat", "data");
- }
- else if (formField == "ui.action" && formFieldValue == "wait") {
- this.addFormField("ui.action", this.m_originalFormFields.get("ui.primaryAction"));
- }
- else if(formField != "m_tracking" && formField != "cv.outputKey") {
- this.addFormField(formField, formFieldValue);
- }
- }
- this.addFormField("widget.reloadToolbar", "true");
- if (this.m_oCV.getViewerWidget()) {
- this.addFormField("cv.buxCurrentUserRole", this.m_oCV.getViewerWidget().getUserRole());
- }
- this.addNonEmptyStringFormField("cv.objectPermissions", oCV.envParams["cv.objectPermissions"]);
- this.addNonEmptyStringFormField("limitedInteractiveMode", oCV.envParams["limitedInteractiveMode"]);
- this.m_oCV.getViewerDispatcher().dispatchRequest(this);
- };
- DispatcherEntry.prototype.abortHttpRequest = function() {
-
- if (!this.m_bCancelCalled) {
- if (this.getRequestHandler()) {
- this.getRequestHandler().onCancel();
- }
- this.m_bCancelCalled = true;
- this.getRequest().abortHttpRequest();
- this.onEntryComplete();
- }
- };
- DispatcherEntry.prototype.cancelRequest = function(forceSynchronous) {
-
- if (!this.m_bCancelCalled) {
- this.m_bCancelCalled = true;
- if (this.getRequestHandler()) {
- this.getRequestHandler().onCancel();
- }
- if (forceSynchronous) {
- this.getRequest().forceSynchronous();
- }
- this.getRequest().cancel();
- this.onEntryComplete();
- }
- };
- DispatcherEntry.prototype.getFormFields = function() {
- return this.m_request.getFormFields();
- };
- DispatcherEntry.prototype.getFormField = function(name) {
- if (this.m_request) {
- return this.m_request.getFormField(name);
- } else {
- return "";
- }
- };
- DispatcherEntry.prototype.clearFormFields = function() {
- this.m_request.clearFormFields();
- };
- DispatcherEntry.prototype.formFieldExists = function(name) {
- if (this.m_request) {
- return this.m_request.getFormFields().exists(name);
- }
- return false;
- };
- DispatcherEntry.prototype.removeFormField = function(name) {
- if (this.formFieldExists(name)) {
- this.m_request.getFormFields().remove(name);
- }
- };
- DispatcherEntry.prototype.addFormField = function(name, value) {
- this.m_request.addFormField(name, value);
- };
- DispatcherEntry.prototype.addDefinedNonNullFormField = function(name, value) {
- if (typeof value != "undefined" && value != null) {
- this.addFormField(name, value);
- }
- };
- DispatcherEntry.prototype.addDefinedFormField = function(name, value) {
- if (typeof value != "undefined") {
- this.addFormField(name, value);
- }
- };
- DispatcherEntry.prototype.addNonNullFormField = function(name, value) {
- if (value != null) {
- this.addFormField(name, value);
- }
- };
- DispatcherEntry.prototype.addNonEmptyStringFormField = function(name, value) {
- if (typeof value != "undefined" && value != null && value != "") {
- this.addFormField(name, value);
- }
- };
- DispatcherEntry.prototype.onWorking = function(response, arg1) {
- if (this.getRequestHandler()) {
- this.getRequestHandler().onWorking(response);
- }
- };
- DispatcherEntry.prototype.onFault = function(response) {
- if (this.getRequestHandler()) {
- this.getRequestHandler().onFault(response);
- }
- };
- DispatcherEntry.prototype.onError = function(response) {
-
- if (this.m_bCancelCalled) {
- return;
- }
-
- if (this.getRequestHandler()) {
- this.getRequestHandler().onError(response);
- }
- };
- DispatcherEntry.prototype.possibleUnloadEvent = function() {
- this.setCallbacks( {"error" : {} });
- };
- DispatcherEntry.prototype.onPreHttpRequest = function(request) {
- if (this.getRequestHandler()) {
- this.getRequestHandler().preHttpRequest(request);
- }
- };
- DispatcherEntry.prototype.onPostHttpRequest = function(response) {
- if (this.getRequestHandler()) {
- this.getRequestHandler().postHttpRequest(response);
- }
- };
- DispatcherEntry.prototype.onPassportTimeout = function(response) {
- if (this.getRequestHandler()) {
- this.getRequestHandler().onPassportTimeout(response);
- }
- };
- DispatcherEntry.prototype.onPrompting = function(response) {
- if (this.getRequestHandler()) {
- this.getRequestHandler().onPrompting(response);
- }
- };
- DispatcherEntry.prototype.onEntryComplete = function(response) {
- if (!this.m_oCV._beingDestroyed) {
- this.m_oCV.getViewerDispatcher().requestComplete(this);
- }
- };
- DispatcherEntry.prototype.onEntryFault = function(response) {
- this.m_oCV.setFaultDispatcherEntry(this);
- this.m_oCV.resetViewerDispatcher();
- if (!this.m_bCancelCalled) {
- this.m_oCV.setRetryDispatcherEntry(this);
- }
- };
- DispatcherEntry.prototype.onCloseErrorDlg = function() {
- var callbacks = this.getCallbacks();
- if (callbacks["closeErrorDlg"]) {
- var callbackFunc = GUtil.generateCallback(callbacks["closeErrorDlg"].method, [], callbacks["closeErrorDlg"].object);
- callbackFunc();
- }
- };
- DispatcherEntry.prototype.onPostEntryComplete = function() {
- if (this.getRequestHandler()) {
- this.getRequestHandler().onPostEntryComplete();
- }
- this.executeCallback("postComplete");
- };
- DispatcherEntry.prototype.executeCallback = function(callback) {
- var callbacks = this.getCallbacks();
- if (callbacks[callback]) {
- var callbackArguments = (callbacks.customArguments)?[this, callbacks.customArguments]: [this];
- var callbackFunc = GUtil.generateCallback(callbacks[callback].method, callbackArguments, callbacks[callback].object);
- callbackFunc();
- return true;
- }
-
- return false;
- };
|