Data Binding API

Data binding is the process of converting server-side database queries to client-side types. The Rich Client System uses RecordSet, a special class, that provides access to the data returned from the server and also can handle data paging.

Overview:

The following diagram illustrates the client/server exchange when the server returns an instance of java.sql.ResultSet or System.Data.DataSet. Numeric designations denote the step-by-step process and each step is described in detail following the diagram.

  1. The client program issues a method invocation request on a server-side object.

  2. The server object performs a database query and returns results as java.sql.ResultSet for Java or System.Data.DataSet or System.Data.DataTable for .NET.

  3. The WebORB Presentation Server processes the response. If paging is turned on for the current request (or globally), the response is placed into the client's session so additional paging requests can be processed.

  4. The initial page (in case of paging) or the entire response (when paging is off) is serialized to the client. When paging is turned on, the initial response contains up to PageSize rows as well as some additional information (total rows and page size).

  5. The Rich Client System deserializes server response and returns an instance of the RecordSet class to the client program.

Below is a list of functions available in the RecordSet class.

Summary:

 
getInitialPage
provides access to the initial data fetch. If the server is configured to return all data, this call returns the entire response. Otherwise, the response is split into pages. Additional pages can be accessed with the getRecords function.
 
getTotalRowCount
returns the total number of rows returned from the database query.

getInitialPageSize
returns the number of rows in the block of data accessible via the getInitialPage function.

getPageSize
returns the page size associated with the current data query. WebORB can be configured to apply the same page size for all queries or specific page size for individual queries.

getColumnNames
returns an array of column names or assigned labels for the current query.

getRecords
fetches additional rows from the server. The call parameters include the starting row number and the number of additional rows to fetch. The call can be executed synchronously or asynchronously.

cleanup
releases any server-side resources associated with the query. The call is recommended especially when server is configured to use data paging.

Functions:

 
recordSetInstance.getInitialPage();

where,

recordSetInstance
is a client-side return value from a server method returning java.sql.ResultSet for Java or System.Data.DataSet, System.Data.DataTable for .NET.

Returns:

An array of rows returned from the database query. The number of rows vary depending on the configuration of the WebORB server. WebORB's default configuration uses paging with the initial page size set to 10. If the default configuration remains unchanged and the server query returns more than 10 rows, getInitialPage will return first 10 rows.

Each row in the returned array is an array as well. Each cell in the row array represents data for a column. Both first row and first column have index 0.

Example:

var proxy = webORB.bind( "weborb.examples.Test", "http://localhost:8080/weborb" );
// invoke method synchronously
var result = proxy.runQuery();
var initialPage = result.getInitialPage();

// print out data from row 1, column 2
alert( initialPage[ 0 ][ 1 ] );

// print out data from row 3, column 1
alert( initialPage[ 2 ][ 0 ] );


 
recordSetInstance.getTotalRowCount();

where,

recordSetInstance
is a client-side return value from a server method returning java.sql.ResultSet for Java or System.Data.DataSet, System.Data.DataTable for .NET.

Returns:

Total number of rows produced by the query.

Example:

var proxy = webORB.bind( "weborb.examples.Test", "http://localhost:8080/weborb" );
// invoke method synchronously
var result = proxy.runQuery();
alert( "total rows available = "  + result.getTotalRowCount() );


 
recordSetInstance.getInitialPageSize();

where,

recordSetInstance
is a client-side return value from a server method returning java.sql.ResultSet for Java or System.Data.DataSet, System.Data.DataTable for .NET.

Returns:

The number of rows in the block of data returned by the getInitialPage function.

Example:

var proxy = webORB.bind( "weborb.examples.Test", "http://localhost:8080/weborb" );
// invoke method synchronously
var result = proxy.runQuery();
alert( "initial page size is = "  + result.getInitialPageSize() );


 
recordSetInstance.getPageSize();

where,

recordSetInstance
is a client-side return value from a server method returning java.sql.ResultSet for Java or System.Data.DataSet, System.Data.DataTable for .NET.

Returns:

The size of the pages the response is broken up to. The page size is configurable in the WebORB's configuration file and can be overridden using the server-side API.

Example:

var proxy = webORB.bind( "weborb.examples.Test", "http://localhost:8080/weborb" );
// invoke method synchronously
var result = proxy.runQuery();
alert( "page size is = "  + result.getPageSize() );


 
recordSetInstance.getColumnNames();

where,

recordSetInstance
is a client-side return value from a server method returning java.sql.ResultSet for Java or System.Data.DataSet, System.Data.DataTable for .NET.

Returns:

An array with column names used in the query. The names of the columns is ordered the same way as they are listed in the originating SELECT query. If a column was assigned a label in the SELECT query, the method will contain a label value.

Example:

var proxy = webORB.bind( "weborb.examples.Test", "http://localhost:8080/weborb" );
// invoke method synchronously
var result = proxy.runQuery();
// iterate over the column names
var columnNames = result.getColumnNames();

for( var i = 0; i < columnNames.length; i++ )
   alert( columnNames[ i ] );


 
recordSetInstance.getRecords( fromRow, rowsToGet[, async] );

where,

recordSetInstance
is a client-side return value from a server method returning java.sql.ResultSet for Java or System.Data.DataSet, System.Data.DataTable for .NET.

Description:

Fetches additional rows from the server. The call parameters include the starting row number and the number of additional rows to fetch. The call can be executed synchronously or asynchronously.

Arguments:

fromRow
the row number from which to start retrieval of subsequent rows. The first row has index 0. If fromRow is greater than the value returned by getTotalRowCount, an exception is thrown.
 
rowsToGet
the number requesting the number of rows to fetch.

async
Optional. When the async argument is present, the method is invoked asynchronously. The async object must be an instance of the Async class. The object encapsulates the function to be called when the response from the method invocation becomes available.

Returns:

A special object providing access to the data returned by query. The object has two fields: 1) Page and 2) Count. Page is an array of rows similar to the return value of the getInitalPage function. Count is the number of rows available in Page.

Example:

var proxy = webORB.bind( "weborb.examples.Test", "http://localhost:8080/weborb" );
// invoke method synchronously
var result = proxy.runQuery();

// get 20 rows starting from the next row after the initial data fetch
var nextPage = result.getRecords( result.getInitialPageSize(), 20 );

// access data in row 1, column 3
alert( nextPage.Page[ 0 ][ 2 ] );


 
recordSetInstance.cleanup( [async]);

where,

recordSetInstance
is a client-side return value from a server method returning java.sql.ResultSet for Java or System.Data.DataSet, System.Data.DataTable for .NET.

Description:

Releases any server-side resources associated with the query. Any paging requests sent after cleanup() is called will fail.

Arguments:

async
Optional. When the async argument is present, the method is invoked asynchronously. The async object must be an instance of the Async class. The object encapsulates the function to be called when the response from the method invocation becomes available

Returns:

N/A

Example:

var proxy = webORB.bind( "weborb.examples.Test", "http://localhost:8080/weborb" );
// invoke method synchronously
var result = proxy.runQuery();
// process query results
// .............
// .............
// run cleanup
result.cleanup();


API Availability:

Browsers:
Internet Explorer 6+
Firefox 1.0+
Opera 7+
Safari
 
Flash client:
The ActionScript version of the API will be available in a future release. Flash Remoting calls can be handled transparently by WebORB. Use Flash Remoting API to connect and invoke server-side objects hosted in WebORB.