ReportDispatcherEntry.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /*
  2. *+------------------------------------------------------------------------+
  3. *| Licensed Materials - Property of IBM
  4. *| IBM Cognos Products: Viewer
  5. *| (C) Copyright IBM Corp. 2001, 2020
  6. *|
  7. *| US Government Users Restricted Rights - Use, duplication or
  8. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  9. *|
  10. *+------------------------------------------------------------------------+
  11. */
  12. /*
  13. *******************************************************************************
  14. *** View DispatcherEntry.js for information on the dispatcher entry classes ***
  15. *******************************************************************************
  16. */
  17. /**
  18. * Should be treated as an abstract class and ViewerDispatcherEntry should
  19. * be used for the request
  20. * @param {Object} oCV
  21. */
  22. function ReportDispatcherEntry(oCV) {
  23. ReportDispatcherEntry.baseConstructor.call(this, oCV);
  24. if (oCV) {
  25. ReportDispatcherEntry.prototype.setDefaultFormFields.call(this);
  26. this.setRequestHandler(new RequestHandler(oCV));
  27. this.setWorkingDialog(oCV.getWorkingDialog());
  28. this.setRequestIndicator(oCV.getRequestIndicator());
  29. this.setCallbacks( {
  30. "complete" : {"object" : this, "method" : this.onComplete},
  31. "prompting" : {"object" : this, "method" : this.onComplete}
  32. });
  33. }
  34. }
  35. ReportDispatcherEntry.prototype = new AsynchDataDispatcherEntry();
  36. ReportDispatcherEntry.baseConstructor = AsynchDataDispatcherEntry;
  37. ReportDispatcherEntry.prototype.parent = AsynchDataDispatcherEntry.prototype;
  38. ReportDispatcherEntry.prototype.prepareRequest = function() {
  39. var action = this.getFormField("ui.action");
  40. var actionState = this.getViewer().getActionState();
  41. if (actionState !== "" && ( action == "wait" || action == "forward" || action == "back")) {
  42. this.addFormField("cv.actionState", actionState);
  43. }
  44. var safeTabActions = ["nextPage", "previousPage", "firstPage", "lastPage", "reportAction", "cancel", "wait"];
  45. var clearTabs = true;
  46. for (var i=0; i < safeTabActions.length; i++) {
  47. if (safeTabActions[i] == action) {
  48. clearTabs = false;
  49. break;
  50. }
  51. }
  52. if (clearTabs) {
  53. this.getViewer().clearTabs();
  54. }
  55. // So that we'll end up on the same tab
  56. // In case of prompting, it should be the same tab
  57. if (this.getViewer().getCurrentlySelectedTab() &&
  58. !this.formFieldExists("generic.anyURI.http://developer.cognos.com/ceba/constants/runOptionEnum#pageGroup") &&
  59. this.getViewer().getStatus() != "prompting") {
  60. this.addFormField("generic.anyURI.http://developer.cognos.com/ceba/constants/runOptionEnum#pageGroup", this.getViewer().getCurrentlySelectedTab());
  61. }
  62. };
  63. /**
  64. * Add all the default form fields needed for report requests (next page, render, ...)
  65. */
  66. ReportDispatcherEntry.prototype.setDefaultFormFields = function() {
  67. var oCV = this.getViewer();
  68. var envParams = oCV.envParams;
  69. this.addFormField("cv.id", oCV.getId());
  70. if (envParams["cv.showFaultPage"]) {
  71. this.addFormField("cv.showFaultPage", envParams["cv.showFaultPage"]);
  72. }
  73. else {
  74. this.addFormField("cv.showFaultPage", "false");
  75. }
  76. this.addDefinedNonNullFormField("ui.object", envParams["ui.object"]);
  77. this.addDefinedNonNullFormField("ui.primaryAction", envParams["ui.primaryAction"]);
  78. this.addDefinedNonNullFormField("ui.objectClass", envParams["ui.objectClass"]);
  79. this.addNonEmptyStringFormField("specificationType", envParams["specificationType"]);
  80. this.addNonEmptyStringFormField("cv.promptForDownload", envParams["cv.promptForDownload"]);
  81. this.addNonEmptyStringFormField("ui.conversation", oCV.getConversation());
  82. this.addNonEmptyStringFormField("m_tracking", oCV.getTracking());
  83. var sExecutionParameters = oCV.getExecutionParameters();
  84. this.addNonEmptyStringFormField("executionParameters", sExecutionParameters);
  85. var sCAF = oCV.getCAFContext();
  86. this.addDefinedNonNullFormField("ui.cafcontextid", sCAF);
  87. };
  88. /**
  89. * Need to update the Viewer state with any information we might have gotten in the working response
  90. * @param {Object} asynchDATAResponse
  91. * @param {Object} arg1
  92. */
  93. ReportDispatcherEntry.prototype.onWorking = function(asynchDATAResponse, arg1) {
  94. var responseState = asynchDATAResponse.getResponseState();
  95. var reqHandler = this.getRequestHandler();
  96. if (reqHandler) {
  97. var workingDialog = reqHandler.getWorkingDialog();
  98. if( workingDialog && workingDialog.setSecondaryRequests && responseState.m_aSecRequests )
  99. {
  100. workingDialog.setSecondaryRequests( responseState.m_aSecRequests );
  101. }
  102. }
  103. DispatcherEntry.prototype.onWorking.call(this, asynchDATAResponse, arg1);
  104. if (reqHandler) {
  105. this.getRequestHandler().updateViewerState(responseState);
  106. }
  107. };
  108. ReportDispatcherEntry.prototype.onComplete = function(asynchDATAResponse, arg1) {
  109. if (this.getRequestHandler()) {
  110. this.getRequestHandler().onComplete(asynchDATAResponse);
  111. }
  112. };