OpenWGA 7.6 - OpenWGA Concepts and Features

Design and development » WebTML » Features » Forms

Data binding and storage

WebTML forms allow to binding their data to the items of a document in a very simple manner. By simply setting attribute source on it you bind the its fields either to the current context document (source="content"), the users personalisation profile (source="profile") or to the current WebTML portlet (source="portlet"). Choosing source="none" disables all binding.

All inputs of this form will on their first rendering now look on the data backend if there is an item with the same name as they have. If there is one then its data is loaded to the field and shown in the input.

From this point on however the form field is independent of the backend and may be seen as a working copy of the backend data, that was created on first rendering. Changes that are done to the backend item while the form persists will not be reflected on the form any more.

To store the modified data of the form back to the original data backend you need a WebTML action. You can use either the default action $store or create a TMLScript action which invokes the method . The control triggering the action should be created inside the <tml:form> tag or refer the form to use by its attribute form.

See this little example of a form that is bound to the user profile:

<tml:form id="userData" source="profile">


<table>

<tr>

<td>Given name:</td>

<td><tml:input name="givenName" type="text"/></td>

</tr>

<tr>

<td>Surname:</td>

<td><tml:input name="surname" type="text"/></td>

</tr>

<tr>

<td>Favorite color:</td>

<td><tml:input name="choices" type="checkbox" options="Red, Blue, Green"/></td>

</tr>

<tr>

<td colspan="2">

<tml:button clickaction="$store">Store</tml:button>

</td>

</tr>

</table>

</tml:form>

A form like this may be used to ask the current user of his personal data and store it permanently to his profile, so it will be available every time he is logged in.

The text field "givenName" and "surname" are requested, also the checkbox field "Favorite color". Clicking the button labeled "store" will store these fields as items to the current user profile.

If the user stores this form and then, on a later browsing session, returns to it he will find the data he entered before directly offered to him in those fields, as their data is automatically retrieved from the profile backend.