> List of tutorials for developing a Fat-Client in Java


Re-display the list with the Project/Language combinations - Fat-Client-Development

* For this document and all references (links) please obey the hints and regulations concerning copyright, disclaimer and trademarks.

  • The owner of this web-site (www.javascout.biz) is not responsible for the content of web-sites linked within this document or linked within other documents of www.javascout.biz.

  • If this document or other documents of this web-site (www.javascout.biz) infringes your rights or you think that rights of others (third parties) are infringed, please inform the author.
    An e-mail can be sent by clicking onto the 'hungry mailbox' in the upper right corner.

Last revision of this document:
2007-01-15

Till now, the application was only able to store data into the database.
To see, what data is already gathered, this step implements functionality to display all existing Project/Language combinations in a 'table'.
The definition 'table' refers to a list with several columns and a header.

Overview:

This document covers the following steps:
Create a method (redisplayProject()) within the 'ActionHandler',
Create the class for DataBaseAccess to get a list of all valid Projects,
Create all derivations of the classes for the Business Object holding the list of valid Projects,
Define a variable for the just created BOC with the set of 'Project's,
Retrieve the list of valid Projects in the method redisplayProject(),
Create a method to fill a JTable with the data from the vector and call this method,
Extend the XML-structure for language dependant text-elements to hold text for table-headers,
Run and verify the result
.

Preface:

* First, a set of classes for a Business Object, that is able to read a set of data, is developed – and the suitable DBA object too.
* Then, the data retrieved from the Business Object is parsed into a Vector for a later display in the 'table'.
Those two subtasks follow the scheme of the Tasks
JS_FC01k – Develop the General Class for the Business Object 'Project',
JS_FC01l – Develop the Client-Side Class for the Business Object 'Project',
JS_FC01m – Data-Base-Access (DBA) Object for the table'Project' and

JS_FC01o – Develop the Server-Side Class for the Business Object 'Project'.

From then on, the code gets more sophisticated.
The historic reason is, that I had the classes alredy developed before I started to write this tutorial.
I had a lot of discussion with friends if I should write more simplified classes for the tutorial.

Finally, I decided to keep the already written classes.
I think, this solution is closer to 'real life': there you also have to use libraries with classes you might not know in detail ;-) .

To fill a JTable with a headline and data – both provided in the structure of a 'Vector', a method is developed in the base class JSBS_XML_DisplayStrings.
The language-dependant text for the header of the table is read from a file with XML-structure; please refer to XML-Structure for language dependant text-elements for the user-interface for a detailed description.

Credits:

Too numerous to mention; the idea is available in dozens of versions – I refined a lot of ideas into my system.

Prerequisites:

Create a method (redisplayProject()) within the ActionHandler:

As the class JS_ErrDB_Project__ActionHandler holds per definition all the methods that carry out actions, a method called redisplayProject()is added to this class.

top.

Create the class for DataBaseAccess to get a list of all valid Projects

First of all, a base-class is developed.
This class holds
* a vector which will later be filled with the data read from the database-table,
* some variables and
* methods
to be used by derived classes.
Please refer to class JSBS_DBA_Set for explanations of the code.

In detail, the class JS_ErrDB_Project_Set_DBA holds the code that reads the set of records from the database.
For an explanation of the code, please refer to the comments.

top.

Create all derivations of the classes for the Business Object holding the list of valid Projects

As like for the DBA object, a base-class for holding a 'set of Business Objects' is developed too.
This class holds
* a vector which will later be filled with the data read from the database-table,
* a vector which holds formatted data for later display,
* some variables and
* methods
to be used by derived classes.
Please refer to class JSBS_BO_Set for explanations of the code.

And now to the individual Business Object (BO) modelling a set of 'Project's.
As lined out in the document Using Business Objects to handle data-storage and retrieval, a Business Object is implemented using 3 classes.

The general steps to develop such a class-triangle for a BO where documented in detail for the BO 'Project', so it is not repeated here.
Please refer to the classes JS_ErrDB_Project_Set_BO, JS_ErrDB_Project_Set_BOS and JS_ErrDB_Project_Set_BOC for an explanation of the code.
Main Differences (compared to the classes to manipulate a single BO) are:
* In the general-class, the method to transfer the data from one object to another is slightly different.
There is a loop within each element of the vector is transferred with the method developed for a BO.
* In the server-side-derivation, a 'store()' method is not implemented as it would be to complicated and intransparent to update or store a whole set of BO.
* In the client-side-derivation, a method is introduced that generates a 'raw-data-vector'. This vector helds the data in the form of strings.
This is a preparation for a later display of the data in a JTable.

Please note that the class JS_ErrDB_Project_Set_BOC shows an error as the method to fill a JTable using the raw-data is not implemented yet – this implementation is documented two steps later.

top.

Define a variable for the just created BOC with the set of 'Projects':

That the class JS_ErrDB_Project_Set_BOC with the set of 'Projects' can be accessed, a variable has to be defined.
This is done in the class JS_ErrDB_Project :

top.

Retrieve the list of valid Projects in the method redisplayProject()

As this step has a pretty long todo-list until a result is visible, you might now use the debugger to verify if the implementation works till now.
Otherwise you may skip this paragraph and forward to Create a method to fill a JTable with the data from the vector and call this method.

To do so, the method redisplayProject() in JS_ErrDB_Project__ActionHandler is extended to use the JS_ErrDB_Project_Set_BO created in the paragraphs before.

You might start the debugger now and watch the result of the database-operation.
If you are not familiar with debugging, please refer to React to the 'Store' button and save the data in the database | Use the debugger to track down programming errors .

top.

Create a method to fill a JTable with the data from the vector and call this method:

For some theory about the the structure of the XML-file with language dependant text please refer to Structure of the XML-file with language-dependant text-elements for the user-interface.

Please refer to the method processJTable() of class JSBS_XML_DisplayStrings for an explanation of the code.

top.

Extend the XML-structure for language dependant text-elements to hold text for table headers:

The language-dependant text for the headers of the table is defined in the file DisplayStrings.xml too.
Additionally, this XML-structure defines the sort-order of the columns.
By omitting the xml-element for a column, this column is not displayed.

Run and verify the result:

The implemented code does not lead to any visible result till now.
A verification that can be done, is to check against absence of errors when constructing the ConnectionManager.

top.

Next Step: