Client-Side Presentation Logic
601
The Update button will make the call across to the servlet when clicked, and download any new sell-offs
that may be available. All sell-offs are displayed in the list box, when the All Deals radio button is
selected. Clicking any one of the other radio buttons will display a subset of the sell-offs for that region.
A sample web page that contains the applet can be found in the projavaxml\Chapter15\vacserv
directory of the distribution. It is called index.html:
<html>
<head>
</head>
<body>
<table width="600">
<tr><td>
<center><h1>Wrox Travel Center</h1></center>
</td></tr>
</table>
<applet archive="aelfred.jar"
code="VacationApplet.class"
width=600
height=400>
<param name="mincomm" value="0">
</applet>
</body>
</html>
Note that the Ælfred XML parser is downloaded via the archive attribute (for more information on
AElfred, see Chapter 2 this assumes that Ælfred is available in the web app). This XML parser library
has a very small footprint (23k), very quick to download even over analog modems.
AElfred is a freely available, lightweight SAX parser specifically built for Java applet
use. Originally created by Microstar, it is now maintained by OpenText. For more
information on the AElfred parser, and to obtain documentation, development kit and
samples, visit: http://www.opentext.com/services
/content_management_services/xml_sgml_solutions.html#aelfred_and_sax
The parameter called mincomm can be used to set filtering based on minimum acceptable commission
value for trips (in dollars). Here it is set to 0. As an example, the applet will only display trips with
commission greater than (or equal to) $300 if we set it to 300.
You can locate the source of VacationApplet.java in the \vacserc\ directory of the distribution.
We will follow it line by line below.
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
import java.util.Vector;
import java.net.URL;
import java.io.InputStream;
import java.io.StringWriter;