OpenWGA 7.6 - OpenWGA Concepts and Features

Design and development » WebTML » Features » Forms

Process context

Besides being a tool to get user input, the WebTML form may also be used as the common object accompanying the steps of a multi-step process. When a WebTML form gets submitted from request to request then this may be seen as some kind of process, no matter what the actual submitting actions are and if the form keeps its form or changes from step to step. The process ends once a request is called that does not post the form and therefor loses the form data.

To provide a storage for custom objects that are needed on this process the TMLForm object in TMLScript offers a property tmlform.processContext. This actually is an enhanced Lookup table for storing arbitrary key/value pairs. The data of the process context is kept on the server, so the context may store any data type. The processContext is NOT stored to the data backend of the form, at least not automatically. It is primarily intended for storing work data neccessary for the process.

The processContext of a form becomes unavailable once a form is not submitted to get to the next request, just like the forms data. A process context can be explicitly "killed" by calling processContext.kill().

Imagine this WebTML form which wants to display different fields on different steps of the process:

<tml:action id="changeStep">

  var stepMod = parseInt(tmlparam1);

  var step = tmlform.processContext.get("step");

  tmlform.processContext.put("step", step + stepMod);


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


       if (!tmlform.processContext.containsKey("step")) {

          tmlform.processContext.put("step", 1);




   <tml:case condition="tmlform.processContext.get('step') == 1">


<td>Given name:</td>

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




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




        <tml:case condition="tmlform.processContext.get('step') == 2">   


<td>Favorite color:</td>

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




  <td colspan="2">

<tml:button clickaction="changeStep" param1="-1">Previous step</tml:button>

<tml:button clickaction="changeStep" param1="1">Next step</tml:button>





This will create an alternating display of the WebTML form for each step. The example explained:

  • On processContext a field "step" is used to store the step of the process we are currently in. This field is initialized with value 1 in the <tml:script> block right after the start of the form
  • The <tml:case>'s inside <table> switch the input fields to display depending on what is stored as "step" on process context
  • The buttons on the bottom of the form call WebTML action "changeStep" to proceed or go back in steps. Therefor they give the textes "-1" and "1" as param to the action
  • The action "changeStep" defined on the top of the code takes this param and converts it to a number. Then it reads the current step from the process context and adds the number value of the parameter to it, so actually increasing or descreasing the step by one