report.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /*
  2. *+------------------------------------------------------------------------+
  3. *| Licensed Materials - Property of IBM
  4. *| BI and PM: prmt
  5. *| (C) Copyright IBM Corp. 2002, 2014
  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. @fileOverview Managing Reports.
  14. @constructor
  15. */
  16. cognos.Report = new Class({});
  17. /**
  18. @private
  19. @param {String} v_sNamespace? Current namespace
  20. @return {void}
  21. */
  22. cognos.Report.prototype.f_initialize = function( v_sNamespace )
  23. {
  24. var v_oPrompt = this.f_checkForGlobalObject( "G_PM", v_sNamespace );
  25. /**
  26. Reference to cognos.Prompt for this instance.
  27. @member
  28. */
  29. this.prompt = (v_oPrompt ? v_oPrompt : new cognos.Prompt()); // use a new cognos.Prompt as default
  30. var v_oCV = this.f_checkForGlobalObject( "oCV", v_sNamespace );
  31. /**
  32. Reference to global CognosViewer
  33. @member
  34. @private
  35. */
  36. this.m_oCV = ( v_oCV ? v_oCV : window.gCognosViewer ); // use window.gCognosViewer as default
  37. if (this.m_oCV) {
  38. this.m_oCV['CognosReport'] = this;
  39. }
  40. };
  41. /**
  42. @private
  43. @param {String} v_sPrefix Prefix for the object we are looking for in the 'window' scope.
  44. @param {String} v_sNamespace current namespace.
  45. @return {Object} Null if not found.
  46. */
  47. cognos.Report.prototype.f_checkForGlobalObject = function( v_sPrefix, v_sNamespace )
  48. {
  49. var v_oRef = null;
  50. // v_sNamespace is the fragment ID passed in.
  51. if ( window[v_sPrefix + v_sNamespace] ) {
  52. v_oRef = window[v_sPrefix + v_sNamespace];
  53. }
  54. // Default Namespace is _NS_
  55. else if ( window[v_sPrefix + "_NS_"] ) {
  56. v_oRef = window[v_sPrefix + "_NS_"];
  57. }
  58. // RS is the default namespace from ReportStudio
  59. else if ( window[v_sPrefix + "RS"] ) {
  60. v_oRef = window[v_sPrefix + "RS"];
  61. }
  62. // _THIS_ is the namespace holder
  63. else if ( window[v_sPrefix + "_THIS_"] ) {
  64. v_oRef = window[v_sPrefix + "_THIS_"];
  65. }
  66. // Maybe we don't have a namespace at all, use the global Viewer object
  67. else if ( window[v_sPrefix] ) {
  68. v_oRef = window[v_sPrefix];
  69. }
  70. return v_oRef;
  71. }
  72. /**
  73. Set up event callbacks for this report.
  74. Supported events: <tt>onBeforeSubmit</tt>
  75. @param {String} evt Can be <ul>
  76. <li><tt>onBeforeSubmit</tt>, before the request is set. Returning <tt>false</tt> will prevent the request to be sent.</li>
  77. <li><tt>onUpdate</tt>, triggered after a page is refreshed by the viewer.</li></ul>
  78. @param {function} fct The Javascript function used as callback.
  79. @return {void}
  80. @example Shows a message when the page is submittted: <br/>
  81. rprt.addEvent( "<tt>onBeforeSubmit</tt>", <tt>function() { alert("Sending your request. Please wait..."); return true; }</tt> );
  82. */
  83. cognos.Report.prototype.addEvent = function(eAction) {};
  84. /**
  85. Getter for a cognos.Report object. Namespaces are used to support fragments. You should always use this call to get a cognos.Report object with a proper namespace.
  86. @static
  87. @return {cognos.Report} The instance of cognos.Report for this namespace.
  88. @type cognos.Report
  89. @param {String} [sNamespace]
  90. @example <ul>
  91. <li>var oCR = cognos.Report.getReport( );</li>
  92. <li>var oCR = cognos.Report.getReport( "_THIS_" );</li>
  93. </ul>
  94. */
  95. cognos.Report.getReport = function(sNamespace)
  96. {
  97. return (new cognos.Report(sNamespace));
  98. };
  99. /**
  100. Sends a requests with the current parameters and values.
  101. @param {cognos.Report.Action} eAction One of the <code>cognos.Report.Action</code> enumeration values only.
  102. @return {void}
  103. */
  104. cognos.Report.prototype.sendRequest = function(eAction)
  105. {
  106. this.m_oCV.promptAction( eAction );
  107. };