|
Last
revision of this document: |
This document gives an overview of the different classes belonging to a Business-Object.
Using
Business Objects to handle data-storage and retrieval is a
general introduction of the general architecture for persistent data
(in simpler words: writing to / reading from database-tables).
It
gives an overview how the different classes cooperate.
If you were lead to this document following a To-Do-List for to code a Business Object and the therefore requiered Data-Base-Access, you should have already worked through the document Business Object, General Class (in particular through the To-Do-List of it).
Mission
of the Client-Side-Class:The
Client-Side Class of the Business Object, designed to fulfill the
tasks of business entity within the client-side of an application,
comprehends
* methods to transfer the values from GUI-elements
into the variables of the Business Object,
* methods to transfer
the values of the variables of the Business Object to the variables
to GUI-elements and
* methods to create the Server-Side derivation
of the Business Object and
call the methods of
this class that furthermore perform operations on the database.
To-Do-List
to implement the class:Please
obey, that all Client-Side Classes for Business Objects are put into
a package (suggestion: application.boc) that is different for
those for General Classes (suggestion: application.bo) and
Server-Side Classes (suggestion:
application.bos).
This is done to
simplify the packaging-script when the application is versioned to
run as Client/Server.
The Client-Side class is only needed on the
Client Application (and packed into the JAR-file for it)
The
General Classes are needed on both the Client-Application as on the
EJB (Enterprise Java Bean) that is running under a JAS (Java
Application Server) and are packed into the JAR-file for the
Client-Side as well as into the JAR-file for the EJB.
The
Server-Side Classes are only needed within the EJB and are packed
only into the JAR-file for it.
A
fast way to get the code is to copy from an existing class and modify
it.
A class with working code (from the tutorial Develop
a Fat-Client in Java) is JS_ErrDB_Project_BOC.
Steps
to code the class:
Create a plain java-class under the package 'application.boc'.
Inherit
from the General Class of the Business Object (in this example:
JS_ErrDB_Project_BO)
.
Example:
public
class JS_ErrDB_Project_BOC extends
JS_ErrDB_Project_BO {
Define
the variable that holds the reference to the frame that constructed
this class .
Example:/*
*
Task-Frame that constructed this Client-Side BO.
* There,
the handles are defined to access the database (if
Stand-Alone-Version)
* or the JAS (if
Client-Server-Version). */ JSBS_TaskFrame
frmTask
=
null;
Code
the 'Constructor' of the class including the storing of the
frame that is passed as parameter in the variable of the
class.:
Example:/*
*
CONSTRUCTOR
* --------------------
* Takes
the task that constructed this class as a parameter and stores
it
* in the above defined variable. */ public
JS_ErrDB_Project_BOC(JSBS_TaskFrame
parmfrmTask) {
frmTask
= parmfrmTask;
}
Code
the method to transfer the values from the GUI-elements to the
variables of the Business Object.
An example would be too
long to be put into this document; to see one, please
follow this link.
The
next implementation steps (for this class) need the Server-Side class
to be implemented to a degree that allows to 'store' the values to
the relevant database-tables.
If you want to do some 'testing'
using the debugger, it is advisable to programm the code that is
triggered by the decisive event to transfer the values from the
GUI-elements to the variables of the Business Object.
If you want
to continue with the task to store and retrieve data, start coding
the DBA
Object and then the Server-Side
class of the Business Object.
Code
the methods to
'store' the values of the object.
An
example would be too long to be put into this document; to see one,
please
follow this link.
Code
the method to transfer the values from the variables of the Business
Object to
the
GUI-elements.
An
example would be too long to be put into this document; to see one,
please
follow this link.
Code
the methods to
'get' the values of the object according to the
defined search-criterias.
An example would be too long
to be put into this document; to see one, please
follow this link.
All
'getBy....' methods that may deliver more than the data of one
database-record are coded in an own class.
To see an example
of such a class, please follow this link.
Related
Documents:A
simplified overview how data is written to / read from a
database:
Using
Business Objects to handle data-storage and retrieval.