- WML2 - Tutorial
- WML - DTD
- WML - Template
- WML - Timer
- WML - Events
- WML - Server Scripts
- WML - Submit Data
- WML - Inputs
- WML - Tasks
- WML - Links
- WML - Tables
- WML - Images
- WML - Fonts
- WML - Formatting
- WML - Variables
- WML - Comments
- WML - Elements
- WML - Syntax
- WML - Environment
- WML - Overview
- WML - Home
WML References
WML Tools
WML Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
WML - Events
Event in ordinary language can be defined as something happened. In programming, event is identical in meaning, but with one major difference. When something happens in a computer system, the system itself has to (1) detect that something has happened and (2) know what to do about it.
WML language also supports events and you can specify an action to be taken whenever an event occurs. This action could be in terms of WMLScript or simply in terms of WML.
WML supports following four event types:
: This event occurs when the user hits a card by normal backward navigational means. That is, user presses the Back key on a later card and arrives back at this card in the history stack.
: This event occurs when the user hits a card by normal forward navigational means.
: This is more pke an attribute but it is being used pke an event. This event occurs when an item of a selection pst is selected or deselected.
: This event is used to trigger an event after a given time period.
These event names are case sensitive and they must be lowercase.
WML <onevent> Element:
The <onevent>...</onevent> tags are used to create event handlers. Its usage takes the following form:
<onevent type="event_type"> A task to be performed. </onevent>
You can use either go, prev or refresh task inside <onevent>...</onevent> tags against an event.
The <onevent> element supports the following attributes:
Attribute | Value | Description |
---|---|---|
type | onenterbackward onenterforward onpick ontimer | Defines a type of event occured. |
class | class data | Sets a class name for the element. |
id | element ID | A unique ID for the element. |
Following is the example showing usage of <onevent> element. In this example, whenever you try to go back from second card to first card then onenterbackward occurs which moves you to card number three. Copy and paste this program and try to play with it.
<?xml version="1.0"?> <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.2//EN" "http://www.wapforum.org/DTD/wml12.dtd"> <wml> <onevent type="onenterbackward"> <go href="#card3"/> </onevent> <card id="card1" title="Card 1"> <p> <anchor> <go href="#card2"/> Go to card 2 </anchor> </p> </card> <card id="card2" title="Card 2"> <p> <anchor> <prev/> Going backwards </anchor> </p> </card> <card id="card3" title="Card 3"> <p> Hello World! </p> </card> </wml>Advertisements