Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • Define weblet parameters
  • Define elements of the anchor tag (for example, IMG ALT) as XSL variables
  • Complete JavaScript for HREF to set reentry field value and call wam / WebRoutine
  • Condition the <A> HREF and IMG tags based on a $hide_if variable
  • Add weblet parameter tooltips.


  1. Switch to the iii_toolbar_menuitem or open it in the editor if necessary. Select the XSL tab.

  2. Immediately following
  3. the 
  4. the <xsl:template name="iii_toolbar_menuitem">
  5.  
  6. tag, paste in the following code to define the weblet parameters. Review the comments for each parameter to see where it will be used.

    <!--
  7.  Used to set the Menu Text on the toolbar image 
  8.  Used to set the Menu Text on the toolbar image -->
  9.       <xsl
  10.       <xsl:param name="menu_text" wd:type="std:mtxt_variable" select="'Caption'" />
  11.       <
  12.       <!-- Used to set the image use for the toolbar Icon -->
  13.       <xsl
  14.       <xsl:param name="menu_image" wd:type="std:html_img_relative"
  15.                  select
  16.                  select="'/icons/normal/16/folder_16.png'" />
  17.       <
  18.       <!-- Used to set the ALT tag on the toolbar IMG tag -->
  19.       <xsl
  20.       <xsl:param name="tooltip_text" wd:type="std:mtxt_variable"
  21.                  select
  22.                  select="'Caption'" />
  23.       <
  24.       <!-- Used to set the Rentry Field Name when the toolbar Icon is clicked -->
  25.       <xsl
  26.       <xsl:param name="reentryfield"
  27.                  wd
  28.                  wd:type="std:field_name_in[wam=$on_click_wamname][webrtn=$on_click_wrname]"
  29.                  select
  30.                  select="'STDRENTRY'" wd:tip_id="" />
  31.       <
  32.       <!-- Used to set the Rentry Field Value when the toolbar Icon is clicked-->
  33.       <xsl
  34.       <xsl:param name="reentryvalue" select="'M'" wd:tip_id="" />
  35.       <
  36.       <!-- Used to set the Menu Text on the toolbar image -->
  37.       <xsl
  38.       <xsl:param name="hide_if" wd:type="std:boolean" select="false()"
  39.                  wd
  40.                  wd:tip_id="" />
  41.       <
  42.       <!-- Used to specify the WAMNAME to call when toolbar Icon is clicked -->
  43.       <
  44.       <!-- It will default to the current WAM if no value is specified -->
  45.       <xsl
  46.       <xsl:param name="on_click_wamname" wd:type="std:wam"
  47.                  select
  48.                  select="/lxml:data/lxml:context/lxml:webapplication" wd:tip="" />
  49.       <
  50.       <!-- Used to specify the WebRoutine to call when toolbar Icon is clicked -->
  51.       <xsl
  52.       <xsl:param name="on_click_wrname"
                     wd:type="std:webroutine[wam=$on_click_wamname]" wd:tip="" />

    This block of code defines
  53. the 
  54. the parameters
  55.  that
  56.  that can be passed into the template when the toolbar menu item template is called, in a similar way to calling a subroutine with parameters. Once defined these become
  57. the 
  58. the properties
  59.  that
  60.  that can be set in
  61. the Design view
  62. the Design view for a web page that uses this weblet.

    For example: a parameter,
  63. named 
  64. named menu_text, has a default value
  65. of 
  66. of 'Caption'. In the completed anchor tag code following, note that the
  67. variable $menu_text is
  68. variable $menu_text is used as the caption text below the toolbar item image.

  69. Save your changes.

  70. You will now complete the code for the <A> anchor tag. Copy the following code and paste it
  71. to replace the
  72. to replace the skeleton code for the <A> tag, which you placed there earlier.
  73. <a href

  74. <a href="../../../ocument./index.htm" target="_blank"yfield}','{$reentryvalue}');HandleEvent('{$on_click_wamname}','{$on_click_wrname}');">
  75.             <img alt
  76.             <img alt="{$tooltip_text}" src="/images/{$menu_image}" border="0" />
  77.             <br 
  78.             <br />
  79.             <span class
  80.             <span class="std_menuitem">
  81.                <xsl
  82.                <xsl:value-of select="$menu_text" />
  83.             <
  84.             </span>
    </
  85. a> 
  86. a> 

    Note the following points about these changes:
    • The value for the alt tag has been replaced with a variable $tooltip_text
    • The value for image file name in the src tag has been replaced with a variable $menu_image
    • The menu text inside the span tag is now generated by an <xsl:value-of which outputs the value of variable $menu_text
    • The href for the A tag has been defined with JavaScript code that passes $reentryfield and $reentryvalue variables to the InsertHidden function
    • The href code also runs the HandleEvent function passing $on_click_wamname and $on_click_wrname variables.

  87. Save your changes

  88. In this step you will add xsl code to condition the anchor tag, based on the $hide_if parameter.
    Note

    Note: The <xsl:if> element must have an </xsl:if> end tag. The <xsl:if> must surround the entire <A HREF . . . .> tag. Add the highlighted code only:

    <xsl:if test="not($hide_if)">

           <a href="j.././index.htm" target="_blank". . . 

          </a>

    </xsl:if>

    Tip

    Hint: The XSL editor autocomplete function will generate the </xsl:if> when you complete the beginning tag, <xsl:if . . . >. Move this to the required position after the </a> tag.   

    The variable $hide_if is a Boolean, with a default value of 'false' as shown in the parameter definitions.



  89. In this step you will add Weblet Parameter tooltips by copying in the following code, following the </wd:definition>. Note this is the end tag for the block beginning<wd:definition>.

    Replace iii in <wd:template name with your initials.

    <wd:
    template name
    template name="iii_toolbar_menuitem">
          <wd
          <wd:description icon="icons/userdefn.ico">
             <wd
             <wd:name lang="ENG">iii Toolbar Menu Item</wd:name>
          <
          </wd:description>
          <wd
          <wd:param name="menu_text">
             <wd
             <wd:tip lang="ENG">Menu Text to display below the image on the toolbar menu item</wd:tip>
          <
          </wd:param>
          <wd
          <wd:param name="menu_image">
             <wd
             <wd:tip lang="ENG">Image to display on the toolbar menu item</wd:tip>
          <
          </wd:param>
          <wd
          <wd:param name="tooltip_text">
             <wd
             <wd:tip lang="ENG">Tooltip text to display on the toolbar menu item</wd:tip>
          <
          </wd:param>
    </wd:template>
     
     

    Note

    Note:

    • Tags such as <wd:template name="iii_toolbar_menu_item"> have a namespace of wd. They are LANSA defined weblet design tags, defined by the standard that is referenced at the top of the weblet XSL. See: xmlns:wd=http://www.lansa.com/2002/XSL/Weblet-Design.
    • Standard XSL tags have a namespace of xsl, for example, <xsl:if…….>
    • The <wd:template . . . . .</wd:template> code is used by the Design view to define the icon and description used in the list of weblets, and the tooltip text for the weblet parameters.
     


  90. Look towards the top of your toolbar XSL to find the statement:

         <xsl:import href="std_types.xsl" /> and add the following line after that line:

         <xsl:import href="std_keys.xsl" />


The std_keys XSL defines xsl:key's such as "field-caption" and "field-value" that are used during transformation to extract data from the Data XML output via the WebRoutine.