FaultDialog.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. /*
  2. *+------------------------------------------------------------------------+
  3. *| Licensed Materials - Property of IBM
  4. *| IBM Cognos Products: Viewer
  5. *| (C) Copyright IBM Corp. 2001, 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. dojo.provide("FaultDialog");
  13. dojo.declare("FaultDialog", IFaultDialog, {
  14. m_soapFault: null,
  15. m_errorMessage : null,
  16. m_oCV: null,
  17. constructor: function(oCV) {
  18. this.m_oCV = oCV;
  19. },
  20. show: function(soapFault) {
  21. this.m_soapFault = soapFault;
  22. this.m_oCV.m_resizeReady = true;
  23. this.renderInlineDialog();
  24. this.m_oCV.getViewerWidget().setErrorDlg( this );
  25. },
  26. handleUnknownHTMLResponse: function(responseText) {
  27. if (responseText) {
  28. var htmlWindow = window.open("","",'height=400,width=500');
  29. if(htmlWindow != null) {
  30. htmlWindow.document.write(responseText);
  31. }
  32. }
  33. },
  34. canRetryRequest: function() {
  35. var canRetry = true;
  36. var canRetryNode = XMLHelper_FindChildrenByTagName(this.m_soapFault, "allowRetry", true);
  37. if(canRetryNode.length > 0) {
  38. canRetry = ( XMLHelper_GetText(canRetryNode[0], false) === "true" );
  39. }
  40. return canRetry;
  41. },
  42. isWarningMessage: function() {
  43. return false;
  44. },
  45. getButtons: function() {
  46. var buttons = [{
  47. label: RV_RES.IDS_JS_OK,
  48. action: dojo.hitch( this, this.ok )
  49. }];
  50. if( this.canRetryRequest() ) {
  51. buttons.push({
  52. label: RV_RES.IDS_JS_RETRY,
  53. action: dojo.hitch( this, this.retry )
  54. });
  55. }
  56. return buttons;
  57. },
  58. renderInlineDialog: function() {
  59. var oPayload = {
  60. "type": this.isWarningMessage() ? "warning" : "error",
  61. "message": this.getErrorMessage(),
  62. "buttons": this.getButtons()
  63. };
  64. var details = this.getDetails();
  65. if (details && details.length>0) {
  66. oPayload.details = details;
  67. }
  68. this.m_oCV.getViewerWidget().fireEvent("com.ibm.bux.widget.notification", null, oPayload);
  69. },
  70. setErrorMessage: function(errorMessage) {
  71. this.m_errorMessage = errorMessage;
  72. },
  73. getErrorMessage: function() {
  74. if(this.m_errorMessage == null) {
  75. var errorMessageNodes = XMLHelper_FindChildrenByTagName(this.m_soapFault, "message", true);
  76. if(errorMessageNodes.length > 0) {
  77. var messageStringNode = XMLHelper_FindChildByTagName(errorMessageNodes[0], "messageString", false);
  78. this.checkAndSetErrorMessage( XMLHelper_GetText(messageStringNode, false) );
  79. }
  80. }
  81. return this.m_errorMessage;
  82. },
  83. checkAndSetErrorMessage: function( errMsg ) {
  84. this.m_detailMessageStartIndex = 1;
  85. if( errMsg.indexOf('RSV-BBP-0038') == 0 ) {
  86. errMsg = RV_RES.IDS_CONV_CANCELED_ERROR;
  87. this.m_detailMessageStartIndex = 0;
  88. }
  89. this.m_errorMessage = errMsg;
  90. },
  91. getDetails: function() {
  92. var detailsString = "";
  93. var errorMessageNodes = XMLHelper_FindChildrenByTagName(this.m_soapFault, "message", true);
  94. if(errorMessageNodes.length > 0)
  95. {
  96. if (typeof this.m_detailMessageStartIndex === "undefined" || this.m_detailMessageStartIndex===null) {
  97. this.m_detailMessageStartIndex = 1;
  98. }
  99. for(var messageIndex = this.m_detailMessageStartIndex; messageIndex < errorMessageNodes.length; ++messageIndex) {
  100. var messageStringNode = XMLHelper_FindChildByTagName(errorMessageNodes[messageIndex], "messageString", false);
  101. detailsString += XMLHelper_GetText(messageStringNode, false) + "\n";
  102. }
  103. }
  104. return detailsString;
  105. },
  106. retry: function() {
  107. var retryEntry = this.m_oCV.getRetryDispatcherEntry();
  108. this.hide();
  109. if (retryEntry) {
  110. retryEntry.retryRequest();
  111. }
  112. else {
  113. // if we don't have a dipstherEntry, the fault must of happened right away.
  114. // build and send a new request using the original form fields from the widget
  115. var originalFormFields = this.m_oCV.getViewerWidget().getOriginalFormFields();
  116. if (originalFormFields && (originalFormFields.get("b_action") == "cvx" || originalFormFields.get("b_action") == "cvx.high")) {
  117. originalFormFields.add("b_action", "cognosViewer");
  118. }
  119. this.m_oCV.executeAction("RetryRequest", originalFormFields);
  120. }
  121. },
  122. ok: function() {
  123. var retryEntry = this.m_oCV.getRetryDispatcherEntry();
  124. this.hide();
  125. if (retryEntry) {
  126. retryEntry.onCloseErrorDlg();
  127. }
  128. },
  129. hide: function() {
  130. this.m_oCV.getViewerWidget().fireEvent("com.ibm.bux.widget.notification", null, {remove:1});
  131. this.m_oCV.getViewerWidget().setErrorDlg(null);
  132. this.m_oCV.setRetryDispatcherEntry(null);
  133. }
  134. });
  135. function buxErrorPage_toggleErrorDetails(event, cvId, htmlNode) {
  136. // left mouse, enter or space bar
  137. if ((event.button == 0 && (event.keyCode == "0" || typeof event.keyCode == "undefined")) || event.keyCode == "32" || event.keyCode == "13") {
  138. var buxErrorPageDetailContentOuter = document.getElementById("buxErrorPageDetailContentOuter" + cvId);
  139. var buxErrorPageDetailsDiv = document.getElementById("buxErrorPageDetails" + cvId);
  140. var buxTitlePaneTitleDiv = document.getElementById("titlePaneTitle" + cvId);
  141. var bShowDetails = (buxErrorPageDetailsDiv.style.display == "none");
  142. dojo.removeClass(buxErrorPageDetailContentOuter, bShowDetails ? 'dijitTitlePaneContentOuterClosed' : 'dijitTitlePaneContentOuterOpen');
  143. dojo.addClass(buxErrorPageDetailContentOuter, bShowDetails ? 'dijitTitlePaneContentOuterOpen' : 'dijitTitlePaneContentOuterClosed');
  144. dojo.removeClass(buxTitlePaneTitleDiv, bShowDetails ? "dijitClose" : "dijitOpen");
  145. dojo.addClass(buxTitlePaneTitleDiv, bShowDetails ? "dijitOpen" : "dijitClose");
  146. buxErrorPageDetailsDiv.style.display = bShowDetails ? "" : "none";
  147. }
  148. }