Chris Cusack

Subscribe to Chris Cusack: eMailAlertsEmail Alerts
Get Chris Cusack: homepageHomepage mobileMobile rssRSS facebookFacebook twitterTwitter linkedinLinkedIn


Related Topics: ColdFusion on Ulitzer

CFDJ: Article

WAP! eh! eh!... Wot's it good for?

Chris examines Ben Forta's latest book

WAP Development with WML and WMLScript
By Ben Forta (Editor), Paul Fonte, Keith Lauver, Robert M. Juncker, Dylan Bromby, and Ronan Mandel
Paperback, 500 pp + CD; $54.99 US
Sams 2000
ISBN: 0672319462

As a first step in getting phones and other mobile devices connected with the Web, WAP Development with WML and WMLScript does a good job illuminating WAP and WML's many possibilities. Working with the conviction that WAP is, "a powerful way to interface with mobile devices," the book explains much of what WAP does and how it does it.

WAP (Wireless Application Protocol) is a protocol designed for wireless devices, a mechanism for transporting data similar to HTTP on the web. Examples of WAP devices include cell phones and PDA devices — Palm Pilots, Visors, and Windows CE devices.

WAP's many components include WML (Wireless Markup Language), WAP's equivalent to the Web's HTML. WML is the language for coding wireless applications, just as HTML is the language for the Web.

WAP, as a buzz-word, is commonly substituted for WML, but they are in fact two distinct things.

For those familiar with HTML, the progression to the stricter WML programming style will require close attention. WML is based on XML, which has a very discrete programming style that, once you get accustomed to it, removes a lot of guesswork from coding.

The book spends a lot of effort emphasizing the syntax of WML. The style of the book is such that at many times while reading it I felt like I was talking to a colleague, except that the book doesn't branch off on irrelevant tangents all of a sudden as my colleagues tend to. This was a pleasant change.

