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

  • Print
  • + Share This

Navigation

WML provides a number of ways to navigate within and between decks of cards. To understand navigation, it's important to examine two related key WML concepts—the "event" and the "task". Basically, events trigger tasks. Events may be user generated, such as a key press or the selection of an on-screen link; events may also be generated by the wireless device itself, such as when a countdown timer expires. A task represents the execution of a piece of code in response to an event. Tasks typically are used to control navigation either within a deck or when loading an entirely new deck.

Events and tasks lead us to the <do> element for navigation. The <do> element provides a way for the user to act upon the currently displayed card. The <do> element must be paired with a task element, such as <go>, in order to perform an action. The <go> task element is used for both inter-card navigation and for making server requests.

Inter-Card Navigation

Figure 5 shows how the <do> and <go> elements work together to provide inter-card navigation. Note the use of the # character to designate that the target (MainCategories) is a card within the current deck. This attribute can also be used to jump directly into a specified card in a new deck (e.g., http://gov.ns.ca/health/inspection.wml#SubCategories). Note, also, the use of comments as defined by XML (<!--comment text...-->).

<wml>
  <!--First card is splash screen--> 
  <card>
    <do type="accept" label="Categories">
      <go href="#MainCategories"/>
    </do>
    <p align="center">
    ...
    </p>
  </card>

  <!--Second card displays categories--> 
  <card id="MainCategories">
    <p mode="nowrap">
   ...
    </p>
  </card>
</wml>

Figure 5

Card Navigation

Inter-Deck Navigation

For navigation to a new deck, WML supports a do-go event handler that references a server URL. Figure 6 illustrates a modified version of the second card from the previous example. Here the href attribute of the go element refers to the URL of a CGI script that will presumably deliver the appropriate WML deck. It's possible to pass data to the specified URL using post fields or by adding parameters. Note the method attribute, which is used to specify whether the request should be made using a get (data will be included in the request) or a post (data will sent separately). The method attribute is not mandatory, and the default is get.

  <card id="MainCategories">
    <do type="accept" label="Details">
      <go method="post" href="http://gov.ns.ca/health/inspect.cgi"/>
    </do>
    <p mode="nowrap">
      ...
    </p>
  </card>

Figure 6

Deck Navigation

When there are a number of possible navigation choices from a single page, you can use a series of do-go event handlers, specifying 'type="options"' for each, as shown in Figure 7. When the user selects an option (e.g., Premises), control will pass to the URL referenced by the 'href' attribute (e.g., http://gov.ns.ca/health/inspect.cgi).

<!--Second card displays categories-->> 
  <card id="MainCategories">
    <do type="options" label="Staff">
      <go method="post" href="http://gov.ns.ca/health/inspect.cgi"/>
    </do>
    <do type="options" label="Food">
      <go method="post" href="http://gov.ns.ca/health/inspect.cgi"/>
    </do>
    <do type="options" label="Premises">
      <go method="post" href="http://gov.ns.ca/health/inspect.cgi"/>
    </do>
    <do type="options" label="Animals">
      <go method="post" href="http://gov.ns.ca/health/inspect.cgi"/>
    </do>
    <p mode="nowrap">
    ...
   </p>
  </card>

Figure 7

Do-Go Event Handlers Using options

How the user agent deals with this method of specifying navigation choices is vendor-dependent. The type attribute serves as a hint to the user agent for it to determine the best way to render the event handlers.

  • + Share This
  • 🔖 Save To Your Account

Related Resources

There are currently no related titles. Please check back later.