2 13 2 Using Weblets in an Inline List

LANSA WAM

2.13.2 Using Weblets in an Inline List

Weblets must be "inline-aware" before they can be used in an inline list.  An alert will notify you if you attempt to drop a weblet that is not inline-aware onto an inline list.

For the most part, inline weblets look and behave the same as their non-inline counterparts.  The key difference is that the inline weblet is generated when you drop it onto a list and, again, each time you change a property.  Because of this, there are a few considerations that you need to be aware of.

Accessing field and column values

In a non-inline list, you would access the value of a column with the $COLUMNNAME XSL variable or a field value with an XPath expression such as key ('field-value', 'FIELDNAME').  Because the XSL in an inline weblet is executed at design time, no XSL like this cannot be used to access runtime data.  There are several special XSL extension functions you can use to access runtime data in a weblet property. These are:

  • wd:column-value('COLUMNNAME') – returns the value of the specified column.  You can type #COLUMNNAME into the property and the LANSA editor will automatically translate it to a wd:column-value for you.
  • wd:field-value('FIELDNAME') – returns the value of the specified field.
  • wd:variable('VARNAME') – returns the value of the specified MTXT or System variable.
  • wd:row-index() – returns the row number of the current row of the list.  The number will be right-padded with zeros to a length of 4 digits.
  • These are XSL functions and should be entered in the XPath expression area.

    These extensions functions need to remain in the result document after the XSL transformation is done (they are parsed by the WAM runtime after  the XSL is executed).  For this reason, when they are processed by the XSL processor they just echo themselves.  For example,  a weblet property of "{wd:column-value('COLUMNNAME')}" results in the string "{wd:column-value('COLUMNNAME')}" in your property variable.  You can place this string directly into any HTML attribute.  If you want to place it into the HTML content you should first convert it into a special tag using the wdTagFromAttr.private template provided in std_util.xsl.

    Accessing Context Data

    As with field and column values, the context information normally available in the <lxml:context> section of the webroutine XML cannot be accessed by XSL at runtime.  Use these XSL extension functions to access context data in a weblet property:

  • wd:web-user()
  • wd:webapplication()
  • wd:webapplication-title()
  • wd:webroutine()
  • wd:webroutine-title()
  • wd:service-name()
  • wd:partition()
  • wd:language()
  • wd:images-path()
  • wd:action-request()
  • wd:layout-name()
  • wd:dbcs()
  • wd:align-right()
  • wd:check-numeric()
  • wd:debug()
  • wd:trace()
  • wd:task()
  • Runtime data cannot be used in all properties

    Some weblet properties affect how a weblet is constructed, others are passed to the browser to control CSS or JavaScript behavior.  Because an inline weblet is constructed at design time, you cannot use runtime data to affect the construction.  For example, see the display_mode property in any of the standard visualization weblets.  A value of 'input' will generate an HTML <input> tag.  A value of 'output' will generate a <span>.  If you need to use runtime data in these properties, you should use a non-inline list.

    The exceptions to this are some boolean properties like hide_if and disabled.

    wd:boolean properties

    Some boolean properties like hide_if and disabled, whose values affect how a weblet is constructed, can still accept runtime data through the use of a string containing a wd:boolean expression.

    The syntax of a wd:boolean expression is designed to optimize runtime performance, so it may not be easy to read.  Properties that accept a wd:boolean expression will provide you with an expression editor dialog so that you don't need to be able to read the expression.  Click the ellipsis button to the right of the property to open the property editor:

    Refreshing Inline Weblets

    Inline Weblets used in a webroutine are not automatically updated when the weblet is changed.  To update an inline weblet it must be refreshed.  You can do this in several ways:

  • Modify a property of the weblet
  • Open the Webroutine in the Design tab then right click on the weblet and select "Refresh Inlined Weblet" from the context menu.
  • Open the Webroutine in the Design tab and select Refresh Inlined Weblets… from the Web menu.
  • Select WAMs from the Repository or Favorites tab and select Refresh Inlined Weblets… from the context menu. This is the recommended way to refresh inlined weblets for a larger number of WAMs and webroutines.
  • When you select WAMs from the Repository or Favorites tab every WAM and its webroutines will be opened to verify if there are any inlined weblets in the webroutine and if they are out-of-date. Depending on how many WAMs and webroutines are selected, their complexity and the number of inlined weblets this process might take a while.
  • When you open a webroutine the LANSA editor will tell you if it contains inlined weblets that need to be refreshed.

    Note that this message only applies to the webroutine being opened. If you have multiple webroutines in a WAM you need to open each webroutine to check for differences in weblet version.

    When you chose Refresh Inlined Weblets you will be able to select which weblets you wish to update.

    By default all Weblets are pre-selected. It is recommended that you refresh all of them.