Home > Articles > Networking > Wireless/High Speed/Optical

  • Print
  • + Share This
This chapter is from the book

This chapter is from the book

Creating the WML Deck

Every WAP application uses a required set of WML elements. Pay particular attention to the concepts within the rest of this chapter. The following elements are used to some degree with every WAP application you create.

Note

Besides simply reading the following examples, type these code examples on the text editor of your choice. Then, try running them from a device-emulator. Understanding and writing the WML elements will play an important part in learning WAP development.

Save your WML files in an easily retrievable directory, such as C:\My Documents.

The WML Element

Every WML deck must contain three things: the document prologue, an element that designates the WML deck, and at least one card. You've already looked at the document prologue previously in this chapter. Now let's focus on the elements that designate the WML deck, specifically the WML elements.

The WML element is a simple, but powerful element. The WML element consists of no attributes, always follows directly after the document prologue, and is always the last tag element of a WML file. The following is a quick example of the WML element in action. Pay particular attention to the areas of code in boldface.

This example creates a WML deck with one card. Save this file as deck.wml. Figure 3.3 shows this code on a device screen:

1 <?xml version="1.0"?>
2 <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
3 "http://www.wapforum.org/DTD/wml_1.1.xml">
4 <wml>
5  <card id="card1">
6   <p>This is the only card within this WML deck.</p>
7  </card>
8 </wml>
Figure 3.3 The deck.wml file on a device screen.

Note

