Previous Next Contents Index


TemplateDataBasic class (deprecated)

TemplateDataBasic is deprecated and is provided for backward compatibility only. New Java applications should use the standard servlet-JSP programming model, where similar functionality is provided through interfaces such as java.sql.ResultSet and javax.sql.RowSet.

For information about replacing TemplateDataBasic functionality in existing applications, see the Migration Guide.

The TemplateDataBasic class represents a memory-based, hierarchical source of data used for HTML template processing. It implements the ITemplateData interface (deprecated), and provides methods for creating and managing this hierarchical data.

The most common sources of data used for template processing are result sets obtained from queries on supported relational database management systems. However, an AppLogic might need to obtain data from non-RDBMS sources. For example, an AppLogic might display a list of numbers generated from a formula, or it might display a list of processors available on the server machine and their CPU loads. To display such information, the AppLogic can create an instance of the TemplateDataBasic class, populate that instance with rows of hierarchical data, and then pass the TemplateDataBasic object to the Template Engine for processing by calling evalTemplate( ) or evalOutput( ) in the AppLogic class (deprecated).

Alternatively, to provide application-specific special processing and to hook into the template generation process, AppLogic can subclass the TemplateDataBasic class and override the member methods in the ITemplateData interface (deprecated).

An AppLogic can create a flat or hierarchical data structure.

The number of nesting levels is limited only by system resources. One parent row can contain many joined child instances, in which case the AppLogic calls the parent's groupAppend( ) more than once after calling the parent's rowAppend( ).

To create a template data source, use the GX.CreateTemplateDataBasic( ) method, as shown in the following example:

TemplateDataBasic data = GX.CreateTemplateDataBasic("data");
Package
com.kivasoft.applogic

Methods
Method
Description
groupAppend( )
Links the specified child group to the current parent group.
rowAppend( )
Appends a new row of data to the current template data object or group.
TemplateDataBasic( )
Creates an empty template data object with the specified name.

Implements
ITemplateData interface (deprecated)

Example 1
// Construct a flat result set

/* Create Data Object */
tdbSalesRev = new TemplateDataBasic("salesOffices");
/* Create records of data */
tdbSalesRev.rowAppend("office=New York;revenue=150M");
tdbSalesRev.rowAppend("office=Hong Kong;revenue=130M");
tdbSalesRev.rowAppend("office=Singapore;revenue=105M");
Example 2
// Construct a hierarchical result set with two child

// levels of data: Asia and Europe.

/* Create the hierarchical data object */
tdbContinents = new TemplateDataBasic("continents");

/* Create the Asia group */
tdbAsia = new TemplateDataBasic("countries");
/* Create child records for Asia group */
tdbAsia.rowAppend("country=China;currency=yuan");
tdbAsia.rowAppend("country=Japan;currency=yen");
tdbAsia.rowAppend("country=South Korea;currency=won");
tdbContinents.rowAppend("name=Asia");
/* Link child records to group */
tdbContinents.groupAppend(tdbAsia);

/* Create the Europe group in the same manner */
tdbEurope = new TemplateDataBasic("countries");
tdbEurope.rowAppend("country=France;currency=franc");
tdbEurope.rowAppend("country=Germany;currency=deutsche mark");
tdbEurope.rowAppend("country=Italy;currency=lire");
tdbContinents.rowAppend("name=Europe");
tdbContinents.groupAppend(tdbEurope);
Related Topics
evalTemplate( ) and evalOutput( ) in the AppLogic class (deprecated)

ITemplateData interface (deprecated)

groupAppend( )
Links the specified child group to the current parent group.

Syntax
public int groupAppend(
	TemplateDataBasic childName)

childName . Name of the child TemplateDataBasic object to link.

Usage
Use groupAppend( ) to define the hierarchical relationship from a parent row to child TemplateDataBasic objects.

Rules
Tip
Use groupAppend( ) for hierarchical data objects only.

Return Value
GXE.SUCCESS if the method succeeds.

Example
// Construct a hierarchical result set with two child

// levels of data: Asia and Europe.

/* Create the hierarchical data object */
tdbContinents = new TemplateDataBasic("continents");

