|
|
|
Terms used and their definitions |
|
One
must understand the terms: Presentation-template or
(or online GUI-API class or GUI-Component Code Generator
or “CCG”), CF (or Component Factory) and
‘Application Component’ to understand the
CBSF’ and other documents. The objective of this
document is to briefly define the terms with simple
examples. Please notice the subtle differences between
these terms.
|
|
Online-GUI-API
or Presentation-templates: A library of Java
Classes for various presentation-components (Ex: charts,
and menus etc.) and presentation-concepts (Ex: rotate-components
and shopping-cart etc.). For example, online-GUI-API
class for pie chart is a Java-class, which could generate
SVG/Jscript code to present a pie chart. To use a GUI-class,
the developers may just instantiate the CCG Class-object
and supply the rum-time data, using class-methods, to
the object. Now, the Java-Object could generate the
browser specific code (Ex: SVG, XHTML, DOM and Jscript
etc.) to present the application-component, using the
data supplied to it at run-time.
|
|
|
For
Example, the following sample code demonstrates a method
to use the online-GUI-Class for the pie-chart component
to generate SVG-code to present the pie chart: |
|
|
//
The Data variables; which could be initialized
at run-time.
// (i.e. this data may be calculated at run-time,
from the user data obtained from databases)
Double
val[] = { 10000, 12000, 14000, 16000, 18000};
String names[]
= {“Sun”, “Microsoft”,
“IBM”, “Intel”, “Oracle”};
//Example
For Presentation Template::
ATPie is a Java Class that contains presentation
logic to
//present the pie-chart. Sample code below,
illustrates how to use the GUI-class for pie
chart.
ATPie Pie1
= new ATPie(“ Portfolio at the end of
2dn Quarter”); //
Set Title.
Pie1.setData(5,
val, names); // Use
Pie-class method to set Data.
Pie1.buildWC(
ati, out);
// This method writes
SVG-code for the AC to the ‘out’
stream. |
|
|
Where:
‘ati’ is an Object; which may contain information
about the requesting User (Ex: preferences, privileges
or authentication etc.) and Browser (type and version
etc.). The ‘ati’ is a simple and very useful
object. This Object will be passed to all sub-components
(or sub-CF); hence the information in it is available
to all the ‘component code generators’ (Ex:
CF and online GUI-Objects etc.). Please refer to Agile-Templates
documentation, If you wish to learn more about the default-contents,
functionality, how to retrieve and save information
in the Object etc. |
|
‘Component
Factory (CF)’ & ‘Application Component
(AC)’: The CF is
a ‘Java-Class’ build by application developers
using simple CBSDF framework. For Example, the following
‘PortifolioCF’ Java-Class code is a simple
example of a CF, which creates pie chart of requesting-user
portfolio: |
|
Pseudo-code
listing#2 |
public class PortfolioCF extends AgileTemplates {
// The Data variables;
which could be initialized at run-time.
Float
val[];
String
names[];
int
count = 0, account_number = 0;
void
buildWC (ATInfo ati, PrintWriter out) {
InitPortifolioData(ati);
// This function
initializes val[] & names[]
//Sample
code; which illustrates how to use Agile-Templates
for Pie-chart.
ATPie
Pie1 = New ATPie(“ Portfolio at the end
of 2nd Quarter”);
Pie1.setData(count,
val, names);
// Use Pie-class
method to set Data.
Pie1.buildWC(
ati, out);
// This may
write SVG-code to the ‘out’
stream.
}
//
Constructor that initializes the user account
jumber
PortfolioCF
(int number) { account_number = number;}
void
InitPortifolioData(ATInfo ati) {
//
Write code to access data for the user using
the “account_number”
//
and init the following Class-variables:
//
vals[] is
an array of net-value of each company in his
portifolio.
// names[]
is an array of company names in his portifolio.
// Note:
The ATInfo contatins references to session-object,
//
user-preferences, identity and database-connection
etc.
//
The “ati” may contain user preferences
& DB-Connection objects etc.
}
}
|
//
The CF encapsulates and hides both application-logic
and presentation-logic,
// and usually needs no more than one line
initialization. For example:
PortfolioCF
user_portifolio = New PortfolioCF (user_account_number);
// Create &
init
user_portifolio.buildWC(Ati,
out); //
Generate code for the AC
|
|
|
Notice,
the minimum requirements for the Java-Class for ‘Component
Factory’ (or CF) are: extend the ‘Agile-Templates-class’
and implement the abstract Class-method ‘buildWC(ATInfo
ati, PrintWriter out)’. The CF reads required
data from data-sources and may access user identity/preferences
from session-object. It generates the code (Ex: SVG,
XHTML, DOM and Jscript etc.) to present the ‘application-component’.
This ‘code’ that renders the component in
the viewer/browser. The CF generates code for the ‘application-component’
|
|
The
design objective of the CF is to be highly cohesive
Java-class, and able to create custom ‘Application
Component’ at run-time as per each requesting
client’s identity and/or preferences etc. The
application developers may partition each web page (or
application) into multiple ACs and design and develop
CFs to generate code for the ACs. We will show later
that the ACs created this way: offer excellent plug-and-play
flexibility, and could be independently refined to easily
accommodate evolving functional needs of the users.
The CFs could be used with out any custom integration
code, as assembling parts, to generate larger components/CFs
or web pages.
|
|
Code
for the Application Component: is a block of
code to present a component in the web page. Usually
the CF generates the code for the AC. However, also
all the online-GUI-classes could generate the code for
the application components, if the developer instantiates
an object and properly initializes (.e.g. please see
the code listing#1). The code for the AC contains instruction
of various presentation markup languages (XHTML, SVG
X3D, SMIL, CSS and DOM etc.), script-functions (Ex:
Jscript, VBscript etc.) and variable-declarations to
present the component.
|
|
It
is critical to understand the basic differences between
the characteristics of these two components: CF and
AC. The CF is a Java class runs on the web-server, which
generates code-block for the AC. The code block is component-presentation
code (Ex: XML, SVG, DOM and Jscript etc.) runs in the
browser/viewer; which contains SVG-elements to displays
the component and contains DOM/Jscript methods to handle
user interactions and animation etc.
|
|
For
example, if the above pie-chart (Figure#1) is presented
on the web page using SVG. The code-block for the AC
is nothing but the SVG/DOM/Jscript code created by the
PortfolioCF Java-class. This code contains SVG-instructions
to render the PIE-chart and DOM/Jscript functions to
provide interactive feature like pop-up tool-tips etc.
The ‘code-block’ for the AC is generated
by ‘online-GUI-class’ for the pie chart,
such that, it encapsulates presentation, animation and
interactivity of the component in single contiguous
block of code.
|
|
An
examples for Component Factory: Example#1
and Example#2
|
|
Summary: |
|
Application
Component: An SVG/DOM/Jscript code that runs
at client in a viewer/browser and presents a component
(Ex: charts, maps, GUI-components like menus, selection-lists
etc.). The code for the AC is generated at server and
embedded in to an SVG-document. It contains SVG elements
to display the component and DOM/Jscript code to handle
user interaction etc.
|
|
Online-GUI-class:
A reusable Java class that can be used by the application
developers to generate code for an AC. Ex: Java classes
for Pie chart, drop-down selection list etc. The application
developer must provide all the data for the class-object,
before the Object could generate the AC. He may use
the Templates to develop CF or Servlet,/JSP-file. The
GUI-class only encapsulates
(or hides) presentation-logic and relies on the
developer to supply all the data.
|
|
Component factory (or CF): An independent component (a
Java class) developed by the application developer;
and generates AC. The CF (a Java class) contains both
application-logic to gather the data and business-intelligence
to personalize the AC. The AC could be used as sub-components
to develop Servlets/JSP-files; or plugged-in to build
larger AC with little or no integration code. The CF
encapsulates (or hides) both application-logic and presentation-logic.
(You would learn in the future that, this ability to
encapsulate or hide both the manufacturing process from
the users of the AC, is the basis for the invention
of the Ideal component paradigm.)
|
|
|
|
|
|
|