Web Services
WebSphere Portal Mobile Access Portlets for WAP Devices
WebSphere Portal Mobile Access Portlets for WAP Devices
Jun. 27, 2002 12:00 AM
IBM's WebSphere Portal currently supports mobile devices by generating portal pages in three markup languages: HTML for desktop computers and some PDAs, WML for WAP devices, and cHTML for devices in the NTT DoCoMo i-mode network. This article focuses on portlet development for WAP devices, including a brief introduction to WAP and WML, and discusses various WAP emulators for portlet testing. The article's source code is not necessarily driven by best practices or performance considerations.
WAP and WML
WAP (Wireless Application Protocol) is a communication protocol designed for wireless devices just as HTTP is for desktop Web browsers. WML (Wireless Markup Language) is a markup language for wireless device microbrowsers as HTML is for browsers on desktop computers. WML content is read and interpreted by a microbrowser built into the WAP device. WML is similar to HTML, but less forgiving because it was designed using XML as a base.
Decks are WML documents and each deck consists of one or more cards. Decks begin with the <wml> and end with the </wml> tag, and cards begin with the <card> and end with the </card> tag. The WAP device's microbrowser reads the whole deck while accessing it in order to navigate its cards without having to load more data. Once a deck is loaded, the cards inside the deck remain in the WML microbrowser's memory until the browser is asked to reload the whole deck. Listing 1 (Listings for this article can be found at www.sys con.com/websphere/sourcec.cfm) will give you a taste of WML and WAP devices; Figure 1 shows the output on a RIM BlackBerry device.
Mobile Access Portlets for WAP Devices
Now that you have an understanding of WAP and WML, we're ready to develop the following portlets:
- Personal bookmark-setting
- WAP URL surfing
- XML and XSLT
- User-agent displaying
Personal Bookmark-Setting Portlet
The personal bookmark-setting portlet can configure an unlimited number of bookmarks to be inserted and deleted, for example, to the portlet deployment descriptor (portlet.xml) file. To develop the portlet, you need to understand the WML <anchor> tag. A WML card can be set up to display WML's anchor functions. The <anchor> tag always has a specified task ("go," "prev," or "refresh") that defines what should be done when the user selects the link. In the example shown in Listing 2, when the user selects the "Die Bahn" link, the task goes to
http://wap.bahn.de.
Note that I'm using the Bookmark-Portlet_04.java example described in the Portlet Development Guide, Introduction to the Portlet API (see the references section). The portlet deployment descriptor is shown in Listing 3 - I've slightly modified the program for WAP device support application; the modified portion appears in bold type. Listing 4 shows the source portlet WAPBookmarkPort-let_04.java. The output is shown in Figure 2.
WAP Site Surfing on the Internet
The WAP URL surfing portlet provides unrestricted WAP site surfing. The user enters any URL of a WAP site. Once the portlet accesses the first page of an external WAP site, consequent links will work as long as the subsequent WML pages are well formed. You can arrange the predefined site with the bookmark-setting portlet. In addition to the following code, see Listings 5 and 6.
<jsp:useBean id="url"
class="java.lang.String" scope="request"/>
<p>
<anchor><go
href="http://<%=url%>"/>
http://<%=url%></anchor>
<br/>
</p>
The output is shown in Figure 3.
XML Access URL Portlet
The XML access URL portlet can access an external site that produces XML content. Using stylesheets, the same XML content can be displayed in a variety of formats applicable for different browsers and devices. This way, a single content source can be used to create content in different formats, such as WML, cHTML, and HTML (see Listings 7 and 8). In this case, you don't have to keep multiple content sources based on different markup languages. In this example the XML content will be applied by an XSLT stylesheet and converted to WML. Note that although I use the FlightInfo.xml and FlightInfoFor-WML.xsl files (see Listings 9 and 10) as provided by the WebSphere Transcoding Publisher, I developed the other necessary source code using XML and XSL stylesheets. The portlet will use the following XML and XSLT sources:
XML URL:
http://home.nc.rr.com/sungik/flightinfo.xml
XSLT URL : Inside the portlet
The output displayed by the different devices is shown in Figure 4.
Portlet Displaying User-Agent Values
A client device with a specific browser sends the user-agent value to the Web server when requesting a Web page. Since WAP devices vary in capability and features such as image support, deck size, and color support, the Web server can use the user-agent value to decipher the specific browser and device making a request, then adjust the content accordingly. Please refer to www.thewirelessfaq.com/useragents.asp for the user-agent values of different devices. The portlet shown in Listing 11 will display the user-agent value to your specific device. Figure 5 shows the output displayed by Nokia and Openwave devices.
Mobile Access Portlets by PDA
To access the WAP portal site using Palm devices, use the Blazer Palm browser, which supports multiple Internet standard protocols including HTML, cHTML, and WML. The AnywhereYouGo.com WAP browser by 4thPass is also good for viewing WAP-enabled sites from any mobile device running the Palm OS. To access the WAP portal site using PocketPC or Win CE devices, use the Klondike WAP Browser. Please refer to the reference section for information on downloading these browsers.
WAP device emulators are software programs that simulate WAP devices on your desktop computer (see Figure 6). The following work well with the IBM WebSphere Portal portlets developed for WAP devices:
Nokia Tool: http://forum.nokia.com/main.html. Select Programs -> Nokia Mobile Internet Toolkit -> Mobile Internet Toolkit.
OpenWave SDK WAP Edition 5.0, 22.5 MEG: http://developer.openwave.com.
Klondike WAP Browser:
www.apachesoftware.com/download_kwpe.html.
Yahoo Germany: http://de.mobile.yahoo.com.
Conclusion
WAP's popularity arises from the fact that it's been adopted and supported by major computing and communications industry players. IBM WebSphere Portal provides developers with the environment to develop WAP applications and build portal Web sites for wireless use. You can develop simple portlets to handle WAP devices and test their outcomes by using various WAP device emulators.
References
IBM products referenced here:
WebSphere Portal:
www-3.ibm.com/software/webservers/portal.
WebSphere Transcoding Publisher:
www.ibm.com/software/webservers/transcoding.
SIDEBAR
FOR MORE INFORMATION
"Portlet Development Guide, Introduction to the Portlet API":
www-3.ibm.com/software/webservers/portal/doc/
PortletDevelopmentGuide.doc.
Nokia WAP Toolkit:
www.nokia.com/corporate/wap/sdk.html.
Palm OS 3.1 Emulator:
www.palmos.com/dev/tools/emulator.
Openwave SDK WAP Edition:
(http://updev.phone.com)
Klondike WAP Browser:
www.apachesoftware.com/download.html.
Blazer Palm Browser:
www.handspring.com/software/blazer_overview.jhtml.
The AnywhereYou Go.com WAP browser, powered by 4thPass:
www.anywhereyougo.com/images/palm35.zip.
Yahoo Germany:
http://de.mobile.yahoo.com.
"WebSphere Solutions for XML, XSL Stylesheet, and Transcoding for Web Application Data Accessible by Various Devices":
www7b.boulder.ibm.com/wsdd/techjournal/0111_son/son.html.
About Sung Ik SonSung-Ik Son is a Senior Software Engineer in the Application and Integration Middleware division of the IBM Raleigh Lab. He has been a key developer for more than 12 years in IBM's system and application software development organizations, and has worked for the past three years on the WebSphere Enablement and Consulting team. He holds a B.S. in Computer Science from the University of New Brunswick in Canada and an M.S. in Computer Science from Purdue University. Sung-Ik is a co-author of the IBM Redbook, WebSphere V3.5 Handbook (SG24-6161-00).