ExportAction.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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. function ExportAction() {
  13. this.m_format = "";
  14. this.m_responseFormat = "";
  15. }
  16. ExportAction.prototype = new CognosViewerAction();
  17. ExportAction.prototype.getWindowTitle = function() {
  18. return "";
  19. };
  20. ExportAction.prototype.execute = function() {
  21. if (!this.m_format) {
  22. return false;
  23. }
  24. this.initializeForm();
  25. this.insertGenericFormElements();
  26. this.insertSpecializedFormElements();
  27. return this.sendRequest();
  28. };
  29. ExportAction.prototype.addFormField = function(sName, sValue) {
  30. if(console) {
  31. console.log("Required method ExportAction.addFormField not implemented");
  32. }
  33. };
  34. ExportAction.prototype.initializeForm = function() {
  35. if(console) {
  36. console.log("Required method ExportAction.initializeForm not implemented");
  37. }
  38. };
  39. ExportAction.prototype.sendRequest = function() {
  40. if(console) {
  41. console.log("Required method ExportAction.sendRequest not implemented");;
  42. }
  43. };
  44. ExportAction.prototype.insertGenericFormElements = function() {
  45. var sRunPrompt = "false";
  46. var bAction = 'cognosViewer';
  47. this.addFormField("b_action", bAction);
  48. this.addFormField("cv.toolbar", "false");
  49. this.addFormField("cv.header", "false");
  50. this.addFormField("ui.windowtitleformat", 'chromeless_window_action_format');
  51. this.addFormField("ui.name", this.getObjectDisplayName());
  52. this.addFormField("cv.responseFormat", this.m_responseFormat);
  53. this.addFormField("ui.reuseWindow", "true");
  54. var sUiSpec = this.m_oCV.envParams["ui.spec"]; // TODO: we may not need this when we move to one Tomcat environment
  55. var sUiConversation = this.m_oCV.getConversation();
  56. this.addFormField("ui.action", 'export');
  57. this.addFormField("ui.conversation", sUiConversation);
  58. this.addFormField("run.prompt", sRunPrompt);
  59. this.addFormField('asynch.attachmentEncoding', 'base64');
  60. this.addFormField("run.outputEncapsulation", 'URLQueryString');
  61. this.addFormField("ui.spec", sUiSpec);
  62. this.addFormField("rap.reportInfo", this.m_oCV.envParams["rapReportInfo"]);
  63. if (this.m_oCV.envParams["ui.routingServerGroup"]) {
  64. this.addFormField("ui.routingServerGroup", this.m_oCV.envParams["ui.routingServerGroup"]);
  65. }
  66. var viewerWidget = this.m_oCV.getViewerWidget();
  67. if(viewerWidget != null) {
  68. //Technically, this call could be asynchronous, however we assume that if
  69. //the user is exporting a report, there's already a storeid.
  70. dojo.when(viewerWidget.getWidgetStoreID(),
  71. dojo.hitch(this, function(widgetStoreID) {
  72. if(typeof widgetStoreID != "undefined" && widgetStoreID != null) {
  73. this.addFormField('widgetStoreID', widgetStoreID);
  74. }
  75. })
  76. );
  77. var cvGateway = viewerWidget.getAttributeValue("gateway");
  78. if(cvGateway) {
  79. this.addFormField('cv.gateway', cvGateway);
  80. }
  81. var cvWebcontent = viewerWidget.getAttributeValue("webcontent");
  82. if(cvWebcontent) {
  83. this.addFormField('cv.webcontent', cvWebcontent);
  84. }
  85. }
  86. this.addFormField("rap.parametersInfo", CViewerCommon.buildParameterValuesSpec(this.m_oCV));
  87. };
  88. ExportAction.prototype.insertSpecializedFormElements = function(request) {
  89. this.addFormField("run.outputFormat", this.m_format);
  90. this.addFormField("ui.windowtitleaction", this.getWindowTitle());
  91. };
  92. ExportAction.prototype.updateMenu = function(json) {
  93. json.visible = !this.isPromptWidget();
  94. if (this.m_oCV.isIWidgetMobile()) {
  95. json.flatten = true;
  96. }
  97. return json;
  98. };
  99. function ExportFromIframeAction() {
  100. this.m_format = "";
  101. this.m_responseFormat = "downloadObject";
  102. }
  103. ExportFromIframeAction.prototype = new ExportAction();
  104. ExportFromIframeAction.prototype.initializeForm = function() {
  105. this.oRequest = new HiddenIframeDispatcherEntry(this.getCognosViewer());
  106. this.addFormField("cv.detachRelease", "true");
  107. };
  108. ExportFromIframeAction.prototype.addFormField = function(sName, sValue) {
  109. this.oRequest.addFormField(sName, sValue);
  110. };
  111. ExportFromIframeAction.prototype.sendRequest = function() {
  112. this.getCognosViewer().dispatchRequest(this.oRequest);
  113. return true;
  114. };