Home arrow Web Services arrow Page 4 - WML: An Introduction

WML: An Introduction

Full-house, Go-Fish, and Blackjack – some of my favorite games to play when I’m with friends. Alright, maybe that’s not true, but they’re definitely a way to pass the time. The words “deck” and “card” are synonymous to playing cards.  However, they are also the terms used when developing WAP-enabled websites using WML.  In this tutorial, I’ll give a breakdown on just what WAP and WML are and how they can be used.  We’ll also run through creating a simple WAP-enabled site making use of multiple cards in a deck.  There will be ample code to get you started on developing your own WAP-enabled site, whether for fun or for business.

Author Info:
By: Frank Manno
Rating: 5 stars5 stars5 stars5 stars5 stars / 23
February 11, 2004
  1. · WML: An Introduction
  2. · Deal 'Em, Baby!
  3. · Shuffle That Deck
  4. · Would You Like My Special Offer
  5. · Welcome Aboard!
  6. · Wrap It Up

print this article

WML: An Introduction - Would You Like My Special Offer
(Page 4 of 6 )

In this next example, I’ll show you how WMLScript can further enhance the interaction between your WAP site and the end-user.  We’ll first start by building the form interface that will be presented to the user:


<card id=&quot;main&quottitle=&quot;Special Officer&quot;>


   Enter your name
:<br />

<input type=&quot;text&quotname=&quot;user_name&quot; />

<do type=&quot;button&quotlabel=&quot;Submit&quot;>

<go href=&quot;example02.wmls#prompt_user()&quot; />




<card id=&quot;result&quottitle=&quot;Thank you!&quot;>


  You chose $result accept the 
&quot;Special Offer&quot;.  Thank you!<br />



  An email has been sent to confirm your $email




We’ve created two cards in our deck.  The first, Special Offer, presents a form to the user in which they can enter their name, followed by a submit button. This is how the form looks to the user:


When the submit button is pressed, our form calls the page indicated in our <go> tag; in this case, example02.wmls#prompt_user(), which calls the prompt_user() function we’re now going to create:

extern function prompt_user(){</p>
p align="left"> </p>
p align="left"> var user_name WMLBrowser.getVar(&quot;userName&quot;); 

var prompt = &quot;Would you like to accept our &quot;Special Offer&quot;, &quot; + user_name + &quot;?&quot;;

var yes = &quot;Yes&quot;;

var no = &quot;No&quot;;

var result Dialogs.confirm(prompt,yes,no);</p>
p align="left"> </p>
p align="left"> if (result == true){

.setVar(&quot;result&quot;, &quot;to&quot;);

.setVar(&quot;email&quot;, &quot;acceptance!&quot;);

.go(&quot;mailto:frank@developershed.com?from=Special Offer Administrator&subject=Special Offer&body=You accepted the special offer.  Thank you!&quot;);

<p align="left"> </p>
p align="left"> } else {</p>
p align="left"> </p>
p align="left">  WMLBrowser.setVar(&quot;result&quot;, &quot;not to&quot;);

.setVar(&quot;email&quot;, &quot;refusal.&quot;);

.go(&quot;mailto:frank@developershed.com?from=Special Offer Administrator&subject=Special Offer&body=Thank you for considering our offer.  Stay tuned for new offers!&quot;);




The prompt_user() function is fairly straightforward.  We first make use of the extern keyword to indicate that the function is available to an outside file, in our case example02.wml.  We then create our local variables, which will be used to create the user prompt.  Our result variable will hold the returned value sent from the user confirmation (a Boolean value).


We then test to see if our result is true.  We then test to see if result is true or false.  Next, we set the value to our variables (result and email) in the “result” card (see example02.wml), which will be displayed to the user after sending a confirmation email indicating the users selection (yes or no).

The final output displayed to the user is shown below:


blog comments powered by Disqus

- Dealing with Loose Coupling in a Service-Ori...
- Loose Coupling in a Service-Oriented Archite...
- Safety, Idempotence, and the Resource-Orient...
- The Resource-Oriented Architecture in Action
- Features of the Resource-Oriented Architectu...
- The Resource-Oriented Architecture
- Getting Started with Flex
- Automated Billing and Faxing for the Web
- An Introduction to Web Services
- The Foundations of Web Services: From Novice...
- Web Services Reengineering: Finishing Touches
- Fault Handling with Web Services
- Flow and Web Services
- Process Lifecycles and Web Services
- Business Processes and Web Services

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 

Developer Shed Affiliates


© 2003-2019 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials