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 to 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:

String dwMine_pbl = "htgenex.pbl";
// Get DataWindow name from page parameter if defined
String dwMine_name = psDocument.GetParam("dwName");
if (dwMine_name + "" == "undefined"){
		dwMine_name = "d_tabular_emp";
}
// Set up DataWindow object variables
PSDataWindowSourceClass dwSrcLoc; 
dwSrcLoc = new PSDataWindowSourceClass(
		dwMine_pbl, dwMine_name);
// Set database connection parameters
// Set ConnectOption to return an error if
// connection fails
PSConnectionParmsClass dwDbParm; 
dwDbParm = new PSConnectionParmsClass(
		"ConnectString='DSN=EAS Demo DB V105;UID=dba;
		PWD=sql', ConnectOption='SQL_DRIVER_CONNECT,
		SQL_DRIVER_NOPROMPT'");
// Set EAServer connection parameters
PSJaguarConnection dwJagParm;
dwJagParm = new PSJaguarConnection("myServer:9000",
		"jagadmin", "", "DataWindow/HTMLGenerator105",        false);

// Create the Web DataWindow server component	
PSDataWindowClass dwMine;
dwMine = new PSDataWindowClass(pageContext, request,       "dwMine", false, 		dwJagParm, dwSrcLoc,       dwDbParm,0);
// Specify what features to include in client control
dwMine.SetWeight(true, true, true, true, true);

// Get generated HTML
dwMine.Generate("dwName");

The example above uses the PSDataWindowClass object to create the server component. For EAServer, you can also 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 or JSP editor (including PowerBuilder’s HTML/JSP editor) to write code that instantiates the server component and calls its methods directly. See “Instantiating and configuring the server component”.