Your web application is made up of a series of JavaServer Pages that will be generated into wireless-supported files at runtime. Here’s the outline of a standard Dynamo wireless JSP:
<%@ page contentType="text/vnd.wap.wml" %>
<%@ taglib uri="/dsp" prefix="dsp" %>
<dsp:page xml=true>
page body
</dsp:page>
Notice how this page consists of a page directive, a tag library import statement, and dsp:page
, a tag from the imported tag library. You can tell dsp:page
is part of the DSP tag library because it uses the established prefix “dsp
.”
Page Directive
The page directive is a standard JSP convention used to specify the file output type. The only necessary difference in a JSP that will be output as WML or any other wireless format, such as cHTML, is the value provided to the contentType
attribute of the page directive. However, it’s likely that if you wanted your page to output to cHTML, you would want to use specific cHTML tags in your page content.
You set the contentType
attribute to the recognized mime type for a page extension. Here are some common wireless extensions:
Kind of Code Used in Page | File Extension | Set contentType to: |
---|---|---|
JSP only |
|
|
cHTML and JSP |
|
|
WML only |
|
|
WML Compiled only |
|
|
WML Script only |
|
|
WML Script Compiled only |
|
|
wBitMap only |
|
|
DSP Tag Library
Each tag library referenced in a JSP must be imported at the top of the page. You can use the DSP tag library to code your pages to interact with temporary objects maintained in Dynamo. One of the key strengths in Dynamo is the Nucleus architecture, which consists of objects, called components, that store data for a period of time that you specify (request, session, global). Each component maintains a set of methods and properties. You can use the DSP tag library to represent component and their properties in a page and pass data to and from components.
The JSPs in your web application can incorporate the same dynamic components available to JSPs for HTML output, using the tags provided in the DSP tag library. Because this tag library was designed for both HTML and wireless output, some tags, such as dsp:input
, won’t apply to wireless pages. In such cases, a wireless-alternative, dsp:postfield
, is provided.
The tag you see in the previous code excerpt, dsp:page
surrounds the content body of the JSP. You’re required to use this tag as such whenever your pages include DSP tag library tags. The dsp:page
tag initiates the page rendering process by creating an instance of the DynamoHTTPServletRequest
. By setting the xml
attribute to true
, you cause the page compiler to generate the page’s tags in an XML rather than HTML format. You can skip the dsp:page
tag and the DSP tag library import statement if you’re not using the DSP tag library.
If you use the JSP templates in the Document Editor to create your JSPs, it will automatically insert the DSP tag library import directive and add opening and closing dsp:page
tags in the appropriate locations. For more information about the DSP tag library and the ATG Control Center Document Editor, see the ATG Page Developer's Guide.
Sample Wireless JSP
The following is a sample JSP that’s made up of three cards. The first card displays text (“Hello World”) and links to the other two cards, which hold the current time and current date respectively. Notice that the servlet bean and dsp:valueof
tags are identical to those available to the JSPs for HTML output.
<%@ page contentType="text/vnd.wap.wml" %> <%@ taglib uri="/dsp" prefix="dsp" %> <dsp:page> <dsp:importbean bean="/atg/dynamo/droplet/Switch"/> <dsp:importbean bean="/atg/dynamo/service/CurrentDate"/> <wml> <card id="top" title="Hello World"> <p>Hello World</p> <p><dsp:a href="#time">Current Time</dsp:a></p> <p><dsp:a href="#day">Current Day</dsp:a></p> </card> <card id="time" title="Current Time"> <p><dsp:valueof bean="CurrentDate.timeAsTimeStamp" date="HH:MM:SS"></dsp:valueof></p> </card> <card id="day" title="Current Day"> <p><dsp:valueof bean="CurrentDate.dayOfWeekName"></dsp:valueof></p> <p> <dsp:droplet name="Switch"> <dsp:param name="value" bean="CurrentDate.dayOfWeekName"/> <dsp:oparam name="Saturday"> <p>Must be the weekend.</p> </dsp:oparam> <dsp:oparam name="Sunday"> <p>Must be the weekend.</p> </dsp:oparam> </dsp:droplet> </p> </card> </wml>
Form Handling in Wireless Pages
Dynamo provides a handful of form handlers, which are components that assist in form processing. The input fields in a form are tied to properties in a form handler and when the form is submitted, those inputs are validated to ensure that they provide required data in an acceptable format.
When you create a form, you can use the DSP tag library dsp:go
and dsp:postfield
tags. The dsp:go
tag provides form-building capabilities in much the same way the go tag does with the added benefit that you can incorporate dynamic elements. For example, you might set the href
attribute by specifying the getREquestURI
attribute of the request object, which always points to the current page. For more information on dsp:go
, see the ATG Page Developer's Guide.
The dsp:postfield
tag offers a host dynamic capabilities. Not only can you specify the form handler (bean
) that will temporarily store the user input, you specify a default value that is itself a bean property value (beanvalue
) or page parameter value (paramvalue
). The dsp:postfield
tag offers other handy functions; see the ATG Page Developer's Guide.
<p>User Name:<dsp:input type="text" name="login" title="User Name" size="20" maxlength="20" bean="ProfileFormHandler.value.login"/></p> <p>Password:<dsp:input type="password" name="password" title="Password" size="35" maxlength="35" bean="ProfileFormHandler.value.password"/></p> <do type="accept" label="Login"> <dsp:go href="`request.getRequestURI()`" method="post"> <dsp:postfield bean="ProfileFormHandler.loginSuccessURL" value="index.jsp" /> <dsp:postfield bean="ProfileFormHandler.value.login" value="$login" /> <dsp:postfield bean="ProfileFormHandler.value.password" value="$password" /> <dsp:postfield bean="ProfileFormHandler.login" value=" " /> </dsp:go> </do>