RunReportAction.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. /*
  2. *+------------------------------------------------------------------------+
  3. *| Licensed Materials - Property of IBM
  4. *| IBM Cognos Products: Viewer
  5. *| (C) Copyright IBM Corp. 2001, 2012
  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. * This is the base class for generating request to re-run the report.
  14. * Classes derived from this will add to it their specific options.
  15. */
  16. function RunReportAction()
  17. {
  18. this.m_reuseQuery = false;
  19. this.m_promptValues = null;
  20. this.m_sendParameterValues = false;
  21. this.m_clearCascadeParamsList = null;
  22. }
  23. RunReportAction.prototype = new CognosViewerAction();
  24. RunReportAction.prototype.setRequestParams = function( params ) {
  25. if( !params ){ return; }
  26. this.m_promptValues = params.promptValues;
  27. this.m_clearCascadeParamsList = params.clearCascadeParamsList;
  28. };
  29. RunReportAction.prototype.setSendParameterValues = function(sendParameterValues) {
  30. this.m_sendParameterValues = sendParameterValues;
  31. };
  32. RunReportAction.prototype.reuseQuery =function() { return this.m_reuseQuery; };
  33. RunReportAction.prototype.setReuseQuery = function( value ) { this.m_reuseQuery = value; };
  34. RunReportAction.prototype.getPromptOption = function() { return "false";};
  35. RunReportAction.prototype.canBeQueued = function() { return false; };
  36. RunReportAction.prototype.getAction = function( limitedInteractiveMode ) {
  37. return limitedInteractiveMode ? 'run' : 'runSpecification';
  38. }
  39. /**
  40. * Overrides base method in CognosViewerAction
  41. */
  42. RunReportAction.prototype.addAdditionalOptions = function(cognosViewerRequest)
  43. {
  44. this._addCommonOptions(cognosViewerRequest);
  45. this._addRunOptionsFromProperties(cognosViewerRequest);
  46. this._addClearCascadeParams( cognosViewerRequest );
  47. this._addPromptValuesToRequest( cognosViewerRequest );
  48. };
  49. RunReportAction.prototype._addClearCascadeParams = function( oReq )
  50. {
  51. if( !this.m_clearCascadeParamsList || this.m_clearCascadeParamsList.length == 0){
  52. return;
  53. }
  54. var iCount = this.m_clearCascadeParamsList.length;
  55. for( var i=0; i <iCount; i++){
  56. oReq.addFormField('c' + this.m_clearCascadeParamsList[i], '1');//adding bogus value so viewer won't reject the parameter.
  57. }
  58. };
  59. RunReportAction.prototype._addPromptValuesToRequest = function( cognosViewerRequest )
  60. {
  61. if ( !this.m_promptValues ){ return; }
  62. cognosViewerRequest.addFormField("sharedPromptRequest", "true");
  63. for (var promptValue in this.m_promptValues)
  64. {
  65. cognosViewerRequest.addFormField( promptValue, this.m_promptValues[promptValue] );
  66. }
  67. };
  68. RunReportAction.prototype._addCommonOptions = function(oReq)
  69. {
  70. var limitedInteractiveMode = this.getCognosViewer().isLimitedInteractiveMode();
  71. if( typeof this.m_action === "undefined" )
  72. {
  73. this.m_action = this.getAction( limitedInteractiveMode );
  74. }
  75. oReq.addFormField("run.prompt", this.getPromptOption());
  76. oReq.addFormField("ui.action", this.m_action);
  77. if( limitedInteractiveMode )
  78. {
  79. oReq.addFormField("run.xslURL", "bux.xsl");
  80. }
  81. oReq.addFormField("run.outputFormat", "HTML");
  82. if( this.reuseQuery() === true )
  83. {
  84. oReq.addFormField("reuseResults", "true");
  85. }
  86. };
  87. RunReportAction.prototype._addRunOptionsFromProperties = function(oReq)
  88. {
  89. var properties = this.getCognosViewer().getViewerWidget().getProperties();
  90. if (properties.getRowsPerPage() != null)
  91. {
  92. oReq.addFormField("run.verticalElements", properties.getRowsPerPage());
  93. }
  94. };
  95. /**
  96. * Overrides base method in CognosViewerAction
  97. */
  98. RunReportAction.prototype.execute = function()
  99. {
  100. var oReq = this.createCognosViewerDispatcherEntry(this.m_action);
  101. oReq.setCanBeQueued( this.canBeQueued() );
  102. if( (this.m_action === "forward" || this.m_action === "back") && ( typeof this.m_bAbortAction === "undefined" || this.m_bAbortAction === true ) )
  103. {
  104. return false;
  105. }
  106. var oCV = this.getCognosViewer();
  107. if (this.m_sendParameterValues && oCV.envParams["delayedLoadingExecutionParams"]) {
  108. oReq.addFormField("delayedLoadingExecutionParams", oCV.envParams["delayedLoadingExecutionParams"]);
  109. delete oCV.envParams["delayedLoadingExecutionParams"];
  110. }
  111. this.getCognosViewer().dispatchRequest(oReq);
  112. return true;
  113. };
  114. RunReportAction.prototype.doAddActionContext = function()
  115. {
  116. return false;
  117. };
  118. RunReportAction.prototype.updateMenu = function(json)
  119. {
  120. json.visible = !this.isPromptWidget();
  121. return json;
  122. };