Using Button and Picture controls
Using Button controls
When a DataWindow object includes a Button control, the button
becomes an HTML or XHTML button element in the Form element for
the Web DataWindow client control. The button action becomes JavaScript
code for the button’s Clicked event. You do not need to
write any code yourself.
You can use Button controls for:
-
Navigation
Buttons with the PageFirst, PageLast, PageNext, and PagePrior
actions let the user scroll to other rows in the result set. -
Getting and editing data
Buttons with Retrieve, Update, InsertRow, DeleteRow, and AppendRow
actions let the user maintain data. There must be updatable columns
in the DataWindow object.
These button actions are not supported and are ignored:
Cancel |
QueryClear |
Filter |
QueryMode |
Preview |
QuerySort |
PreviewWithRulers |
SaveRowsAs |
|
Sort |
Setting SelfLink properties
to enable navigation buttons
Button actions send information back to the server, whose
scripts apply the action to the DataWindow data. Then the Web page
is reloaded. To complete 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” and the SetSelfLink method in
the DataWindow Reference.
GIF and JPEG images for buttons
The picture on a button in a DataWindow object can be rendered
in the Web 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 SAPSharedPowerBuilder 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: use methods of the client
control
If you want to use an existing DataWindow object that does
not have Button controls, you can edit the DataWindow object and
save a new version with 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”.
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:
1 |
dwMine.Modify("DataWindow.HTMLGen.ResourceBase= |
1 |
'C:SAPMyAppImages'") |
The ResourceBase property also specifies the location of JavaScript
include files. See “Using JavaScript caching
for Web DataWindow methods”.
The image files need to be deployed to the Web server, not
the component server. If these servers are on different computers,
the files belong with the templates and Web files of the application,
not the PBL containing the DataWindow objects.