Sybase Technical Library - Product Manuals Home
[Search Forms] [Previous Section with Hits] [Next Section with Hits] [Clear Search] Expand Search

Deploying DataWindow objects
to the component server [Table of Contents] Writing client-side scripts

DataWindow Programmer's Guide

[-] Chapter 6: Using the Web DataWindow
[-] Creating Web page templates

Creating Web page templates

Different approaches to creating Web page templates are described below. You can use all of the following techniques in a Web target.

Using the Web DataWindow DTC

The Web DataWindow DTC makes it easy to add a DataWindow to a Web page without writing the code required to connect to EAServer and configure the server component. The DTC accesses the server and creates a Web page template for the generated HTML. You set up the DTC to reference your DataWindow object and the HTML Generator component in a wizard or on a property sheet. The Web DataWindow DTC embedded in the page includes the code required to connect to EAServer, establish database connections, and render the page as HTML. The generated scripts use the Web Target object model. If you use a 4GL Web page, you can use the EAServer extensions to server-side scripting that are built into the Web Target object model. You cannot hand code a Web DataWindow on a 4GL Web page.

For how to use the DTC, see Working with Web and JSP Targets.

Using the Web Target object model

The Web DataWindow DTC uses a set of objects in the Web Target object model. If you want more flexibility than the Web DataWindow DTC provides, you can write your own server-side scripts that instantiate and manipulate the server component using the Web Target object model.

For example, the following script defines the DataWindow object name and the PBL that contains it, sets up database and EAServer connection parameters, instantiates the server component, specifies client control properties, and generates HTML:

<!--SCRIPT 
var dwMine_pbl = "htgenex.pbl";
// Get DataWindow name from page parameter if defined
var dwMine_name = psDocument.GetParam("dwName");
if (dwMine_name + "" == "undefined"){
        dwMine_name = "d_tabular_emp";
}
// Set up DataWindow object variables
dwSrcLoc = new PSDataWindowSourceClass(
        dwMine_pbl, dwMine_name);

// Set database connection parameters
// Set ConnectOption to return an error if
// connection fails
dwDbParm = new PSConnectionParmsClass(
        "ConnectString='DSN=EAS Demo DB V3;UID=dba;
        PWD=sql', ConnectOption='SQL_DRIVER_CONNECT,
        SQL_DRIVER_NOPROMPT'");

// Set EAServer connection parameters
dwJagParm = new PSJaguarConnection("localhost:9000",
        "jagadmin", "", "DataWindow/HTMLGenerator90", false);
// Create the Web DataWindow server component    
dwMine = new PSDataWindowClass("dwMine", false, 
        dwJagParm, dwSrcLoc, dwDbParm);

// Specify what features to include in client control
dwMine.SetWeight(true, true, true, true);
// Get generated HTML
dwMine.Generate("dwName");
-->

The example above uses the PSDataWindowClass object to create the server component. If you are using EAServer, you can use the PSWebDataWindowClass object, which provides server-side events and additional methods.

For more information about the Web DataWindow DTC and the Web Target object model, see Working with Web and JSP Targets. For information about methods and events of Web Target object model classes, see the Web and JSP Target Reference.

Extending the DTC code

The code generated by the Web DataWindow DTC can be modified by changing DataWindow object properties in the DataWindow painter or changing DTC properties and then regenerating the code. If you want to include additional customizations, you can modify the generated code in the editor's Source view. To prevent your customizations from being overwritten when the Web page is regenerated, remove the METADATA tags that surround the code.

Calling the Web DataWindow server component methods

Instead of using the DTC or Web Target object model, you can use any HTML editor (including the Web Target HTML editor) to write code that instantiates the server component and calls its methods directly. See "Instantiating and configuring the server component".


Deploying DataWindow objects
to the component server [Table of Contents] Writing client-side scripts