PowerBuilder Web Forms DataWindow Limitations & Settings


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
  • 0 – Continue processing
ButtonClicking sender, rowNumber, buttonName
  • 0 – Execute action assigned to button, then trigger ButtonClicked
  • 1 – Do not execute action or trigger ButtonClicked
Clicked sender, rowNumber, objectName
  • 0 – Continue processing
  • 1 – Prevent focus change
DoubleClicked sender, rowNumber, objectName
  • 0 – Continue processing
  • 1 – Prevent focus change
ItemChanged sender, rowNumber, columnName, newValue
  • 0 – Accept data value
  • 1 – Reject data value and prevent focus change
  • 2 – Reject data value but allow focus change
ItemError sender, rowNumber, columnName, newValue
  • 0 – Reject data value and show error message
  • 1 – Reject data value with no error message
  • 2 – Accept data value
  • 3 – Reject data value but allow focus change
ItemFocusChanged sender, rowNumber, columnName
  • 0 – Continue processing
RButtonDown sender, rowNumber, objectName
  • 0 – Continue processing
  • 1 – Prevent focus change
RowFocusChanged sender, newRowNumber
  • 0 – Continue processing
RowFocusChanging sender, currentRowNumber, newRowNumber
  • 0 – Continue processing
  • 1 – Prevent focus change

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.

For example, in the ItemChanged event, set the return code to 2 to reject an empty string as a data value:

if (newValue = "") {	
   return 2;
}
This example prevents focus from changing if the user tries to go back to an earlier row:

function dwCustomer_RowFocusChanging(sender, currentRowNumber, newRowNumber)
   {
	if (newRowNumber < currentRowNumber) 
      { return 1; }
   }
This example displays a message box informing the user which column and row number were clicked:

function dwCustomer_Clicked(sender, rowNumber,  objectName)
   {
	alert ("You clicked the " + objectName +  " column in row " + rowNumber)
   }

 

Leave a comment

Your email address will not be published. Required fields are marked *