Proceed to WirelessDevNet Home Page
Publications, e-books, and more! Community Tutorials Store Downloads, tools, & Freebies! IT Career Center News Home
newnav.gif

Newsletters
EMail Address:



   Content
  - Articles
  - Columns
  - Training
  - Library
  - Glossary
 
   Career Center
  - Career Center Home
  - View Jobs
  - Post A Job
  - Resumes/CVs
  - Resource Center
 
   Marketplace
  - Marketplace Home
  - Software Products
  - Wireless Market Data
  - Technical Books
 
   News
  - Daily News
  - Submit News
  - Events Calendar
  - Unsubscribe
  - Delivery Options
 
   Community
  - Discussion Boards
  - Mailing List
  - Mailing List Archives
 
   About Us
  - About WirelessDevNet
  - Wireless Source Disks
  - Partners
  - About MindSites Group
  - Advertising Information
 
INDEX
>Introduction
>Understanding the Wireless Markup Language
>Valid WML Elements
>Building Applications With WML
>Creating A WML Deck
>Calling A Server Script
>Conclusion
 

Creating A WML Deck

In this example, we’ll start by creating a WML deck that allows us to first select a username from a list, enter in a password, then have our selections repeated back to us. This will illustrate the basic handling of user input, events, and variables all within one deck using multiple cards.

Listing 1 - WMLExample.wml


<?xml version='1.0'?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
 
<wml>
 
	<card id="Login" title="Login">
		<do type="accept" label="Password">
			<go href="#Password"/>
		</do>
		<p>
		UserName:
		<select name="name" title="Name:">
			<option value="John Doe">John Doe</option>
			<option value="Paul Smith">Paul Smith</option>
			<option value="Joe Dean">Joe Dean</option>
			<option value="Bill Todd">Bill Todd</option>
		</select>
		</p>
	</card>

	<card id="Password" title="Password:">
		<do type="accept" label="Results">
			<go href="#Results"/>
		</do>
		<p>
		Password: <input type="text" name="password"/>
		</p>
	</card>

	<card id="Results" title="Results:">
	<p>
	You entered:<br/>
	Name: $(name)<br/>
Password: $(password)<br/>
	</p>
	</card>
</wml>

As you can see, the prolog of this document contains the XML version number to be used as well as the Document Type Definition to be referenced. Following this comes the wml document element (the deck) that contains three cards: Login, Password, and Results. Each of these cards is defined using the element. Because the Login and Password cards also define events, they use the element to define the event to be triggered. Figure 1 shows the initial card loaded in a test browser.


Figure 1

When the "accept" type of the do element is encountered, it is displayed as an option on the WAP device display (see Figures 2, 3, and 4).


Figure 2

Figure 3

Figure 4

Selecting this option causes the element to be analyzed.

If you are familiar with the anchor tag () in HTML, you know that it specifies an href attribute that tells the browser where to link to if this anchor is selected. The WML element’s "href" attribute works in the same manner. As with HTML, to link to another card in the document, you simply prepend a # symbol before it. For example, to link to the Results card, we define the following element:


<go href="#Results"/>

This Results card makes use of variables by retrieving and displaying the contents of the name and password variables. Recall that variables are substituted into a card or deck by using the following syntax:


$(variable_name)



Next: Calling A Server Script
Sponsors

Search

Eliminate irrelevant hits with our industry-specific search engine!









Wireless Developer Network - A MindSites Group Trade Community
Copyright© 2000-2010 MindSites Group / Privacy Policy
Send Comments to:
feedback@wirelessdevnet.com