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:
1 |
<!--SCRIPT |
1 |
var dwMine_pbl = "htgenex.pbl"; |
1 |
// Get DataWindow name from page parameter if defined |
1 |
var dwMine_name = psDocument.GetParam("dwName"); |
1 |
if (dwMine_name + "" == "undefined"){ |
1 |
dwMine_name = "d_tabular_emp"; |
1 |
} |
1 |
// Set up DataWindow object variables |
1 |
dwSrcLoc = new PSDataWindowSourceClass( |
1 |
dwMine_pbl, dwMine_name); |
1 |
// Set database connection parameters |
1 |
// Set ConnectOption to return an error if |
1 |
// connection fails |
1 |
dwDbParm = new PSConnectionParmsClass( |
1 |
"ConnectString='DSN=EAS Demo DB V3;UID=dba; |
1 |
PWD=sql', ConnectOption='SQL_DRIVER_CONNECT, |
1 |
SQL_DRIVER_NOPROMPT'"); |
1 |
// Set EAServer connection parameters |
1 |
dwJagParm = new PSJaguarConnection("localhost:9000", |
1 |
"jagadmin", "", "DataWindow/HTMLGenerator90", false); |
1 |
1 |
// Create the Web DataWindow server component |
1 |
dwMine = new PSDataWindowClass("dwMine", false, |
1 |
dwJagParm, dwSrcLoc, dwDbParm); |
1 |
// Specify what features to include in client control |
1 |
dwMine.SetWeight(true, true, true, true); |
1 |
1 |
// Get generated HTML |
1 |
dwMine.Generate("dwName"); |
1 |
--> |
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”.