frag-handler.xsl 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. Licensed Materials - Property of IBM
  4. IBM Cognos Products: ps
  5. (C) Copyright IBM Corp. 2005, 2011
  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"
  9. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  10. xmlns:out="dummy-uri"
  11. xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt"
  12. xmlns:xts="http://developer.cognos.com/schemas/xts/"
  13. xmlns:mvc="http://developer.cognos.com/schemas/xts/mvc"
  14. xmlns:cp="http://developer.cognos.com/schemas/xts/logicsheets/xslt/presentation/controls/presentation/"
  15. exclude-result-prefixes="mvc xtsext xts cp">
  16. <xsl:output method="xml" encoding="UTF-8" indent="no"/>
  17. <xsl:namespace-alias stylesheet-prefix="out" result-prefix="xsl"/>
  18. <xsl:template match="mvc:fragment-vars">
  19. <out:variable name="fragment-id">
  20. <!-- Ensure passed-in fragment-id does not contain bad chars -->
  21. <out:variable name="id" select="/root/env/param[@name='mvcfragment-id']"/>
  22. <out:if test="translate($id, 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890_-', '') = ''">
  23. <out:value-of select="$id"/>
  24. </out:if>
  25. </out:variable>
  26. </xsl:template>
  27. <xsl:template match="mvc:include-fragment-controller">
  28. <script language="javascript">
  29. <!--
  30. * Retrieve the N gateway to set the domain for Javascript to work properly between N and N-1 spaces.
  31. * See also its counterpart: ../portal/mvc/multi-instance.xsl.
  32. -->
  33. <out:variable name="mvc-gateway" select="string(/root/mvcSettings/configuration/property[@name='MVC_gateway'])"/>
  34. <out:variable name="domain">
  35. <out:choose>
  36. <out:when test="$mvc-domain != ''">
  37. <!-- Use the configured domain in 'MVC_domain', if specified -->
  38. <out:value-of select="$mvc-domain"/>
  39. </out:when>
  40. <out:otherwise>
  41. <out:call-template name="parseDocumentDomain">
  42. <out:with-param name="url" select="$mvc-gateway"/>
  43. </out:call-template>
  44. </out:otherwise>
  45. </out:choose>
  46. </out:variable>
  47. <out:if test="$domain != ''">
  48. document.domain = "<out:value-of select="$domain"/>"; // N-1 side
  49. </out:if>
  50. </script>
  51. <script language="javascript" src="{'{$gateway}'}/dashboard/messages/messages/pfmessages?section=JS"/>
  52. <script language="javascript" src="{'{$webRoot}'}/dojo16/dojo/dojo.js"/>
  53. <script language="javascript" src="{'{$webRoot}'}/fragments/xdojo/core.js"/>
  54. <script language="javascript" src="{'{$webRoot}'}/fragments/fragments.js"/>
  55. <script language="javascript" src="{'{$webRoot}'}/common/framework/validator/CValidator.js"/>
  56. <script language="javascript" src="{'{$webRoot}'}/fragments/uicommon.js"/>
  57. <script language="javascript" src="{'{$webRoot}'}/fragments/layout.js"/>
  58. </xsl:template>
  59. <xsl:template match="mvc:add-fragment-content-div">
  60. <div id="{'{concat($fragment-id, &quot;content&quot;)}'}">
  61. <xsl:attribute name="style"><xsl:value-of select="@style"/></xsl:attribute>
  62. <div id="{'{concat($fragment-id, &quot;content&quot;)}'}_wait" style="display:none"/>
  63. </div>
  64. </xsl:template>
  65. <xsl:template match="mvc:add-fragment">
  66. <out:variable name="mvc-back-url" select="/root/env/param[@name='mvc-back-url']"/>
  67. <xsl:variable name="fragment-name">
  68. <xsl:choose>
  69. <xsl:when test="@name">
  70. <xsl:value-of select="@name"/>
  71. </xsl:when>
  72. <xsl:otherwise>fragment</xsl:otherwise>
  73. </xsl:choose>
  74. </xsl:variable>
  75. <xsl:variable name="fragment-path">
  76. <xsl:value-of select="@path"/>
  77. </xsl:variable>
  78. <out:if test="$gateway != ''">
  79. <script language="javascript">
  80. _F_Config.gateway = "<out:value-of select="$gateway"/>";
  81. _F_Config.webContent = "<out:value-of select="$webRoot"/>";
  82. _F_Config.application = "/dashboard";
  83. <out:variable name="error-template">
  84. <xsl:text/>&lt;table style="padding-top:50px;" cellpadding="3"><xsl:text/>
  85. <xsl:text/>&lt;tr><xsl:text/>
  86. <xsl:text/>&lt;td class="formText"><xsl:text/>
  87. <xsl:text/>&lt;img src="<out:value-of select="$image_root"/>msg_error.gif" alt="" title=""/><xsl:text/>
  88. <xsl:text/>&lt;/td><xsl:text/>
  89. <xsl:text/>&lt;td class="formText" valign="top"><xsl:text/>
  90. <xsl:text/>&lt;div id="_THIS_errormsg"/><xsl:text/>
  91. <xsl:text/>&lt;/td><xsl:text/>
  92. <xsl:text/>&lt;/tr><xsl:text/>
  93. <xsl:text/>&lt;/table><xsl:text/>
  94. </out:variable>
  95. ui_error.prototype.template = "<out:value-of select="xtsext:javascriptencode($error-template)"/>";
  96. </script>
  97. <script language="javascript">
  98. var fragment_id = "<out:value-of select="xtsext:javascriptencode($fragment-id)"/>";
  99. var fragment_path = "<out:value-of select="xtsext:javascriptencode({$fragment-path})"/>";
  100. var <out:value-of select="{$fragment-name}"/> = new fragment(fragment_path, fragment_id);
  101. var thisFragment = <out:value-of select="{$fragment-name}"/>;
  102. thisFragment.isMaintainState = true;
  103. var loadPending = false;
  104. thisFragment.setOnloadHandler(
  105. function() {
  106. ui_init();
  107. retrieve();
  108. }
  109. )
  110. function retrieve() {
  111. loadPending = true;
  112. setTimeout(function() { wait(true); }, 500);
  113. var cookied_fragstate = parent.mvcGetFragmentState(fragment_id);
  114. var isCookiedStateValid = (cookied_fragstate != null &amp;&amp; cookied_fragstate != "") ? true : false;
  115. if (isCookiedStateValid) {
  116. thisFragment.isMaintainState=true;
  117. thisFragment.state = cookied_fragstate;
  118. } else {
  119. parent.mvcSetFragmentState(fragment_id + "state", "");
  120. }
  121. var initial_parameters = (isCookiedStateValid ? "" : parent.mvcGetInitialParams());
  122. initial_parameters += '&amp;webRoot=<out:value-of select="xtsext:javascriptencode($webRoot)"/>';
  123. initial_parameters += '&amp;skin=<out:value-of select="xtsext:javascriptencode($user_skin)"/>';
  124. <!-- Set the back url to hold the current N-stack context -->
  125. thisFragment.mvc_back_url = parent.mvcGetBackURL();
  126. thisFragment.encoded_mvc_back_url = parent.mvcGetEncodedBackURL();
  127. thisFragment.retrieve(initial_parameters);
  128. }
  129. xAddEventListener(window, "beforeunload",
  130. function() {
  131. parent.remoteFragmentUnloads(thisFragment.state, thisFragment.isMaintainState);
  132. }
  133. );
  134. thisFragment.addEventListener("fragment.retrieve.after",
  135. function(evt) {
  136. loadPending = false;
  137. wait(false);
  138. thisFragment.removeEventListener("fragment.retrieve.after", arguments.callee);
  139. }
  140. );
  141. function wait(bShow) {
  142. var div = document.getElementById(fragment_id + "content" + "_wait");
  143. if (div != null) {
  144. if (bShow) {
  145. if (loadPending) {
  146. var waitHTML = '<div style="padding-top:50px;">' +
  147. '<table cellspacing="0" cellpadding="0" border="0" width="100%">' +
  148. '<tr>' +
  149. '<td style="text-align:center">' +
  150. '<img src="{'{$image_root}'}progress.gif" title="" alt=""/><br/>' +
  151. '<span class="formText"><xts:string id="IDS_WAIT"/></span>' +
  152. '</td>' +
  153. '</tr>' +
  154. '</table>' +
  155. '</div>';
  156. div.innerHTML = waitHTML;
  157. div.style.display = "";
  158. }
  159. } else {
  160. if (div.style.display != "none") {
  161. div.style.display = "none"; // hide
  162. }
  163. }
  164. }
  165. }
  166. function clearMVCState(mode) {
  167. thisFragment.isMaintainState = false;
  168. }
  169. </script>
  170. </out:if>
  171. </xsl:template>
  172. <xsl:template match="*">
  173. <xsl:copy>
  174. <xsl:copy-of select="@*"/>
  175. <xsl:apply-templates/>
  176. </xsl:copy>
  177. </xsl:template>
  178. </xsl:stylesheet>