HTML similarities
WML has many similarities to HTML. It has <p>, <a href... > (relative, absolute, and relative fragment [#somewhere]) and <br> tags, but with stricter tag enforcement requirements than HTML.

A <p> tag, for example, lacking a closing </p> will generate an error. Also, placing text in a card or deck (more on them in a minute) without a <p> tag enclosure will generate an error.

One annoying WML aspect is its character limitation. The book recommends you to keep your anchor titles to a maximum of 6 characters as not all devices can display more than that. After years of Web programming and with broadband just starting to happen so that we can finally loosen up, the WML limitations may prove frustrating. However, it is a disadvantage that opens up the much greater advantage of being able to communicate to millions of handheld devices.

Restricted interface: handicap or opportunity?
Since WML is a standard while WAP devices are not, a WML app can behave differently on different devices. Throughout the book the authors do a good job in posting many warnings to keep code as simple and as basic as possible so that its code will work with as many WAP devices as possible. The book accomplishes a very difficult task in communicating the basics of WAP and WML where there is no standard device display under which all things are equal.

Remember when we used to look at Microsoft and Netscape's Web browsers and bitch about the inconsistencies? Those were the good old days — WAP devices can vary in every way. The authors of the book do a good job of dealing with these issues by listing the limitations of different WAP devices, device differences, and varying screen sizes.

These differences can be observed on a device simulator: software that allows you to test your WML code with various emulated devices. Fortunately there are a lot of emulators available to demonstrate just how your WML will display in a variety of different manufacturers' WAP devices. The book's CD provides URL's for downloading some of these emulators, including the Ericsson WapIDE SDK Browser, the Nokia WAP Toolkit, and the Phone.com UP.SDK.

Data delivery
WAP data delivery is accomplished the same ways it is in a client/server model. The book describes the two methods of data delivery: POST and GET. The post is accomplished using post variables from a form. The get is accomplished using URL variables in the same format as HTML. In the example below, the goal is to pass the name/value pair of COLOR=red.

POST:
<go method="post" href="http://www.cfadvisor.com">
	<postfield name="COLOR" value="red" />
</go>

GET:
http://www.cfadvisor.com?COLOR=red

Generally, you would use the GET in a situation where you have a hard-coded URL that you want to append variable data to.

A big surprise to me in the WML specification was that it doesn't have any built-in functionality to handle e-mail directly. But the book demonstrates how simple it is to integrate with an application server, such as ColdFusion, and utilize the CFMAIL tag to send a message captured in WML.

The book goes into great detail on WML Script and Timer elements but, unless you need to do something in these areas specifically, the area is a little dry and drawn out.

Restricted interface
Since most WAP devices are phones or other handheld objects, they have restricted interfaces. Restricted not only in their size, but as devices with no mice or keyboards for input.

The restricted interface, however, has a bright side as it has lead to innovative methods for navigation and content interaction — methods that would never have been considered in HTML. Being forced to come up with new ways of accomplishing "old tricks" has given WML a lot of cool features that HTML could benefit from.

For one, although the nomenclature may be a little difficult to get accustomed to, there is the card/deck notion. A deck is like a single file in HTML while cards are similar to display screens held within the deck that can be navigated to at any time.

An entire deck is downloaded to the WAP device, even though only one card may immediately appear on the device display. (This can be compared to a client side JavaScript where an entire .js file is downloaded to a browser but may be executed with a function-by-function basis.) While decks do have a maximum size, there is no downloading time difference between sending a deck with many cards to the WAP device (client) and sending a deck with only one card.

Once a deck has been loaded to a client phone or other handheld device, the interaction to view the other cards could be tough as the only standard that exists with all WAP devices, besides a numeric keypad, is the two navigation buttons. This problem lead to the novel concept of "Softkey" actions, which perform some of the actions and tasks commonly performed by a mouse in HTML.

Using Softkeys is like reading an HTML document that is one of 5 pages and being able to just hit your keyboard's right arrow key, regardless of where you are, to move to the next page. Softkeys assign definitive actions to a device's keys. So, instead of having to select the text that reads "More" by highlighting it and then hitting Enter, you simply hit the pre-programmed Softkey navigation button that has that action assigned to it.

What about cookies?
While the WAP platform doesn't require WML browsers to support HTTP cookies, many WAP gateways proxy HTTP cookies on their behalf. In addition, the "setvar" variable setting maintains variable state information between decks and cards. Consequently, persistent state information can be accomplished with WML, it's just a little trickier than it is in HTML.

Another cool WML form element addition is the "optgroups" portion of a select form element control. In HTML, Select offers only one level of choices that contain values. Taking from the card/deck notion, optgroups in WML allow the nesting of choices two levels deep without resubmitting the form.

For example: if a Select asked: "Where do you live?," optgroups could list all the continents and options within the individual continent optgroups could list more specific choices, such as countries.

When a user picked their continent, Asia for example, the choices would then change to display the countries of Asia — all without a form being submitted. If the user got to a sub-choice and realized that her country wasn't on that list, she could then just go back up one level and choose another continent.

This provides a solution to the HTML problem of having to post to get new data (and more choices) while turning the disadvantage of a WAP device's limited screen size and bandwith into the advantage of a better user experience.

Another WML advantage is the ability to restrict input types to numeric, alpha (upper/lower case), etc. This allows control over which types of input are permitted to be entered on forms. (In HTML, JavaScript has to be implemented to gain this type of functionality.)

Intrinsic events are useful in events like order processing. With HTML, one can only process entirely from the top down. In WML, there are specifications like "onenterbackward" (on enter backward) in which — depending upon how a user visits the card — different actions will occur.

This would be useful when a user processed an e-commerce order and came to a "Thank you for your order" screen. If he hit the back button, the "onenterbackward" event would tell the app that the user is returning to the card and not to process the order again. This would save the user from being billed multiple times for the same order.

Images
Images in WML are presented in similar way to they are in HTML. WML has the familiar <img> tag, but with slight variations. Other than syntax, a big difference is that images are in a 1-bit form. PhotoShop has a plugin for producing and converting color images into the new format (WBMP) and many free converters are also available. The book contains helpful methods to prevent high contrast when distilling images into WBMP format.

The book points out that ColdFusion coders won't have to write repeated code for multiple cards in a program as WML supports writing Templates with a <template> </template> tag. A single template tag in a WML script will apply to all the cards in the deck and a <noop /> command will exclude cards from the template.

Security
Security is always an issue and the book does a good job in covering all the basics. Included are explanations of common threats such as Trojan Horse and eavesdropper attacks.

The book describes Wireless Transport Layer Security (WTLS), similar to SSL in the HTML world, which guarantees confidentiality by using public-key cryptography.

Client security certificates are currently missing from the current WML specification, but the book says they are promised to be coming soon. While WML lacks built-in session management, the book helpfully provides session management code that can be implemented in its stead.

The book discusses some very useful sample applications in great detail. These include a User Directory, Currency Converter, Scheduling, and E-Commerce applications, all with complete code. I found these to be very useful demonstrations of just how WML is used in building real applications. Also, as the Scheduling application is written for ColdFusion, it discloses many highly relevant ColdFusion techniques. Just as useful is the E-Commerce application written in Java Server Pages (JSP).

CD-ROM
The book comes with a CD-ROM that contains all the book's source code. The CD also has a Software Library with links to all the software mentioned in the book, such as ColdFusion and Dreamweaver.

I found the CD to be uncomprehensive as many of the resource links (including the software links) are to Web sites. Considering the storage capacity of the CD, I think a better job could have been done in assembling some electronic documentation and media related to WAP. But the links are a comprehensive set — as well as a way of avoiding outdated apps — and include links to various WAP device emulators, WAP servers, layout tools, ColdFusion Studio, and other editors.

If you already program, especially in HTML, CFML, XML or Java, you may find much of the book repetitious. What is said concisely at the start of the book is all too often again explained in greater detail — sometimes more than once — for the beginner. Consequently, from an experienced coder's point of view, the book is often cumbersome in its efforts to include all possible audiences.

I would like to see an Advanced WAP/WML book that communicates more directly with experienced coders already in the field doing Web programming. However, regardless of your previous experience, WAP Development with WML and WMLScript is a Boot Camp for WML programming and if you have the time to make the effort, it's a great read.

More Stories By Chris Cusack

Chris Cusack is a New Media Engineer at MapInfo Corp. where he is responsible for developing content management and new media applications.

Comments (0)

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.