controller-templates.xsl 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655
  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. <!--
  9. Copyright (C) 2008 Cognos ULC, an IBM Company. All rights reserved.
  10. Cognos (R) is a trademark of Cognos ULC, (formerly Cognos Incorporated).
  11. -->
  12. <xsl:stylesheet version="1.0"
  13. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  14. xmlns:dlgctrl="http://developer.cognos.com/schemas/xts/logicsheets/xslt/presentation/dialog/controller-templates/"
  15. xmlns:req-params="http://developer.cognos.com/schemas/request/params"
  16. xmlns:out="dummy-uri"
  17. xmlns:pf="http://developer.cognos.com/schemas/xts/pf"
  18. xmlns:xts="http://developer.cognos.com/schemas/xts/"
  19. xmlns:df="http://developer.cognos.com/schemas/xts/logicsheets/xslt/presentation/dialog/framework/"
  20. exclude-result-prefixes="xsl xts dlgctrl pf req-params df">
  21. <xsl:output method="xml" encoding="UTF-8" indent="no"/>
  22. <xsl:namespace-alias stylesheet-prefix="out" result-prefix="xsl"/>
  23. <!--
  24. =================================================================================================================================
  25. Will automaticaly add the global 'current-stack' hidden variable for blocks that use the processResponse template
  26. ====================================================================================================================================
  27. -->
  28. <xsl:template match="xsl:stylesheet[//*[local-name()='processXTS2Response']]">
  29. <xsl:copy>
  30. <xsl:copy-of select="@*"/>
  31. <xsl:variable name="stackName" select="concat('request_stack_',descendant::*[local-name()='stackName' and namespace-uri()='http://developer.cognos.com/schemas/xts/logicsheets/xslt/presentation/dialog/controller-templates/'])"/>
  32. <out:variable name="ctrl-template-current-stack">
  33. <out:variable name="passport">
  34. <out:choose>
  35. <out:when test="/root/credential/param[@name='CAM']/*[local-name() ='CAM']/*[local-name() = 'CAMPassport']/*[local-name() = 'id']">
  36. <out:value-of select="/root/credential/param[@name='CAM']/*[local-name() ='CAM']/*[local-name() = 'CAMPassport']/*[local-name() = 'id']"/>
  37. </out:when>
  38. <out:otherwise>
  39. <out:variable name="cam_cookie" select="/root/cookies/cookie[@name='cam_passport']"/>
  40. <out:value-of select="xtsext:camcookie_action('getPassportID', $cam_cookie)"/>
  41. </out:otherwise>
  42. </out:choose>
  43. </out:variable>
  44. <out:variable name="env-markup">
  45. <out:call-template name="serialize-xml">
  46. <out:with-param name="node-set" select="/root/env/param[@name!='m' and not(starts-with(@name,'request_stack_')) and @name!='controller_state']"/>
  47. </out:call-template>
  48. </out:variable>
  49. <out:choose>
  50. <out:when test="not(/root/env/param[@name='{$stackName}'])">
  51. <out:value-of select="xtsext:cafaction( concat('sign_wrap_setpassportid_', $passport), xtsext:web64encode(string($env-markup), true()))"/>
  52. </out:when>
  53. <out:otherwise>
  54. <out:value-of select="/root/env/param[@name='{$stackName}']"/>
  55. </out:otherwise>
  56. </out:choose>
  57. </out:variable>
  58. <xsl:apply-templates/>
  59. <pf:serialize-xml/>
  60. </xsl:copy>
  61. </xsl:template>
  62. <!--
  63. =================================================================================================================================
  64. dlgctrl:XTS2Request - sends a xts:request to another morphlet
  65. /root/env, /root/http, /root/system and /root/session must be present in the DOM for dlgctrl:XTS2Request
  66. Input parameter Description required
  67. ___________________________ ___________________________________________________________ ____________________________
  68. <dlgctrl:target> morphlet to be called yes
  69. <dlgctrl:stackName> unique name to get appended to 'request_stack_' and used as yes
  70. <dlgctrl:resultLocation> xpath to where the result should be appended no, default is /root
  71. <dlgctrl:resultNode> parent node of the response no, default is <morphletResponse>
  72. <req-params:param name=""> specific input parameters for the morphlet getting called no, view documentation for
  73. morphlet getting called
  74. ====================================================================================================================================
  75. -->
  76. <xsl:template match="dlgctrl:XTS2Request">
  77. <!-- current controller_state -->
  78. <out:variable name="ctrl-template-controller-state">
  79. <xsl:choose>
  80. <xsl:when test="dlgctrl:requestState != ''">
  81. <xsl:value-of select="dlgctrl:requestState"/>
  82. </xsl:when>
  83. <xsl:otherwise>
  84. <out:choose>
  85. <out:when test="not(/root/*[local-name()='requestParams']/*[local-name()='param' and @name='requestState'])">
  86. <out:value-of select="/root/env/param[@name='controller_state']"/>
  87. </out:when>
  88. <out:otherwise>
  89. <out:value-of select="/root/*[local-name()='requestParams']/*[local-name()='param' and @name='requestState']"/>
  90. </out:otherwise>
  91. </out:choose>
  92. </xsl:otherwise>
  93. </xsl:choose>
  94. </out:variable>
  95. <!-- state that will be sent in the request. -->
  96. <out:variable name="ctrl-template-new-state">
  97. <out:value-of select="substring-after($ctrl-template-controller-state,'|')"/>
  98. </out:variable>
  99. <!-- where should the result be appended to -->
  100. <xsl:variable name="resultLocation">
  101. <xsl:choose>
  102. <xsl:when test="./*[local-name()='resultLocation'] != ''">
  103. <xsl:value-of select="./*[local-name()='resultLocation']"/>
  104. </xsl:when>
  105. <xsl:otherwise>
  106. <xsl:value-of select="'/root'"/>
  107. </xsl:otherwise>
  108. </xsl:choose>
  109. </xsl:variable>
  110. <!-- what node name should we use as the parent of the response -->
  111. <xsl:variable name="resultNode">
  112. <xsl:choose>
  113. <xsl:when test="./*[local-name()='resultNode'] != ''">
  114. <xsl:value-of select="./*[local-name()='resultNode']"/>
  115. </xsl:when>
  116. <xsl:otherwise>
  117. <xsl:value-of select="'morphletResponse'"/>
  118. </xsl:otherwise>
  119. </xsl:choose>
  120. </xsl:variable>
  121. <xsl:variable name="stackName" select="concat('request_stack_',./*[local-name()='stackName'])"/>
  122. <!-- Call the morphlet -->
  123. <xts:append select="{$resultLocation}">
  124. <xts:request name="BUS" target="bus://xts2{./*[local-name()='target']}" option="xml" outputHeader="true">
  125. <req-params:requestParams>
  126. <req-params:param name="requestState"><out:value-of select="$ctrl-template-new-state"/></req-params:param>
  127. <req-params:param name="resultNode"><xsl:value-of select="$resultNode"/></req-params:param>
  128. <!-- copy all the params that were passes in -->
  129. <xsl:copy-of select="./*[local-name()='param']"/>
  130. </req-params:requestParams>
  131. <!-- env -->
  132. <xts:queryNode select="/root/env | /root/http | /root/session | /root/credential | /root/cookies | /root/header | /root/user "/>
  133. </xts:request>
  134. </xts:append>
  135. </xsl:template>
  136. <!--
  137. =================================================================================================================================
  138. dlgctrl:processXTS2Response - Process the response returned from dlgctrl:XTS2Request
  139. Input parameter Description required
  140. ___________________________ ___________________________________________________________ ____________________________
  141. <dlgctrl:stackName> unique name to get appended to 'request_stack_' and used as yes
  142. an element name to contain the current stack
  143. <dlgctrl:resultLocation> xpath to where the result should be appended no, default is /root
  144. <dlgctrl:resultNode> parent node of the response no, default is <morphletResponse>
  145. <dlgctrl:mode match=""> Section to be used if the root element of the response no, only need for post processing
  146. matches the attribute 'match' of the result
  147. Any descendant of <dlgctrl:mode match=""> which has the dlgctrl namespace will get changed to use the xts namespace. <dlgctrl:morphletResponse/> will
  148. get replaced by the response.
  149. ====================================================================================================================================
  150. -->
  151. <xsl:template match="dlgctrl:processXTS2Response">
  152. <xsl:variable name="stackName" select="concat('request_stack_',./*[local-name()='stackName'])"/>
  153. <!-- what's the parent node of the response -->
  154. <xsl:variable name="resultNode">
  155. <xsl:choose>
  156. <xsl:when test="./*[local-name()='resultNode']!=''">
  157. <xsl:value-of select="./*[local-name()='resultNode']"/>
  158. </xsl:when>
  159. <xsl:otherwise>
  160. <xsl:value-of select="'morphletResponse'"/>
  161. </xsl:otherwise>
  162. </xsl:choose>
  163. </xsl:variable>
  164. <!-- where was the response appeneded in the DOM -->
  165. <xsl:variable name="resultLocation">
  166. <xsl:choose>
  167. <xsl:when test="./*[local-name()='resultLocation'] != ''">
  168. <xsl:value-of select="concat(./*[local-name()='resultLocation'],'/*[local-name()=&quot;',$resultNode,'&quot;]')"/>
  169. </xsl:when>
  170. <xsl:otherwise>
  171. <xsl:value-of select="concat('/root/*[local-name()=&quot;',$resultNode,'&quot;]')"/>
  172. </xsl:otherwise>
  173. </xsl:choose>
  174. </xsl:variable>
  175. <out:choose>
  176. <!-- append any markup that was returned to the output spec -->
  177. <out:when test="local-name({$resultLocation}/*) = 'markup'">
  178. <out:choose>
  179. <!-- if there's no request state then we're not a nested request, so process the returned markup -->
  180. <out:when test="not(/root/*[local-name()='requestParams']/*[local-name()='param' and @name='requestState'])">
  181. <xsl:apply-templates select="*[@match='markup' and local-name()='mode' and namespace-uri()='http://developer.cognos.com/schemas/xts/logicsheets/xslt/presentation/dialog/controller-templates/']/*" mode="processResponse">
  182. <xsl:with-param name="resultLocation" select="string($resultLocation)"/>
  183. <xsl:with-param name="stackName" select="string($stackName)"/>
  184. <xsl:with-param name="resultNode" select="string($resultNode)"/>
  185. </xsl:apply-templates>
  186. </out:when>
  187. <!-- if there's a request state, then it means that this is a nested request.
  188. Add the current stack and send back the markup -->
  189. <out:otherwise>
  190. <xts:append select="/root/output">
  191. <xts:transform name="Null" option="part" mimeType="text/html">
  192. <xsl:element name="{$resultNode}" namespace="">
  193. <markup>
  194. <out:value-of select="{$resultLocation}/*[local-name()='markup']"/>
  195. <xts:transform name="XMLEncode">
  196. <input type="hidden" name="{$stackName}">
  197. <out:attribute name="value">
  198. <out:value-of select="$ctrl-template-current-stack"/>
  199. </out:attribute>
  200. </input>
  201. </xts:transform>
  202. </markup>
  203. <out:copy-of select="{$resultLocation}/*[local-name() != 'markup']"/>
  204. </xsl:element>
  205. </xts:transform>
  206. </xts:append>
  207. </out:otherwise>
  208. </out:choose>
  209. </out:when>
  210. <!-- the response isn't markup, so process it -->
  211. <out:otherwise>
  212. <out:variable name="xml-encoded-stack" select="xtsext:web64decode( xtsext:cafaction( 'sign_unwrap', string( $ctrl-template-current-stack )), true())"/>
  213. <!-- we've gotten a response, so remove the requested morphlet and action from the controller state -->
  214. <out:variable name="ctrl-template-controller-state">
  215. <out:value-of select="xtsext:substringBeforeLast(string( xtsext:substringBeforeLast(string(/root/env/param[@name='controller_state']), '|') ), '|')"/>
  216. </out:variable>
  217. <xts:delete select="/root/env/param[@name != 'm' and (not(starts-with(@name,'request_stack_')) or @name= '{$stackName}')]"/>
  218. <!-- unpack the stack -->
  219. <out:if test="$xml-encoded-stack != ''">
  220. <xts:append select="/root/env">
  221. <xts:transform name="XMLDecode">
  222. <out:value-of select="$xml-encoded-stack"/>
  223. </xts:transform>
  224. </xts:append>
  225. </out:if>
  226. <!-- if the controller state isn't empty then we must be in a nested request. Switch the action to markup
  227. to allow the current morphlet to produce the proper markup with the results just received -->
  228. <out:if test="$ctrl-template-controller-state != ''">
  229. <xts:append select="/root/env">
  230. <param name="controller_state">
  231. <out:value-of select="concat($ctrl-template-controller-state, '|markup')"/>
  232. </param>
  233. </xts:append>
  234. </out:if>
  235. <xsl:for-each select="*[local-name()='mode' and @match!='markup' and namespace-uri()='http://developer.cognos.com/schemas/xts/logicsheets/xslt/presentation/dialog/controller-templates/']">
  236. <out:if test="{$resultLocation}/*[local-name()='{@match}']">
  237. <!-- check to see if the results should get processed -->
  238. <xsl:apply-templates select="./*" mode="processResponse">
  239. <xsl:with-param name="resultLocation" select="string($resultLocation)"/>
  240. <xsl:with-param name="stackName" select="string($stackName)"/>
  241. <xsl:with-param name="resultNode" select="string($resultNode)"/>
  242. <xsl:with-param name="match" select="@match"/>
  243. </xsl:apply-templates>
  244. </out:if>
  245. </xsl:for-each>
  246. </out:otherwise>
  247. </out:choose>
  248. </xsl:template>
  249. <!--
  250. ====================================================================================================================================
  251. Take <dlgctrl:morphletResponse> and replace it with the response returned from the request. If we're dealing with markup then
  252. also append the appropriate stack information
  253. ====================================================================================================================================
  254. -->
  255. <xsl:template match="*[local-name()='morphletResponse' and namespace-uri()='http://developer.cognos.com/schemas/xts/logicsheets/xslt/presentation/dialog/controller-templates/']" mode="processResponse" priority="2">
  256. <xsl:param name="resultLocation"/>
  257. <xsl:param name="stackName"/>
  258. <xsl:param name="resultNode"/>
  259. <xsl:param name="match"/>
  260. <out:choose>
  261. <!-- special case if the response is markup -->
  262. <out:when test="local-name({$resultLocation}/*) = 'markup'">
  263. <xsl:element name="{$resultNode}">
  264. <markup>
  265. <out:value-of select="{$resultLocation}/*[local-name()='markup']"/>
  266. <xts:transform name="XMLEncode">
  267. <input type="hidden" name="{$stackName}">
  268. <out:attribute name="value">
  269. <out:value-of select="$ctrl-template-current-stack"/>
  270. </out:attribute>
  271. </input>
  272. </xts:transform>
  273. </markup>
  274. <out:copy-of select="{$resultLocation}/*[local-name() != 'markup']"/>
  275. </xsl:element>
  276. </out:when>
  277. <out:otherwise>
  278. <out:copy-of select="{$resultLocation}/*[local-name()='{$match}']"/>
  279. </out:otherwise>
  280. </out:choose>
  281. </xsl:template>
  282. <!--
  283. ====================================================================================================================================
  284. Simply copy any element that under <dlgctrl:mode match=""> that doesn't have the dlgctrl namespace
  285. ====================================================================================================================================
  286. -->
  287. <xsl:template match="*" mode="processResponse" priority="0">
  288. <xsl:param name="resultLocation"/>
  289. <xsl:param name="stackName"/>
  290. <xsl:param name="resultNode"/>
  291. <xsl:param name="match"/>
  292. <xsl:copy>
  293. <xsl:copy-of select="@*"/>
  294. <xsl:apply-templates mode="processResponse">
  295. <xsl:with-param name="resultLocation" select="$resultLocation"/>
  296. <xsl:with-param name="stackName" select="$stackName"/>
  297. <xsl:with-param name="resultNode" select="$resultNode"/>
  298. <xsl:with-param name="match" select="$match"/>
  299. </xsl:apply-templates>
  300. </xsl:copy>
  301. </xsl:template>
  302. <!--
  303. ===============================================================================================
  304. dlgctrl:markupHelper
  305. same hidden inputs and javascript in each morphlet that uses the controller architecture
  306. ===============================================================================================
  307. -->
  308. <xsl:template match="dlgctrl:markupHelper">
  309. <input type="hidden" name="controller_state" value="{'{/root/env/param[@name=&quot;controller_state&quot;]}'}"/>
  310. <out:variable name="ctrl-template-controller-state" select="xtsext:javascriptencode(string(xtsext:substringBeforeLast(string(/root/env/param[@name='controller_state']), '|')))"/>
  311. <out:variable name="ctrl-template-formName">
  312. <out:choose>
  313. <out:when test="/root/*[local-name()='requestParams']/*[local-name()='param'][@name='formName'] != ''">
  314. <out:value-of select="/root/*[local-name()='requestParams']/*[local-name()='param'][@name='formName']"/>
  315. </out:when>
  316. <out:otherwise>
  317. <xsl:value-of select="'pform'"/>
  318. </out:otherwise>
  319. </out:choose>
  320. </out:variable>
  321. <out:variable name="ctrl-template-targetDefault" select="/root/*[local-name()='requestParams']/*[local-name()='param'][@name='defaultTarget']"/>
  322. <out:variable name="ctrl-template-requestParams" select="/root/*[local-name()='requestParams']/*[local-name()='param']"/>
  323. <script language="javascript">
  324. function controller_doSubmit(callMorph, morphState, navOp)
  325. {
  326. frm = document.<out:value-of select="$ctrl-template-formName"/>;
  327. frm.controller_state.value = '<out:value-of select="xtsext:javascriptencode($ctrl-template-controller-state)"/>';
  328. if (callMorph != '')
  329. {
  330. frm.controller_state.value += '|' + callMorph;
  331. }
  332. if (morphState != '')
  333. {
  334. frm.controller_state.value += '|' + morphState;
  335. }
  336. controller_submitForm('default');
  337. }
  338. function controller_changeState(newState)
  339. {
  340. frm = document.<out:value-of select="$ctrl-template-formName"/>;
  341. frm.controller_state.value = '<out:value-of select="xtsext:javascriptencode($ctrl-template-controller-state)"/>';
  342. frm.controller_state.value += '|' + newState;
  343. }
  344. function controller_setTarget(target)
  345. {
  346. if (target != '')
  347. {
  348. document.<out:value-of select="$ctrl-template-formName"/>.target = target;
  349. }
  350. }
  351. function controller_submitForm(action)
  352. {
  353. frm = document.<out:value-of select="$ctrl-template-formName"/>;
  354. <out:choose>
  355. <!-- wizard buttons -->
  356. <out:when test="$ctrl-template-requestParams[@name='inWizard'] = 'true'">
  357. <!-- back -->
  358. if (action == 'back')
  359. {
  360. <xsl:call-template name="dlgctrl:buttonSubmitJavaScript">
  361. <xsl:with-param name="button" select="'backTarget'"/>
  362. </xsl:call-template>
  363. }
  364. <!-- next -->
  365. if (action == 'next')
  366. {
  367. <xsl:call-template name="dlgctrl:buttonSubmitJavaScript">
  368. <xsl:with-param name="button" select="'nextTarget'"/>
  369. </xsl:call-template>
  370. }
  371. <!-- finish -->
  372. if (action == 'finish')
  373. {
  374. <out:if test="$ctrl-template-requestParams[@name='agentStudio'] = 'true'">
  375. <!-- Event Studio specific javascript -->
  376. if (window.getConfigFrame)
  377. {
  378. var cf = getConfigFrame();
  379. if (cf != null)
  380. {
  381. cf.cfgSet("agentHasChanged", true);
  382. }
  383. }
  384. </out:if>
  385. <xsl:call-template name="dlgctrl:buttonSubmitJavaScript">
  386. <xsl:with-param name="button" select="'finishTarget'"/>
  387. </xsl:call-template>
  388. }
  389. </out:when>
  390. <!-- ok button -->
  391. <out:otherwise>
  392. if (action == 'ok')
  393. {
  394. <xsl:call-template name="dlgctrl:buttonSubmitJavaScript">
  395. <xsl:with-param name="button" select="'okTarget'"/>
  396. </xsl:call-template>
  397. }
  398. </out:otherwise>
  399. </out:choose>
  400. <!-- cancel -->
  401. if (action == 'cancel')
  402. {
  403. <out:choose>
  404. <out:when test="$ctrl-template-requestParams[@name='fromFM']='true'">
  405. window.external.OnClose(1);
  406. </out:when>
  407. <out:otherwise>
  408. <xsl:call-template name="dlgctrl:buttonSubmitJavaScript">
  409. <xsl:with-param name="button" select="'cancelTarget'"/>
  410. </xsl:call-template>
  411. </out:otherwise>
  412. </out:choose>
  413. }
  414. <!-- default action -->
  415. if (action == 'default' || action == '')
  416. {
  417. <xsl:call-template name="dlgctrl:buttonSubmitJavaScript">
  418. <xsl:with-param name="button" select="'defaultTarget'"/>
  419. </xsl:call-template>
  420. }
  421. frm.submit();
  422. }
  423. </script>
  424. </xsl:template>
  425. <!--
  426. ===============================================================================================
  427. dlgctrl:buttonSubmitJavaScript
  428. generate the javascript for the buttons
  429. ===============================================================================================
  430. -->
  431. <!-- generate the javascript for the buttons -->
  432. <xsl:template name="dlgctrl:buttonSubmitJavaScript">
  433. <xsl:param name="button"/>
  434. <out:choose>
  435. <out:when test="$ctrl-template-requestParams[@name='{$button}'] = 'disable'"/>
  436. <out:when test="$ctrl-template-requestParams[@name='{$button}'] != ''">
  437. frm.m.value = '<out:value-of select="xtsext:javascriptencode(string($ctrl-template-requestParams[@name=&quot;{$button}&quot;]))"/>';
  438. </out:when>
  439. <out:otherwise>
  440. frm.m.value = '<out:value-of select="xtsext:javascriptencode(string(/root/*[local-name()='requestParams']/*[local-name()='param'][@name='defaultTarget']))"/>';
  441. </out:otherwise>
  442. </out:choose>
  443. </xsl:template>
  444. <!--
  445. ===============================================================================================
  446. dlgctrl:wizardButtons
  447. Add the wizard buttons (cancel, back, next and finish)
  448. ===============================================================================================
  449. -->
  450. <xsl:template match="dlgctrl:wizardButtons">
  451. <out:variable name="wizardButtons-requestParams" select="/root/*[local-name()='requestParams']/*[local-name()='param']"/>
  452. <xsl:call-template name="dlgctrl:genButton">
  453. <xsl:with-param name="button" select="'cancel'"/>
  454. <xsl:with-param name="newState" select="'canceled'"/>
  455. <xsl:with-param name="buttonText" select="'IDS_CANCEL'"/>
  456. </xsl:call-template>
  457. <xsl:call-template name="dlgctrl:genButton">
  458. <xsl:with-param name="button" select="'back'"/>
  459. <xsl:with-param name="newState" select="'back'"/>
  460. <xsl:with-param name="buttonText" select="'IDS_BACK'"/>
  461. <xsl:with-param name="validateFunction" select="@validateFunction"/>
  462. </xsl:call-template>
  463. <xsl:call-template name="dlgctrl:genButton">
  464. <xsl:with-param name="button" select="'next'"/>
  465. <xsl:with-param name="newState" select="'next'"/>
  466. <xsl:with-param name="buttonText" select="'IDS_NEXT'"/>
  467. <xsl:with-param name="validateFunction" select="@validateFunction"/>
  468. </xsl:call-template>
  469. <xsl:call-template name="dlgctrl:genButton">
  470. <xsl:with-param name="button" select="'finish'"/>
  471. <xsl:with-param name="newState" select="'finished'"/>
  472. <xsl:with-param name="buttonText" select="'IDS_FINISH'"/>
  473. <xsl:with-param name="validateFunction" select="@validateFunction"/>
  474. </xsl:call-template>
  475. </xsl:template>
  476. <!--
  477. ===============================================================================================
  478. dlgctrl:okCancelButtons
  479. Add the ok cancel buttons
  480. ===============================================================================================
  481. -->
  482. <xsl:template match="dlgctrl:okCancelButtons">
  483. <out:variable name="wizardButtons-requestParams" select="/root/*[local-name()='requestParams']/*[local-name()='param']"/>
  484. <xsl:call-template name="dlgctrl:genButton">
  485. <xsl:with-param name="button" select="'ok'"/>
  486. <xsl:with-param name="newState" select="'finished'"/>
  487. <xsl:with-param name="buttonText" select="'IDS_OK'"/>
  488. <xsl:with-param name="validateFunction" select="@validateFunction"/>
  489. </xsl:call-template>
  490. <xsl:call-template name="dlgctrl:genButton">
  491. <xsl:with-param name="button" select="'cancel'"/>
  492. <xsl:with-param name="newState" select="'canceled'"/>
  493. <xsl:with-param name="buttonText" select="'IDS_CANCEL'"/>
  494. </xsl:call-template>
  495. </xsl:template>
  496. <!--
  497. ===============================================================================================
  498. dlgctrl:genButton
  499. generate a button
  500. ===============================================================================================
  501. -->
  502. <xsl:template name="dlgctrl:genButton">
  503. <xsl:param name="button"/>
  504. <xsl:param name="newState"/>
  505. <xsl:param name="buttonText"/>
  506. <xsl:param name="validateFunction" select="''"/>
  507. <out:choose>
  508. <out:when test="$wizardButtons-requestParams[@name='{concat($button,'Target')}'] = 'disable'">
  509. <df:button df:id="{$buttonText}"/>
  510. </out:when>
  511. <out:when test="$wizardButtons-requestParams[@name='{concat($button,'URL')}'] and $wizardButtons-requestParams[@name='{concat($button,'URL')}'] != ''">
  512. <out:variable name="target">
  513. <out:choose>
  514. <out:when test="$wizardButtons-requestParams[@name='{concat($button,'URL')}' and @target != '']">
  515. <out:value-of select="$wizardButtons-requestParams[@name='{concat($button,'URL')}']/@target"/>
  516. </out:when>
  517. <out:otherwise>
  518. <xsl:value-of select="'_self'"/>
  519. </out:otherwise>
  520. </out:choose>
  521. </out:variable>
  522. <out:variable name="URLButton">
  523. <out:value-of select="xtsext:javascriptencode(string($wizardButtons-requestParams[@name=&quot;{concat($button,'URL')}&quot;]))"/>
  524. </out:variable>
  525. <script language="javascript">
  526. function submitButton_<xsl:value-of select="$button"/>()
  527. {
  528. <!-- always set the target to _top for the buttons in the footer -->
  529. <out:if test="$wizardButtons-requestParams[@name='isPopup'] = 'true'">
  530. document.<out:value-of select="$ctrl-template-formName"/>.target = '_parent';
  531. </out:if>
  532. <xsl:choose>
  533. <xsl:when test="$validateFunction != ''">
  534. if ( (window.<xsl:value-of select="$validateFunction"/> &amp;&amp; <xsl:value-of select="$validateFunction"/>()) || !window.<xsl:value-of select="$validateFunction"/> )
  535. {
  536. document.location.href = "<out:value-of select="$URLButton"/>";
  537. }
  538. </xsl:when>
  539. <xsl:otherwise>
  540. document.location.href = "<out:value-of select="$URLButton"/>";
  541. </xsl:otherwise>
  542. </xsl:choose>
  543. }
  544. </script>
  545. <df:button df:id="{$buttonText}" df:style="href" onclick="submitButton_{$button}();" df:href="#" target="{'{$target}'}"/>
  546. </out:when>
  547. <out:otherwise>
  548. <script language="javascript">
  549. function submitButton_<xsl:value-of select="$button"/>()
  550. {
  551. <xsl:choose>
  552. <xsl:when test="$validateFunction != ''">
  553. if ( (window.<xsl:value-of select="$validateFunction"/> &amp;&amp; <xsl:value-of select="$validateFunction"/>()) || !window.<xsl:value-of select="$validateFunction"/> )
  554. {
  555. <!-- always set the target to _top for the buttons in the footer -->
  556. <out:if test="$wizardButtons-requestParams[@name='isPopup'] = 'true'">
  557. document.<out:value-of select="$ctrl-template-formName"/>.target = '_parent';
  558. </out:if>
  559. controller_changeState('<xsl:value-of select="$newState"/>');
  560. controller_submitForm('<xsl:value-of select="$button"/>');
  561. }
  562. </xsl:when>
  563. <xsl:otherwise>
  564. <!-- always set the target to _top for the buttons in the footer -->
  565. <out:if test="$wizardButtons-requestParams[@name='isPopup'] = 'true'">
  566. document.<out:value-of select="$ctrl-template-formName"/>.target = '_parent';
  567. </out:if>
  568. controller_changeState('<xsl:value-of select="$newState"/>');
  569. controller_submitForm('<xsl:value-of select="$button"/>');
  570. </xsl:otherwise>
  571. </xsl:choose>
  572. }
  573. </script>
  574. <df:button df:id="{$buttonText}" df:style="href" df:href="#" onclick="submitButton_{$button}();"/>
  575. </out:otherwise>
  576. </out:choose>
  577. </xsl:template>
  578. <!-- the main engine -->
  579. <xsl:template match="*">
  580. <xsl:copy>
  581. <xsl:copy-of select="@*"/>
  582. <xsl:apply-templates/>
  583. </xsl:copy>
  584. </xsl:template>
  585. </xsl:stylesheet>