Use Nokia WAP Toolkit to test the program. Start Nokia WAP Toolkit and select "Open Location" under "Go". After entering the URL address, you can see the interface that appears on the emulator. The event selection appears after selecting Optionos. Note that "InputName" is the do tag name. After the "InputName" event is selected, the interface output name will appear on the simulator
The syntax of <onevent> is as follows:
<onevent type="type">Task</onevent>
The values of the required attribute type are shown in Table 3-6:
Table 3-6 Values of type attributes
Enumerate the value Execute the task if the user performs the following operations
onpick When the user selects or does not select a <option> item
onenterforward When a user reaches a card using the <go> task
Onenterbackward user returns to the previous card using the <prev> task, or press the BACK button
ontimer When <timer> expires
Please see the following example program:
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "/DTD/wml_1.">
<wml>
<head>
<meta http-equiv="Cache-Control" content="max-age=0"/>
</head>
<card ordered="false">
<p>
Please select a city...
<select title="Cities List" name="city">
<option title="Beijing" value="Beijing">
<onevent type="onpick">
<go href="#card01"/>
</onevent>Beijing</option>
<option title="Shanghai" value="Shanghai" onpick="#card01">Shanghai</option>
<option title="Hongkong" value="Hongkong" onpick="#card01">Hongkong</option>
</select>
</p>
</card>
<card >
<p>
You are Living in $(city:noesc)
</p>
</card>
</wml>
<timer/> can be used to automatically execute a task after a period of time when the user does not perform any operations. Any task that activates the card page and user operations will start <timer/>, and when the task is in progress, <timer/> will stop. Each card can only have one <timer/>, and one <timer/> can only trigger one task. The syntax is as follows:
<timer name="variable" value="value"/>
where name is an optional attribute and is specified as a variable name. When exiting the card, the variable stores the value of the timer at this time. When the timer timed out, the phone sets the variable to 0; value is a required property, which is used to set the timer timing value, with a minimum unit of 0.1 seconds.
Please study the following example program:
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
"/DTD/wml_1.">
<wml>
<head>
<meta http-equiv="Cache-Control" content="max-age=0"/>
</head>
<card ontimer="#card2">
<timer name="time1" value="50"/>
<p align="center">
After 5s, goto card2
</p>
</card>
<card >
<onevent type="ontimer">
<go href="#card1"/>
</onevent>
<timer name="time2" value="50"/>
<p align="center">
Here is card2!
</p>
</card>
</wml>
Let me mention again: <onevent>, <timer>, and <do> must be written in the above order.
In addition, <template> can be added at the page level to bundle events on the page level. The syntax is as follows:
<template onenterforward="url" onenterbackward="url" ontimer="url">
<do> or <onevent>
</template>
Please study the following example program:
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "/DTD/wml_1.">
<wml>
<head>
<meta http-equiv="Cache-Control" content="max-age=0"/>
</head>
<template>
<do type="accept" label="deckPress" name="do1">
<go href="#card01"/>
</do>
</template>
<card ordered="false">
<do type="accept" label="cardPress" name="do1">
<go href="#card02"/>
</do>
<p>
Press ACCEPT...
</p>
</card>
<card >
<p>
Here is card01
</p>
</card>
<card >
<p>
Here is card02
</p>
</card>
</wml>
Previous page123Read the full text