[Top] [Prev] [Next] [Bottom] [Contents]

Data Site Callbacks

When a Sapphire/Web-generated server application finds a data site, the application looks for Population Callbacks registered for the site through an Object Bind Editor Binding. This section describes two specific types of data site callbacks not included in Object Binding.

String Replacement

The first of these data site callback types is basically string substitution, and allows your Server Application to insert simple pieces of text into an HTML template before it is transferred to the user. You register this with a call to the function

SaRegisterStringSite
Its function prototype is:

int SaRegisterStringSite(char* file, char* site, char* 
value); 
The first parameter, file, specifies the filepath name of an HTML template file. If non-null and not an empty string, this file will be "played", if it is not already on the "play" list.

If NULL or an empty string, the second parameter, site, will still be registered, but can be overridden by a similar site name with a specified filename.

The third parameter, value, is a string to substitute for the specified data site. The string is copied locally.

In this way your program can specify a string for inclusion in the HTML at run-time, but the content of the string can be decided upon just prior to the function call.

Function Processing

The second of these data site callback types is more general, although you must write a data site callback function. You register this with a call to the function, SaRegisterFuncSite(). Its function prototype is:

typedef void (*SaSiteCallback)(char* file, char* site, 
void* client); 
int SaRegisterFuncSite(char* file, char* site, 
SaSiteCallback func, void* client);
The first parameter, file, specifies the filepath name of an HTML template file. If non-null and not an empty string, this file will be "played", if it is not already on the "play" list.

If NULL or an empty string, the second parameter, site, will still be registered, but can be overridden by a similar site name with a specified filename.

The third parameter, func, is a site callback function which must be of the type, SaSiteCallback, as declared above. The fourth parameter, client, is a general purpose pointer that is sent to the Callback Function. It must be valid when function is called.

Data Site Callbacks are powerful features which extend the functionality of Sapphire. See the section on Login Functionality in the User's Guide as one example of how they can be used.

With this technique, your program can call upon functions to provide processing for the HTML page. For example, the callback could provide news text from a wire service such as API or Reuters, always providing the latest breaking story whenever the HTML was played.

Data Site Processing

The rules for data site processing can be stated as follows:

1. A Sapphire/Web Server Application looks for any Population Callbacks registered on a Data Site. The first one registered on the site is called, all other population callbacks on that site are "shadowed" (i.e., not called).

2. Whether or not any population callbacks are found, the Data Site Callbacks are checked.

3. If the site is registered with a filename parameter, then those without are shadowed.

4. If multiple registrations are found, only the last one is called and the others are shadowed.

5. If any data site is found in a ##Sa_BeginLoop##... ##Sa_EndLoop## construct, even if one of these does not have a Population Callback, the entire loop is not "played", not even once.



[Top] [Prev] [Next] [Bottom] [Contents]

info@bluestone.com
Copyright © 1997, Bluestone. All rights reserved.