render-renderings.xslt 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. Licensed Materials - Property of IBM
  4. IBM Cognos Products: HTS
  5. (C) Copyright IBM Corp. 2005, 2010
  6. US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  7. -->
  8. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xts="http://developer.cognos.com/schemas/xts/" xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt">
  9. <xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
  10. <xsl:template match="/">
  11. <xsl:variable name="uri" select="/root/input[@name='dep']/queryResponse/text()"/>
  12. <script language="javascript">
  13. _THIS_.addEventListener('fragment.unload','_THIS_unload', false);
  14. _THIS_.addEventListener('fragment.load','_THIS_init', false);
  15. //This event will be fired when sub fragment is retrieved and done.
  16. //The calls starts with children first, and when the target of the event
  17. //is the same as this fragments id it means all children have been done.
  18. _THIS_.addEventListener("fragment.retrieve.after", "_THIS_retrieveAfter",false);
  19. /**
  20. * On refresh subfrag are not notified of the load. So we need
  21. * to do this explicitly. This is very IMPORTANT. Otherwise
  22. * the onload is not passed to children.
  23. */
  24. function _THIS_init(evt) {
  25. var _THIS_distList = new Array();
  26. var _THIS_children = _THIS_.getChildren();
  27. var i, l = _THIS_children.length;
  28. for (i = 0; i &lt; l; i++) {
  29. _THIS_distList[i] = _THIS_children[i].id;
  30. }
  31. _F_Event.distribute(_THIS_distList,evt);
  32. }
  33. /**
  34. * This method will be fired when sub fragment is retrieved and done.
  35. * The calls starts with children first, and when the target of the event
  36. * is the same as this fragments id it means all children have been done.
  37. */
  38. function _THIS_retrieveAfter(evt) {
  39. if (evt.target.id == "_THIS_") {
  40. var params = _THIS_getRenderingParams();
  41. if (params.isValid) {
  42. //get the 'real' rendering subfragment which is the only child of the current one
  43. var children = _THIS_.getChildren();
  44. var subFragment;
  45. //we are only expected one i.e. the rendering subfragment
  46. if (children.length>0) {
  47. subFragment = children[0];
  48. var utils = new hts_utils(subFragment);
  49. var subfragContent = $('_THIS_renderingSubFragcontent');
  50. utils.setUIState(subfragContent,!params.visible,true);
  51. }
  52. _THIS_.raiseEvent(params.event);
  53. }
  54. }
  55. }
  56. /*
  57. * There are two rendering information parameters, one for tasks and one for notifications. There should be one or the other not both.
  58. * Both have the same JSON structure : {"id":"ec32f725-dd70-4694-ae8c-f8a0a1671c18","visible":false}
  59. * This function adds a couple extra properties; event - the event to be raised and isValid - determines whether the parameter is correct
  60. */
  61. function _THIS_getRenderingParams() {
  62. var payload = new Object();
  63. payload.id="";
  64. payload.visible="";
  65. payload.event="";
  66. payload.isValid=false;
  67. var notificationParams = '<xsl:value-of select="xtsext:javascriptencode(string(/root/transients/param[@name='renderingNotificationInfo']))"/>';
  68. var taskParams = '<xsl:value-of select="xtsext:javascriptencode(string(/root/transients/param[@name='renderingTaskInfo']))"/>';
  69. if(notificationParams != '') {
  70. eval('payload = ' + _F_Strings.urlDecode(notificationParams));
  71. payload.event='cognos.hts.showNotificationTaskViewer';
  72. } else if(taskParams != '') {
  73. eval('payload = ' + _F_Strings.urlDecode(taskParams));
  74. payload.event='cognos.hts.showTaskViewer';
  75. }
  76. payload.isValid = (payload.id &amp;&amp; payload.id !="");
  77. return payload;
  78. }
  79. /*
  80. this method clears the javascript objects that are associated with the subfragment
  81. that this class sets and resets dynamically into itself
  82. without this method, because the subfrag id is constant
  83. the javascript object for the first sub fragment hangs around
  84. and causes trouble
  85. */
  86. function _THIS_unload(evt) {
  87. //only deal with this if source and target are the same. This
  88. //is because when this frag in reloaded it fires an unload
  89. //event prior to loading. So source and target will be the same.
  90. //When children are destroyed the unload is fired again, this time
  91. // source will be child , so this condition will ignore it.
  92. if (evt.target.id == "_THIS_" &amp;&amp; evt.source.id == "_THIS_") {
  93. var _THIS_distList = new Array();
  94. var _THIS_children = _THIS_.getChildren();
  95. var i, l = _THIS_children.length;
  96. for (i = 0; i &lt; l; i++) {
  97. //Will cascade to all subchildren recusivley
  98. //And will fire unload before destroy and fragment.detroyed
  99. //after the destrcution is complete.
  100. _THIS_children[i].destroy();
  101. }
  102. }
  103. }
  104. </script>
  105. <!--currently this is the rendering and we assume it is a uri -->
  106. <!-- this is where the subfragment content will go -->
  107. <div id="_THIS_renderingSubFragcontent">
  108. <table class="cogstyle-usv-rendering-table">
  109. <tr>
  110. <td>_THIS?frag-subfragment=renderingSubFrag/THIS_</td>
  111. </tr>
  112. </table>
  113. </div>
  114. </xsl:template>
  115. </xsl:stylesheet>