O'Reilly logo

Learning WML, and WMLScript by Martin Frost

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 3. WML Tasks and Events

In the last chapter, you learned about variables in WML, something not found in HTML. This chapter covers two further parts of WML—tasks and events—that have no real equivalent in HTML. (In some cases you can use JavaScript to achieve similar effects.)

Tasks

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) 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.

A <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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required