Template functions are defining an utility toolbox for snippet developers.
The bool() function converts an expression to a boolean.
bool(expr)
expr
is the expression to convert.The number() function converts an expression to a number.
number(expr)
expr
is the expression to convert.The string() function converts an expression to a string.
string(expr)
expr
is the expression to convert.object(expr)
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.<p gwc:replace="object(value) />
This insert the value of a field as XHTML code in the html page.
The for() function creates a numeric sequence.
bool(expr1, expr2, [expr3])
number(expr1)
to number(expr2)
with a step of number(expr3)
[1
by default].
<div gwc:repeat="i for(0, 20, 2)" gwc:content="i"
/>
The switch() function compares an expression to different values, and return a result dependant on which value it equals to.
switch(expr1, array1, array2, [expr2])
<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...')" />
The min() function returns the minimum between two numbers.
min(expr1, expr2)
number(expr1)
and number(expr2)
.The max() function returns the maximum between two numbers.
max(expr1, expr2)
number(expr1)
and number(expr2)
.round(expr)
number(expr)
.The fill() function formats a number by filling its string representation.
fill(expr1, expr2, [expr3, [expr4]])
string(number(expr1))
filled with string(expr3)
[" " by default] to reach
number(expr2)
width. bool(expr4)
[true by default]: true means
filling to left, false filling to right.precision(expr1, expr2)
number(expr1)
decimal part to number(expr2)
.abs(expr)
number(expr)
.sin(expr)
number(expr)
.number(expr)
is the angle in degrees.cos(expr)
number(expr)
.number(expr)
is the angle in degrees.tan(expr)
number(expr)
.number(expr)
is the angle in degrees.The excapeJS() function escapes JavaScript-sensitive characters.
escapeJS(expr)
string(expr)
with ["'", "\", "\n", "\r"] characters escaped with a "\".The translate() function translates a string.
translate(expr1, expr2, expr3)
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.
<div gwc:attributes="class translate(style, ' -/\#.=+()[]', '____________')"/>
To replace character by character.
To replace each strings in the array expr2 by the string expr3
<div gwc:attributes="class translate(style, ['\\r\\n','\\n','\\r'],
'<br/>')"/>
.
The split() function splits a string using a delimiter.
split(expr1, expr2)
string(expr1)
split into an array of substrings according to
string(expr2)
delimiter.
<option gwc:attributes="selected valueChecked in split(value , '|') ? 'selected' : null"/>
length(expr)
string(expr)
length.The substring() function returns a substring of a string.
substring(expr1, expr2, [expr3])
string(expr1)
substring from number(expr2)
position to
number(expr3)
position [end of string(expr1)
by default].contains(expr1, expr2)
string(expr2)
is a substring of string(expr1)
.The indexOf() function returns the position of a substring in a string.
indexOf(expr1, expr2)
string(expr2)
in string(expr1)
[return -1 if
string(expr2)
is not found in string(expr1)
].The replace() function replaces a specified part of a string with another string.
replace(expr1, expr2, expr3)
string(expr2)
in string(expr1)
by
string(expr3)
.The filterAmpersand() function filters the ampersand (&) on a given string. Double ampersand (&&) are replaced by a simple one.
filterAmpersand(expr)
<span gwc:content="filterAmpersand('&Save && exit'/>
will produce ...
<span>Save & exit</span>
The makeScrollOffsetIDID() function builds offset action.
makeScrollOffsetIDID(expr1, expr2)
expr1
is the table id.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"... />
The makePageSizeIDID() function builds page size action.
makePageSizeIDID(expr1, expr2)
expr1
is the table id.expr2
is a size value.Example
<input type="submit" gwc:attributes="name makePageSizeIDID(ID,
'50');... />
produces
<input type="submit" name="s88/50"... />
The makeRowSelectionIDID() function builds inclusive row selection action.
makeRowSelectionIDID(expr1, expr2)
expr1
is the table id or the selectorID for a matrix.expr2
is the row index.<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"... />
The makeTableNoSortValue() function builds a reset value for table sort.
The makeColumnSortIDID() function builds a column sort action in inclusive format
makeColumnSortIDID(expr1,expr2)
Notes
The makeValueIDID() function builds a value in inclusive format
makeValueIDID(expr1,expr2)
Notes
Example
<input type="submit" gwc:attributes="name makeValueIDID(ID, value)"
.../>
produces
<input type="submit" name="v89/tata"... />
The makeFocusXDID() function gives the focus to an item.
makeFocusXDID()
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"... />
The makeFocusIDID() function gives the focus to an item.
makeFocusIDID(expr)
expr
is the field id.Example
<input type="submit" gwc:attributes="name makeFocusIDID(ID);"... />
produces
<input type="submit" name="f/89"... />
The makeKeyXDID() function sends a key.
makeKeyXDID(expr)
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".. />
The makeKeyIDID() function sends a key.
makeKeyIDID(expr)
expr
is the the key.Example
<input type="submit" gwc:attributes="name makeKeyIDID('tab');"... />
produces
<input type="submit" name="f/tab"... />
The makeProcessingXDID() function sends an action to get the page in process.
makeKeyIDID()
Example
<input type="submit" gwc:attributes="name makeProcessingXDID();"... />
produces
<input type="radio" name="t" value=""... />
The combEvents() function combines multiple actions.
combEvents(expr1, [expr2, ...])
string(expr1)
, string(expr2)
,... into a single action.The makeSessionVarIDID() function builds a session variable.
makeSessionVarIDID(expr1,expr2)
expr1
is the session variable nameexpr2
is the session variable value.Example
<input type="hidden" gwc:attributes="name makeSessionVarIDID('var1','value1')" />
The XPath() function returns xpath evaluation on current AUI tree context.
The result can only be a string not a node.
xpath(expr)
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.
The XPathConfig() function returns xpath evaluation on current application configuration.
xpathConfig(expr)
string(expr)
result on current application configuration.
<input id="gKeepaliveValue" gwc:attributes="value XPathConfig('/APPLICATION/TIMEOUT/USER_AGENT/text()')" />
The ImageURI() function builds the URI to the default image location.
imageURI(expr)
string(expr)
default image location.
<img gwc:attributes="src imageURI('accept')" alt="accept" />
The IncludeSnippet() function includes a snippet.
includeSnippet(expr)
string(expr).
<div gwc:condition="application/state/ended" gwc:content="includeSnippet('EndingPage')" />
The check() function checks the validity of an expression.
check(expr)
expr
is the expression to be checked.The noOp() function evaluates an expression and returns true.
noOp(expr)
expr
is the expression to be validated.The colorToRGB() function gets the RGB value of a Genero predefined color name.
colorToRGB(expr)
expr
is the name of a Genero color name.expr
is not a predefined Genero color name, expr
is returned.