DataWindow Programmers Guide PowerBuilde
DataWindow Programmers Guide PowerBuilde
PowerBuilder® Classic
12.5
DOCUMENT ID: DC37775-01-1250-01
This publication pertains to Sybase software and to any subsequent release until otherwise indicated in new editions or technical notes.
Information in this document is subject to change without notice. The software described herein is furnished under a license agreement,
and it may be used or copied only in accordance with the terms of that agreement.
To order additional documents, U.S. and Canadian customers should call Customer Fulfillment at (800) 685-8225, fax (617) 229-9845.
Customers in other countries with a U.S. license agreement may contact Customer Fulfillment via the above fax number. All other
international customers should contact their Sybase subsidiary or local distributor. Upgrades are provided only at regularly scheduled
software release dates. No part of this publication may be reproduced, transmitted, or translated in any form or by any means, electronic,
mechanical, manual, optical, or otherwise, without the prior written permission of Sybase, Inc.
Sybase trademarks can be viewed at the Sybase trademarks page at http://www.sybase.com/detail?id=1011207. Sybase and the marks listed
are trademarks of Sybase, Inc. ® indicates registration in the United States of America.
SAP and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of
SAP AG in Germany and in several other countries all over the world.
Java and all Java-based marks are trademarks or registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries.
Unicode and the Unicode Logo are registered trademarks of Unicode, Inc.
All other company and product names mentioned may be trademarks of the respective companies with which they are associated.
Use, duplication, or disclosure by the government is subject to the restrictions set forth in subparagraph (c)(1)(ii) of DFARS 52.227-7013
for the DOD and as set forth in FAR 52.227-19(a)-(d) for civilian agencies.
iv PowerBuilder Classic
Contents
CHAPTER 8 Using the DataWindow Web Control for ActiveX ..................... 205
About the Web ActiveX ................................................................ 205
HTML for inserting the controls on a Web page........................... 209
Object element ...................................................................... 209
Properties and Param elements............................................ 211
DataWindow objects for the Web ActiveX.................................... 212
What the DataWindow object can include............................. 213
Managing DataWindow objects in PowerBuilder libraries ..... 213
Specifying a DataWindow object for the control.................... 214
Using the DataWindow Transaction Object control...................... 215
Making database connections...................................................... 216
Connecting and retrieving data ............................................. 218
Coding for the Web ActiveX ......................................................... 218
vi PowerBuilder Classic
Datatypes for method arguments and return values.............. 219
Setting event return codes..................................................... 220
Deploying the Web ActiveX .......................................................... 220
Index............................................................................................................................................ 223
2 Either select the product family and product under Search by Base
Product; or select the platform and product under Search by Platform.
3 Select Search to display the availability and certification report for the
selection.
x PowerBuilder Classic
About This Book
Sybase EBFs and You can find information about EBFs and software maintenance on the Sybase
software Web site.
maintenance
About this chapter This chapter describes what DataWindow objects are and the ways you
can use them in various application architectures and programming
environments.
Contents
Topic Page
About DataWindow objects, controls, and components 3
Choosing a DataWindow technology 7
PowerBuilder DataWindow control 10
4 PowerBuilder Classic
CHAPTER 1 About DataWindow Technology
Where to define You define DataWindow objects in the PowerBuilder DataWindow painter.
DataWindow objects You can also define nonupdatable DataWindow objects in the InfoMaker
Report painter.
For examples of the presentation styles, see the PowerBuilder Users Guide.
Data sources The data source specifies where the data in the DataWindow comes from and
what data items are displayed. Data can come from tables in a database, a Web
service, a file with data that you can import, or code that specifies the data. For
databases, the data specification is saved in a SQL statement. In all cases, the
DataWindow object saves the names of the data items to display, as well as
their datatypes.
Table 1-2: Data sources you can use for a DataWindow
Data source Description
Quick Select The data is coming from one or more tables in a SQL database.
The tables must be related through a foreign key. You need to
choose only columns, selection criteria, and sorting.
SQL Select You want more control over the select statement that is
generated for the data source. You can specify grouping,
computed columns, and so on.
Query The data has already been selected and the SQL statement is
saved in a query object that you have defined in the Query
painter. When you define the DataWindow object, the query
object is incorporated into the DataWindow and does not need
to be present when you run the application.
External The data is not stored in a database, but is imported from a file
(such as a tab-separated or dBASE file) or populated from
code.
Stored Procedure The data is defined in a database stored procedure.
Web Service The data is defined in a Web service. Support for a Web service
data source is not available for the Composite, RichText, and
OLE presentation styles.
6 PowerBuilder Classic
CHAPTER 1 About DataWindow Technology
Basic process
Using a DataWindow involves two main steps:
1 Use the DataWindow painter to create or edit a DataWindow object.
In the painter, you define the data source, presentation style, and all other
properties of the object, such as display formats, validation rules, sorting
and filtering criteria, and graphs.
2 In your development environment, put a DataWindow control in a
window, visual user object, or form or a DataWindow container in a Web
page and associate a DataWindow object with the control or container.
It is through the control or container that your application communicates
with the DataWindow object you created in the DataWindow painter. You
write code to manipulate the DataWindow control or container and the
DataWindow object it contains. Typically, your code retrieves and updates
data, changes the appearance of the data, handles errors, and shares data
between DataWindow controls.
• Web application A client Web browser sends requests for HTML or JSP
documents to a Web server. The Web server passes control to a page or
application server, where server-side scripts can access components on a
transaction server that can connect to databases on a database server.
• .NET application PowerBuilder lets you deploy DataWindows in .NET
Web Forms and Windows Forms applications. For more information about
.NET applications, see Deploying Applications and Components to .NET.
• WPF Window application Using the PowerBuilder .NET IDE, you can
create Windows Presentation Foundation Window applications. This
allows you to take advantage of XAML and WPF technology. For more
information, refer to the PowerBuilder .NET documentation.
8 PowerBuilder Classic
CHAPTER 1 About DataWindow Technology
Web DataWindow
The Web DataWindow is a thin-client DataWindow implementation for Web
applications. It provides most of the data manipulation, presentation, and
scripting capabilities of the PowerBuilder DataWindow without requiring any
PowerBuilder DLLs on the client.
Functionality The Web DataWindow supports a subset of the PowerBuilder DataWindow
events and methods, including dynamic modification of the DataWindow
object. The user can modify and update data. Composite, Graph, OLE,
TreeView, and RichText presentation styles and controls are not supported.
Client requirements The HTML Web DataWindow works in most browsers, but the appearance of
the generated HTML is usually best in Internet Explorer. Generated HTML can
be dynamically optimized for Netscape or Internet Explorer, or scaled back to
handle older browsers. The XML Web DataWindow and the XHTML Web
DataWindow require browsers that support the following client-side
technologies: XML, XSLT, XHTML, CSS, and JavaScript. For information
about supported browsers, see “Browser requirements for the XML Web
DataWindow” on page 126.
Server requirements A component server and a dynamic page server work together to generate a
client control with data and include it in a Web page. Each time the user
requests a new page of data, updates data, or inserts or deletes rows, the server
gets a request to generate a new page. Depending on how state is managed, the
component might retrieve data each time it is called, causing added load on the
server.
Client requirements The control uses ActiveX technology and works in Microsoft Internet Explorer
only.
The user must download the CAB file for the component, which is less than
two megabytes in size. Database connection through JDBC occurs from the
client, which must be configured with the connection software. The software
can be downloaded from the Web server.
DataWindow behavior that would compromise security of the client, such as
the SaveAs functionality, is disabled.
Server requirements The JDBC database connection can access databases on a remote server.
For more information, see Chapter 8, “Using the DataWindow Web Control
for ActiveX.”
.NET applications
For information, see Deploying Applications and Components to .NET.
10 PowerBuilder Classic
CHAPTER 1 About DataWindow Technology
Coding You write scripts in the Window or User Object painter to connect to the
database, retrieve data, process user input, and update data.
In PowerBuilder, you can take advantage of object inheritance by defining a
user object inherited from a DataWindow control and adding your own custom
functionality. You can reuse the customized DataWindow control throughout
your applications.
You create DataStore objects, the nonvisual version of a DataWindow control,
by creating them in a script and calling methods for the object. You can also
define a user object that is inherited from a DataStore and customize it. For
more information, see Chapter 4, “Using DataStore Objects.”
Libraries and You store DataWindow objects in PowerBuilder libraries (PBLs) during
applications development. When you build your application, you can include the
DataWindow objects in the application executable or in PowerBuilder dynamic
libraries (PBDs).
For more information about designing DataWindow objects and building a
PowerBuilder application, see the PowerBuilder Users Guide and Application
Techniques.
12 PowerBuilder Classic
CH A PTE R 2 Using DataWindow Objects
About this chapter This chapter describes how to use DataWindow objects in an application.
Contents
Topic Page
About using DataWindow objects 14
Putting a DataWindow object into a control 15
Accessing the database 21
Accessing a Web service data source 29
Importing data from an external source 30
Manipulating data in a DataWindow control 30
Accessing the properties of a DataWindow object 38
Handling DataWindow errors 40
Updating the database 45
Creating reports 49
Using nested reports 51
Using crosstabs 53
Generating HTML 56
Before you begin This chapter assumes that you know how to build DataWindow objects in
the DataWindow painter, as described in the PowerBuilder Users Guide.
Managing Several painters let you manage and package your DataWindow objects for use
DataWindow objects in applications.
In particular, you can maintain DataWindow objects in one or more libraries
(PBL files). When you are ready to use your DataWindow objects in
applications, you can package them in more compact runtime libraries (PBD
files).
For further details on how to build and organize DataWindow objects, see the
PowerBuilder Users Guide.
Using DataWindow After you build a DataWindow object (or PSR file) in the DataWindow painter,
objects you can use it to display and process information from the appropriate data
source. The sections that follow explore the details of how to do this.
14 PowerBuilder Classic
CHAPTER 2 Using DataWindow Objects
The DataWindow object name To avoid confusion, you should use different
prefixes for DataWindow objects and DataWindow controls. The prefix d_ is
commonly used for DataWindow objects. For example, if the name of the
DataWindow control is dw_customer, you might want to name the
corresponding DataWindow object d_customer.
16 PowerBuilder Classic
CHAPTER 2 Using DataWindow Objects
18 PowerBuilder Classic
CHAPTER 2 Using DataWindow Objects
Setting the transaction object when you change the DataWindow object
When you change the DataWindow object during execution, you might need to
call setTrans or setTransObject again.
For more information, see “Setting the transaction object for the DataWindow
control” on page 22.
Dynamically creating You can also create a new DataWindow object during execution and associate
a DataWindow object it with a control.
For more information, see Chapter 3, “Dynamically Changing DataWindow
Objects.”
Preventing redrawing
You can use the SetRedraw method to turn off redrawing in order to avoid
flicker and reduce redrawing time when you are making several changes to the
properties of an object or control. Dynamically changing the DataWindow
object at execution time implicitly turns redrawing on. To turn redrawing off
again, call the SetRedraw method every time you change the DataWindow
object:
dw_emp.DataObject = "d_emp_hist"
dw_emp.SetRedraw(FALSE)
Using PSR files To put a PSR file into a DataWindow control at execution time, change the
control’s DataObject property to specify that PSR file name.
20 PowerBuilder Classic
CHAPTER 2 Using DataWindow Objects
To learn more about setting values for the transaction object, connecting to the
database, and disconnecting from the database, see:
• PowerBuilder Application Techniques, “Using Transaction Objects”
• Web DataWindow “Specifying the database connection and retrieving
data” on page 184
• Web ActiveX “Using the DataWindow Transaction Object control” on
page 215
22 PowerBuilder Classic
CHAPTER 2 Using DataWindow Objects
24 PowerBuilder Classic
CHAPTER 2 Using DataWindow Objects
The transaction object also stores error messages returned from the database in
its properties. You can use the error information to determine whether to
commit or roll back database changes.
When to use it When the DataWindow control uses a separate transaction object, you have
more control of the database processing and are responsible for managing the
database transaction.
There are several reasons to use a separate transaction object:
• You have several DataWindow controls that connect to the same database
and you want to make one database connection for all of them, saving the
overhead of multiple connections
• You want to control transaction processing
• You require the improved performance provided by keeping database
connections open
How it works PowerBuilder The SetTransObject method associates a transaction object
with the DataWindow control. PowerBuilder has a default transaction object
called SQLCA that is automatically instantiated. You can set its connection
properties, connect, and assign it to the DataWindow control.
The following statement uses SetTransObject to associate the DataWindow
control dw_emp with the default transaction object (SQLCA):
// Set connection parameters in the transaction object
SQLCA.DBMS = ...
SQLCA.database = ...
CONNECT USING SQLCA;
dw_emp.SetTransObject(SQLCA)
dw_emp.Retrieve( )
Instead of or in addition to using the predefined SQLCA transaction object, you
can define your own transaction object in a script. This is necessary if your
application needs to connect to more than one database at the same time.
The following statement uses SetTransObject to associate dw_customer with a
programmer-created transaction object (trans_customer):
transaction trans_customer
trans_customer = CREATE transaction
// Set connection parameters in the transaction object
trans_customer.DBMS = ...
trans_customer.database = ...
CONNECT USING trans_customer;
dw_customer.SetTransObject(trans_customer)
dw_customer.Retrieve( )
Web ActiveX To use a separate transaction object for the Web ActiveX, you
add an OBJECT element for the Sybase DataWindow Transaction Object
control to the Web page. You can set its connection properties using Param
elements or a script.
A script that connects and retrieves data would have statements like these:
trans_1.Connect( );
dw_employee.SetTransObject( trans_1 );
dw_employee.Retrieve( );
trans_1.Disconnect( );
For more information For more information about database transaction processing:
• PowerBuilder See the chapter on using transaction objects in
Application Techniques
• Web ActiveX See Chapter 8, “Using the DataWindow Web Control for
ActiveX”
For more information about SetTrans and SetTransObject methods, see the
DataWindow Reference.
26 PowerBuilder Classic
CHAPTER 2 Using DataWindow Objects
Updating data
After users have made changes to data in a DataWindow control, you can use
the Update method to save those changes in the database.
In PowerBuilder, the code looks like this:
dw_emp.Update()
Update sends to the database all inserts, changes, and deletions made in the
DataWindow control since the last Update method. When you are using an
external transaction object, you can then commit (or roll back) those database
updates. In PowerBuilder, you use SQL statements. In the Web ActiveX, you
use methods and properties of the transaction object. In the Web DataWindow
client control, update requests call the update method in the server component,
which handles the commit or rollback.
For more specifics on how a DataWindow control updates the database (that is,
which SQL statements are sent in which situations), see “Updating the
database” on page 45.
Examples The following example shows code that connects, retrieves, updates, commits
or rolls back, and disconnects from the database.
Although the example shows all database operations in a single script or
function, most applications separate these operations. In a PowerBuilder
application, for example, an application could connect to the database in the
application Open event, retrieve and update data in one or more window
scripts, and disconnect from the database in the application Close event.
PowerBuilder The following statements retrieve and update data using the
transaction object EmpSQL and the DataWindow control dw_emp:
// Connect to the database specified in the
// transaction object EmpSQL
CONNECT USING EmpSQL;
28 PowerBuilder Classic
CHAPTER 2 Using DataWindow Objects
Web ActiveX The following JavaScript statements retrieve and update data
using the transaction object EmpSQL and the DataWindow control dw_emp.
// Connect to the database specified in the
// transaction object EmpSQL
EmpSQL.Connect( );
30 PowerBuilder Classic
CHAPTER 2 Using DataWindow Objects
About the edit control As the user moves around the DataWindow control, the DataWindow places an
edit control over the current cell (row and column):
About text The contents of the edit control are called text. Text is data that has not yet been
accepted by the DataWindow control. Data entered in the edit control is not in
a DataWindow buffer yet; it is simply text in the edit control.
About items When the user changes the contents of the edit control and presses Enter or
leaves the cell (by tabbing, using the mouse, or pressing UP ARROW or DOWN
ARROW), the DataWindow processes the data and either accepts or rejects it,
depending on whether it meets the requirements specified for the column. If the
data is accepted, the text is moved to the current row and column in the
DataWindow Primary buffer. The data in the Primary buffer for a particular
column is referred to as an item.
Events for changing When data is changed in the edit control, several events occur. The names of
text and items the events are different in each environment, as shown in the table. This chapter
refers to events using PowerBuilder names.
Table 2-2: Event names in different environments
Event Description
For PowerBuilder,
Web DataWindow
client control For Web ActiveX
EditChanged (not onEditChange Occurs for each keystroke the
available on client user types in the edit control
control)
Event Description
For PowerBuilder,
Web DataWindow
client control For Web ActiveX
ItemChanged beforeItemChange Occurs when a cell has been
modified and loses focus
ItemError onItemError Occurs when new data fails the
validation rules for the column
ItemFocusChanged onItemFocusChange Occurs when the current item in
the control changes
How text is processed When the data in a column in a DataWindow has been changed and the column
in the edit control loses focus (for example, because the user tabs to the next column), the
following sequence of events occurs:
1 The DataWindow control converts the text into the correct datatype for the
column. For example, if the user is in a numeric column, the DataWindow
control converts the string that was entered into a number. If the data
cannot be converted, the ItemError event is triggered.
2 If the data converts successfully to the correct type, the DataWindow
control applies any validation rule used by the column. If the data fails
validation, the ItemError event is triggered.
3 If the data passes validation, then the ItemChanged event is triggered. If
you set an action/return code of 1 in the ItemChanged event, the
DataWindow control rejects the data and does not allow the focus to
change. In this case, the ItemError event is triggered.
4 If the ItemChanged event accepts the data, the ItemFocusChanged event
is triggered next and the data is stored as an item in a buffer.
32 PowerBuilder Classic
CHAPTER 2 Using DataWindow Objects
Action/return codes You can affect the outcome of events by specifying numeric values in the
for events event’s program code. For example, step 3 above describes how you can force
data to be rejected with a code of 1 in the ItemChanged event.
To specify action/return codes:
• PowerBuilder and Web DataWindow Use a RETURN statement
• Web ActiveX Call the SetActionCode or setActionCode method
For information about codes for individual events, see the DataWindow
Reference.
For more information about these methods, see the DataWindow Reference.
34 PowerBuilder Classic
CHAPTER 2 Using DataWindow Objects
36 PowerBuilder Classic
CHAPTER 2 Using DataWindow Objects
Some, but not all, of these methods are available for the Web DataWindow
client control, server component, or both. Each development environment
provides a reference list of methods.
For complete information on DataWindow methods, see the DataWindow
Reference.
38 PowerBuilder Classic
CHAPTER 2 Using DataWindow Objects
The following statement changes the value of the Border property for the
empname column to 1:
dw_emp.Modify("empname.Border=1")
Web ActiveX The JavaScript code is nearly identical to PowerScript. These
statements get the value of the Border property for the empname column:
string ls_border
ls_border = dw_1.Describe("empname.Border");
The following statement changes the value of the Border property for the
empname column to 1:
dw_emp.Modify("empname.Border=1");
Using expressions DataWindow property expressions provide access to properties with fewer
nested strings. In PowerBuilder, you can handle problems with incorrect object
and property names in the Error event:
PowerBuilder Use the Object property and dot notation. For example:
integer li_border
li_border = Integer(dw_1.Object.empname.Border)
dw_1.Object.empname.Border = 1
For reference material on the available variations for property expressions, see
the DataWindow Reference.
Table 2-4: Return codes for the Retrieve and Update methods
Return
Method code Meaning
Retrieve >=1 Retrieval succeeded; returns the number of rows retrieved.
-1 Retrieval failed; DBError event triggered.
0 No data retrieved.
Update 1 Update succeeded.
-1 Update failed; DBError event triggered.
40 PowerBuilder Classic
CHAPTER 2 Using DataWindow Objects
In many cases you might want to code your own processing in the DBError
event and suppress the default message box. Here are some tips for doing this:
Table 2-5: Tips for processing messages from DBError event
To Do this
Get the DBMS's error code Use the SQLDBCode argument of the DBError
event.
Get the DBMS's message text Use the SQLErrText argument of the DBError
event.
Suppress the default message box Specify an action/return code of 1.
42 PowerBuilder Classic
CHAPTER 2 Using DataWindow Objects
Web ActiveX In JavaScript, the code for the DBError event might look like
this:
// Database error -195 means that some of the
// required values are missing
if (sqldbcode == -195) {
alert("Missing information:\n" +
"You have not supplied values for all " +
"the required fields.");
}
// Action code suppresses default message box
dw_1.SetActionCode(1);
Determining the cause The Error event has several arguments that provide information about the error
of the error condition. You can check the values of the arguments to determine the cause of
the error. For example, you can obtain the internal error number and error text,
the name of the object whose script caused the error, and the full text of the
script where the error occurred. The information provided by the Error event’s
arguments can be helpful in debugging expressions that are not checked by the
compiler.
If you catch a DWRuntimeError error, you can use the properties of that class
instead of the Error event arguments to provide information about the error
condition. The following table displays the correspondences between the Error
event arguments and the DWRuntimeError properties.
Table 2-6: Correspondence between Error event arguments and
DWRuntimeError properties
Error event argument DWRuntimeError property
errornumber number
errorline line
errortext text
errorwindowmenu objectname
errorobject class
errorscript routinename
Controlling the When the Error event is triggered, you can have the application ignore the error
outcome of the event and continue processing, substitute a different return value, or escalate the error
by triggering the SystemError event. In the Error event, you can set two
arguments passed by reference to control the outcome of the event.
Table 2-7: Setting arguments in the Error event
Argument Description
Action A value you specify to control the application's course of action as
a result of the error. Values are:
ExceptionIgnore!
ExceptionSubstituteReturnValue!
ExceptionFail! (default action)
ReturnValue A value whose datatype matches the expected value that the
DataWindow would have returned. This value is used when the
value of action is ExceptionSubstituteReturnValue!.
For a complete description of the arguments of the Error event, see the
DataWindow Reference.
44 PowerBuilder Classic
CHAPTER 2 Using DataWindow Objects
How statuses are set When data is retrieved When data is retrieved into a DataWindow, all rows
and columns initially have a status of NotModified!.
After data has changed in a column in a particular row, either because the user
changed the data or the data was changed programmatically, such as through
the SetItem method, the column status for that column changes to
DataModified!. Once the status for any column in a retrieved row changes to
DataModified!, the row status also changes to DataModified!.
When rows are inserted When a row is inserted into a DataWindow, it
initially has a row status of New!, and all columns in that row initially have a
column status of NotModified!. After data has changed in a column in the row,
either because the user changed the data or the data was changed
programmatically, such as through the SetItem method, the column status
changes to DataModified!. Once the status for any column in the inserted row
changes to DataModified!, the row status changes to NewModified!.
When a DataWindow column has a default value, the column’s status does not
change to DataModified! until the user makes at least one actual change to a
column in that row.
When Update is called For rows in the Primary and Filter buffers When the Update method is
called, the DataWindow control generates SQL INSERT and UPDATE
statements for rows in the Primary and/or Filter buffers based upon the
following row statuses:
Table 2-9: Row status after INSERT and UPDATE statements
Row status SQL statement generated
NewModified! INSERT
DataModified! UPDATE
46 PowerBuilder Classic
CHAPTER 2 Using DataWindow Objects
Changing row status Changing row status is a little more complicated. The following table
illustrates the effect of changing from one row status to another:
Table 2-10: Effects of changing from one row status to another
Specified status
Original status New! NewModified! DataModified! NotModified!
New! - Yes Yes No
NewModified! No - Yes New!
DataModified! NewModified! Yes - Yes
NotModified! Yes Yes Yes -
In the preceding table, Yes means the change is valid. For example, issuing
SetItemStatus on a row that has the status NotModified! to change the status to
New! does change the status to New!. No means that the change is not valid
and the status is not changed.
Issuing SetItemStatus to change a row status from NewModified! to
NotModified! actually changes the status to New!. Issuing SetItemStatus to
change a row status from DataModified! to New! actually changes the status to
NewModified!.
Changing a row's status to NotModified! or New! causes all columns in that
row to be assigned a column status of NotModified!. Change the column’s
status to DataModified! to ensure that an update results in a SQL Update.
48 PowerBuilder Classic
CHAPTER 2 Using DataWindow Objects
Creating reports
You can use DataWindow objects to create standard business reports such as
financial statements, sales order reports, employee lists, or inventory reports.
To create a production report, you:
• Determine the type of report you want to produce
• Build a DataWindow object to display data for the report
• Place the DataWindow object in a DataWindow control on a window or
form
• Write code to perform the processing required to populate the
DataWindow control and print the contents as a report
Using fonts
Printer fonts are usually shorter and fatter than screen fonts, so text might not
print in the report exactly as it displays in the DataWindow painter. You can pad
the text fields to compensate for this discrepancy. You should test the report
format with a small amount of data before you print a large report.
50 PowerBuilder Classic
CHAPTER 2 Using DataWindow Objects
Availability
Composite and nested reports are not available in the Web DataWindow.
To learn about designing nested reports, see the PowerBuilder Users Guide.
Printing multiple An advantage of composite reports is that you can print multiple reports on a
updatable page. A limitation of composite reports is that they are not updatable, so you
DataWindows on a
page cannot directly print several updatable DataWindows on one page. However,
there is an indirect way to do that, as follows.
You can use the GetChild method on named nested reports in a composite
report to get a reference to a nested report. After getting the reference to the
nested report, you can address the nested report during execution like other
DataWindows.
Using this technique, you can call the ShareData method to share data between
multiple updatable DataWindow controls and the nested reports in your
composite report. This allows you to print multiple updatable DataWindows on
a page through the composite report.
3 Add the composite report to the window or form (it can be hidden).
Re-retrieving data
Each time you retrieve data into the composite report, all references (handles)
to nested reports become invalid, and data sharing with the nested reports is
terminated. Therefore, be sure to call GetChild and ShareData each time after
retrieving data.
Creating and You can create and destroy nested reports in a DataWindow object dynamically
destroying nested during execution using the same technique you use to create and destroy other
reports during
execution controls in a DataWindow object.
Creating nested reports To create a nested report, use the CREATE
keyword with the Modify method. Supply the appropriate values for the nested
report's properties.
When creating a nested report, you need to re-retrieve data to see the report. In
a composite report, you can either retrieve data for the whole report or use
GetChild to get a reference to the new nested report and retrieve its data
directly. For nested reports in other reports, you need to retrieve data for the
base report.
Destroying nested reports To destroy a nested report, use the DESTROY
keyword with the Modify method. The nested report disappears immediately.
52 PowerBuilder Classic
CHAPTER 2 Using DataWindow Objects
Using crosstabs
To perform certain kinds of data analysis, you might want to design
DataWindow objects in the Crosstab presentation style. The basic steps for
using crosstabs in an application are the same ones you follow for the other
DataWindow types, but there are some additional topics concerning crosstabs
that you should know about.
To learn about designing crosstabs, see the PowerBuilder Users Guide.
For more about composite DataWindows, see the PowerBuilder Users Guide.
Availability
This technique is available in PowerBuilder and the Web ActiveX.
With the CrosstabDialog method, you can allow users to redefine which
columns in the retrieved data are associated with the crosstab’s columns, rows,
and values during execution.
The CrossTabDialog method displays the Crosstab Definition dialog box for
the user to define the data for the crosstab's columns, rows, and values (using
the same techniques you use in the DataWindow painter). When the user clicks
OK in the dialog box, the DataWindow control rebuilds the crosstab with the
new specifications.
Displaying You can display informational messages when a crosstab is rebuilt during
informational execution as a result of the call to CrosstabDialog. (The messages are the same
messages
ones you see when building a crosstab in the DataWindow painter, such as
Retrieving data and Building crosstab.) You might want to do this if
you are working with a very large number of rows and rebuilding the crosstab
could take a long time.
PowerBuilder In PowerBuilder, you use a user event to display the crosstab’s
informational messages.
54 PowerBuilder Classic
CHAPTER 2 Using DataWindow Objects
With that script in place, after CrosstabDialog has been called and the user has
redefined the crosstab, as the crosstab is being rebuilt, your application
dynamically displays the informational messages in the static text control
st_message. (You might want to reset st_message.Text to be the empty string
in the line following the CrosstabDialog call.)
In this example, code in the user event for pbm_dwnmessagetext displays
informational messages as MicroHelp in an MDI application (w_crosstab is an
MDI frame window):
w_crosstab.SetMicroHelp(text)
The informational messages are displayed in the MDI application's MicroHelp
as the crosstab is rebuilt.
For more information For more about user events in PowerBuilder, see the PowerBuilder Users
Guide.
For more about the CrosstabDialog method and MessageText event, see the
DataWindow Reference.
Availability
You can use this technique in all DataWindow environments.
Changes that do not You can change the following properties without forcing the DataWindow
force a rebuild control to rebuild the crosstab:
Table 2-11: Properties you can change on a crosstab DataWindow
without forcing a rebuild
Properties Objects
Alignment Column, Compute, Text
Background Column, Compute, Line, Oval, Rectangle,
RoundRectangle, Text
Border Column, Compute, Text
Brush Line, Oval, Rectangle, RoundRectangle
Color Column, Compute, Text
Properties Objects
Edit styles (dddw, ddlb, checkbox, Column
edit, editmask, radiobutton,
richtext)
Font Column, Compute, Text
Format Column, Compute
Pen Line, Oval, Rectangle, RoundRectangle
Pointer Column, Compute, Line, Oval, Rectangle,
RoundRectangle, Text
Changes that force a If you change any other properties, the DataWindow control rebuilds the
rebuild structure of the crosstab when Modify is called. You should combine all needed
expressions into one Modify call so that the DataWindow control has to rebuild
the crosstab only once.
Default values for For computations derived from existing columns, the DataWindow control by
properties default uses the properties from the existing columns. For completely new
columns, properties (such as font, color, and so on) default to the first column
of the preexisting crosstab. Properties for text in headers default to the
properties of the first text control in the preexisting crosstab’s first header line.
For more about the Modify method, see Chapter 3, “Dynamically Changing
DataWindow Objects.” For details on the DataWindow object properties, see
the DataWindow Reference.
Generating HTML
You can use the data in a DataWindow object to create HyperText Markup
Language (HTML) syntax. Once the HTML has been created, you can display
it in a Web browser.
56 PowerBuilder Classic
CHAPTER 2 Using DataWindow Objects
Techniques you can You can use any of several techniques to generate HTML from a DataWindow
use object.
In a painter In both the DataWindow painter and the Output view in the
Database painter, you can save retrieved data in HTML format. To do this in
the DataWindow painter, select File>Save Rows As from the menu. In the
Database painter, open the Output view, then select Rows>Save Rows As from
the menu. In both painters, specify HTML Table as the format for the file.
In your application code You can obtain an HTML string of the
DataWindow presentation and data from the Data.HTMLTable property. You
can save the string in a variable and modify the HTML with string
manipulation operations. In PowerBuilder, you can also use the FileOpen and
FileWrite functions to save the HTML to a file.
The HTMLTable property has its own properties which you can set to control
the HTML attributes and style sheet associated with the Table HTML element.
PowerBuilder only In PowerBuilder, there are two more techniques
available to you. You can:
• Call the SaveAs method to save the contents of a DataWindow directly to
a file on disk. To save the data in HTML format, you need to specify
HTMLTable as the file type when you call SaveAs.
• Call the GenerateHTMLForm method to create an HTML form from data
contained in a DataWindow control or DataStore whose DataWindow
object uses the Freeform or Tabular presentation style.
Choosing presentation Some DataWindow presentation styles translate better into HTML than others.
styles The following presentation styles produce good results:
Tabular
Group
TreeView
Freeform
Crosstab
Grid
The Composite, Graph, RichText, and OLE 2.0 presentation styles produce
HTML output that is based on the result only, and not on the presentation style.
DataWindows that have overlapping controls might not produce the expected
results. Nested reports are ignored; they are not included in the generated
HTML.
Example This example illustrates how you might use DataWindow-generated HTML in
an application.
The key line of code gets the HTML from the DataWindow by referring to its
HTMLTable property. Variations for each environment are shown below. In
PowerBuilder, you can use the Describe method or a property expression. The
Web ActiveX has to use Describe.
PowerBuilder
ls_htmlstring = dw_1.Object.DataWindow.Data.HTMLTable
Web ActiveX
str_html = dw_1.Describe("DataWindow.Data.HTMLTable");
The complete example that follows is implemented in PowerBuilder.
The window below displays customer data in a tabular DataWindow object. By
pressing the Browse button, the user can translate the contents of the
DataWindow object into HTML format and invoke a Web browser to view the
HTML output. By pressing the Select Browser button, the user can tell the
application which Web browser to use:
58 PowerBuilder Classic
CHAPTER 2 Using DataWindow Objects
Script for the Select Browser button The script for the Select Browser
button displays a dialog box where the user can select an executable file for a
Web browser. The path to the executable is stored in is_Browser, which is an
instance variable defined on the window:
String ls_BrowserName
Integer li_Result
IF li_Result = -1 THEN
MessageBox("No Browser", "No Browser selected")
END IF
Script for the Browse button The script for the Browse button creates an
HTML string from the data in the DataWindow by assigning the
Data.HTMLTable property to a string variable. After constructing the HTML
string, the script adds a header to the HTML string. Then the script saves the
HTML to a file and runs the Web browser to display the output.
String ls_HTML, ls_FileName, ls_BrowserPath
Integer li_FileNumber, li_Bytes,
Integer li_RunResult, li_Result
Controlling display
You control table display and style sheet usage through the
HTMLTable.GenerateCSS property. The HTMLTable.GenerateCSS property
controls the downward compatibility of the HTML found in the HTMLTable
property. If HTMLTable.GenerateCSS is FALSE, formatting (style sheet
references) is not referenced in the HTMLTable property; if it is TRUE, the
HTMLTable property includes elements that reference the cascading style
sheet saved in HTML.StyleSheet.
60 PowerBuilder Classic
CHAPTER 2 Using DataWindow Objects
This screen shows an HTML table in a browser using custom display features:
62 PowerBuilder Classic
CHAPTER 2 Using DataWindow Objects
Availability
The SaveAs method is not available for the Web control for ActiveX.
.3{COLOR:#000000;BACKGROUND:#ffffff;FONT-
STYLE:normal;FONT-WEIGHT:normal;FONT:8pt "MS Sans
Serif", sans-serif;TEXT-DECORATION:none}
.3{COLOR:#000000;BACKGROUND:#ffffff;FONT-
STYLE:normal;FONT-WEIGHT:normal;FONT:8pt "MS Sans
Serif", sans-serif;TEXT-DECORATION:none}
-->
</STYLE>
64 PowerBuilder Classic
CHAPTER 2 Using DataWindow Objects
Edit style conversion The GenerateHTMLForm method converts column edit styles into the
appropriate HTML elements:
Table 2-12: HTML elements generated for column edit styles
Column edit style HTML element
CheckBox Input element specifying TYPE=CHECKBOX
DropDownDataWindow Select element with a single Option element
DropDownListBox Select element with one Option element for each item
in the DropDownListBox
Edit Input element specifying TYPE=TEXT
RadioButton Input element specifying TYPE=RADIO
Generating syntax To generate HTML form syntax, you call the GenerateHTMLForm method:
instancename.GenerateHTMLForm ( syntax, style, action { , startrow,
endrow, startcolumn, endcolumn { , buffer } } )
The method places the Form element syntax into the syntax argument and the
HTML style sheet into the style argument, both of which are passed by
reference.
<P><FONT CLASS=2>Status:</FONT>
<INPUT TYPE="RADIO" NAME="status_1" CHECKED CLASS=5
><FONT CLASS=5 >Active
<P>
<INPUT TYPE="RADIO" NAME="status_1" CLASS=5 >
<FONT CLASS=5 >Terminated
<P>
<INPUT TYPE="RADIO" NAME="status_1" CLASS=5 >
<FONT CLASS=5 >On Leave
<P>
<P>
<BR>
<INPUT TYPE=SUBMIT NAME=SAMPLE VALUE="OK">
</FORM>
66 PowerBuilder Classic
CHAPTER 2 Using DataWindow Objects
The ls_stylesheet variable from the previous example contains a Style element,
an example of which is shown below:
<STYLE TYPE="text/css">
<!--
.2{COLOR:#000000;BACKGROUND:#ffffff;FONT-
STYLE:normal;FONT-WEIGHT:normal;FONT:9pt "Arial",
sans-serif;TEXT-DECORATION:none}
.3{COLOR:#000000;BACKGROUND:#ffffff;FONT-
STYLE:normal;FONT-WEIGHT:normal;FONT:8pt "MS Sans
Serif", sans-serif;TEXT-DECORATION:none}
.5{COLOR:#000000;BACKGROUND:#ffffff;FONT-
STYLE:normal;FONT-WEIGHT:normal;FONT:8pt "MS Sans
Serif", sans-serif;TEXT-DECORATION:none}
-->
</STYLE>
Creating an HTML To use the syntax and style sheet returned by the GenerateHTMLForm method,
page you must write code to merge them into an HTML page. A complete HTML
page requires <HTML> and <BODY> elements to contain the style sheet and
syntax.
One way to do this is to create a global or object function that returns a
complete HTML page, taking as arguments the Form and Style elements
generated by the GenerateHTMLForm method. Such a function might contain
the following code:
// Function Name: of_MakeHTMLPage
// Arguments: String as_syntax, String as_style
// Returns: String
//***********************************
String ls_html
IF as_syntax = "" THEN
RETURN ""
END IF
ls_html = "<HTML>"
ls_html += as_style
ls_html += "<BODY>"
ls_html += "<H1>Employee Information</H1>"
ls_html += as_syntax
ls_html += "</BODY></HTML>"
RETURN ls_html
68 PowerBuilder Classic
CH A PTE R 3 Dynamically Changing
DataWindow Objects
About this chapter This chapter describes how to modify and create DataWindow objects
during execution.
Contents
Topic Page
About dynamic DataWindow processing 69
Modifying a DataWindow object 70
Creating a DataWindow object 71
Providing query ability to users 74
Providing Help buttons 79
Reusing a DataWindow object 79
Using DWSyntax 80
What you can do Using this dynamic capability, you can allow users to change the appearance
of the DataWindow object (for example, change the color and font of the text)
or create ad hoc queries by redefining the data source. After you create a
dynamic DataWindow object and the user is satisfied with the way it looks and
the data that is displayed, the user can print the contents as a report.
70 PowerBuilder Classic
CHAPTER 3 Dynamically Changing DataWindow Objects
Adding and deleting You can also use the Modify method to:
controls within the
DataWindow object • Create new objects in a DataWindow object
This lets you add DataWindow controls (such as text, bitmaps, and graphic
controls) dynamically to the DataWindow object.
For how to get a good idea of the correct Create syntax, see “Specifying
the DataWindow object syntax” on page 72.
• Destroy controls in a DataWindow object
This lets you dynamically remove controls you no longer need.
PowerBuilder tool for PowerBuilder only Included with PowerBuilder is DW Syntax, a tool that
easier coding of makes it easy to build the correct syntax for property expressions, Describe,
DataWindow syntax
Modify, and SyntaxFromSQL statements. You click buttons to specify which
properties of a DataWindow you want to use, and DW Syntax automatically
builds the appropriate syntax, which you can copy and paste into your
application code.
See Using DWSyntax for more information.
Viewing DataWindow PowerBuilder only You can use the PowerBuilder Browser to get a list of
object properties in DataWindow properties: on the DataWindow tab, select a DataWindow object
PowerBuilder
in the left pane and Properties in the right pane. To see the properties for a
control in a DataWindow object, double-click the DataWindow object name,
then select the control.
DataWindow painter
You should use the techniques described here for creating a DataWindow from
syntax only if you cannot accomplish what you need to in the DataWindow
painter. The usual way of creating DataWindow objects is to use the
DataWindow painter.
To learn about creating DataWindow objects in the DataWindow painter, see
the PowerBuilder Users Guide.
You use the Create method to create a DataWindow object dynamically during
execution. Create generates a DataWindow object using source code that you
specify. It replaces the DataWindow object currently in the specified
DataWindow control with the new DataWindow object.
Specifying the There are several ways to specify or generate the syntax required for the Create
DataWindow object method. Not all the techniques are available in all environments.
syntax
In PowerBuilder, you can:
• Use the SyntaxFromSQL method of the transaction object
• Use the LibraryExport PowerScript function
In all environments, you can:
• Use the DataWindow.Syntax property of the DataWindow object
• Create the syntax yourself
Using SyntaxFromSQL You are likely to use SyntaxFromSQL to create the
syntax for most dynamic DataWindow objects. If you use SyntaxFromSQL, all
you have to do is provide the SELECT statement and the presentation style.
In PowerBuilder, SyntaxFromSQL is a method of the transaction object. The
transaction object must be connected when you call the method.
72 PowerBuilder Classic
CHAPTER 3 Dynamically Changing DataWindow Objects
The DataWindow source code syntax that you need to supply to the Create
method can be very complex. To see examples of DataWindow object syntax,
go to the Library painter and export a DataWindow object to a text file, then
view the file in a text editor.
For more information on Create and Describe methods as well as DataWindow
object properties and syntax, see the DataWindow Reference.
Limitations
You cannot use query mode in a DataWindow object that contains the UNION
keyword or nested SELECT statements.
74 PowerBuilder Classic
CHAPTER 3 Dynamically Changing DataWindow Objects
Next, query mode is turned on. The retrieved data disappears and users are
presented with empty rows where they can specify selection criteria. Here the
user wants to retrieve rows where Quarter = Q1 and Units > 15:
Next, Retrieve is called and query mode is turned off. The DataWindow control
adds the criteria to the SELECT statement, retrieves the three rows that meet
the criteria, and displays them to the user:
You can turn query mode back on, allow the user to revise the selection criteria,
and retrieve again.
76 PowerBuilder Classic
CHAPTER 3 Dynamically Changing DataWindow Objects
How the criteria affect Criteria specified by the user are added to the SELECT statement that
the SELECT originally defined the DataWindow object.
statement
For example, if the original SELECT statement was:
SELECT printer.rep, printer.quarter, printer.product,
printer.units
FROM printer
WHERE printer.units < 70
and the following criteria are specified:
Sorting in query mode You can allow users to sort rows in a DataWindow while specifying criteria in
query mode using the QuerySort property. The following statement makes the
first row in the DataWindow dedicated to sort criteria (just as in Quick Select
in the DataWindow wizard).
In PowerBuilder:
dw_1.Modify("datawindow.querysort=yes")
In JavaScript:
dw_1.Modify("datawindow.querysort=yes");
Overriding column By default, query mode uses edit styles and other definitions of the column
properties during (such as the number of allowable characters). If you want to override these
query mode
properties during query mode and provide a standard edit control for the
column, use the Criteria.Override_Edit property for each column.
In PowerBuilder:
dw_1.Modify("mycolumn.criteria.override_edit=yes")
In JavaScript:
dw_1.Modify("mycolumn.criteria.override_edit=yes");
You can also specify this in the DataWindow painter by checking Override Edit
on the General property page for the column. With properties overridden for
criteria, users can specify any number of characters in a cell (they are not
constrained by the number of characters allowed in the column in the
database).
Forcing users to You can force users to specify criteria for a column during query mode by
specify criteria for a coding the following:
column
In PowerBuilder:
dw_1.Modify("mycolumn.criteria.required=yes")
In JavaScript:
dw_1.Modify("mycolumn.criteria.required=yes");
You can also specify this in the DataWindow painter by checking Equality
Required on the General property page for the column. Doing this ensures that
the user specifies criteria for the column and that the criteria for the column use
= rather than other operators, such as < or >=.
78 PowerBuilder Classic
CHAPTER 3 Dynamically Changing DataWindow Objects
You can reuse a DataWindow object by retrieving its syntax from the library it
is stored in, then using the syntax to create a DataWindow object dynamically
in a DataWindow control.
Here is a typical way to accomplish this in an application. Use:
• The LibraryDirectory function to obtain a list of DataWindow objects and
other library entries in the current library
• A DropDownListBox to list the DataWindow objects in the library and
then allow the user to select a DataWindow from the list
• The LibraryExport function to export the selected DataWindow object
syntax into a string variable
• The Create method to use the DataWindow syntax to create the
DataWindow object in the specified DataWindow control
• The Describe method to get the current DataWindow object syntax—for
example:
string dwSyntax
dwSyntax = dw_1.Describe("datawindow.syntax")
• The Modify method to allow the user to modify the DataWindow object
• The LibraryImport function to save the user-modified DataWindow object
in a library
Using DWSyntax
The DWSyntax tool, available on the Tool tab in the New dialog box, makes it
easy to specify dot notation, Describe, Modify, and SyntaxFromSQL
statements.
To access DWSyntax, select File>New and select the Tool tab. Select the type
of statement you want to create from the Syntax menu:
• Describe
Select an object type from the Object dropdown listbox. In the Attributes
listbox, select the property you want to describe. The bottom of the
window displays Describe and dot notation statements.
• Modify
• Attributes
Select an object type and the property you want to modify. The bottom
of the window displays Modify and dot notation statements.
• Create
Select the object type that you want to create. The bottom of the
window displays a Modify statement.
• Destroy
Select the object type that you want to destroy. The bottom of the
window displays a Modify statement.
• SyntaxFromSQL
On each tab, select the properties you want to include in the arguments for
the SyntaxFromSQL function. Notice that you can select multiple tabs and
multiple properties per object for SyntaxFromSQL. When you have
finished selecting properties, click Build Syntax to display the
SyntaxFromSQL function at the bottom of the window.
• Tips on the syntax generated by DWSyntax
80 PowerBuilder Classic
CHAPTER 3 Dynamically Changing DataWindow Objects
Describe
Reports the values of properties of a DataWindow object and objects within the
DataWindow object. Each column and graphic object in the DataWindow has
a set of properties. You specify one or more properties as a string and Describe
returns the values of the properties.
Modify
Modifies a DataWindow object by applying specifications, specified as a list
of instructions, that change the DataWindow object's definition. You can
change appearance, behavior, and database information for the DataWindow
object by changing the values of properties. You can add and remove objects
from the DataWindow object by providing specifications for the objects.
Create
Creates a DataWindow object using DataWindow source code and puts that
object in the specified DataWindow control. This “dynamic" DataWindow
object does not become a permanent part of the application source library.
Destroy
Deletes a DataWindow object. This dynamic DataWindow object change does
not become a permanent part of the application source library.
SyntaxFromSQL
Generates DataWindow source code based on a SQL SELECT statement and
Style. A full presentation string has the format:
"Style(Type= value property=value ...)
DataWindow(property = value...)
Column(property = value...)
Group(groupby_col1 groupby_col2 ... property...)
Text(property = value...)
Title('titlestring')"
82 PowerBuilder Classic
CH A PTE R 4 Using DataStore Objects
About this chapter This chapter describes how to use DataStore objects in an application.
Contents
Topic Page
About DataStores 83
Working with a DataStore 86
Using a custom DataStore object 86
Accessing and manipulating data in a DataStore 88
Sharing information 90
Before you begin This chapter assumes you know how to build DataWindow objects in the
DataWindow painter, as described in the PowerBuilder Users Guide.
About DataStores
A DataStore is a nonvisual DataWindow control. DataStores act just like
DataWindow controls except that they do not have many of the visual
characteristics associated with DataWindow controls. Like a DataWindow
control, a DataStore has a DataWindow object associated with it.
Availability
In PowerBuilder, a DataStore is a nonvisual object. The Web control for
ActiveX does not support DataStores.
The Web DataWindow server component uses an instance of a custom
DataStore object to hold the DataWindow definition and data. See “Using
a custom DataStore object” on page 86.
When to use a DataStores are useful when you need to access data but do not need the visual
DataStore presentation of a DataWindow control. DataStores allow you to:
• Perform background processing against the database without
having to hide DataWindow controls in a window
When a window shows multiple views of the same information, you can
use a DataStore to hold the result set. By sharing data between a DataStore
and one or more DataWindow controls, you can provide different views of
the same information without retrieving the data more than once.
• Manipulate table rows without using embedded SQL statements
In places where an application calls for row manipulation without the need
for display, you can use DataStores to handle the database processing
instead of embedded SQL statements. DataStores typically perform faster
at execution time than embedded SQL statements. Also, because the SQL
is stored with the DataWindow object when you use a DataStore, you can
easily reuse the SQL.
• Perform database access on an application server
84 PowerBuilder Classic
CHAPTER 4 Using DataStore Objects
Prompting for When you are working with DataStores, you cannot use functionality that
information causes a dialog box to display to prompt the user for more information. Here
are some examples of ways to overcome this restriction:
SetSort and SetFilter You can use the SetSort and SetFilter methods to
specify sort and filter criteria for a DataStore object, just as you would with a
DataWindow control. However, when you are working with a DataWindow
control, if you pass a NULL value to either SetSort or SetFilter, the
DataWindow prompts the user to enter information. When you are working
with a DataStore, you must supply a valid format when you call the method.
Moreover, you must supply a valid format when you share data between a
DataStore and a DataWindow control; you cannot pass the NULL value to the
DataWindow control rather than the DataStore.
Prompt for Criteria You can define your DataWindow objects so that the
user is prompted for retrieval criteria before the DataWindow retrieves data.
This feature works with DataWindow controls only. It is not supported with
DataStores.
SaveAs When you use the SaveAs method with a DataWindow object, you
can pass an empty string for the filename argument so that the user is prompted
for a file name to save to. If you are working with a DataStore, you must supply
the filename argument.
Prompt for Printing For DataWindow controls, you can specify that a print
setup dialog box display at execution time, either by checking the Prompt
Before Printing check box on the DataWindow object’s Print Specifications
property page, or by setting the DataWindow object’s Print.Prompt property in
a script. This is not supported with DataStores.
Retrieval arguments If you call the Retrieve method for a DataWindow
control that has a DataWindow object that expects an argument, but do not
specify the argument in the method call, the DataWindow prompts the user for
a retrieval argument. This behavior is not supported with DataStores.
DataStores have Many of the methods and events that pertain to the visual presentation of the
some visual methods data in a DataWindow do not apply to DataStores. However, because you can
print the contents of a DataStore and also import data into a DataStore,
DataStores have some visually oriented events and methods. For example,
DataStores support the SetBorderStyle and SetSeriesStyle methods so that you
can control the presentation of the data at print time. Similarly, DataStores
support the ItemError event, because data imported from a string or file that
does not pass the validation rules for a column triggers this event.
For a complete list of the methods and events for the DataStore object and
information about each method, see the DataWindow Reference.
DataStores require no Unlike DataWindow controls, DataStores do not require any visual overhead
visual overhead in a window. Using a DataStore is therefore more efficient than hiding a
DataWindow control in a window.
86 PowerBuilder Classic
CHAPTER 4 Using DataStore Objects
Notice that this script does not assign the DataWindow object to the
DataStore. This is because the DataWindow object is specified in the user
object definition.
88 PowerBuilder Classic
CHAPTER 4 Using DataStore Objects
About the DataStore Like a DataWindow control, a DataStore uses three buffers to manage data:
buffers
Table 4-1: DataStore buffers
Buffer Contents
Primary Data that has not been deleted or filtered out (that is, the rows that are
viewable)
Filter Data that was filtered out
Delete Data that was deleted by the user or in a script
About the Edit control The DataStore object has an Edit control. However, the Edit control for a
DataStore behaves in a slightly different manner from the Edit control for a
DataWindow. The Edit control for a DataWindow keeps track of text entered
by the user in the current cell (row and column); the Edit control for a
DataStore is used to manage data imported from an external source, such as the
clipboard or a file. The text in the Edit control for a DataStore cannot be
changed directly by the user. It must be manipulated programmatically.
Programming with There are many methods for manipulating DataStore objects. These are some
DataStores of the more commonly used:
Table 4-2: Common methods in DataStore objects
Method Purpose
DeleteRow Deletes the specified row from the DataStore.
Filter Filters rows in the DataStore based on the current filter criteria.
InsertRow Inserts a new row.
Print Sends the contents of the DataStore to the current printer.
Reset Clears all rows in the DataStore.
Retrieve Retrieves rows from the database.
RowsCopy Copies rows from one DataStore to another DataStore or
DataWindow control.
RowsMove Moves rows from one DataStore to another DataStore or
DataWindow control.
ShareData Shares data among different DataStores or DataWindow controls.
See “Sharing information” on page 90.
Sort Sorts the rows of the DataStore based on the current sort criteria.
Update Sends to the database all inserts, changes, and deletions that have
been made since the last Update.
Sharing information
The ShareData method allows you to share a result set among two different
DataStores or DataWindow controls. When you share information, you remove
the need to retrieve the same data multiple times.
The ShareData method shares data retrieved by one DataWindow control or
DataStore (called the primary DataWindow) with another DataWindow control
or DataStore (the secondary DataWindow).
Result set When you share data, the result set descriptions for the DataWindow objects
descriptions must must be the same. However, the SELECT statements can be different. For
match
example, you could use the ShareData method to share data between
DataWindow objects that have the following SELECT statements (because the
result set descriptions are the same):
SELECT dept_id from dept
90 PowerBuilder Classic
CHAPTER 4 Using DataStore Objects
You can also share data between two DataWindow objects where the source of
one is a database and the source of the other is external. As long as the lists of
columns and their datatypes match, you can share the data.
What is shared? When you use the ShareData method, the following information is shared:
Primary buffer
Delete buffer
Filter buffer
Sort order
ShareData does not share the formatting characteristics of the DataWindow
objects. That means you can use ShareData to apply different presentations to
the same result set.
When you alter the If you perform an operation that affects the result set for either the primary or
result set the secondary DataWindow, the change affects both of the objects sharing the
data. Operations that alter the buffers or the sort order of the secondary
DataWindows are rerouted to the primary DataWindow. For example, if you
call the Update method for the secondary DataWindow, the update operation is
applied to the primary DataWindow also.
Turning off sharing To turn off the sharing of data, you use the ShareDataOff method. When you
data call ShareDataOff for a primary DataWindow, any secondary DataWindows
are disassociated and no longer contain data. When you call ShareDataOff for
a secondary DataWindow, that DataWindow no longer contains data, but the
primary DataWindow and other secondary DataWindows are not affected.
In most cases you do not need to turn off sharing, because the sharing of data
is turned off automatically when a window is closed and any DataWindow
controls (or DataStores) associated with the window are destroyed.
Crosstabs You cannot share data with a DataWindow object that has the Crosstab
presentation style.
92 PowerBuilder Classic
CHAPTER 4 Using DataStore Objects
Code for the Update Code for the cb_update button applies the update operation to the
button dw_employees DataWindow control.
This code is for the Update button’s Clicked event:
IF dw_employees.Update() = 1 THEN
COMMIT using SQLCA;
MessageBox("Save","Save succeeded")
ELSE
ROLLBACK using SQLCA;
MessageBox("Save","Save failed")
END IF
Code for the Print The Clicked event of the cb_print button prints the contents of ids_datastore.
button Because the DataWindow object for the DataStore is d_employees, the printed
output uses the presentation specified for this object.
This code is for the Print button’s Clicked event:
ids_datastore.Print()
When the window or When the window closes, the DataStore gets destroyed.
form closes
This code is for the window’s Close event:
destroy ids_datastore
When the Employee Salary Information radio button is selected, the window
displays a graph that shows employee salary information by department:
This window has one DataWindow control called dw_display. It uses two
DataStores to process data retrieved from the database. The first DataStore
(ids_emp_list) shares its result set with the second DataStore (ids_emp_graph).
The DataWindow objects associated with the two DataStores have the same
result set description.
When the window or When the window or form opens, the application sets the mouse pointer to the
form opens hourglass shape. Then the code creates the two DataStores and sets the
DataWindow objects for the DataStores. Next the code sets the transaction
object for ids_emp_list and issues a Retrieve method to retrieve some data.
After retrieving data, the code shares the result set for ids_emp_list with
ids_emp_graph. The final statement triggers the Clicked event for the
Employee List radio button.
This code is for the window’s Open event:
SetPointer(HourGlass!)
ids_emp_list = Create DataStore
ids_emp_graph = Create DataStore
ids_emp_list.DataObject = "d_emp_list"
ids_emp_graph.DataObject = "d_emp_graph"
ids_emp_list.SetTransObject(sqlca)
ids_emp_list.Retrieve()
ids_emp_list.ShareData(ids_emp_graph)
rb_emp_list.EVENT Clicked()
94 PowerBuilder Classic
CHAPTER 4 Using DataStore Objects
Code for the The code for the Employee List radio button (called rb_emp_list) sets the
Employee List radio DataWindow object for the DataWindow control to be the same as the
button
DataWindow object for ids_emp_list. Then the script displays the data by
sharing the result set for the ids_emp_list DataStore with the DataWindow
control.
This code is for the Employee List radio button’s Clicked event:
dw_display.DataObject = ids_emp_list.DataObject
ids_emp_list.ShareData(dw_display)
Code for the The code for the Employee Salary Information radio button (called rb_graph)
Employee Salary is similar to the code for the List radio button. It sets the DataWindow object
Information radio
button for the DataWindow control to be the same as the DataWindow object for
ids_emp_graph. Then it displays the data by sharing the result set for the
ids_emp_graph DataStore with the DataWindow control.
This code is for the Employee Salary Information radio button’s Clicked event:
dw_display.DataObject = ids_emp_graph.DataObject
ids_emp_graph.ShareData(dw_display)
When the window or When the window closes, the DataStores get destroyed.
form closes
This code is for the window’s Close event:
Destroy ids_emp_list
Destroy ids_emp_graph
96 PowerBuilder Classic
CH A PTE R 5 Manipulating Graphs
About this chapter This chapter describes how to write code that allows you to access and
change a graph in your application at execution time.
Contents
Topic Page
Using graphs 97
Modifying graph properties 98
Accessing data properties 101
Using point and click 108
Using graphs
Supported environments
PowerBuilder and Web ActiveX Graphs are supported. Because you
can print DataStores, PowerBuilder provides some events and functions
for DataStores that pertain to the visual presentation of the data. However,
graph functions such as CategoryCount, CategoryName, GetData,
SeriesCount, and so forth depend on the visual graph control, which is not
created for a DataStore. These functions return an error value or an empty
string when used with DataStore objects.
Web DataWindow Graphs are not supported. If you use a DataWindow
object that includes graphs, the graphs are ignored. If you use a
DataWindow object with the Graph presentation style, nothing displays.
Working with graphs The following sections describe how you can access (and optionally modify) a
in your code graph by addressing its properties in code at execution time. There are two
kinds of graph properties:
• Properties of the graph definition itself These properties are initially
set in the DataWindow painter when you create a graph. They include a
graph’s type, title, axis labels, whether axes have major divisions, and so
on. For 3D graphs, this includes the Render 3D property that uses
transparency rather than overlays to enhance a graph’s appearence and
give it a more sophisticated look.
• Properties of the data These properties are relevant only at execution
time, when data has been loaded into the graph. They include the number
of series in a graph (series are created at execution time), colors of bars or
columns for a series, whether the series is an overlay, text that identifies
the categories (categories are created at execution time), and so on.
You can change these graph properties at execution time by assigning values to
the graph’s properties in code.
98 PowerBuilder Classic
CHAPTER 5 Manipulating Graphs
Property expressions PowerBuilder You can modify properties using property expressions. For
example, to change the type of the graph gr_emp to Column, you could code:
dw_empinfo.Object.gr_emp.GraphType = ColGraph!
To change the title of the graph at execution time, you could code:
dw_empinfo.Object.gr_emp.Title = "New title"
Modify method In any environment , you can use the Modify method to reference parts of a
graph.
Example for PowerBuilder For example, to change the title of graph gr_emp
in DataWindow control dw_empinfo, you could code:
dw_empinfo.Modify("gr_emp.Title = 'New title'")
Example for Web ActiveX This example changes the label text for the Value
axis of graph gr_emp in the DataWindow control dw_empinfo:
dw_empinfo.Modify("gr_emp.Values.Label = 'New label'");
For a complete list of graph properties, see the DataWindow Reference.
PowerBuilder These methods get information about the data and its display.
For several of them, an argument is passed by reference to hold the requested
information:
Table 5-1: Common methods for graph DataWindows in PowerBuilder
Method Information provided
CategoryCount The number of categories in a graph
CategoryName The name of a category, given its number
DataCount The number of data points in a series
FindCategory The number of a category, given its name
FindSeries The number of a series, given its name
GetData The value of a data point, given its series and position
(superseded by GetDataValue, which is more flexible)
GetDataLabelling The display setting for the data label at a given data point
in a DirectX 3D graph
GetDataPieExplode The percentage at which a pie slice is exploded
GetDataStyle The color, fill pattern, or other visual property of a
specified data point
GetDataTransparency The transparency percentage of a data point in a DirectX
3D graph
GetDataValue The value of a data point, given its series and position
GetSeriesLabelling The display setting for the series label for a given series in
a DirectX 3D graph
GetSeriesStyle The color, fill pattern, or other visual property of a
specified series
GetSeriesTransparency The transparency percentage of a series in a DirectX 3D
graph
ObjectAtPointer The graph element the mouse was positioned over when it
was clicked
SeriesCount The number of series in a graph
SeriesName The name of a series, given its number
Web ActiveX These methods get information about the data and its display.
There are additional helper methods available whenever the equivalent
PowerBuilder method uses an argument passed by reference. These helper
methods are identified in the second column of the following table (and are
described in the DataWindow Reference):
Web ActiveX You can save an image of the graph on the clipboard, but you
cannot save data in a file. Writing to the file system is a security violation for
an ActiveX control:
Table 5-4: Web Active X method for saving data from a graph
Method Action
Clipboard Copies a bitmap image of the specified graph to the clipboard
The following statement changes the foreground (fill) color to red of the
second data point in the Stellar series in the graph gr_sale in a window. The
statement can be in a script for any event:
int SeriesNum
// Get the number of the series.
SeriesNum = gr_sale.FindSeries("Stellar")
You should call ObjectAtPointer in the first statement of the event’s code.
Using ObjectAtPointer ObjectAtPointer works differently in PowerBuilder and the Web ActiveX.
PowerBuilder ObjectAtPointer has this syntax:
DataWindowName.ObjectAtPointer ( "graphName", seriesNumber,
dataNumber )
Example Assume there is a graph named gr_sales in the DataWindow control dw_sales.
The following code for the control’s MouseDown event displays a message
box:
• If the user clicks on a series (that is, if ObjectAtPointer returns 1), the
message box shows the name of the series clicked on. The example uses
the method GetSeriesName to get the series name, given the series number
stored by ObjectAtPointer.
• If the user clicks on a data point (that is, if ObjectAtPointer returns 2), the
message box lists the name of the series and the value clicked on. The
example uses GetDataNumber to get the data’s value, given the data’s
series and data point number.
PowerBuilder This code is for the Clicked event:
int SeriesNum, DataNum
double Value
grObjectType ObjectType
string SeriesName, ValueAsString
string GraphName
GraphName = "gr_sale"
GraphName = "gr_sales";
ObjectType =
dw_sales.GrObjectAtPointer(GraphName);
if (ObjectType == 1) {
SeriesName =
dw_sales.GetSeriesName(GraphName,
SeriesNum);
alert(dw_sales.GetSeriesName(GraphName,
SeriesNum) +" value is " + Value);
}
}
}
About this chapter This chapter describes how to use the Web DataWindow in data-based
Web applications. Particular focus is given to the XML Web DataWindow
because it can provide the best performance and you can customize its
generation by applying a custom template to the default generation.
Contents
Topic Page
What the Web DataWindow is 115
Using the XML Web DataWindow 121
Designing DataWindow objects for the Web DataWindow 128
Setting up database connections 149
Deploying DataWindow objects to the component server 153
Writing client-side scripts 155
Customizing Web DataWindow generation 157
JavaScript keywords
You cannot use JavaScript reserved words to name fields or bands in a
DataWindow control that you deploy to the Web. The list of reserved
words is available on the Sun Microsystems Web site at
http://docs.sun.com/source/816-6410-10/keywords.htm.
Web DataWindow use No matter what type of Web DataWindow you want to use, the way you use it
is the same. For specific information about using the XML Web DataWindow,
see “Using the XML Web DataWindow” on page 121.
What happens when a Figure 6-1 shows you graphically (in eight steps) what happens when a user
user requests a page accesses a Web page containing an XHTML or HTML Web DataWindow.
Figure 6-1: How the Web DataWindow works
The numbers 1 through 8 in the figure correspond to the events that occur after
you develop and deploy a Web DataWindow and a user accesses a page
containing the Web DataWindow:
1 In a Web browser, a user requests the URL for a page.
2 The Web server passes the request to the page server, which locates the
template for the requested page and executes server-side scripts in the
template.
3 The server-side scripts connect to the (transaction) server component,
passing it information about the DataWindow and database connection.
4 Methods on the server component retrieve data required for the
DataWindow from the database and translate the DataWindow definition,
data, and state into JavaScript and XHTML or HTML.
5 The server component returns the JavaScript and XHTML or HTML and
to the page server.
6 The page server replaces the server-side script in the requested Web page
with the generated JavaScript and XHTML or HTML and returns the page
to the Web browser through the Web server.
7 The user interacts with the DataWindow—for example, requesting the
next page or updating the data.
8 The Web server passes the URL with added action parameters to the page
server, and the cycle begins again.
The generic component has methods that you call in your Web page template
to instantiate and configure the component. The generic component also
provides most of the methods available on the PowerBuilder DataWindow
control. You should probably use the generic component when you are getting
started with the Web DataWindow. Later you might want to build and deploy
a custom component that uses the methods of the generic EAServer component
interface or that uses only the methods you design for the component. For
information, see “Using a custom server component” on page 189.
Types of server The following table describes all the types of Web DataWindow server
components and components and their supported platforms:
platforms
Table 6-1: Web DataWindow server components and platforms
Web
DataWindow
server Platform
component (server component name) Description
Generic EAServer Prebuilt EAServer
(DataWindow::HTMLGenerator125) component. No generation
or compiling of stubs
required.
Container EAServer Deploy with Web DW
(can include (PackageName::ComponentName Container project wizard.
multiple using generic Increases performance by
DataWindow DataWindow::HTMLGenerator125 reducing calls to server. No
definitions) interface) generation or compiling of
stubs required.
Custom EAServer Use to increase flexibility
(hybrid) (PackageName::ComponentName of generic component. Can
using generic build and deploy with PB
DataWindow::HTMLGenerator125 object or project wizard.
interface) Generic methods remain
available.
Custom EAServer Potentially best for
(user- (PackageName::ComponentName) performance and
designed) scalability. Can use to
avoid downloads of
unneeded generic methods
to client.
Web DataWindow Embedding client-side scripts The Web DataWindow client control is the
client control JavaScript plus XML, XSLT, and CSS; the JavaScript plus XHTML; or the
JavaScript plus HTML that is generated by the server component and
embedded in the page returned to the Web client. Client-side scripts that you
add to your Web page template and wrap in SCRIPT tags are embedded as
JavaScript in the client control.
JavaScript caching Some features available on the client control are
optional: events, methods, data update and validation, and display formatting
for newly entered data. The size of the generated JavaScript increases as you
add more client-side functionality. You can cache client-side methods in
JavaScript files on your Web server to reduce the size of the markup generated
for Web DataWindow pages and, if the browser is configured to use cached
files, improve the performance on the client machine.
For information about enabling JavaScript caching, see “Using JavaScript
caching for Web DataWindow methods” on page 140. You can find additional
information about client-side caching, HTMLGen properties, and other
generation properties in the DataWindow Reference.
Using client-side events Events that are triggered on the client control and
several of the client control methods do not require the server component to
reload the page, so processing on the client is typically much faster than
processing performed on the server.
For more information about enabling features on the client, see “Web
DataWindow properties” on page 131 and “Controlling what is generated” on
page 182. For more about writing scripts, see “Writing client-side scripts” on
page 155.
For complete documentation of the events and methods available on the server
component and the client control, see the DataWindow Reference or the
PowerBuilder online Help.
Using the HTML Web DataWindow and the XHTML Web DataWindow
The process for using the HTML Web DataWindow and the XHTML Web
DataWindow is similar to the process of using the XML Web DataWindow.
The only difference is in selecting the type of Web Generation you specify and
and the DataWindow object properties you set.
XML documents separate the content from the presentation, and they can be
transformed (using XSLT, the Extensible Stylesheet Language for
Transformations) into a variety of presentation types such as:
• An HTML page that includes <td>12345</td>
• A PDF file that includes zip code information
• A display of zip code information in wireless phones or pagers
With XSLT, you can transform XML documents into other documents, which
are often XML documents themselves. For example, Web pages created in
XHTML (an XML-compliant version of HTML) are XML documents, and you
can use XSLT to transform any XML document into a styled XHTML Web
page for display in a browser.
A cascading style sheet (CSS) allows you to add style rules to the elements of
a document that define how the content of the elements should be rendered.
Using a CSS enables you to separate the contents of an HTML, XHTML, or
XML document from its visual presentation. However, XSLT moves you
beyond CSS because XSLT offers you complete flexibility to change the layout
of content. XSLT also allows you to define rules that not only alter the design,
but also add, change, or remove elements of the content if appropriate.
For an overview of XML, see the first section of the chapter on exporting and
importing XML in the PowerBuilder Users Guide. For detailed information
about XML and XSLT, see the O’Reilly and Associates, Inc. Learning XML
and XSLT books.
Which type of Web DataWindow to use? The XML and XHTML Web
DataWindow expand on the functionality provided by the HTML Web
DataWindow. The following table shows you when you should use the XML
or XHTML Web DataWindow and when you should use the HTML Web
DataWindow:
Table 6-2: Features of Web DataWindow rendering formats
Feature XML XHTML HTML
Web pages conform to industry Yes Yes No
standards
Pages can be customized using Yes Yes No
an XHTML export template
XSLT stylesheets are cached Yes No No
CSS stylesheets are cached Yes Yes No
Common JavaScript files can be Yes Yes Yes
cached
Most efficient handling of large Yes No No
amounts of paged data
Callback mechanism for paging Yes Yes Yes
and other client actions
Client-side mechanism for Yes No No
paging and other client actions
A Grid DataWindow page can Yes No No
be sorted on the client without a
postback
Composite and nested No Yes No
DataWindows are supported
Absolute positioning is Yes Yes No
supported in Grid DataWindows
Greatest compatibility with No Yes No
accessibility software (Section
508)
The XML rendering format does not support accessibility software. Some
aspects of the HTML generated using the HTML rendering format do not
support accessibility software.
The caching and bandwidth savings and the client-side paging feature of the
XML Web DataWindow result in better performance. In addition, you can
customize the XHTML rendering of the XML Web DataWindow using
XHTML export templates.
3 In the Web server’s root publishing folder, create distinct Web publishing
folders (for static JavaScript) and JavaScript publishing folders (for
dynamic JavaScript) and set the Web and JavaScript Generation properties
(that point to these folders) for your DataWindow.
If you do not create these folders, the generator creates them for you. If
you do not set these properties, then the default object model creates a
temp publishing folder _tmp automatically.
4 In the Java implementation for your JSP page, ensure you are calling the
GenerateXMLWeb method on the server component to request the XML
generation format.
The XML generation format results in the separate generation of data and
presentation in XML and XSLT for transformation to XHTML, and is the
optimal format for the XML Web DataWindow.
For an example of a JSP page calling the GenerateXMLWeb method, see
the XML WebDataWindow Code Sample in the DataWindow N-Tier
section on the CodeXchange Web site at
https://powerbuilder.codexchange.sybase.com/.
Using existing Many existing DataWindow objects work in the Web DataWindow. If a
DataWindow objects DataWindow object uses features that the Web DataWindow does not support,
then the features are ignored. You can still use the DataWindow object if the
remaining functionality is acceptable for your application. For example: if the
DataWindow includes a graph control, the graph is ignored; if the DataWindow
uses the Graph presentation style, the DataWindow object will not be useful.
Supported and Table 6-3: Web DataWindow supported and unsupported features
unsupported features
DataWindow feature Supported and unsupported features
Presentation styles All presentation styles except OLE, Graph, and RichText are supported. Unsupported
presentation styles retrieve data but display nothing. The Grid presentation style is
rendered as an HTML table if you use the HTML format, and as a result absolute
positioning is not supported and the display characteristics differ from those of XML
and XHTML Web DataWindows.
Nested and composite Supported for the XHTML format only.
reports
Using a drop-down The drop-down calendar DataWindow option is available for use on any
calendar DataWindow column with an EditMask, and a Date, DateTime, or TimeStamp
datatype. The DDCalendar EditMask property option allows for separate
selections of the calendar month, year, and date. This option can be set in a
check box on the Edit tab of the DataWindow painter Properties view when a
column with the EditMask edit style is selected. It can also be set in code, as in
this example for the birth_date column:
dw_1.Modify("birth_date.EditMask.DDCalendar='Yes'")
You can set the following properties to control the display of the calendar in a
script or on the Other page in the Properties view for the column:
Painter option Property
Drop Align Right Column.Editmask.ddcal_alignright
CalendarBackColor Column.Editmask.ddcal_backcolor
CalendarTextColor Column.Editmask.ddcal_textcolor
CalendarTitleBackColor Column.Editmask.ddcal_titlebackcolor
To make sure that dates selected with the drop-down calendar option are
displayed with the desired edit mask for Web DataWindows, you should
specify that the Client Formatting option be included with the static JavaScript
generated and deployed for the DataWindow. To conserve bandwidth,
JavaScript for client formatting is not included by default. To include this
script, you can select the Client Formatting check box on the Web Generation
page of the DataWindow Properties view. If you do not include script for client
formatting, the drop-down calendar will use a default edit mask to display the
column data based on the client machine’s default localization settings.
To navigate in the drop-down calendar, a user can:
• Click the arrows in the top corners to move from month to month.
• Click the month to display a list of months, then click a month to select it.
• Click the year to display a spin control, then use the spin control’s arrows
to select a year.
• Click a date to select the date and close the calendar.
• Press the Esc key to close the calendar without changing the selection.
XML and XHTML Table 6-4 shows row data properties for the XML and XHTML Web
data properties DataWindow.
Table 6-4: Row properties for the XML and XHTML Web DataWindow
Property User interface fields Description
Data.XHTML Read only, so no user A string containing the row
interface field data content of the
DataWindow object in
XHTML format
Data.XMLWeb Read only, so no user A string containing
interface field browser-specific JavaScript
that performs the XSLT
transformation on the browser
XML Web Table 6-5 lists properties supporting XML Web DataWindow generation.
DataWindow
generation properties Table 6-5: Properties supporting XML Web DataWindow generation
Property User interface fields Allows you to
CSSGen.property Web Generation property Specify the physical path to
page with CSS selected which a generated CSS style
as the format to sheet is published and the URL
configure: resource base indicating the location of the
and publish path style sheet where the property
variable is PublishPath or
ResourceBase.
JSGen.property JavaScript Generation Specify the physical path to
property page with which generated JavaScript
XHTML selected as the (that is included in the final
format to configure: XHTML page) is published and
resource base and publish the URL indicating the location
path of the generated JavaScript
where the property variable is
PublishPath or ResourceBase.
XMLGen.property Web Generation property Specify the physical path to
page with XML selected which XML is published and
as the format to the URL referenced by the
configure: resource base JavaScript that transforms the
and publish path XML to XHTML where the
property variable is PublishPath
or ResourceBase. You can also
specify whether XML is
generated inline to the XSLT
transformation script and
whether paging is performed on
the client or server.
HTML properties There are four types of HTML properties you can set in the DataWindow
painter. The first three apply to the DataWindow object itself. The last applies
to bitmap, column, computed field, and text controls in the DataWindow
object.
Some properties are now shared but property names are unchanged
In previous versions of PowerBuilder, HTML properties applied only to the
HTML Web DataWindow. Now some HTML properties are shared with the
XML Web DataWindow and the XHTML Web DataWindow. The HTML
property names have not changed.
Table 6-6: HTML properties you can set in the DataWindow painter
Property User interface fields Allows you to
HTMLDW Web DataWindow check View the HTML in a browser
(shared) box on the General page using Design>HTML Preview
of the DataWindow (or if you plan to use the
object Property view. DataWindow object with a
Selecting this check box custom Web DataWindow
sets this property to Yes. server component). The generic
server component automatically
sets this property to Yes.
To configure a particular Web format, you use the Web Generation page in the
DataWindow object property view. The Web Generation page is controlled by
the Format to configure drop-down list box at the top of the view that displays
the Web formats for the Web DataWindow:
The properties that are shared by all rendering formats display in the view by
default:
The properties you can set are subject to change based on the format you select:
Format to
configure Description Properties
HTML and XHTML Properties that are Rows per page
(shared) shared by all Web Generate JavaScript
DataWindow rendering Client events
formats Client validation
Client computed fields
Client formatting
Client scriptable
Generate DDW Frames
Object name
Self link
Self link arguments
Encode self link arguments
TabIndex base
Paging method
HTML HTML-only Web Browser
DataWindow properties HTML version
XHTML XHTML-only XML Browser
Web DataWindow
properties
CSS XML Web DataWindow Resource base
CSS properties Publish path
Session specific file names
XML XML Web DataWindow Resource base
data and presentation Publish path
properties Generate securely inline
Paging method
XSLT XML Web DataWindow Resource base
XSLT properties Publish path
Typically you share style (CSS), layout (XSLT), and control definitions (JS) for
use by all clients; however, if you use dynamic DataWindows customized for
specific clients, you can force generation of the DataWindow
presentation-related document names to be specific to each client. You do this
by selecting the Session Specific CSS, XSLT and JS Filenames check box or
by setting the CSSGen.SessionSpecific property to “yes”. This eliminates the
possibility of server-side contention for presentation formats when the
DataWindow generation is specific to the client.
For different DataWindows with the same name in the same application, you
can eliminate the possibility of server-side contention for presentation formats
and data content by entering a fully qualified file name (rather than a path) for
the publish path properties of those DataWindows. If you do use a file name for
a publish path property, the file extension must correspond to the type of format
you are configuring. For example, if you are adding a file name to the publish
path of the XML format, the file extension must be XML.
You set the display properties for the column on the Edit page in the Properties
view in the DataWindow painter. The Width of DropDown property sets the
width of the drop-down display to a size that is a percentage of the width of the
column. For example, 300 sets the display width to three times the column
width.
The default behavior uses inline frames (iFrames), which increases the volume
of markup generated. For DataWindow objects that make heavy use of
drop-down DataWindows, you can save bandwidth by generating the
drop-down DataWindows in HTML select elements. To do so, clear the
Generate DDDW Frames check box on the Web Generation page with the
Format to Configure option set to HTML/XHTML or set the
HTMLGen.GenerateDDDWFrames property to “No”.
For information about the HTMLGen.GenerateDDDWFrames property, see
the DataWindow Reference or online Help.
Each pass of the wizard generates only one file—which allows you to combine
or separate classes of functions. Once you have generated one or more
JavaScript files, you can attach them to a DataWindow object using the
Filename drop-down lists (for Common Class, Date Time Management,
Number Format, String Format, and User Class) in the JavaScript Generation
property page. Generating and associating JavaScript files with a DataWindow
object enables the JavaScript functions to be cached and then reused each time
the page containing the DataWindow object displays in the browser.
XML and XHTML To configure the JavaScript generation properties that are only for the XML
JavaScript generation Web DataWindow and XHTML Web DataWindow, you select XHTML and
properties
provide the resource base and the publish path:
Improving server-side When you set new DataWindow properties to reference included JavaScript
and client-side files, the methods defined in the referenced files are not generated with the
performance
HTML in any Web DataWindow pages that are sent to the page server and
client browser. Using JavaScript files also reduces the size of the HTML page
rendered in the browser.
With JavaScript caching, you improve performance on the client machine as
long as the client browser is configured to use cached files. With caching
enabled, the browser loads the JavaScript files from the Web server into its
cache, and these become available for all the Web DataWindow pages in your
application. There is no client-side performance gain if the browser does not
find the JavaScript files in its cache since, in this case, it reloads the files from
the Web server.
Web DataWindow With the Web DataWindow JavaScript Generator wizard, you can generate
JavaScript Generator only one JavaScript file at a time. The wizard gives you the option of including
wizard
all Web DataWindow methods in a single file, but you can also restrict the
types of methods to include in each JavaScript file it generates every time you
use the wizard. The different method types correspond to the following
DataWindow HTML properties:
Table 6-7: Methods generated by JavaScript Generator wizard in
cached files
HTMLGen.property Contents of cached file
CommonJSFile Methods used by all DataWindows.
DateJSFile Methods used by DataWindows with date and time
formatting.
NumberJSFile Methods used by DataWindows with number formatting.
StringJSFile Methods used by DataWindows with string formatting.
UserJSFile User-defined client-side JavaScript methods—these
cannot be generated by the Web DataWindow JavaScript
Generator wizard (see “User-defined JavaScript methods”
on page 142).
All of these properties are optional. You can set each of the properties from the
JavaScript Generation page of the DataWindow property view, selecting the
files you generate with the wizard as values. The wizard registers each file it
generates, making it available for selection from the drop-down lists in the
DataWindow property view.
Using the You must deploy all cached files for your Web application to your Web server.
ResourceBase You can use relative URLs or path names for cached JavaScript files if you
property
specify their location in the HTMLGen.ResourceBase property.
You set these on the JavaScript Generation page of the DataWindow property
view in the DataWindow painter. The ResourceBase property is also used to
specify the location of image files.
If you do not set the HTMLGen.ResourceBase property, you must include the
complete URL in the values of any of the HTMLGen properties that you set.
In either case, the URLs are rendered as SRC attributes inside SCRIPT tags in
the pages generated by the Web DataWindow component and sent to the client
browser.
Setting the properties You can customize the DataWindow HTML Generator component
in script (nv_remote_datawindow in PBDWRMT.PBL that ships with PowerBuilder),
setting the HTMLGen properties in the script for the Generate method. This
example sets the URL location for included files and names the files for
common and date-formatted Web DataWindow methods that you deploy to the
Web server (and that will be downloaded to browser clients the first time they
connect to the Web site):
ids_datastore.Modify &
("DataWindow.HTMLGen.ResourceBase=" +&
"'http://www.myserver.com/JavaScripts'")
ids_datastore.Modify &
("DataWindow.HTMLGen.CommonJSFile=" +&
"'dwcomn.js'")
ids_datastore.Modify &
("DataWindow.HTMLGen.DateJSFile=" +&
"'dwdate.js'")
User-defined You can also reference a file where you store your own client-side JavaScript
JavaScript methods methods. To use this feature, you must assign the name of the file to the
DataWindow HTMLGen.UserJSFile property and make sure the file is
available to your Web server. As for the wizard-generated JavaScript files, you
can use the HTMLGen.ResourceBase property to set the location for the file,
or you can include the complete path to the file in the property value
assignment.
You can make this assignment in the DataWindow painter or in script. The
following script sets the user-defined JavaScript file to MyMethods.JS:
ids_datastore.Modify &
("DataWindow.HTMLGen.UserJSFile=" +&
"'http://my_server.com/JavaScripts/MyMethods.JS'")
Using expressions
In general, expressions for validation rules and computed fields are translated
into JavaScript and evaluated in the client browser. For validation of data entry,
the user gets immediate feedback on the new data.
Some expressions have to be evaluated on the server. This might be because
the evaluation involves all the rows, rather than data on the current page only,
or because the expression does not translate into JavaScript.
If an expression includes these functions, it will be evaluated on the server:
• Aggregation functions, like Sum, Max, Average, First
• Case function
• External functions
If you use an aggregation function in a computed field, the value is computed
on the server and displayed on the client. If the user edits data, the value is not
updated. If an action occurs that reloads the page, the value is computed again
based on the changed data.
Including HTML in a You can include valid HTML in some controls in a DataWindow object,
control including a text control, column, or computed field. To render the contents of
the control as HTML when the HTML for the DataWindow is generated, set
the control’s ValueIsHTML property to TRUE. For example, suppose a text
control’s text property is <I>Name</I>. The following table shows how the
text is rendered in the generated HTML and displayed in a browser.
Table 6-8: Effect of ValueIsHTML property on rendered text
ValueIsHTML Generated HTML source Output in browser
TRUE <I>Name</I> Name
FALSE <I>Name</I> <I>Name</I>
No validation
The HTML Generator does not validate the HTML you include in controls in
DataWindow objects. If the HTML is not valid, the DataWindow might not
display correctly.
Appending HTML to a The AppendedHTML property enables you to append your own HTML to the
control HTML generated by the HTML Generator component. You can use this feature
to specify attributes and event actions. The HTML you specify for the
AppendedHTML property value is appended to generated syntax for the
rendering of a DataWindow control before the closing bracket of the HTML
element for that control.
No validation
The HTML Generator does not validate the HTML you append to controls in
DataWindow objects. If the HTML is not valid, the DataWindow might not
display correctly.
You must also make sure not to use an event handler name that is already
generated for a DataWindow control as a client-side event handler. These
include the event handlers in Table 6-9.
Setting SelfLink Button actions send information back to the server, whose scripts apply the
properties to enable action to the DataWindow data. Then the Web page is reloaded. To complete
navigation buttons
this loop, you must set the SelfLink property for the DataWindow object so that
the server knows what page to reload.
You can set this property in the DataWindow painter on the Web Generation
tab in the DataWindow properties view, or you can set it in a server-side script.
The value is the name of the application server template or file to be reloaded—
generally, the name of the current document. If the DataWindow uses retrieval
arguments, they must be provided in the SelfLinkArgs property.
For more information, see “Passing page-specific data to the reloaded page”
on page 185 and the SetSelfLink method in the DataWindow Reference.
GIF and JPEG images The picture on a button in a DataWindow object can be rendered in the Web
for buttons browser as a JPEG, GIF, or BMP image. Use a JPEG or GIF image to ensure
that the image will display on all browsers. PowerBuilder provides GIF images
for commonly used buttons such as Retrieve, Update, PageNext, and so on.
These pictures are included in the DWACTION.JAR file in the
Sybase\Shared\PowerBuilder directory.
To make the images available to the Web page in the Web browser, you must
uncompress the JAR file, deploy the image files to the page server, and set the
HTMLGen.ResourceBase property to the directory where the files are located.
Alternative to buttons: If you want to use an existing DataWindow object that does not have Button
use methods of the controls, you can edit the DataWindow object and save a new version with
client control
Button controls. However, if you are sharing DataWindow objects with an
existing application and it is not practical to edit them, your Web page can
include HTML or XHTML buttons that call methods of the Web DataWindow
client control.
There are methods of the client control that correspond to each of the supported
button actions. For information, see “Writing client-side scripts” on page 155.
Using Picture controls You can use any image types the browser supports, most commonly JPEG or
GIF. Use relative paths for ease of deployment.
To make sure the images are available to the Web page in the browser, place
the image files in a directory on the Web server and then set the
HTMLGen.ResourceBase property to that directory. You can do this in the
DataWindow painter on the JavaScript Generation page of the DataWindow
property view, or in a script:
dwMine.Modify("DataWindow.HTMLGen.ResourceBase=
'C:\Sybase\MyApp\Images'")
The ResourceBase property also specifies the location of JavaScript include
files. See “Using JavaScript caching for Web DataWindow methods” on page
140.
Limitations in Netscape
Certain functionality in a Netscape browser using absolute positioning might
not be identical to the functionality available with Internet Explorer. For
example, you cannot tab between DataWindow columns using a Netscape
browser on an NT machine, although you can do this using a Netscape browser
on a Solaris machine.
When you are defining DataWindow objects, you can use the types of
connectivity software documented in Connecting to Your Database. To
simplify setting up database connections on the server, use the same type of
connection in the DataWindow painter that will be used when the DataWindow
is deployed. For example, if you plan to use the DataWindow object in
EAServer with an Open Client connection, use Open Client in the
DataWindow painter too.
Creating a connection To use the HTMLGenerator125 component (or your own custom component)
cache on EAServer in EAServer, you need to define a connection cache (EAServer 5.x) or data
5.x
source cache (EAServer 6.x) for the database it will use.
4 Enter a data source name for the cache on the second page of the wizard
and click Next.
You cannot change this name in the console, although you can delete it and
start the wizard again.
5 On the remaining wizard pages, select the database type of the DBMS and
change the default entries for other wizard fields for which you are not
using default settings and click Finish.
You can change the settings you enter in the wizard on the tabs of the data
source property sheet that displays in the right pane of the console after
you click Finish.
For ODBC on Windows: for the Server Name in the wizard or on the
General tab of the data source property sheet, specify the DSN you defined
in step 1. You do not need to specify a user name or password if they are
specified as part of the DSN.
For other connection types: see the EAServer Getting Started book for
your platform.
6 Click Apply after making any changes on the tabs of the data source
property sheet.
7 To test the connection, right-click the data source you created under the
Data Sources node in the left pane of the console, and select Ping.
You might need to restart EAServer if the ping is not successful.
For more detailed information about setting up data sources, see the EAServer
6.x documentation.
Service classes You can add a custom class user object to your project to perform any special
processing you require. This object acts as a service class. The custom class
user object must be in the same library as the DataWindow objects or on the
target’s library list. When you build the Web DataWindow Container project,
select the class in the Select Objects dialog box in the Project painter. For more
information, see “Using service classes” on page 198.
Instantiating the When you create an instance of the container component, you must either
container component provide a Java proxy for the component or pass
DataWindow/HTMLGenerator125 as the last argument to the
CreateComponent method. This specifies that the component uses the proxy
provided for the generic component. For example:
dwObj = java.CreateComponent
("ContainerPkg/ContComponent",
"iiop://testMachine:2000", "Jagadmin", "mypass",
"DataWindow/HTMLGenerator125" );
This is the same way you instantiate custom components. For more
information on custom components, see “Instantiating the custom component”
on page 195.
Selecting a To select a DataWindow from the container component, you must use the
DataWindow from the SetDWObjectEx method rather than the SetDWObject method:
container component
//Only the DW is needed, as package already specified
//above when connecting
retVal = dwObj.SetDWObjectEx("d_mydw");
document.write("SetDwObject = " + retVal);
For more information on the SetDWObject method, see “Loading the
DataWindow object” on page 181 and the DataWindow Reference.
Most of these events have similar arguments and the same return codes as the
events of the PowerBuilder DataWindow control. For information, see the
DataWindow Reference or online Help.
Implementing an To write a script for an event of the client control, you define a function whose
event name is the control name plus the event name, separated by an underscore:
HTMLGenObjectName_eventname ( arguments )
The control name is the one you specified using the SetHTMLObjectName
method or the Object Name property on the Web Generation page in the
DataWindow painter. The script must be enclosed in SCRIPT tags. You can
include client methods in the script if client scripting is enabled (described
next).
This example prevents focus from changing if the user tries to go back to an
earlier row. In this case the name of the DataWindow control is dwMine:
<SCRIPT Language=JavaScript>
function dwMine_RowFocusChanging(curRow, newRow)
{
if (newRow < curRow) { return 1; }
}
</SCRIPT>
You can put the script anywhere in your Web page template.
Calling client methods To write scripts that call methods of the client control, you must enable client
scripting. To do so, you can set the Client Scriptable property in the
DataWindow painter or call the SetWeight method in a server-side script.
GetNextModified
The GetNextModified method finds modified rows in the current page only.
For information about these methods, see the DataWindow Reference or online
Help.
This example includes a form with a button that causes data to be updated on
the server:
<FORM NAME="update">
<INPUT type="button" value="Update"
onClick="{dwMine.Update();}">
Note that you can get the same functionality with the Update action for a
Button control in the DataWindow object.
Multiple DataWindows If you have multiple updatable Web DataWindows on the same Web page, you
on a page can script the OnSubmit client-side event to synchronize them before the
changes on the page are submitted. You call the GetFullContext method to get
a string that represents the context of the client side control that would be
passed on a submit, and transfer the context to the other DataWindow control.
To enable the second DataWindow to create the required fields on the submit
form, each of the DataWindows must have two arguments defined as self-link
arguments:
dw_1.SetSelfLink(document.name,
"dw_2_context=''|dw_2_action=''")
dw_2.SetSelfLink(document.name,
"dw_1_context=''|dw_1_action=''")
This client-side script transfers the context and action from dw_2 to dw_1
when dw_1 is submitted, and from dw_1 to dw_2 when dw_2 is submitted:
<SCRIPT>
function dw_1_OnSubmit()
{
dw_1.submitForm.dw_2_context.value =
dw_2.GetFullContext();
dw_1.submitForm.dw_2_action.value = "";
}
function dw_2_OnSubmit()
{
dw_2.submitForm.dw_1_context.value =
dw_1.GetFullContext();
dw_2.submitForm.dw_1_action.value = "";
}
</SCRIPT>
At design time, you can customize each of these XML Web DataWindow
components:
• Elements or contents of the <form> element
• CSS stylesheet declarations
• Other XHTML element-specific attributes (including style attributes) in
the DataWindow form
• JavaScript event handlers
Examples of Your customizations can include these types of modifications:
customization
Customization Example
Structural layout Add or remove elements and content (input fields
of the XHTML <form> element) from the header,
detail, summary, and footer bands
Style rules of data input field Modify the default CSS stylesheet property values
elements in the <form> element and add or remove CSS stylesheet declarations
Other attributes of elements of Override attribute values and remove or add
the DataWindow attributes specific to these elements
JavaScript event handlers Override, redirect, add, or remove JavaScript
event handlers
You can create multiple templates and save them by name with the
DataWindow object. Each template is uniquely associated with the
DataWindow object open in the painter. For information, see “Managing
templates” on page 161.
How tree view items Each item in the XHTML export template displays as a single tree view item
are represented with an image and font color that denotes its type. Elements are represented by
a yellow icon that resembles a luggage tag. The end tags of elements and the
markup delimiters (angle brackets) used in an XHTML document do not
display.
Table 6-10 shows the icons used in the Export Template view for XHTML.
Table 6-10: Icons used in the Export Template view for XHTML
Icon Description
Root or child element
Group header element
DataWindow column reference
Static text control reference
Computed field or DataWindow expression reference
Icon Description
Literal text
CDATA section
Nested report
Managing templates
From the pop-up menu for the default XHTML export template (with no items
selected), you can create multiple templates and save them by name with the
DataWindow object open in the painter. You also can edit existing templates
associated with the current DataWindow object and, when you asccoiate more
than one template with the DataWindow, delete the current template:
Saving the template To save a new default template, select Save from the pop-up menu in the
Export Template view for XHTML, name the template, and provide a comment
that identifies its use.
The template is stored inside the DataWindow object in the PBL. After saving
a template with a DataWindow object, you can see its definition in the Source
editor for the DataWindow object. For example, this is part of the source for a
DataWindow that has two templates. The templates have required elements
only:
export.xhtml(usetemplate = "t_phone"
template = (name = "t_address"
comment = "Employee Address Book" xhtml = "<…>")
template = (name = "t_phone"
comment = "Employee Phone Book" xhtml = "<…>") )
You can specify the template you want to apply to the default XML Web
DataWindow or XHTML Web DataWindow generation at runtime by setting
the Export.XHTML.UseTemplate property. You set the property using the Data
Export tab in the DataWindow painter’s Properties view by selecting XHTML
as the format and then selecting the XHTML export template’s name from the
Use Template drop-down list box.
Properties related to Table 6-11 shows properties related to XHTML export templates.
XHTML export
templates
Template structure
An XHTML export template has a Header section and a Detail section
separated graphically by a line across the tree view. Other DataWindow bands
are incorporated into these sections.
The Detail Start A line across the Export/Import Template view separates the Header section
element from the Detail section. The first element after this line, d_dept_list_row in the
previous screen shot, is called the Detail Start element.
There can be only one Detail Start element, and it must be inside the
document’s root element. Each band of the DataWindow is wrapped by a <div>
element. When the DataWindow is exported in XHTML, this element and all
children and/or siblings after it are generated iteratively for each row.
Header section
The Header section can contain the items listed in Table 6-12. Only the root
XHTML <form> element is required:
Table 6-12: Items permitted in the Header section of an XHTML
document
Item Details
Root <form> element The XHTML <form> element is the root element of the
(start tag) XHTML template. See “Root element” on page 169.
XHTML elements Additional elements below the root element.
DataWindow control Text. See “DataWindow controls” on page 170.
references
DataWindow Text. See “DataWindow expressions” on page 170.
expressions
Literal text Text that does not correspond to a DW control.
Attributes Can be assigned to all elements. See “Element attributes”
on page 171.
CDATA sections See “CDATA sections” on page 173.
Child elements Child elements in the Header section cannot be iterative
except for the Group DataWindow.
The items in the Header section are generated only once at runtime (when the
DataWindow is exported to XHTML), unless the DataWindow is a Group
DataWindow. For Group DataWindows, the corresponding XHTML fragment
in the Header section is repeated so that it iteratively heads each group detail—
the group of XHTML rows corresponding to the group specified in the
DataWindow.
The Header section contains the rendering of the DataWindow header band and
any group header bands. Bands are generated within <div> elements. The
controls rendered in the Header section (such as computed titles and text
control column headings) are typically also generated within <div> elements,
with referenced content.
These entities are generated only once and are not iterated for each row.
However, for DataWindows with group headers, the corresponding XHTML
fragment in the Header section is repeated, iteratively heading each group of
XHTML rows corresponding to the group specified in the DataWindow.
Detail section
The Detail section contains the rendering of the DataWindow Detail band,
delimited by the first <div> element. The <div> element’s contents represent a
single row instance to be generated iteratively. Any group trailers, summary
band, and footer band are also appended and enclosed by <div> elements. The
controls rendered in the Detail section (for example, column, computed field,
DropDownDataWindow, DropDownListBox, checkbox, and button controls)
are usually also generated within <div>, <input>, or <select> elements with
referenced content.
The Detail section can contain the items listed in Table 6-13.
Table 6-13: Items permitted in the Detail section of an XHTML document
Item Details
First <div> element The contents of the <div> element represent a single row
instance to be generated iteratively.
XHTML elements Additional elements below the root element.
DataWindow control Text. See “DataWindow controls” on page 170.
references
DataWindow Text. See “DataWindow expressions” on page 170.
expressions
Literal text Text that does not correspond to a DW control.
Attributes Can be assigned to all elements. See “Element attributes”
on page 171.
CDATA sections See “CDATA sections” on page 173.
Child elements Child elements in the Header section cannot be iterative
except in the case of group DataWindows.
If an element has no attributes, you can edit its tag in the Export Template view
for XHTML by selecting it and left-clicking the tag or pressing F2. Literal text
nodes can be edited in the same way. You can delete items (and their children)
by pressing the Delete key.
Root element
The root element of the XHTML export template is the XHTML <form>
element. You can change the name of the root element and add attributes and
children.
Changing the name of the root element changes the name of its start and end
tags. You can change the name using the Edit Attributes menu item to display
the Element Attributes dialog box. For information about editing attributes, see
“Element attributes” on page 171.
You can add the following kinds of children to the root element:
• Elements
• Text
• DataWindow control references
• DataWindow expressions (including column references)
• CDATA sections
DataWindow controls
Adding a DataWindow control reference opens a dialog box containing a list
of the columns, computed fields, report controls, and text controls in the
document.
DataWindow expressions
Adding a DataWindow expression using the Add Child>DataWindow Control
Reference menu item opens the Modify Expression dialog box. This enables
you to create references to columns from the data source of the DataWindow
object. It also enables the calling of global functions. One use of this feature is
to return a fragment of XHTML to embed, providing another level of dynamic
XHTML generation.
Using Date and If you use a control reference or a DataWindow expression that does not
DateTime with strings include a string to represent Date and DateTime columns in a template, the
XHTML output conforms to ISO 8601 date and time formats. For example,
consider a date that displays as 12/27/2002 in the DataWindow, using the
display format mm/dd/yyyy. If the export template does not use an expression
that includes a string, the date is exported to XHTML as 2002-12-27.
However, if the export template uses an expression that combines a column
with a Date or DateTime datatype with a string, the entire expression is
exported as a string and the regional settings in the Windows registry are used
to format the date and time.
Using the previous example, if the short date format in the registry is
mm/dd/yy, and the DataWindow expression is: "Start Date is " +
start_date, the XHTML output is Start Date is 12/27/02.
Element attributes
Select Edit Attributes from the pop-up menu for elements to edit an existing
attribute or add a new one. The attributes that display include all the default
attributes for the elements with any template changes applied. The name
attribute (and in some cases the class attribute) used to identify the element is
omitted and cannot be changed.
You can change or delete the default attribute values or add new ones. Controls
or expressions can also be referenced for element attribute values.
For each attribute specified, you can select a control reference from the
drop-down list or enter a literal text value. A literal text value takes precedence
over a control reference. You can also use the expression button to the right of
the Text box to enter an expression.
Style declarations
If you right-click an element and select Edit Styles from the pop-up menu, the
Style Declarations dialog box displays the read-only set of default style
declarations for the element on the left:
For clarity, style declarations are omitted from the XHTML export template.
You can add new style declarations or override the existing ones by declaring
them on the right side, or remove them by adding them with an empty value.
This dialog displays the current JavaScript event handlers, if any. You can add
new event handlers or override the existing ones by declaring them on the right
side, or remove them by adding them with an empty value.
CDATA sections
Everything inside a CDATA section is ignored by the parser. If text contains
characters such as less than or greater than signs (< or >) or ampersands (&)
that are significant to the parser, it should be defined as a CDATA section. A
CDATA section starts with <![CDATA[ and ends with ]]>. CDATA sections
cannot be nested, and there can be no white space characters inside the ]]>
delimiter—for example, you cannot put a space between the two square
brackets.
Example <![CDATA[
do not parse me
]]>
DOM-based actions Edit allows changing the label of the tree view item representing the XHTML
element name. All element items that display no attributes, as well as literal
text nodes selected in the tree view, can also be edited with a single
mouse-click or with the shortcut key F2. Add Child allows appending an entity
as a last child. The submenu option DataWindow Control Reference invokes a
dialog containing a filtered list box of Column, Computed Field, and Text
controls for user selection. Control references can also be added to empty
attribute values or element contents using drag-and-drop from the existing
Control List View. DataWindow Expressions can also be added using the
existing dialog. DataWindow column references (in the form of expressions)
can also be added using drag-and-drop from the Column Specification View.
Tree view items, except the <form> element, can also be deleted with the
Delete key.
Presentation and The remaining context menu items invoke dialogs that allow overriding
function presentational and functional specifications of each element. These include:
• Style declarations
• Element attributes
• JavaScript event handlers
The dialogs first display these specifications as they would be generated at
runtime by default. The painter gets these from the XML Web Generator in
DWE in real-time, read-only display on one half of the dialog. Within input
field(s) on the other half of the dialog, the developer can override these
specifications at the atomic declaration or attribute level. This includes
resetting included declarations/attributes, setting declarations/attributes not
included, or removing declarations/attributes. These change specifications will
then persist in the XHTML export template, and be applied to the default
presentation generated by the XML Web Generator at runtime.
ls_template_count=dw_1.Describe
("DataWindow.Export.XHTML.TemplateCount")
Exporting in XHTML You can export the DataWindow or DataStore object in XHTML using
PowerScript dot notation or the Describe method:
ls_xmlstring = dw_1.Object.DataWindow.Data.XHTML
ls_xmlstring = dw_1.Describe("DataWindow.Data.XHTML")
When you export the DataWindow or DataStore object, PowerBuilder uses an
export template to specify the content of the generated XHTML and CSS style
sheet.
About this chapter This chapter describes configuration requirements for the server-side Web
DataWindow component and design and programming techniques.
Contents
Topic Page
Server configuration requirements 177
Instantiating and configuring the server component 179
Using a custom server component 189
Using service classes 198
Using the Web If you are not running your Web server as a service and you have a user
DataWindow with CLASSPATH environment variable, make sure that this variable includes the
EAServer
paths to all classes needed for communication between the Web server and
EAServer. This includes the Sybase\EAServer\html\classes directory and the
path to any component stubs that you generate for use with your Web pages
(if these are in a different directory). When you install EAServer, the path
information for the server is placed only in the system CLASSPATH variable,
not the user variable.
Transaction server You must perform the following configuration tasks on the EAServer
configuration tasks transaction server:
• Copy the PBLs, PBDs, SRDs, or PSRs containing the definitions of your
DataWindow objects to a directory on the EAServer server’s path or the
system path if the server component is running as a service.
• Set up a DSN and a connection cache for your data source.
Configuration and Other methods are available to set up the component, retrieve data, establish
generation methods persistent values needed by your Web page, and generate HTML.
If you use a custom server component, there are additional configuration tasks.
For more information, see “Using a custom server component” on page 189.
Coding steps In your server-side script, you will code these tasks:
1 Instantiate the component.
2 Load the DataWindow object.
3 Control what HTML is generated (for example, by specifying what
functionality to include and what browser to target).
4 Specify the database connection and retrieve data.
5 Pass page-specific data to the reloaded page.
6 Pass user action information to the server component.
7 Insert the generated HTML in the page template.
Sample code for some of these tasks follows. For detailed information about
the methods used in the examples, see the DataWindow Reference or the online
Help.
SessionManager.FactoryHelper.narrow
(cntx.resolve(name));
dwGen =
HTMLGenerator125Helper.narrow(factory.create
("jagadmin",""));
} catch(org.omg.CORBA.ORBPackage.InvalidName ie) {
out.print("Error: " + ie.getMessage());
} catch
(org.omg.CosNaming.NamingContextPackage.NotFound ne) {
out.print("Error: " + ne.getMessage());
} catch
(org.omg.CosNaming.NamingContextPackage.CannotProceed
ce) {
out.print("Error: " + ce.getMessage());
} catch
(org.omg.CosNaming.NamingContextPackage.InvalidName
ie1) {
out.print("Error: " + ie1.getMessage()); }
This code uses the same name for the server component variable and the client
control:
dwGen.SetHTMLObjectName ("dw_1");
Optimizing HTML for a SetBrowser The Web DataWindow can generate HTML optimized for
browser particular browsers and versions. In particular, it can generate code for
Microsoft and Netscape browsers. 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. In the painter, you can set the HTML
Version property to specify what level of HTML to generate if the browser is
not recognized.
For information on what HTML features the DataWindow uses for different
browsers, see the DataWindow Reference or the HTMLGen.property topic in
online Help.
At runtime, 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.
Retrieving data Retrieve To tell the server component to retrieve data when the DataWindow
object does not have retrieval arguments, you call the Retrieve method:
retVal = dwGen.Retrieve();
Specifying retrieval RetrieveEx If the DataWindow object expects retrieval arguments, call
arguments RetrieveEx:
dwGen.RetrieveEx("60000");
Typically, the retrieval arguments are not constants. They are page parameters
passed to the page from another page where you filled in a form or clicked a
hyperlink. If the DataWindow expects more than one retrieval argument, the
arguments must be passed in a single string. Separate arguments in the string
by newline characters (\n). Individual values cannot contain newline characters
as part of the value. Separate array values by tab characters (\t).
Getting the retrieval argument from another page works the first time you load
the page. The retrieval arguments have to be page parameters each time the
page is reloaded. To specify page parameters for the reloaded page, you use the
SetSelfLink method.
To get the value from the current Logname parameter, which is already defined
for the page, you build the expression using the Logname page parameter. The
single quotes and inner double quotes are embedded in the expression. The
current value is inserted between the quotes:
String logname = (String)
request.getParameter("Logname");
String linkargs =
"logname='\"" + logname + "\"'";
An expression does not need the inner quotes:
String linkargs = "date='String(Today())'";
Passing the URL and SetSelfLink Use the URL and the link arguments string as arguments to the
argument string to SetSelfLink method:
SetSelfLink
dwGen.SetSelfLink(pageName, linkargs);
Retrieval arguments The first time the page is loaded, the retrieval argument might be:
as self-link values
• A page parameter passed from another page. The user might have clicked
a URL that included the value or filled in a form that posted the value.
• A new value calculated in the current script.
If the value is a page parameter, then you can re-create the page parameter
using SetSelfLink. If the value is from some other source, you need to write
code that gets the value from the source (which might be a page parameter) the
first time the page is loaded and from a page parameter when it is reloaded.
Examples These examples show code that works with the types of values listed above.
They illustrate how to get each type of value and use it in both RetrieveEx and
SetSelfLink method calls.
Value from another page If the user entered a product ID in a form to get
detailed information on the product, the product ID is passed to the product
report template as a page parameter. The page parameter should always exist
because it comes from the calling page, but the code provides a default value
anyway:
String prod_id;
prod_id=(String) request.getParameter("ProdID");
if (prod_id == null){
prod_id = "1";
}
dwGen.RetrieveEx(prod_id);
dwGen.SetSelfLink("ProdID=" + "'\"" + prod_id + "\"'");
Multiple values In this example, a Web page with a form prompts the user for
a user name and a product category and the level of detail the user wants to see.
The code uses the product category as a retrieval argument for the Web
DataWindow. The script selects a DataWindow object based on the level of
detail. All three values are carried over each time the page is reloaded:
// Get product category as a retrieval arg
String retrievearg, username, rptlevel, dw;
retrievearg =
(String)request.getParameter("category");
if (retrievearg == null) {
retrievearg = "all";
}
int rtn = dwGen.RetrieveEx(retrievearg);
if (rtn < 0) {
... // Check for error
}
// Get the user name
username =(String)request.getParameter("username");
if (username != null){
out.print("<P>Dear " + username + "</P>");
}
out.print("<P>Here is the report you
requested.</P>");
This code checks whether parameters have been defined (meaning that the
page is a reloaded page) and if so, calls SetAction to send the action
information to the server component:
int retVal;
String dw_1_action =(String)request.GetParameter
("dw_1_action");
String dw_1_context = (String)request.GetParameter
("dw_1_context");
if (dw_1_context == null){
dw_1_context = " ";
}
// Check if we need to perform the action
if (dw_1_action!=null){
retVal = dwGen.SetAction(dw_1_action, dw_1_context);
if (retVal < 0 ) {
out.print("Error on SetAction: "+ retVal + "<BR>");
out.print(dwGen.GetLastErrorString()+ "<BR>");
}
}
For information on creating a custom component that uses the generic Web
DataWindow interface, see “Creating a custom server component in
EAServer” on page 191 or “Deploying DataWindow objects to the component
server” on page 153.
Writing your own For full control of Web generation and the state of the DataStore object that
custom component holds the DataWindow definition and data, you can write your own custom
class user object in PowerBuilder and deploy it as an EAServer or COM
component. Using a custom component that includes only the processing you
need can reduce the size of the client control returned to the Web client.
The source code for the generic component is available in PBDWRMT.PBL in
the PowerBuilder code examples directory so that you can examine or reuse it.
You can modify or add to the code in this PBL or start from scratch, using the
sample PBL as a model for your own component.
Your server component will use methods on a DataStore object to retrieve data
and return the data and state to the client as HTML. To get the HTML and
JavaScript that represents the state, data, and presentation of the DataWindow
object, use the Describe method:
ls_html = ds_1.Describe("DataWindow.Data.HTML");
8 On the All Properties tab, add the properties for which you want preset
values.
6 On the Advanced tab of the component property sheet, add the properties
for which you want preset values.
Using OneTrip to set up the component and get the generated HTML
“Instantiating and configuring the server component” on page 179 described
several items your server script should include to set up the Web DataWindow
correctly. Instead of coding all these things separately, you can do all the setup
and get the generated HTML with a single method when the EAServer
component has been configured with a DataWindow definition and transaction
information. This technique is especially useful for improving performance
without requiring the server component to maintain state.
String browser=(String)request.getHeader("User-Agent");
dwGen.SetBrowser(browser);
String URI = request.getRequestURI();
String [] myArray = URI.split ("/");
String selfLink = myArray [myArray.length-1];
int retVal;
String dw_1_action =(String)request.GetParameter
("dw_1_action");
String dw_1_context = (String)request.GetParameter
("dw_1_context");
if (dw_1_action == null){
dw_1_action = "";
}
if (dw_1_context == null){
dw_1_context = "";
}
// Pass setup info to server
String dwHTML = dwGen.OneTrip("dw_1", browser,
selfLink, "", dw_1_action, dw_1_context);
// Insert HTML returned from OneTrip in the page
out.print (dwHTML);
Using OneTripEx for retrieval arguments If your DataWindow requires
retrieval arguments, use OneTripEx instead of OneTrip. The code checks for a
page parameter that has the retrieval argument value. It also makes sure the
value will still be available in a reloaded page by providing a selflinkargs
expression:
String retrievearg = (String) request.getParameter
("RetArg"):
if (retrievearg == null){
// Provide some meaningful default value
retrievearg = "default";
}
String selflinkarg = "RetArg='\"" + retrievearg + "\"'";
String dwHTML = dwGen.OneTripEx("dw_1", retrievearg,
browser, selfLink, selflinkarg, action, context);
out.print (dwHTML);
Setting timeout values To set the timeout value for the HTMLGenerator125 component, open its
Component Properties dialog box in EAServer Manager and set the
com.sybase.jaguar.component.timeout property. Timeout values are specified
in seconds; a value of 0 means the component never times out.
This script for the UpdateStart event has a DataStore that retrieves data from a
budget table and compares it to the component’s data:
DataStore ds_budget
double darray[], total
long ll_upper
integer i
FOR i = 1 to ll_upper
total = total + darray[i]
NEXT
IF ds_budget.Object.cf_expense_total < total THEN
RETURN 1
END IF
The arguments are the same as those documented for the similarly named
DataWindow, Java Edition events in the DataWindow Reference, with the
exception of the additional DataStore argument, which gives the Java class
access to the Web DataWindow data.
3 In the class methods, set the return codes to specify whether the server
component should cancel the event.
The return codes are also the same as those documented in the
DataWindow Reference. Any of the service classes that implements the
event can specify that the event be canceled.
4 Register the service classes for the component.
There are two ways to make the Java class available as a service class:
• For any component in EAServer, call the SetServerServiceClasses
method in the Web page template’s server-side script:
dwGen.SetServerServiceClasses
("UpdateValidate;RetrieveProcess");
• For a custom component in EAServer, add this property in EAServer
Manager:
com.sybase.datawindow.serverServiceClasses
Set its value to the list of user object names, with names separated by
semicolons. For example:
UpdateValidate;RetrieveProcess
Example Suppose that you want to check that data did not exceed a budgeted total before
it was updated in the database. You might set up a service class that implements
the UpdateStart event.
The method declaration would be:
public void UpdateStart (UpdateEvent event,
DataStore ds)
The body of this method has a DataStore that retrieves data from a budget table
and compares it to the component’s data:
import powersoft.datawindow.event.*;
import powersoft.datawindow.*;
About this chapter This chapter describes how to use the Sybase DataWindow Web control
for ActiveX (Web ActiveX).
Deprecated technology
The DataWindow Web Control for ActiveX is deprecated technology and
might not be supported in future releases of PowerBuilder.
Contents
Topic Page
About the Web ActiveX 205
HTML for inserting the controls on a Web page 209
DataWindow objects for the Web ActiveX 212
Using the DataWindow Transaction Object control 215
Making database connections 216
Coding for the Web ActiveX 218
Deploying the Web ActiveX 220
Included with the Web ActiveX is the Sybase DataWindow Transaction Object
control for making database connections that can be shared by several Web
ActiveX controls.
Browser support
The Web ActiveX and Transaction Object control are designed to work in
browsers that support ActiveX controls, such as Microsoft Internet Explorer
version 3 and higher.
The DataWindow controls are not designed to work in Netscape browsers,
which do not support ActiveX controls. Even if you use third-party plug-ins to
enable ActiveX support, scripting for the controls works differently and is not
tested.
Development When you install PowerBuilder, the Setup program registers the Web ActiveX
environment and the Transaction Object controls in the Windows registry. The class
information entered in the registry is visible in the PowerBuilder Browser
under OLE Custom Controls on the OLE tab. You can also examine the
properties, events, and methods of the controls on the OLE tab of the Browser.
To use the Web ActiveX, your development system must meet the following
requirements, all of which are met when you install any PowerBuilder
component that requires the Java VM:
• The Sun JRE 1.2 or later must be installed on your system
• The path to the jvm.dll file must be in your system PATH environment
variable
The path is ...\JRE\bin\client for JRE 1.4 and ...\JRE\bin\classic for
JRE 1.2 or 1.3
• The following files must be in a directory in your system PATH
environment variable: pbjvm125.dll, pbshr125.dll, and pbjdbc12125.jar
• If you are using Internet Infomation Services (IIS) 6.0, you need to
configure IIS to recognize the .pbl, .pbd, and .psr extensions as MIME
types. See “Adding MIME types to IIS 6.0” on page 207.
In addition, the Java classes required by your database vendor's client layer
must be installed on your system.
For information about the required HTML, see “HTML for inserting the
controls on a Web page” on page 209.
DataWindow objects The Web ActiveX uses a DataWindow object, which determines what data is
retrieved and how it is displayed. The Web ActiveX can also display Powersoft
reports (PSRs), which do not need to retrieve data. A DataWindow object for
the Web ActiveX can have any presentation style except RichText.
DataWindow objects are stored in PowerBuilder libraries (PBLs) or
PowerBuilder dynamic libraries (PBDs). The DataWindow libraries are stored
on the Web server and downloaded as needed by the Internet Explorer browser.
You use a URL to point to the library. It can be relative or absolute, using any
supported protocol—for example, http, ftp, or file.
For more information, see “DataWindow objects for the Web ActiveX” on
page 212.
Adding MIME types to To use the Web ActiveX with IIS 6.0, which is the IIS version included in
IIS 6.0 Windows Server 2003, you need to configure IIS to recognize the .pbl, .pbd,
and .psr extensions. Previous versions of IIS include a wildcard character
MIME mapping that allows IIS to serve any file.
You must be a member of the Administrators group on the local computer to
perform the following procedure, or you must have been delegated the
appropriate authority. For more information, see the Microsoft documentation
for IIS 6.0 or this Microsoft support document at
http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/cd
72c0dc-c5b8-42e4-96c2-b3c656f99ead.mspx.
Database connections The Web ActiveX uses JDBC for database connectivity. Users can connect to
a data source on any server to which they have access, including databases and
middle-tier servers on the Internet.
You can use internal transaction properties for specifying a connection; or you
can make the connection with a separate Transaction object, the Sybase
DataWindow Transaction Object control. When you connect using a separate
transaction object, you can control when SQL COMMIT and ROLLBACK
statements occur and you can use the same connection for multiple Web
ActiveX controls.
For more information, see “Using the DataWindow Transaction Object
control” on page 215.
Scripting Since the Web ActiveX is designed for Internet Explorer, you can use Jscript
or another ECMAScript-compatible scripting language for scripting purposes.
In general, you can use the same methods as in a PowerBuilder application.
However, there are a few differences:
• Datatypes are mapped to the basic JavaScript types of string, number,
boolean, and various object types
• ECMAScript languages do not support arguments passed by reference; so
instead of checking the value of a reference argument, you call a separate
method to retrieve the value
• Enumerated datatypes are not supported; instead, specify the integer that
corresponds to the enumerated data value
For more information, see “Coding for the Web ActiveX” on page 218.
Events The Web ActiveX supports the same events as a standard DataWindow control,
with these differences:
• Event names are different to conform to Web conventions
• Events in ECMAScript languages do not have return values; instead you
can call SetActionCode to affect the outcome of an event
Deployment The Web ActiveX is provided as a CAB file, which allows the client browser
to install and register the control. When the user downloads a Web page that
refers to the CAB file, the browser also downloads the CAB file if necessary,
unpacks it, and registers the control. Some additional files must also be
deployed to the client.
For more information, see “Deploying the Web ActiveX” on page 220.
Object element
How it works ActiveX controls use the Object element to specify the GUID (a unique
identifier) of the control as well as the space the control takes on the page. The
Object tag looks like this:
<OBJECT id=PSDWC1 height=357 classid="CLSID:CCCC1503-
CCCC-1000-8000-080009AC61A9" width=343>
</OBJECT>
CODEBASE attribute If your users need to download the controls, you can include the CODEBASE
attribute in the Object element to identify the file to be downloaded. After the
browser downloads the CAB file, it unpacks it and registers the ActiveX
controls in the user’s system registry.
The value for CODEBASE has the format:
url#version
A typical value for CODEBASE uses a relative URL:
CODEBASE="cabs/psdwc125.cab#12,0,0,1053"
URL The URL is the location of the DataWindow control’s CAB file on your
Web server. It can be an absolute or relative URL.
Version The version is a set of four numbers, separated by commas. The
numbers must match the version of the CAB file. The version number of the
CAB file is the same as the version number for PowerBuilder.
Example The Object element with a CODEBASE attribute looks like this:
<OBJECT codeBase=
"http://www.domain.com/psdwc125.cab#Version=12,0,0,
1053" id=PSDWC1 height=357 classid="CLSID:CCCC1503-
CCCC-1000-8000-080009AC61A9" width=343>
</OBJECT>
New versions When you get new versions of the CAB file, you can change the version
numbers on the Web page and cause the browser to install a new version of the
control.
For more information about how to deploy new versions, see “Deploying the
Web ActiveX” on page 220.
Putting the Object tag If the Cumulative Security Update for Internet Explorer (912812) or a
in a separate file subsequent update is installed on the computer where the Web ActiveX control
is running, a browser refresh does not refresh the control correctly. This update
is described in Microsoft Security Bulletin MS06-013, published in April
2006.
To work around this issue, put the <OBJECT> tag in a separate JavaScript file
instead of the main HTML file, as shown in this example:
// HTML file
<HTML>
<HEAD>
<TITLE>test</TITLE>
</HEAD>
<BODY bgColor="white" PSPARAMS="">
<P>Put your data here </P>
<P> </P>
<P>
<div id="DivID">
<script src="createElement.js"></script>
</div>
</BODY>
</HTML>
The Sybase DataWindow Web Control Properties dialog box has four tab pages
where you can set custom properties: General, Scrolling, Transaction, and
Trans User. The Transaction Object control has only two custom property
pages: Transaction and Trans User.
Standard ActiveX <PARAM VALUE=65536 NAME="_Version"></PARAM>
properties <PARAM VALUE=9280 NAME="_ExtentX"></PARAM>
<PARAM VALUE=5155 NAME="_ExtentY"></PARAM>
<PARAM VALUE=2 NAME="_StockProps"></PARAM>
<PARAM VALUE="" NAME=Caption></PARAM>
Properties on General <PARAM VALUE="javadwtest.pbl" NAME=SourceFileName>
page </PARAM>
<PARAM VALUE="d_emp" NAME=DataWindowObject></PARAM>
<PARAM VALUE=0 NAME=SuppressEvents></PARAM>
Properties on <PARAM VALUE=0 NAME=VScrollBar></PARAM>
Scrolling page <PARAM VALUE=0 NAME=HScrollBar></PARAM>
<PARAM VALUE=0 NAME=HSplitScroll></PARAM>
<PARAM VALUE=0 NAME=LiveScroll></PARAM>
Properties on <PARAM
Transaction page VALUE="Driver='com.sybase.jdbc3.jdbc.SybDriver',
URL='jdbc:sybase:Tds:localhost:2638'" NAME=dbParm>
</PARAM>
Properties on Trans <PARAM VALUE=dba NAME=LogId></PARAM>
User page <PARAM VALUE=sql NAME=LogPass></PARAM>
PowerBuilder version
PBLs must be migrated to Version 10 or later.
Grouping A PBL or PBD is downloaded in its entirety from the Web server; therefore,
DataWindow objects you should make sure your library includes only those objects needed on your
into libraries
Web pages. You can group DataWindow objects that are used on different Web
pages in a single library; however, you should avoid forcing users to download
objects used on pages they will not view.
When choosing how to group DataWindow objects into libraries, make the set
of objects in the library correspond to the typical set of pages the user will view.
Although a single download saves a lot of communications overhead, it is
worthwhile for users only if they view the pages that use the objects.
Using other resources A DataWindow object can use external resources such as bitmaps or cursors.
in the DataWindow You can use a resource file when you build a PBD to include these resources
object
in the library. You can also store these resources on the Web server. A relative
path in the DataWindow object can point to the file’s location on the Web
server. The browser retrieves the resource as needed.
A DataWindow object can use other DataWindow objects, such as drop-down
DataWindows. Make sure these objects are included in the downloaded library.
About The value for DataWindowObject is the name of a DataWindow object that is
DataWindowObject in the library specified in SourceFileName.
If the library is accessible in the development environment (for example, it is
part of the PowerBuilder workspace and you specify a relative URL), then the
property sheet displays a drop-down list of the DataWindow objects contained
in the library.
Status and error The Transaction Object control receives status information from the database.
information You can test the success or failure of a database operation and get status
information with these methods, which are equivalent to PowerBuilder
transaction object properties:
• GetSQLCode
• GetDBCode
• GetSQLErrText
• GetSQLNRows
• GetSQLReturnData
Hiding the Transaction The Transaction Object control has no visual aspect, but if it is in the BODY
Object control section of the Web page, it still takes up space. You can set its HEIGHT and
WIDTH attributes to very small values or use stylesheet settings to make it
invisible.
For information on setting properties for making a database connection, see
"Making database connections" next.
If you want to use the JDBC driver when you are defining DataWindow
objects, you need to do some additional installation, such as putting the JDBC
driver classes on the system class path.
For more information, see Connecting to Your Database or the online Help for
PowerBuilder.
Connection properties The connection information for the Transaction Object or Web ActiveX is set
as Param elements enclosed in the Object element. Whether you use a separate
Transaction object or the internal connection properties of the Web ActiveX,
the connection properties are the same:
Table 8-1: Connection properties of the Transaction Object and Web
ActiveX controls
Param name Meaning Typical value
LogID The ID needed to log dba (default ID for ASA databases)
in to the database.
LogPass The password sql (default password for ASA databases)
needed to log in to
the database.
dbParm A string specifying For the JConnect driver:
the Java classes for Driver='com.sybase.jdbc3.jdbc.SybDriver',
the driver and the URL='jdbc:sybase:Tds:199.1.1.1:9999/my
URL for the database'
database.
Lock The isolation level of Vendor-specific values
the connection.
AutoCommit Whether a commit False (default)
occurs immediately
after the database is
updated.
About dbParm For JDBC drivers, the dbParm property specifies essential connection
information. Its value is a string that contains at least two values. Those values
identify the driver you want to use and the URL of the database, in a format
understood by the driver.
The format is:
Driver='JDBCclassname',URL='database_url '
To find the class name for Driver and the format of the database URL, check
the documentation from the DBMS vendor.
For examples of setting these properties in Param elements, see “Properties
and Param elements” on page 211.
JConnect in the If you want to use JConnect when you define DataWindow objects, put the
development Java classes for JConnect on the class path.
environment
If your Web page uses a JDBC connection, the Web ActiveX has additional
deployment requirements:
• The Sun JRE 1.2 or later must be installed on the client. Users can
download the latest version of the JRE from the Sun Java Web site at
http://www.java.com:80/en/download/windows_manual.jsp (where en
indicates the English language version).
• The path to the file jvm.dll (...\JRE\bin\client for JRE 1.4 and
...\JRE\bin\classic for JRE 1.2 or 1.3) must be added to each user’s system
PATH environment variable.
• The following files must be in a directory in the client's system PATH
environment variable: pbjvm125.dlland pbshr125.dll.
• The pbjdbc12125.jar file, which contains class files required by the Web
ActiveX, must be deployed to the client. You can deploy the JAR file by
referencing it in the CODEBASE attribute of the Object element in your
Web page.
• Java classes required by your database vendor’s client layer must be
available on the client. They can be added to a CAB file that is referenced
in the CODEBASE attribute of the Object element in your Web page. For
example, if you are using Sybase jConnect to connect to a database, the
jconn2.jar file should be included in the CAB file. If the client layer is
provided in a JAR file, it can be referenced directly in the CODEBASE
attribute.
Deploying a new The version number in the value of the CODEBASE attribute determines
version whether the browser downloads and installs a new version of the ActiveX
controls. The browser compares the version number in the CODEBASE value
with the version of the controls that is installed in the system registry. If the
version numbers do not match, the browser downloads the CAB file again and
installs it.
❖ To deploy the new CAB file when you get a new version of PowerBuilder:
1 Find the new version number by checking the version number of any
PowerBuilder DLL (as described in “HTML for inserting the controls on
a Web page” on page 209).
2 Edit the Web pages that refer to the CAB file. Change the version number
in the CODEBASE attribute to match the new number.
3 Replace the CAB file on the Web server with the new version.
A crosstabs
modifying during execution 55
absolute positioning, Netscape browser 148
users redefining during execution 54
accent marks, Web DataWindow 144
using in applications 53
action codes 42
viewing underlying data 53
aggregation functions, Web DataWindow 143
custom DataStore objects 86
applications
architectures 7
using DataWindow objects in 13
D
data
B retrieving and updating 26
saving in graphs 104
bitmaps, dynamically adding and removing 71
sharing 89
buffers
updating 27
DataStore 89
Web control for ActiveX 218
DataWindow 30, 45
Web DataWindow 129, 184
Button controls, Web DataWindow 146
data sources
external 30, 88
types 6
C database connections
about 21
CAB file, Web control for ActiveX 220 Web control for ActiveX 216
CallBack paging 139 Web DataWindow 184
Case function, Web DataWindow 143 database errors 40
character set, foreign language 144 databases
Clicked events in graphs 108 communicating with 21
client control, Web DataWindow 120 connecting automatically 23
client/server applications 7 data source 6
client-side paging 139 disconnecting automatically 23
CODEBASE HTML attribute, Web ActiveX 209 retrieving, presenting, and manipulating data 4, 26
column status in DataWindow controls 45 snapshot connections 23
COMMIT statement and SetTransObject 24 transaction management 24
communication with databases 21 updating 27
CONNECT statement and SetTransObject 24 DataModified status 45
connection caches, defining in EAServer 150, 151 DataObject property of DataWindow controls 19
controls, supported in Web DataWindow 129 DataStore objects
create capability for Modify 71 accessing data 88
Create method 71 buffers 89
CrosstabDialog function 54 custom 86
L P
language, character sets 144 PagingMethod property 139
libraries painters 14
for DataWindow objects 12, 14 Param elements, Web control for ActiveX 211
locked by EAServer 190 PBD files see libraries 12
Web control for ActiveX 213 PBL files see libraries 12
LibraryExport function 73 Picture button in Web DataWindow 147
Picture controls in Web DataWindow 147
point and click, in graphs 108
PowerBuilder libraries see libraries 12
M Powersoft reports
MessageText event 54 about 4, 14
methods displaying in DataWindow controls 20
DataStore 89 displaying in Web control for ActiveX 21
DataWindow 37 no database connection needed 22
graph 101 presentation styles
JavaScript caching 140 list 5
Web DataWindow client control 156 supported in Web control for ActiveX 213
Web DataWindow server component 179 supported in Web DataWindow 128
Modify method Primary buffer 30, 89
basic usage 38, 70 Print method 50
using query mode 74 printing
using with graphs 99 multiple DataWindow objects on a page 51
with crosstabs 55 reports 50
multiple Web DataWindows on a page 156 programs, using DataWindow objects in 13
properties
DataWindow object 38
retrieving current values of 70, 72, 73
N PSR files see Powersoft reports
names of DataWindow controls and DataWindow objects
16
nested reports
creating during execution 52 Q
destroying during execution 52 query mode
using in applications 51 clearing 77
Netscape browser, absolute positioning 148 forcing equality 78
New status 45 providing to users 74
NewModified status 45 sorting in 78
NotModified status 45 quotation marks in self-link expressions 185
O R
OneTrip method, Web DataWindow 196 reports
see also Powersoft reports 4
creating with DataWindow objects 49
nested 51 T
printing 50
text controls in DataWindow objects 71
Retrieve method
text in DataWindow edit control 31
handling errors 40
transaction objects
using 26
reassociating DataWindow controls with 72
Web DataWindow example 184
Web control for ActiveX 215
RetrieveEx method, example 184
ROLLBACK statement and SetTransObject 24
rows
providing user-specified retrieval 74 U
status in DataWindow controls 45
runtime libraries see libraries 14 Update method
handling errors 40
using 27
URLs, Web control for ActiveX 214
S user events, for graphs in DataWindow controls 106
user objects, inherited from DataStore objects 87
saving data in graphs 104
scripts, modifying graphs in 98
SELECT statements, modifying at execution time 77
selection criteria see query mode 74 V
self-link arguments, Web DataWindow 185
separator line in XML template 166 validation rules in Web DataWindow 130
server component validation, server-side 198
accessing from server-side scripts 179
properties 193
server component, Web DataWindow 118
server-side validation for Web DataWindow 198
W
service classes for Web DataWindow 198 Web applications and DataWindow technology 8,
SetAction method, example 188 115, 205
SetBrowser method, example 183 Web browsers
SetDWObject method, example 181 Web control for ActiveX 206
SetHTMLObjectName method, example 182 Web DataWindow 148, 183
SetItem method 35 Web control for ActiveX
SetText method 33 about 9, 205
SetTrans method CODEBASE HTML attribute 209
about 23 database connections 216
Web DataWindow example 184 DataWindow objects 213
SetTransObject method 24 DataWindowObject property 20, 214
SetWeight method, example 182 deployment 220
ShareData method 51 event return codes 220
sorting in query mode 78 libraries 213
SourceFileName property, Web control for ActiveX library versions 213
20, 214 retrieving data 218
SRD file for Web DataWindow 181 setting DataWindow object during execution 214
status of DataWindow rows or columns 45 SourceFileName property 20, 214
SyntaxFromSQL method 73 transaction objects 215
version number of CAB 209