Back to Contents


Template Functions

Template functions are defining an utility toolbox for snippet developers.


Conversion Functions

Back to the top


bool()

The bool() function converts an expression to a boolean.

Syntax

bool(expr)

Notes

  1. expr is the expression to convert.

Back to the top


number()

The number() function converts an expression to a number.

Syntax

number(expr)

Notes

  1. expr is the expression to convert.

Back to the top


string()

The string() function converts an expression to a string.

Syntax

string(expr)

Notes

  1. expr is the expression to convert.

Back to the top


object()

The object() function inserts XML code.

Syntax

object(expr)

Notes

  1. expr is a string interpreted as an XML snippet. expr can be the XML code between the gwc:snippet-root tags. All the template instructions in this string is interpreted against the current context. Any parsing error detected is written in the log files, assuming the TEMPLATE category is set.

Example

<p gwc:replace="object(value) />

This insert the value of a field as XHTML code in the html page.

Back to the top


Logical Functions

Back to the top


for()

The for() function creates a numeric sequence.

Syntax

bool(expr1, expr2, [expr3])

Notes

  1. Return a numeric sequence from number(expr1) to number(expr2) with a step of number(expr3) [1 by default].

Example

<div gwc:repeat="i for(0, 20, 2)" gwc:content="i" />

Back to the top


switch()

The switch() function compares an expression to different values, and return a result dependant on which value it equals to.

Syntax

switch(expr1, array1, array2, [expr2])  

Notes

  1. If expr1 is in array1 at position x, return value inside array2 at position x, if any. In other cases return expr2, if any.

Example

<div gwc:content="switch( number(i), [1, 2, 3, 4], ['this is one', 'this is two', 'this is three', 'this is four' ], 'Don\'t know that number...')" /> 

Back to the top


Number Functions

Back to the top


min()

The min() function returns the minimum between two numbers.

Syntax

min(expr1, expr2)

Notes

  1. Return the minimum between number(expr1) and number(expr2).

Back to the top


max()

The max() function returns the maximum between two numbers.

Syntax

max(expr1, expr2)

Notes

  1. Return the maximum between number(expr1) and number(expr2).

Back to the top


round()

The round() function returns the rounded value of a number.

Syntax

round(expr)

Notes

  1. Return the rounded value of number(expr).

Back to the top


fill()

The fill() function formats a number by filling its string representation.

Syntax

fill(expr1, expr2, [expr3, [expr4]])

Notes

  1. Return string(number(expr1)) filled with string(expr3) [" " by default] to reach number(expr2) width.
    Fill is done according on bool(expr4) [true by default]: true means filling to left, false filling to right.

Back to the top


precision()

The precision() function sets precision when displaying a number.

Syntax

precision(expr1, expr2)

Notes

  1. Set precision of number(expr1) decimal part to number(expr2).

Back to the top


abs()

The abs() function calculates the absolute value.

Syntax

abs(expr)

Notes

  1. Calculates the absolute value of number(expr).

Back to the top


sin()

The sin() function calculates the sine of an angle.

Syntax

sin(expr)

Notes

  1. Calculates the sine of number(expr).
  2. number(expr) is the angle in degrees.

Back to the top


cos()

The cos() function calculates the cosine of an angle.

Syntax

cos(expr)

Notes

  1. Calculates the cosine of number(expr).
  2. number(expr) is the angle in degrees.

Back to the top


tan()

The tan() function calculates the tangent of an angle.

Syntax

tan(expr)

Notes

  1. Calculates the tangent of number(expr).
  2. number(expr) is the angle in degrees.

Back to the top


String Functions

Back to the top


escapeJS()

The excapeJS() function escapes JavaScript-sensitive characters.

Syntax

escapeJS(expr)

