Web Services
  Home arrow Web Services arrow Page 4 - WML: An Introduction
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
WEB SERVICES

WML: An Introduction
By: Frank Manno
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 16
    2004-02-11

    Table of Contents:
  • WML: An Introduction
  • Deal 'Em, Baby!
  • Shuffle That Deck
  • Would You Like My Special Offer
  • Welcome Aboard!
  • Wrap It Up

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    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:



    <wml>

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

      
    <p>

       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; />

       
    </do>

      
    </p>

     
    </card

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

      
    <p>

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

      
    </p>

      
    <p>

      An email has been sent to confirm your $email
    .

      
    </p>

     
    </card>

    </wml>


    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:

    WML & WAP

    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){

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

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

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

      WMLBrowser
    .go(&quot;example02.wml#result&quot;);</p>
    <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;);

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

      WMLBrowser
    .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;);

      WMLBrowser
    .go(&quot;example.wml#result&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).

    WML & WAP

    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:

    WML & WAP

    More Web Services Articles
    More By Frank Manno


     

    WEB SERVICES ARTICLES

    - 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
    - Orchestrating Web Services
    - Notifications and Resources in the WS-Resour...
    - WS Notification and WS Topics in the WS Reso...
    - Introducing the Implied Resource Pattern
    - Web Services and Stateful Resources
    - Deploying an EJB Application






    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
    Stay green...Green IT