Java Reference
In-Depth Information
described in the next section). Events can be handled by being bound to a task (such as <go> or
<option> ). <onevent> accepts one simple attribute: type . Different elements accept different
event types. The following list illustrates the event types handled in WML by the <card> and
<select> elements:
<card> onenterforward , onenterbackward , ontimer
<select> onpick
The next section introduces the use of the ontimer event when using timer elements.
Timers
One interesting element introduced in WML is the <timer></timer> tag. Timers built into a
card allow that card to be displayed for a set amount of time before transferring focus to
another target URL. This is very useful to force the display of a splash screen or advertisement
to your users. The timer tag syntax is as follows:
<timer value=”25”/>
The value parameter specifies a time in tenths of a second. For example, the timer listed in the
preceding syntax would display for 2.5 seconds. A timer is used with the ontimer event in a
<card> tag to specify a URL to transfer to when the timer goes off (see Listing 24.2).
Variables
Note that both the input and select elements include a name attribute. Because multiple cards
can be stored within a single deck (to eliminate round trips to the server), it is important that
global data be able to be shared across cards. To do this, WML introduces the concept of a
variable that can either be defined implicitly or explicitly. In the two snippets above, the vari-
ables zipcode and state are implicitly defined and could be accessed using the $ operator. For
example, to output the contents of the zipcode variable, the following code could be used:
24
<p>
Zip Code: $(zipcode)
</p>
Variables can also be accessed through WMLScript, as we will see later in this chapter. Now
that the WML basics have been introduced, it is time to undertake a larger example to be tested
in a series of WAP emulators.
A WML Example
In this section, you'll develop a fairly simple example using multiple cards within a deck
named WMLExample.wml . The code in Listing 24.2 illustrates some of the basic concepts dis-
cussed in this chapter: multiple cards, anchors, variables, and lists.
 
Search WWH ::




Custom Search