When you click the Accept button (this button has the Back label above it), you are returned to the default main menu of the device-emulator. This main menu displays as your default page until you add navigational functionality to your applications (you'll do this in the Chapter 5).

The following is an explanation of this example:

  • The first line specifies the XML version number.

  • The second line specifies the public document identifier.

  • The third line specifies the location of the WML document type definition.

  • The fourth line uses the WML element to begin the WML deck. All WML decks must begin with a <wml> tag and end with a </wml> tag.

  • The fifth line uses the <card> tag to start a card.

  • The sixth line uses the P element to start a paragraph.

  • The seventh line uses the </card> tag to end the card.

  • The last line uses the </wml> tag to end the WML deck.

The CARD Element

All WML decks require at least one card. The CARD element is one of the most widely used WML elements in WAP development. Think of cards as the screens of an application, and you can see the importance of the CARD element.

Cards have a lot of functionality, much more than the WML element. Table 3.3 lists the attributes available for the CARD element. Although there are a lot of them, the main attributes to concern yourself with are id and title.

Table 3.3 The Attributes of the CARD Element

Attribute

Required

Description

id

No

Specifies a name for the card. For easier programming, avoid using an id longer than eight characters.

newcontext

No

A true or false (Boolean) value that specifies whether the device should initialize the context whenever the card is loaded. The default value is false.

onenterbackward

No

Specifies the URL to open if the user navigates to this card through a PREV task (discussed in Chapter 5).

onenterforward

No

Specifies the URL to open if the user navigates to this card through a GO task (discussed in Chapter 5).

ontimer

No

Specifies the URL to open if a specified TIMER element expires.

ordered

No

A true or false (Boolean) value that specifies the organization of the card content. The default is true.

title

No

Specifies a brief text label for the card.


The id attribute provides the card with an identifier. Identifiers are something of major importance, especially in navigating from one card to another. The id attribute also allows cards to access other cards in other, external decks.

The title attribute is the name of the card presented to the user. This attribute can also provide more advanced functionality such as creating pop-ups or bookmarks. Not all WAP devices use a browser that present title attributes.

Note

Don't worry if a WML element you're using isn't supported by all WML browsers. If a device does not support a WML element, the device browser ignores the element.

Most device manufacturers supply documentation regarding the WML elements their products do and do not support. For the most part, most WAP devices support all elements discussed in this book.

The syntax for using attributes is to start the element, and then set the attributes equal to a value. All this information is then set within brackets.

For example, in the case of the CARD element that uses the id and title attributes, the syntax would be something similar to this:

<card id="card1" title="Card 1">

When incorporating more than one card into a WML deck, you must include a unique id attribute for each card. The following example displays a WML deck with multiple cards and creates an application that allows users to navigate between the two cards within a deck. Save this file as card.wml. Figure 3.4 displays the card.wml file on a device screen.

Figure 3.4 The card.wml file on a device screen.

1 <?xml version="1.0"?>
2 <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
3 "http://www.wapforum.org/DTD/wml_1.1.xml">
4 <wml>

5 <!-- This is card 1 -->
6  <card id="card1" title="Card 1">
7   <do type="accept" label="Next">
8   <go href="#card2"/>
9   </do>
10    <p>This is card 1</p>
11  </card>

12 <!-- This is card 2 -->
13  <card id="card2" title="Card 2">
14   <do type="accept" label="Back">
15   <go href="#card1"/>
16   </do>
17    <p>This is card 2</p>
18  </card>
19 </wml>

Note

This example uses the DO element, which is discussed in more detail in Chapter 5 when you look at creating navigation within your applications.

The overall functionality created in this application is that by clicking the Accept button, the application navigates to one of the two cards in this deck.

The following is a line-by-line explanation of this example:

  • The sixth line uses the <card> tag to start a card. In addition, the id and title attributes are used.

  • The id attribute sets the reference name of the card to card1. This name is useful as your applications become more advanced and you begin to incorporate navigational functionality.

  • The title of the card is Card 1. If the WAP device you're using supports the title attribute of the CARD element, the text Card 1 displays when accessed. Otherwise, if the device does not support this attribute, the title does not display. This isn't a big deal, but you should be aware of such factors.

  • The seventh line uses the DO element to assign functionality to a user interface on the device. This line of code specifies that the device's Accept button be used for some sort of functionality. The label that displays above this Accept button is Next.

  • The eighth line uses the GO element (which is one of WML's task elements). This line of code assigns a link to the user interface defined in the previous line of code. In this example, whenever the Accept button is clicked, users are taken to the card2 card.

  • The ninth line uses the </do> tag to end the DO element.

  • The tenth line uses the <p> tag to start a paragraph.

  • The eleventh line uses the </card> tag to end the card.

  • Lines 13–18 contain functionality similar to that found in lines 6–11. The only difference is that these lines create a second card named card2. This card also uses a DO element. In this second card, the DO element specifies the Accept button to return users to card1 when clicked.

The HEAD Element

Before concluding this chapter, we should discuss the HEAD element. The HEAD element provides the capability to specify information about the WML deck as a whole. Although you won't use this element within the applications in this book, the HEAD element is useful, especially for creating security within your WAP applications.

The HEAD element does not contain any attributes. Rather, it must contain one of these two elements:

  • ACCESS

  • META

The following sections examine these two elements and the functionality they provide within a deck-level header.

The ACCESS Element

The ACCESS element provides the functionality that restricts unauthorized users from accessing content-sensitive information. You won't use the ACCESS element in the examples in this book, though.

The ACCESS element contains two attributes, summarized in Table 3.4.

Table 3.4 The ACCESS Element Attributes

Attribute

Required

Description

domain

Yes

The URL domain of other WML decks that can access the cards within the current deck. The default value is the domain of the current deck.

path

Yes

The URL root of other WML decks that can access the cards in the current WML deck.


The META Element

The META element provides information to the browser about meta- information. Meta-information tells a device to treat the data in a specific way.

Not all WAP devices support every meta-information type. The device browser ignores any meta-information it does not support. Refer to the device manufacturer's documentation if you have questions about whether a particular type of meta-information is supported by a WAP device. Table 3.5 lists the attributes included with the META element.

Table 3.5 The META Element Attributes

Attribute

Required

Description

content

Yes

Specifies the metadata value to assign to the property.

forua

Yes

A true or false value that specifies whether the content is intended for the device's browser (rather than, say, a proxy server or some other program).

name

Yes*

The property name that represents the meta-information.

property

Yes*

Used in place of the name attribute to specify information the browser should interpret as an HTTP header.

schema

No

Form or structure used to interpret the property value.


* Define either the name or the property attribute when using the META element.

In the world of WAP development, a common example of meta-information is the cache duration of a WAP device. Cache refers to previously downloaded material.

Caching is a WAP device's attempt at remembering the history of the data accessed. You can set a time limit within the META element that specifies how long the device will save cached cards.

Let's look at a quick example of how you could use the META element to change the memory cache.

The default cache for most devices is 30 days, or until the memory has exhausted. A developer does not need to define the cache, unless you want to lengthen, shorten, or disable the cache.

Note

For the most part, you should use a device's cache. Doing so improves the performance of a WAP application. Cache memory also enables cards to reload quickly because they're already stored within the device. Cards load more quickly from the cache than they do if accessed from a remote server.

However, some WAP developers like to disable the cache when working with cards that use user-inputted information. Disabling the cache ensures that the correct information is always used with a card.

The following example disables the memory cache. Save this file as head.wml. Figure 3.5 shows this example on a device screen:

1 <?xml version="1.0"?>
2 <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
3 "http://www.wapforum.org/DTD/wml_1.1.xml">
4 <wml>
5  <head>
6  <meta http-equiv="Cache-Control" content="max-age=0" forua="true"/>
7  </head>
8  <card>

9    <p>The memory cache has now been disabled.</p>
10  </card>
11 </wml>

Figure 3.5 The head.wml file on a device screen.

The following is a line-by-line explanation of this example:

  • The fifth line is the start tag of the HEAD element.

  • The sixth and seventh lines instruct the device to drop the deck from the cache immediately by setting the max-age to 0. To length or shorten the time interval of the cache, the time interval must be written in seconds. For example, to set the cache equal to one hour, set the max-age equal to 3600 (the number of seconds in an hour).

Note

The META element is a little peculiar in that it does not require an ending tag. Instead, the META tag uses the following structure:

<meta/>

You won't use the HEAD and META elements very much throughout this book. However, they are important elements, especially when developing wireless applications where security and access are necessary.

  • + Share This
  • 🔖 Save To Your Account

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020