OpenWGA 7.9 - WebTML reference


Item Expressions

Item Expression are available if the version compliance of your design is at last 7.2 or the publisher option "Enable enhanced item expressions" (WebTML.EnhancedItemExpressions) is specified as true.

The main usage of item expressions is as "name" attribute in <tml:item>:

<tml:item name="some-item-expression"/>

Item expressions are also used in "dynamic minus attributes" as in u-paramname="expression" (in <tml:url/>), p-param="expression" (in <tml:query>) or html-attrib="expression" (allowed in all <tml:tag>s).

In addition to that attributes for conditional rendering on <tml:tag>s "if" and "unless" and "wrapif" in <tml:range> expects item expressions.

The following values are accepted in item expressions:

  • String literals surrounded by ' : 'some text'
  • Number literals by simply specifying the number: 1, 1.5, -1
  • Boolean literals: true, false
  • Other literals: null, undefined
  • if item name begins with $:
    • The current portlet controller: $pc
    • The current module controller: $mc
    • Other $-value replacements ($option_<name>, $item_<name>, ...) (see below for a list of all system provided item expression)
  • Values of WebTML variables by variable name
  • Values of mapped item values
  • Values of Content Items

Samples:

<tml:item name="$mc.someMethod"/>

calls module controller method someMethod() and outputs the return value


<tml:item name="$option_customer"/>

outputs the value of option "customer"


<tml:item name="$urlParam_search"/>

outputs the request url parameter "search"


<tml:item name="$field_customer"/>

outputs the current value of form field "customer"


<tml:children if="$is_selected">...</tml:children>

renders a child navigator if isSelected()


<tml:url u-zip="'40878'"/> which is the same as <tml:url u_zip="40878"/>

Uses a String literal '40878' as value

In addition for each non-literal you can append "call chains" to the name, i.e. retrieve properties or call methods on the returned value object using the dot "." as divider. For example:

<tml:item name="$mc.someMethod.someFieldOnReturnValue"/>

<tml:script>
    _contact = { name: "walter", lastname: "matthau"};

</tml:script>

<tml:item name="_contact.lastname"/>


System provided item expressions

The following item expressions are provided by the OpenWGA system

  • $cx - access the current TMLContenxt (same as "this" in TMLScript)
  • $form - access proerties of the current TMLForm object (like $form.formid)
  • $portlet - access the current portlet object
  • $portlet_<itemname> - portlet items
  • $pMode - portlet mode
  • $request - access to request object
  • $request_<metaname> - access to properties of META "request"
  • $cookie_<name> - a cookie object with the specified name
  • $option_<name> - an TML option with given name
  • $field_<fieldname> - Value of a WebTML form field
  • $fieldList_<fieldname> - Value of a WebTML form field in list form
  • $item_<itemname> - Value of a WebTML item
  • $itemList_<itemname> - Value of a WebTML item in list form
  • $urlParam_<name> - Value of an URL parameter
  • $urlParams_<name>- url parameter as list
  • $tagInfo_<tagid>_<infoname> - Some WebTML tag info from the current page
  • $is_selected
  • $is_maindocument
  • $is_firstloop / $is_lastloop
  • $is_root
  • $is_browserinterface
  • $is_anonymous
  • $haschildren - (new in 7.9.8)
  • $hassilblings (new in 7.9.8)

Samples:

Shows a login form if the current user is anonymous:

<tml:form if="$is_anonymous">
   ... a login form
</tml:form>

Renders a child navigator if the current context is selected:

<tml:children if="$is_selected"> ... </tml:children>

Uses $taginfo_... to output the number of results of a query and outputs a error message if there was an error:

<tml:query id="q">...</tml:query>

<tml:item name="$tagInfo_q_count"/> documents found


<tml:{div} html_class="error" if="$tagInfo_q_error">

    The following error occurred: <tml:item name="$tagInfo_q_error"/>

</tml:{div}>