4.4. Programming server requests/answers

4.4.1. Adressing widget data

Widget data elements elements are addressed by using the relative path of the element from the widget where the request or answer was specified. The relative path is a sequence of widget object names separated by dots ('.'). Only atomic element references are specified in request/answer structure.

Biggest common ancestor path

The grouping of elements into structures is done by the biggest common ancestor path of all atomic element references in a structure. It is assumed that this biggest common ancestor is addressing the structure. If for example a structure has the atomic widget element references "home.user.name" and "home.user.id" then we assume that "home.user" is adressing the structure containing "name" and "id" in the widget data.

Addressing atomic elements

Table 4.8. Basic elements of request/answer

DescriptionSyntax
Constant (server request only)string with single (') or double (") quotes or numeric integral constant
Mandatory attributename={variablepath}
Mandatory content valuename{{variablepath}}
Optional attributename={variablepath:?}
Optional content valuename{{variablepath:?}}
Optional attribute with defaultname={variablepath:default}
Optional content with default valuename{{variablepath:default}}
Ignored attributename={?}
Ignored content valuename{{?}}
Ignored sub structurename{?}

Special path elements

Variable references can address other widgets than sub widgets of the current widget.

Addressing the form widget

The reserved path element 'main' addresses the form widget root.

Widget links

A dynamic property with the prefix 'link:' followed by an identifier as name declares the widget with the widget id as dynamic property value of the link definition to be referencable by name. The referencing name is the identifier after the prefix 'link:'. So if we for example define a dynamic property 'link:myform' with a widget id as value, then we can use the variable 'myform' in a widget path to address the widget.

The mechanism of widget links is mainly used for implementing form/sub-form relationships. A form opens a subform and passes its widget id to it with the form parameter 'widgetid=..'. A link is defined to the sub-form with the widget id passed to it. The subform signals some action to the parent that can address the data entered in the subform via this link.

4.4.2. Data structures

Structure elements are separated by semicolon ';' and put into '{' brackets '}' with the name of the structure in front.

Example

The following example shows an address as structure:

		
address{
  tag=1;
  surname{{person.surname}};
  prename{{person.prename}};
  street{{address.street}}
}

		

4.4.3. Arrays

Arrays are marked with opened and closed square brackets '[' ']' without specifying dimension (arbitrary size or empty when missing).

Description

Table 4.9. Types of arrays

DescriptionSyntax
Arbitrary Size Array of Content Valuesname[]{{variablepath}}
Arbitrary Size Array of Structuresname[]{structure definition}

Example

The following example shows an array of addresses:

		address[]{
  surname{{address.surname}};
  prename{{address.prename}};
  street{{address.street}}
}

		

The widget element paths used to address the widget elements have to have a common ancestor path. In our example this would be 'address'. The common ancestor path is determining how elements are grouped together in the widget. It tells what belongs together to the same array element in the widget. Without common common ancestor path it would be impossible to determine what is forming a structure in the widget data. It distinguishes the case of having an array of adresses and the case of having an array of surnames, and array of prenames and an array of streets. The later makes not much sense here. With the common prefix we state how entities are grouped together to structures in the representation in the widget.

4.4.4. Indirection and recursion

Indirection allows to define recursive structures. Indirection means that an element is specified as reference that is expanded when the element appears in the data structure to map. The grouping element of the indirection elements is the common ancestor of all non indirection elements in the structure containing the indirection.

Description

Table 4.10. Types of indirections

DescriptionSyntax (name equals ancestor name)Syntax (name differs from ancestor name)
Single Element Indirection^ancestor^item:ancestor
Multiple Indirection^ancestor[]^item:ancestor[]

Example (arbitrary tree)

Example representing a tree with arbitrary number of children per node:

		
item{
  id={treewidget.id};
  name{{treewidget.name}};
  ^item[]
}

		

Example (binary tree)

Example representing a binary tree:

		
item{
  id={treewidget.id};
  name{{treewidget.name}};
  ^left:item;
  ^right:item
}