A Genero Web Client template instruction is prefixed by "gwc". The Genero Web Client processes the template instruction and generates new HTML code.
<tag
gwc:instruction="expression" ... >
...
</tag>
tag
is an HTML tag GWC Template Instruction | Description |
gwc:snippet-root |
Delimit a snippet. |
GWC Template Instruction | Description |
gwc:define | Define a variable to be used in the current tag or the children tags. |
gwc:condition | Test the condition. |
gwc:repeat | Repeat the children tags. |
gwc:replace | Replace the entire tag. |
gwc:attributes | Dynamically change an attribute of the current HTML tag. |
gwc:content | Replace the text between the tags. |
gwc:omit-tag |
Suppress the surrounding tag after instructions in the children tags have been processed. |
gwc:marks |
Associate custom data to the element |
With Genero Web Client instructions, as with XML, you can write attributes in any order. The processing of instructions, however, is interpreted in the order listed above, from the highest priority to the lowest. For example, once gwc:replace has been executed, there is no material to achieve the gwc:content processing.
Replace the XHMTL DIV element by the rendering of the component. Snippet-root instructions are typically found in snippet XHTML files. See Application Rendering for more information on snippet files.
<
gwc:snippet-root>
...
</gwc:snippet-root>
<gwc:snippet-root> <input type="text" readonly="readonly" class="gField gEdit" gwc:marks=" field [CID]; currentFieldStyle [CID,'gCurrentField']; modifiable isModifiable?[CID]:null; " gwc:attributes=" class _tpl_+(isModifiable ? '':' gDisabled')+(color?' gColor_'+color:'')+(hidden!=2?'':' gHidden'); value value; size width; maxLength maxLength || null; title comment; " /> </gwc:snippet-root>
This defines the rendering of an Edit field.
The define instruction declares a local variable that can be used in the HTML tag (the current element) and in its child elements. This variable is undefined outside of the current element.
<tag
gwc:define="var expression [; ...]" ...>
...
</tag>
<div gwc:define="i menu">
i is set to the current item of a menu.
If the expression is TRUE, render the element. If the expression is FALSE, remove the tag and its children.
<tag
gwc:condition="expression"
...>
...
</tag>
Expression Value Type | Test |
Boolean | Expression value is true. |
Numeric | Expression value is not 0. (zero) |
String | String is not empty or "0". (zero) |
Template path with identified node | The identified element exists (i.e. formfield[edt1] ). |
Template path with value | The value is not empty if it is a string, or 0 if it is a
numeric or boolean value (i.e. formfield[edt1]/id ). |
For a specified collection, iterate through the collection and repeat the element, once per item in the collection.
<tag
gwc:repeat="elt eltList">
statements
</tag>
<div gwc:repeat="item menu/actions"> <a href="..." gwc:condition="item/text" gwc:define="text item/text" gwc:attributes="href string:${document/URL}?${item/id}" gwc:content="text">Input</a> </div>
Displays the text of each action of a menu as an HTML link.
The following table lists special template paths for use with a gwc:repeat instruction. For more information on template paths, see Template Paths for the Snippet-Based Rendering Engine.
Template Path | Type | Component | AUI object |
repeat | object | ||
repeat/elt | object | ||
Template Path | Type | Description | Attribute Type |
repeat/elt/length | attribute | Get the length of the repeat sequence (the number of elements in the sequence). | number |
repeat/elt/index | attribute | Get the index of the current element in the sequence, starting with 0 (zero). | number |
repeat/elt/first | attribute | Test if the current repeat element is the first element of the sequence | boolean |
repeat/elt/last | attribute | Test if the current repeat element is the last element of the sequence | boolean |
repeat/elt/even | attribute | Test if the current repeat element is an even element of the sequence | boolean |
repeat/elt/odd | attribute | Test if the current repeat element is an odd element of the sequence | boolean |
Replace the HTML tag (current element and its children) with the value of a template expression.
<tag
gwc:replace="expression"
...>
...
</tag>
<div gwc:replace="window"></div>
The DIV tag is replaced by the application window.
This instruction dynamically sets a value to an attribute of the current tag. If the attribute does not exist, it will be created. If it exists, its value will be changed.
<tag gwc:attributes="att expression [; ...] " ...>
...
</tag>
<form action="..." method="post" gwc:attributes="action document/URL ; method string:get">
The action attribute is set to the document URL and the method attribute to get.
Replace the element content (between the HTML tags) with the value of a template expression.
<tag
gwc:content="expression"
...>
...
</tag>
<div id="gForm-div" gwc:content="form" />
The content of the div tag is set to the generated code of the current form.
If the expression evaluates to TRUE, replace the element by its content. If the expression is FALSE, remove the element.
<tag
gwc:omit-tag="expression"...>
...
</tag>
<div gwc:content="formfield[edt1]/value" gwc:omit-tag="true"></div>
This displays the value of the form field "edt1" and removes the DIV tag.
Associates data with the current element, in order to be used by JavaScript on the client side.
<tag gwc:marks="mkp expression [; ...] " ...>
...
</tag>
<gwc:snippet-root> <input type="text" readonly="readonly" class="gField gEdit" gwc:marks=" field [CID]; currentFieldStyle [CID,'gCurrentField']; modifiable isModifiable?[CID]:null; " gwc:attributes=" class _tpl_+(isModifiable ? '':' gDisabled')+(color?' gColor_'+color:'')+(hidden!=2?'':' gHidden'); value value; size width; maxLength maxLength || null; title comment; " /> </gwc:snippet-root>
This defines the rendering of an Edit field.