Football Demonstration Application
This application uses similar styles to Restaurant
in terms of tabbed pages, lookups etc, but it's worth looking at
the way page pre-population is handled.
Input
|
|
Main class diagram
|
|
|
|
Create match diagram
|
|
|
|
View league table diagram
|
|
Model
football.mdl Rational Rose file
Output
football.zip 99.8% generated.
See It Running
Application running
Description
The best example is for the Show Table
event (in the View Table diagram). Let me draw your attention to the code behind the
event, which calculates the league table dynamically, and stores it ready for the next
page to display it. This could have been handled as a call to a session method (and in
retrospect probably should have been). Nevertheless the techniques to manipulate the
data are quite interesting, as the database is not as solidly connected as it might seem.
The first thing to notice when tackling code for an event like this is that the next page,
the one we are preparing the data for has two connected dataviews. The primary
dataview is LeagueTableDV and this is related to ClubResultsDV. Dataviews have
value objects associated with them (called by the name of the dataview with a suffix
of Info). It is these value objects that are picked up by a page, and the values
displayed. The value objects of related dataviews, such as these, each have variables,
and associated getters and setters of a type of the other. The variable in
LeagueTableInfo is actually of type Collection as the relationship is to-many. This
allows many instances of ClubResultsInfo to be associated with one LeagueTableInfo
instance.
The first line ArrayList arrayList = (ArrayList) getCollectionSettings();
returns an ArrayList containing the value object associated with the selection of the
previous page. This is the maintenance value object for the league table record, which
points to the same entity as LeagueTableDV, and also has connectivity to the Game
entity, which stores the match results.
The line lvo = (new LeagueDataViewSessionRD()).populateValues(lvo);
adds associated data values, including those of the Games for that particular league.
After plenty of calculations for each club for which we have results, we have built of
a collection of ClubResultsDVInfo objects, these are then inserted in descending points
order into an ArrayList, which is in turn set as the Collection in the LeagueTableDVInfo
object. This is stored using the call to store(ltvo), one of a series of methods that lets
the application programmer manipulate data from and for pages.
|