A WML task is an element that specifies an action to be performed by the browser, rather than something to be displayed. For example, the action of changing to a new card is represented by a
<go> task element, and the action of returning to the previous card visited is represented by a
<prev> task element. Task elements encapsulate all the information required to perform the action.
Tasks are used in many places in WML. Events (discussed later in this chapter) are tied closely with tasks, and many of the user interface elements (see Chapter 4, WML User Interaction) use tasks to perform actions.
To see how tasks are used in context, consider the element
<do>, which represents some sort of control that the user can activate, such as a softkey, a menu item on a cell phone, or maybe even an onscreen button if the device has a touchscreen. A
<do> element isn't itself a task element. Rather, it contains a task subelement that specifies the action to perform when the user activates the control.
<do> element that, on activation, simply assigns the value
wibble to the variable
test can be written as:
<do type="accept"> <refresh> <setvar name="test" value="wibble"/> </refresh> </do>
To have the same
<do> element instead send the browser to a card called
card2 in the current deck, you could write:
<do type="accept"> <go href="#card2"/> </do>
Note that the
<do> element is exactly the same for these two examples. The only difference is the task element (the
<refresh> or the
<go>). This added consistency (or orthogonality to use the technical term) is an important benefit of using tasks.
<do> element is explained more fully in Chapter 4.