PowerBuilder Web Forms DataWindow – Differences, Limitations & Settings
Performance Settings for the Web DataWindow
SetWeight Method: PowerBuilder generates a considerable amount of HTML or XHTML and JavaScript for the Web DataWindow client control. There are steps you can take to reduce the amount of client code. To reduce the amount of code generated on the client you can use the SetWeight method to instruct the component to leave out code for features you are not using such as:
- Updating data (large feature)
- Validating newly entered data
- Client-side events
- Allowing client-side scripts to call methods of the client control
- Applying display formats to newly entered data (large feature)
Note: You can disable any of these on the Web Generation property page in the DataWindow painter instead of using the SetWeight method
EXAMPLE 1: This example enables all features and will generate the most client script:
dw_1.SetWeight(true, true, true, true, true);
EXAMPLE 2: If updating of data is false, no validation or display formatting code is generated either. The following examples will both omit code for “Updating Data”, “Validating newly entered data”, and “Applying display formats to newly entered data”. The examples below are essentially the same.
dw_1.SetWeight(false, true, true, true, true)
dw_1.SetWeight(false, false, true, false, false)
EXAMPLE 3: This example turns off the client-side scripting capability:
dw_1.SetWeight(true, true, true, false, true);
Summary: Updating data and display formatting add the most code to the client-side control. Date processing also generates additional code so for the smallest client control, turn on only the features you need and restrict the use of date columns if possible.
Optimizing HTML for a Browser
SetBrowser: The Web DataWindow can generate HTML optimized for particular browsers and versions. The browser might be different each time the server component is instantiated by a different client, so this information cannot be preset in the DataWindow painter. You can tell it what browser and version to target in the server-side script. It can generate code for:
- Microsoft browser versions
- Netscape browser versions
In the painter, you can set the HTML Version property to specify what level of HTML to generate if the browser is not recognized. At run-time, the HTTP header sent from the client browser to the Web server contains the User-Agent or HTTP_USER_AGENT value, which the server component can use to identify the client browser.
Client Side Events
The client-side programming capabilities of the Web DataWindow enable the use of client-side JavaScript event handlers.
The ClientEvent properties of the Web DataWindow have also been exposed, allowing the creation of customized event handlers that can override the default event handlers in the PBDataWindow.js file. The names of the ClientEvent properties consist of the name of a client-side event with an “OnClient” prefix. For example, the ClientEvent property that corresponds to the Clicked event would be OnClientClicked. You can circumvent the default event handler for the Clicked event by setting OnClientClicked to the name of a JavaScript function that uses the client-side Clicked event arguments.
The Web DataWindow client control supports the events listed in this table:
Event | Arguments | Return Codes |
---|---|---|
ButtonClicked | sender, rowNumber, buttonName |
|
ButtonClicking | sender, rowNumber, buttonName |
|
Clicked | sender, rowNumber, objectName |
|
DoubleClicked | sender, rowNumber, objectName |
|
ItemChanged | sender, rowNumber, columnName, newValue |
|
ItemError | sender, rowNumber, columnName, newValue |
|
ItemFocusChanged | sender, rowNumber, columnName |
|
RButtonDown | sender, rowNumber, objectName |
|
RowFocusChanged | sender, newRowNumber |
|
RowFocusChanging | sender, currentRowNumber, newRowNumber |
|
The signatures of the client-side events and the effects of their return values are the same as for the Web DataWindow control in DataWindow .NET.
Return Values for Events
In client events, you can use a return statement as the last statement in the event script. The datatype of the value is number.
if (newValue = "") { return 2; }
function dwCustomer_RowFocusChanging(sender, currentRowNumber, newRowNumber) { if (newRowNumber < currentRowNumber) { return 1; } }
function dwCustomer_Clicked(sender, rowNumber, objectName) { alert ("You clicked the " + objectName + " column in row " + rowNumber) }
No responses yet