Client-Side Presentation Logic
599
<trip number="33" region="3">
<startdate>Jan 16</startdate>
<duration>1 week</duration>
<location>Calinda in Aruba</location>
<price commission="300">1299</price>
</trip>
<trip number="34" region="2">
<startdate>May 12</startdate>
<duration>1 week</duration>
<location>Westin Regina in Puerto Vallarta</location>
<price commission="300">1399</price>
</trip>
</selloff>
We can see here that a selloff element consists of multiple trip elements. Each trip has a number
and region attribute. The number is monotonically increasing as new sell-offs arrives, and is used by
the client to download only newer trips.
The region is used by the applet for filtering trips. We can also see that a trip has startdate,
duration, location, and price sub-elements. commission for a trip is an attribute of the price
sub-element.
Client-Side Classes
The main user interface is the VacationApplet class; this applet will handle user interactions. It
allows the user to query the headquarters for the latest sell-off update (fetching only new trip
information since the last update). It also presents the travel agency user with specialized filtering
capabilities. For example, it can be configured to show only those trips that offer commission of a
certain value or above, and it can also show trips by different regions via the user interface.
When the user clicks the Update button, the applet connects to the headquarters computer and makes a
call to the servlet via an HTTP GET request. The call sends the highest trip number that it has already
received, and the servlet returns a sell-offs XML dataset document consisting of all the new sell-offs that
have arrived since the last update.
The customized XML parser for the disconnected dataset that is transmitted from the servlet is called
DealsParser. This parser will parse the data and create a vector of TravelDeal objects that the
VacationApplet can use to populate its user interface elements.
To parse the XML dataset, it makes use of the Ælfred lightweight SAX2-compliant parser that is
obtainable from http://www.opentext.com/microstar.
TravelDeal encapsulates a single sell-off. It has a description field that is 'human friendly' and is
displayed by the VacationApplet in its listbox. It also contains easily accessible commission and
region fields used in the intelligent filtering.