RequestHandler.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. /*
  2. *+------------------------------------------------------------------------+
  3. *| Licensed Materials - Property of IBM
  4. *| IBM Cognos Products: Viewer
  5. *| (C) Copyright IBM Corp. 2013
  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. function RequestHandler( oCV ) {
  13. if (oCV) {
  14. RequestHandler.baseConstructor.call(this, oCV);
  15. }
  16. }
  17. RequestHandler.prototype = new BaseRequestHandler();
  18. RequestHandler.baseConstructor = BaseRequestHandler;
  19. RequestHandler.prototype.parent = BaseRequestHandler.prototype;
  20. RequestHandler.prototype.resubmitInSafeMode = function() {
  21. this.getViewer().resubmitInSafeMode(this.getDispatcherEntry());
  22. };
  23. /**
  24. * Should on be called when the response has a status of 'complete' or 'prompting'
  25. * @param {Object} response
  26. */
  27. RequestHandler.prototype.onComplete = function(response) {
  28. this.parent.onComplete.call(this, response);
  29. this.processDATAReportResponse(response);
  30. this.postComplete();
  31. };
  32. /**
  33. * Should only be called once when the Viewer first loads. This is because
  34. * the initial response from the server didn't go through the dispatcher entries,
  35. * so we need logic to handle complete, working, fault, ...
  36. */
  37. RequestHandler.prototype.processInitialResponse = function(oState) {
  38. this.parent.processInitialResponse.call(this, oState);
  39. var oCV = this.getViewer();
  40. var status = oCV.getStatus();
  41. oCV.setMaxContentSize();
  42. var bShowWaitPage = ( oCV.isWorking(status) || status == "default" );
  43. if (bShowWaitPage) {
  44. if (oCV.getWorkingDialog()) {
  45. oCV.getWorkingDialog().show();
  46. }
  47. // add a delay for this callback to allow the server request to clean up, and not block any futher server requests
  48. setTimeout(getCognosViewerObjectRefAsString(oCV.getId())+".executeCallback(\"wait\");",10);
  49. }
  50. else if (status == "fault") {
  51. oCV.setSoapFault(oState.m_sSoapFault);
  52. oCV.executeCallback("fault");
  53. }
  54. else if(oState.status == "cancel") {
  55. oCV.executeCallback("cancel");
  56. }
  57. else {
  58. oCV.updateSkipToReportLink();
  59. // in case where ajax is off, we sent the pinFreeze info as a form field. re-initialize the pinFreeze manager
  60. if (oCV.envParams && oCV.envParams["pinFreezeInfo"]) {
  61. var oPinFreezeManager = oCV.getPinFreezeManager();
  62. oPinFreezeManager.fromJSONString(oCV.envParams["pinFreezeInfo"]);
  63. delete oCV.envParams["pinFreezeInfo"];
  64. }
  65. if (status != "prompting" || !oCV.executeCallback("prompt")) {
  66. this.postComplete();
  67. }
  68. else {
  69. oCV.updateSkipToNavigationLink(true);
  70. }
  71. }
  72. this.showReport();
  73. this.getViewer().renderTabs();
  74. this.onAsynchStatusUpdate(status);
  75. };
  76. /**
  77. * Called once the Viewer state and HTML report have been updated.
  78. * This is last set of 'tweaks' needed to show the UI
  79. */
  80. RequestHandler.prototype.postComplete = function() {
  81. this.parent.postComplete.call(this);
  82. var oCV = this.getViewer();
  83. var oRVContent = document.getElementById('RVContent' + oCV.getId());
  84. if (oRVContent) {
  85. oRVContent.scrollTop=0;
  86. }
  87. oCV.updateSkipToReportLink();
  88. if (oCV.rvMainWnd) {
  89. oCV.updateLayout(oCV.getStatus());
  90. if (!oCV.getUIConfig() || oCV.getUIConfig().getShowToolbar()) {
  91. var oToolbar = oCV.rvMainWnd.getToolbar();
  92. if (oToolbar) {
  93. oCV.rvMainWnd.updateToolbar(oCV.outputFormat);
  94. oToolbar.draw();
  95. }
  96. }
  97. if (!oCV.getUIConfig() || oCV.getUIConfig().getShowBanner()) {
  98. var oBannerToolber = oCV.rvMainWnd.getBannerToolbar();
  99. if (oBannerToolber) {
  100. oBannerToolber.draw();
  101. }
  102. }
  103. }
  104. if (oCV.getBrowser() == 'moz') {
  105. if (oRVContent) {
  106. if (oCV.outputFormat == 'XML' && oCV.getStatus() != 'prompting') {
  107. oRVContent.style.overflow = "hidden";
  108. }
  109. else {
  110. oRVContent.style.overflow = "auto";
  111. }
  112. }
  113. }
  114. oCV.gbPromptRequestSubmitted = false;
  115. this.showReport();
  116. if (oCV.getPinFreezeManager() && oCV.getPinFreezeManager().hasFrozenContainers()) {
  117. var oReportDiv = document.getElementById("CVReport" + oCV.getId());
  118. if (oReportDiv) {
  119. setTimeout(function() {
  120. oCV.getPinFreezeManager().renderReportWithFrozenContainers(oReportDiv);
  121. // force IE to repaint the div or the the RVContent div won't resize and you'll be left with scrollbars
  122. if (isIE()) {
  123. oCV.repaintDiv(oRVContent);
  124. }
  125. }, 1);
  126. }
  127. }
  128. oCV.setMaxContentSize();
  129. oCV.executeCallback("done");
  130. oCV.doneLoading();
  131. };