/* Create the Asia group */
tdbAsia = new TemplateDataBasic("countries");
/* Create child records for Asia group */
tdbAsia.rowAppend("country=China;currency=yuan");
tdbAsia.rowAppend("country=Japan;currency=yen");
tdbAsia.rowAppend("country=South Korea;currency=won");
tdbContinents.rowAppend("name=Asia");
/* Link child records to group */
tdbContinents.groupAppend(tdbAsia);

/* Create the Europe group in the same manner */
tdbEurope = new TemplateDataBasic("countries");
tdbEurope.rowAppend("country=France;currency=franc");
tdbEurope.rowAppend("country=Germany;currency=deutsche mark");
tdbEurope.rowAppend("country=Italy;currency=lire");
tdbContinents.rowAppend("name=Europe");
tdbContinents.groupAppend(tdbEurope);
Related Topics
evalTemplate( ) and evalOutput( ) in the AppLogic class (deprecated)

ITemplateData interface (deprecated)

rowAppend( )
Appends a new row of data to the current template data object or group.

Syntax
public int rowAppend(
	String rowString)

rowString . String containing a series of column name and value pairs, separated by semi-colons, using the following format:

"column1=value1[;column2=value2[...]]"
The columns must be identical for each rowAppend( ) call within the same TemplateDataBasic object.

Usage
Use rowAppend( ) to populate the template data object with rows of data.

Rule
AppLogic must first create the template data object using TemplateDataBasic( ).

Tip
Add rows in the sequence in which you want the Template Engine to process them. The template data object is processed in physical order only. AppLogic can only append rows to the data object. It cannot subsequently insert, delete, or sort records in the template data object.

Return Value
GXE.SUCCESS if the method succeeds.

Example
// Construct a hierarchical result set with two child

// levels of data: Asia and Europe.

/* Create the hierarchical data object */
tdbContinents = new TemplateDataBasic("continents");

/* Create the Asia group */
tdbAsia = new TemplateDataBasic("countries");
/* Create child records for Asia group */
tdbAsia.rowAppend("country=China;currency=yuan");
tdbAsia.rowAppend("country=Japan;currency=yen");
tdbAsia.rowAppend("country=South Korea;currency=won");
tdbContinents.rowAppend("name=Asia");
/* Link child records to group */
tdbContinents.groupAppend(tdbAsia);

/* Create the Europe group in the same manner */
tdbEurope = new TemplateDataBasic("countries");
tdbEurope.rowAppend("country=France;currency=franc");
tdbEurope.rowAppend("country=Germany;currency=deutsche mark");
tdbEurope.rowAppend("country=Italy;currency=lire");
tdbContinents.rowAppend("name=Europe");
tdbContinents.groupAppend(tdbEurope);
Related Topics
evalTemplate( ) and evalOutput( ) in the AppLogic class (deprecated)

ITemplateData interface (deprecated)

TemplateDataBasic( )
Creates an empty template data object with the specified name.

Syntax
public TemplateDataBasic(
	String dataObjectName)

dataObjectName . Name of the parent or child data object referred to in the template.

Usage
Use new TemplateDataBasic( ) to create parent and child data objects.

Rule
The specified data object name must be unique within this template data object.

Tips
Return Value
An empty TemplateDataBasic object, or null for failure.

Example
// Construct a hierarchical result set with two child

// levels of data: Asia and Europe.

/* Create the hierarchical data object */
tdbContinents = new TemplateDataBasic("continents");

/* Create the Asia group */
tdbAsia = new TemplateDataBasic("countries");
/* Create child records for Asia group */
tdbAsia.rowAppend("country=China;currency=yuan");
tdbAsia.rowAppend("country=Japan;currency=yen");
tdbAsia.rowAppend("country=South Korea;currency=won");
tdbContinents.rowAppend("name=Asia");
/* Link child records to group */
tdbContinents.groupAppend(tdbAsia);

/* Create the Europe group in the same manner */
tdbEurope = new TemplateDataBasic("countries");
tdbEurope.rowAppend("country=France;currency=franc");
tdbEurope.rowAppend("country=Germany;currency=deutsche mark");
tdbEurope.rowAppend("country=Italy;currency=lire");
tdbContinents.rowAppend("name=Europe");
tdbContinents.groupAppend(tdbEurope);
Related Topics
evalTemplate( ) and evalOutput( ) in the AppLogic class (deprecated)

ITemplateData interface (deprecated)

 

© Copyright 1999 Netscape Communications Corp.