Lecture 10 - Handling Events
Lecture 10 - Handling Events
Qadri Hamarsheh
Overview of WML
Handling Events
Syntax:
<onevent type="event_type">
A single task to be done whenever the event occurs
</onevent>
<onevent type="onenterbackward">
<refresh>
<setvar name="Name" value=""/>
<setvar name="Gender" value=""/>
<setvar name=" part" value=""/>
</refresh>
</onevent>
<p>
Hello, welcome to our Online Course.<br/>
Enter your name?<br/>
<input name="Name"/><br/>
Are you a boy or a girl?<br/>
<select name="Gender">
<option value="Boy"> boy</option>
<option value="Girl"> girl</option>
</select><br/>
Which part of our Online Course do you like?<br/>
<select name=" part" multiple="true">
<option value="WML"> WML </option>
<option value="HTML"> HTML </option>
<option value="WAP">WAP</option>
<option value="WMLScript"> WMLScript </option>
</select><br/><br/>
<anchor>
<go method="get" href="clearProc.asp">
<postfield name="name" value="$(Name)"/>
<postfield name="gender" value="$(Gender)"/>
<postfield name="tutorial_part" value="$( part)"/>
</go>
Submit Data
</anchor>
</p></card></wml>
• The ASP file that handles the form data submitted to the server. It simply prints out
the name-value pairs received (Optional example).
<wml>
<card id="card1" title="Submission Result">
<p>
Data received at the server:<br/>
Name: <% =Request.QueryString("name") %><br/>
Gender: <% =Request.QueryString("gender") %><br/>
Which part of our WML tutorial do you like?
<% =Request.QueryString("part") %><br/>
</p>
</card>
</wml>
Syntax
• Its value attribute specifies the period of time after which the timer will expire. The time
unit is 1/10 second. For example, the following WML markup:
<timer value="10"/>
• You can add a timer to refresh the content of a card regularly so that the information on
the card can be kept updated without involving any user actions.
Example 10.2
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.3//EN"
"http://www.wapforum.org/DTD/wml13.dtd">
<wml>
<card id="card1" title="Timer in WML">
<onevent type="ontimer">
<go href="ontimerEg1.wml"/>
Page 3 of 5 3
Wireless Markup Language Dr.Qadri Hamarsheh
Overview of WML
</onevent>
<timer value="50"/>
<p>
WML Timer Test
</p></card></wml>
• The above example can be written in the following short form. The ontimer attribute
of the <card> tag is used instead of the <onevent></onevent> and <go/> tags.
• Note that the order of the <timer> element and the <onevent> element in the WML
document does matter.
Example 10.3
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
"http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
<template>
<do type="options" label="Server">
<go href="http://localhost/Somefile.asp" method="get">
<postfield name="UserID" value="ADSF452"/>
<postfield name="Password" value="SSSSSSS"/>
<postfield name="Country" value="$Country"/>
</go>
</do>
</template>
<card id="Main" title="FAQ">
<onevent type="onenterforward">
<refresh>
<setvar name="Name" value="Ahmed"/>
<setvar name="Age" value="20"/>
</refresh>
</onevent>
<onevent type="onenterbackward">
<refresh>
Page 4 of 5 4
Wireless Markup Language Dr.Qadri Hamarsheh
Overview of WML
Page 5 of 5 5