Notes

  1. Return string(expr) with ["'", "\", "\n", "\r"] characters escaped with a "\".

Back to the top


translate()

The translate() function translates a string.

Syntax

translate(expr1, expr2, expr3)

Notes

  1. Return string(expr1) with occurrences of string in string(expr2) replaced by the string at the corresponding position in string(expr3). Use expression with square brackets [] to replace a list of strings. Use quotes to replace character by character.

Examples

<div gwc:attributes="class translate(style, ' -/\#.=+()[]', '____________')"/>
To replace character by character.

<div gwc:attributes="class translate(style, ['\\r\\n','\\n','\\r'], '<br/>')"/>
To replace each strings in the array expr2 by the string expr3.

Back to the top


split()

The split() function splits a string using a delimiter.

Syntax

split(expr1, expr2)

Notes

  1. Return string(expr1) split into an array of substrings according to string(expr2) delimiter.

Example

<option gwc:attributes="selected valueChecked in split(value , '|') ? 'selected' : null"/>

Back to the top


length()

The length() function returns string length.

Syntax

length(expr)

Notes

  1. Return string(expr) length.

Back to the top


substring()

The substring() function returns a substring of a string.

Syntax

substring(expr1, expr2, [expr3])

Notes

  1. Return string(expr1) substring from number(expr2) position to number(expr3) position [end of string(expr1) by default].

Back to the top


contains()

The contains() function returns true if a string contains a substring.

Syntax

contains(expr1, expr2)

Notes

  1. Return true if string(expr2) is a substring of string(expr1).

Back to the top


indexOf()

The indexOf() function returns the position of a substring in a string.

Sytnax

indexOf(expr1, expr2)

Notes

  1. Return position of subtring string(expr2) in string(expr1) [return -1 if string(expr2) is not found in string(expr1)].

Back to the top


replace()

The replace() function replaces a specified part of a string with another string.

Syntax

replace(expr1, expr2, expr3)

Notes

  1. Replace any location of string(expr2) in string(expr1) by string(expr3).

Back to the top


filterAmpersand()

The filterAmpersand() function filters the ampersand (&) on a given string. Double ampersand (&&) are replaced by a simple one.

Syntax

filterAmpersand(expr)

Notes

  1. This function is useful to filter labels containing GDC accelerators as defined in in the Genero Business Language documentation.

Example

<span gwc:content="filterAmpersand('&Save && exit'/>

will produce ...

<span>Save & exit</span>

Back to the top


Front End Protocol Functions

Back to the top


makeScrollOffsetIDID()

The  makeScrollOffsetIDID() function builds offset action.

Syntax

 makeScrollOffsetIDID(expr1, expr2)

Notes

  1. expr1 is the table id.
  2. expr2 is a value for the offset.

Example

<input type="submit" gwc:attributes="name makeScrollOffsetIDID(ID, repeat/p/index);... />
produces
<input type="submit" name="o88/50"... />

Back to the top


makePageSizeIDID()

The makePageSizeIDID() function builds page size action.

Syntax

makePageSizeIDID(expr1, expr2)

Notes

  1. expr1 is the table id.
  2. expr2 is a size value.

Example

<input type="submit" gwc:attributes="name makePageSizeIDID(ID, '50');... />
produces
<input type="submit" name="s88/50"... />

 

Back to the top


makeRowSelectionIDID()

The makeRowSelectionIDID() function builds inclusive row selection action.

Syntax

 makeRowSelectionIDID(expr1, expr2)

Notes

  1. expr1 is the table id or the selectorID for a matrix.
  2. expr2 is the row index.

Example

<input type="submit" gwc:attributes="name makeRowSelectionIDID(r/ID, repeat/r/index);... />
or
<input type="submit" gwc:attributes="name makeRowSelectionIDID(selectorID, selectorIndex);... />

produces
<input type="submit" name="r89/50"... />

Back to the top


makeTableNoSortValue()

The makeTableNoSortValue() function builds a reset value for table sort.

Syntax

    makeTableNoSortValue()

Back to the top


makeColumnSortIDID()

The makeColumnSortIDID() function builds a column sort action in inclusive format

Syntax

 makeColumnSortIDID(expr1,expr2)

Notes

  1. expr1 is the table id, for example the template path table/ID.
  2. expr2 is the sort value, for example the template path table/ID or the template function makeTableNoSortValue.

Back to the top


makeValueIDID()

The makeValueIDID() function builds a value in inclusive format

Syntax

 makeValueIDID(expr1,expr2)

Notes

  1. expr1 is the object id.
  2. expr2 is the value of the field.

Example

<input type="submit" gwc:attributes="name makeValueIDID(ID, value)" .../>
produces
<input type="submit" name="v89/tata"... />

Back to the top


makeFocusXDID()

The makeFocusXDID() function gives the focus to an item.

Syntax

makeFocusXDID()

Notes

  1. the syntax is control-name=control-value where control-name is makeFocusXDID() and control-value is the field id.

Example

<input type="radio" gwc:attributes="name makeFocusXDID(); value ID;... />
produces
<input type="radio" name="f" value="89"... />

Back to the top


makeFocusIDID()

The makeFocusIDID() function gives the focus to an item.

Syntax

makeFocusIDID(expr)

Notes

  1. expr is the field id.

Example

<input type="submit" gwc:attributes="name makeFocusIDID(ID);"... />
produces
<input type="submit" name="f/89"... />

Back to the top


makeKeyXDID()

The makeKeyXDID() function sends a key.

Syntax

makeKeyXDID(expr)

Notes

  1. the syntax is control-name=control-value where control-name is makeKeyXDID() and control-value is the key.

Example

<input type="radio" gwc:attributes="name makeKeyXDID(); value 'tab';... />
produces
<input type="radio" name="f" value="tab".. />

Back to the top


makeKeyIDID()

The makeKeyIDID() function sends a key.

Syntax

makeKeyIDID(expr)

Notes

  1. expr is the the key.

Example

<input type="submit" gwc:attributes="name makeKeyIDID('tab');"... />
produces
<input type="submit" name="f/tab"... />

Back to the top


makeProcessingXDID()

The makeProcessingXDID() function sends an action to get the page in process.

Syntax

makeKeyIDID()

Example

<input type="submit" gwc:attributes="name makeProcessingXDID();"... />
produces
<input type="radio" name="t" value=""... />

Back to the top


combEvents()

The combEvents() function combines multiple actions.

Syntax

combEvents(expr1, [expr2, ...])

Notes

  1. Combine multiple action string(expr1), string(expr2),... into a single action.

Back to the top


makeSessionVarIDID()

The makeSessionVarIDID() function builds a session variable.

Syntax

makeSessionVarIDID(expr1,expr2)

Notes

  1. expr1 is the session variable name
  2. expr2 is the session variable value.
  3. setting a variable to a empty string is equivalent to deleting the variable.

Example

<input type="hidden" gwc:attributes="name makeSessionVarIDID('var1','value1')" />

Back to the top


Other Functions

Back to the top


XPath()

The XPath() function returns xpath evaluation on current AUI tree context.
The result can only be a string not a node.

Syntax

xpath(expr)

Notes

  1. Return evaluation of xpath string(expr) result on current AUI tree context.

Example

<span gwc:content="xpath('//Window[1]/@name')" />

This gives the name of the first window.

<div gwc:repeat="i for(1,application/ui/windows/length)" gwc:omit-tag="true">
  <span gwc:condition="xpath('//Window[' + i + ']/Form/@name')" gwc:content="' :: ' + ( xpath('//Window[' + i + ']/Form/@text') || xpath('//Window[' + i + ']/@text') || xpath('//Window[' + i + ']/Form/@name') ) " />
  <span gwc:condition="!xpath('//Window[' + i + ']/Form/@name')" gwc:content="':: ' + xpath('//Window[' + i + ']/@name')" />
</div>

This gives the list of windows.

Back to the top


XPathConfig()

The XPathConfig() function returns xpath evaluation on current application configuration.

Syntax

xpathConfig(expr)

Notes

  1. Return evaluation of xpath string(expr) result on current application configuration.

Example

<input id="gKeepaliveValue" gwc:attributes="value XPathConfig('/APPLICATION/TIMEOUT/USER_AGENT/text()')" />

Back to the top


ImageURI()

The ImageURI() function builds the URI to the default image location.

Syntax

imageURI(expr)

Notes

  1. Return URI to string(expr) default image location.

Example

<img gwc:attributes="src imageURI('accept')" alt="accept" />

Back to the top


includeSnippet()

The IncludeSnippet() function includes a snippet.

Syntax

includeSnippet(expr)

Notes

  1. Include snippet with id string(expr).

Example

<div gwc:condition="application/state/ended" gwc:content="includeSnippet('EndingPage')" />

Back to the top


check()

The check() function checks the validity of an expression.

Syntax

check(expr)

Notes

  1. expr is the expression to be checked.

Back to the top


noOp()

The noOp() function evaluates an expression and returns true.

Syntax

noOp(expr)

Notes

  1. expr is the expression to be validated.

Back to the top


colorToRGB()

The colorToRGB() function gets the RGB value of a Genero predefined color name.

Syntax

colorToRGB(expr)

Notes

  1. expr is the name of a Genero color name.
  2. If expr is not a predefined Genero color name, expr is returned.

Back to the top