UltraLite ActiveX User's Guide
Understanding UltraLite ActiveX Development
In Pocket IE, UltraLite ActiveX is accessed using JScript embedded on an HTML page.
In the following code fragment, a ULDatabaseManager object is created. When a page containing this script is loaded, a new ULDatabaseManager object is created. When the browser moves to another page, that object is discarded. If a database connection was obtained on one page, it is lost when that page is unloaded.
<SCRIPT LANGUAGE="JScript"> var DatabaseMgr; DatabaseMgr = new ActiveXObject( "UltraLite.ULDatabaseManager" ); </SCRIPT>
Losing application state, including database connections, whenever a form changes, is slow and expensive. To avoid this, Pocket IE applications can use HTML frames to maintain application state. The database connection can be kept by the frameset document. Pocket IE requires at least two frames within a frameset, and draws a three-pixel border between the frames.
NoteSupport for frames is not included in versions of Pocket IE prior to 1.1. |
The following code fragment defines two frames.
// JScript <frameset rows="5%,*" BORDER=0> <frame SRC="topline.htm" NAME="TopLine" MARGINWIDTH=0 MARGINHEIGHT=0> <frame SRC="connect.htm" NAME="Connect" MARGINWIDTH=0 MARGINHEIGHT=0> </frameset> <SCRIPT LANGUAGE="JScript"> var Connection; // UltraLite Connection var DatabaseMgr; // UltraLite Database Manager </SCRIPT>
In the CustDB example, the minimal frame defined in topline.htm is a placeholder that displays the application name at the top of the screen. The rest of the screen is used to display the other pages of the application. The HTML and JScript in connect.htm provide the initial form for the application. Since all these forms will be swapped into the same frameset, they can access their parent frameset objects using window.topwindow.
The following code fragment creates a new variable, conn, and assigns the connection created in the top frame to it. If you are in top, referencing the connection as top.Connection is optional.
// JScript <SCRIPT> function usingConnection() { if ( top.Connection == null ) { return; // not yet connected.. } var conn = top.Connection; ... } </SCRIPT>
To swap forms in and out of the frameset, a JScript function can use the document.location.replace method. The following code fragment closes the current connection and returns to the connect form.
// JScript <SCRIPT> function exitApp() { if ( top.Connection != null ) { top.Connection.Close(); } document.location.replace("connect.htm"); } </SCRIPT> <INPUT NAME="b_Done" TYPE="BUTTON" VALUE="Done" onClick="exitApp()">