Power Builder Tutorial_4
Power Builder Tutorial_4
PowerBuilder®
11.0 CTP
DOCUMENT ID: DC11CTP-01-1100-01
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, the Sybase logo, ADA Workbench, Adaptable Windowing Environment, Adaptive Component Architecture, Adaptive Server,
Adaptive Server Anywhere, Adaptive Server Enterprise, Adaptive Server Enterprise Monitor, Adaptive Server Enterprise Replication,
Adaptive Server Everywhere, Adaptive Warehouse, Afaria, Answers Anywhere, Anywhere Studio, Application Manager, AppModeler,
APT Workbench, APT-Build, APT-Edit, APT-Execute, APT-Translator, APT-Library, AvantGo Mobile Delivery, AvantGo Mobile
Inspection, AvantGo Mobile Marketing Channel, AvantGo Mobile Pharma, AvantGo Mobile Sales, AvantGo Pylon, AvantGo Pylon
Application Server, AvantGo Pylon Conduit, AvantGo Pylon PIM Server, AvantGo Pylon Pro, Backup Server, BizTracker,
ClearConnect, Client-Library, Client Services, Convoy/DM, Copernicus, Data Pipeline, Data Workbench, DataArchitect, Database
Analyzer, DataExpress, DataServer, DataWindow, DataWindow .NET, DB-Library, dbQueue, Developers Workbench, DirectConnect,
DirectConnect Anywhere, Distribution Director, e-ADK, E-Anywhere, e-Biz Impact, e-Biz Integrator, E-Whatever, EC Gateway,
ECMAP, ECRTP, eFulfillment Accelerator, Embedded SQL, EMS, Enterprise Application Studio, Enterprise Client/Server, Enterprise
Connect, Enterprise Data Studio, Enterprise Manager, Enterprise SQL Server Manager, Enterprise Work Architecture, Enterprise Work
Designer, Enterprise Work Modeler, eProcurement Accelerator, EWA, Financial Fusion, Financial Fusion Server, Gateway Manager,
GlobalFIX, iAnywhere, iAnywhere Solutions, ImpactNow, Industry Warehouse Studio, InfoMaker, Information Anywhere, Information
Everywhere, InformationConnect, InternetBuilder, iScript, Jaguar CTS, jConnect for JDBC, M2M Anywhere, Mach Desktop, Mail
Anywhere Studio, Mainframe Connect, Maintenance Express, Manage Anywhere Studio, M-Business Anywhere, M-Business Channel,
M-Business Network, M-Business Suite, MDI Access Server, MDI Database Gateway, media.splash, MetaWorks, mFolio, Mirror
Activator, MySupport, Net-Gateway, Net-Library, New Era of Networks, ObjectConnect, ObjectCycle, OmniConnect, OmniSQL
Access Module, OmniSQL Toolkit, Open Biz, Open Client, Open ClientConnect, Open Client/Server, Open Client/Server Interfaces,
Open Gateway, Open Server, Open ServerConnect, Open Solutions, Optima++, PB-Gen, PC APT Execute, PC DB-Net, PC Net Library,
Pharma Anywhere, PocketBuilder, Pocket PowerBuilder, Power++, power.stop, PowerAMC, PowerBuilder, PowerBuilder Foundation
Class Library, PowerDesigner, PowerDimensions, PowerDynamo, PowerScript, PowerSite, PowerSocket, Powersoft, PowerStage,
PowerStudio, PowerTips, Powersoft Portfolio, Powersoft Professional, PowerWare Desktop, PowerWare Enterprise, ProcessAnalyst,
QAnywhere, Rapport, RemoteWare, RepConnector, Replication Agent, Replication Driver, Replication Server, Replication Server
Manager, Replication Toolkit, Report-Execute, Report Workbench, Resource Manager, RFID Anywhere, RW-DisplayLib, RW-Library,
Sales Anywhere, SDF, Search Anywhere, Secure SQL Server, Secure SQL Toolset, Security Guardian, SKILS, smart.partners,
smart.parts, smart.script, SOA Anywhere, SQL Advantage, SQL Anywhere, SQL Anywhere Studio, SQL Code Checker, SQL Debug,
SQL Edit, SQL Edit/TPU, SQL Everywhere, SQL Modeler, SQL Remote, SQL Server, SQL Server Manager, SQL SMART, SQL
Toolset, SQL Server/CFT, SQL Server/DBM, SQL Server SNMP SubAgent, SQL Station, SQLJ, STEP, SupportNow, S.W.I.F.T.
Message Format Libraries, Sybase Central, Sybase Client/Server Interfaces, Sybase Financial Server, Sybase Gateways, Sybase IQ,
Sybase MPP, Sybase SQL Desktop, Sybase SQL Lifecycle, Sybase SQL Workgroup, Sybase User Workbench, SybaseWare, Syber
Financial, SyberAssist, SybFlex, SyBooks, System 10, System 11, System XI (logo), SystemTools, Tabular Data Stream, TradeForce,
Transact-SQL, Translation Toolkit, UltraLite, UltraLite.NET, UNIBOM, Unilib, Uninull, Unisep, Unistring, URK Runtime Kit for
UniCode, VisualWriter, VQL, WarehouseArchitect, Warehouse Control Center, Warehouse Studio, Warehouse WORKS, Watcom,
Watcom SQL, Watcom SQL Server, Web Deployment Kit, Web.PB, Web.SQL, WebSights, WebViewer, WorkGroup SQL Server, XA-
Library, XA-Server, XcelleNet, and XP Server are trademarks of Sybase, Inc. 10/05
Unicode and the Unicode Logo are registered trademarks of Unicode, Inc.
All other company and product names used herein may be trademarks or registered trademarks of their respective companies.
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.
CHAPTER 3 Print, File, Mail, and Registry Operations in Web Forms ........... 47
Using the Web Form Print Manager............................................... 47
Print Manager icon display ...................................................... 48
Where printed output is saved................................................. 48
Requirements for saving files in PDF or XSL format............... 49
Installing GNU Ghostscript ...................................................... 50
Where PDF and XSL-FO output is saved ............................... 51
Using the Web Form File Manager ................................................ 52
Using the Web Form Mail Profile Manager .................................... 58
Using the registry functions ............................................................ 61
Audience This book is for programmers who plan to convert traditional client-server
PowerBuilder® applications to PowerBuilder .NET Web Form
applications, or to develop new .NET Web Form applications in
PowerBuilder.
How to use this book This book describes the generation of Web Form applications using the
PowerBuilder .NET Web Form Application project wizard. It provides
information on design and coding considerations for converting
PowerBuilder applications to Web Form applications and it describes the
client-side events and event handlers you can use to enhance the
performance of your Web Form applications.
Related documents For a description of books in the PowerBuilder documentation set, see the
preface of PowerBuilder Getting Started.
Other sources of Use the Sybase Getting Started CD, the SyBooks CD, and the Sybase
information Product Manuals Web site to learn more about your product:
• The Getting Started CD contains release bulletins and installation
guides in PDF format, and may also contain other documents or
updated information not included on the SyBooks CD. It is included
with your software. To read or print documents on the Getting Started
CD, you need Adobe Acrobat Reader, which you can download at no
charge from the Adobe Web site using a link provided on the CD.
• The SyBooks CD contains product manuals and is included with your
software. The Eclipse-based SyBooks browser allows you to access
the manuals in an easy-to-use, HTML-based format.
Some documentation may be provided in PDF format, which you can
access through the PDF directory on the SyBooks CD. To read or
print the PDF files, you need Adobe Acrobat Reader.
Refer to the SyBooks Installation Guide on the Getting Started CD, or
the README.txt file on the SyBooks CD for instructions on installing
and starting SyBooks.
If you need help Each Sybase installation that has purchased a support contract has one or more
designated people who are authorized to contact Sybase Technical Support. If
you cannot resolve a problem using the manuals or online help, please have the
designated person contact Sybase Technical Support or the Sybase subsidiary
in your area.
About this chapter This Community Technology Preview (CTP) release of PowerBuilder
11.0 features the .NET Web Form Application wizard which lets you
deploy your PowerBuilder applications as ASP.NET Web applications.
This chapter explains how to generate PowerBuilder applications as Web
Form applications and provides tips on design and coding for the .NET
environment.
Contents
Topic Page
About PowerBuilder Web Form applications 1
Advantages of Web Form applications 2
Creating a PowerBuilder .NET Web Form project 3
Configuring ASP.NET for a PowerBuilder project 7
Best practices for C# and .NET coding 13
Global Web configuration properties 22
Sharing data across sessions 26
Troubleshooting tips 26
Table 1-1 displays some of the relative advantages and disadvantages of Web
Form and Windows Form applications.
Table 1-1: Relative advantages of Web Form and Windows Form
applications
Application type Advantages Disadvantages
Web • No installation • Slower response
• Easy to upgrade • Must be online
• Broader reach
Windows • Quicker response • Difficult to upgrade
time • Requires client-side
• Availability of installation
client-side resources,
such as 3D animation
For more information on the relative advantages of Web Forms and Windows
Forms, see the Microsoft Web site at http://msdn2.microsoft.com/en-
us/library/5t6z562c(VS.80).aspx.
About the .NET Web You use the PowerBuilder .NET Web Form project wizard to create a Web
Form project Form project from an existing PowerBuilder application. The project you
create allows you to deploy the PowerBuilder application to an IIS 5.0 or
higher server and allows end users to run the application from a Web browser.
Table 1-2 lists optional and required items in the .NET Web Form project
wizard:
Table 1-2: .NET Web Form Project wizard fields and descriptions
.NET Web Form wizard field Description
Destination library Library where you want to store the .NET Web
Form project.
Project object Name of the .NET Web Form project.
Web application name Name of the .NET Web Form application—by
default, this is the name of the application for the
current PowerBuilder target.
Application URL preview Address for starting the .NET Web Form
application in a browser (minus the default.aspx
or default.htm start-up file name).
Initial current directory in virtual The directory path that you want to use as the
file system current directory in the virtual file system on the
server. By default, this is the full path name for
the PowerBuilder target that will be mirrored on
the server.
Command line parameters Command-line parameters required for running
a PowerBuilder application that you deploy as a
Web Form application. You must use an empty
space as a separation character if an application
requires multiple parameters.
Window style Style for the Web Form application—either
Classic Web Style or Classic Windows Style. For
more information, see “About application style”
on page 6.
Render file manager icon Selecting this check box adds a file manager icon
to the Web Form application. The icon opens the
File Manager for the application’s virtual file
system on the server. The File Manager is not
fully functional for the CTP release.
Render mail manager icon Selecting this check box adds a mail manager
icon to the Web Form application. The icon
opens the Mail Manager for the application on
the server. The Mail Manager is not fully
functional for the CTP release.
Using the Properties After you click Finish in the wizard, PowerBuilder creates a .NET Web Form
dialog box for a .NET project in the target library that you selected and opens the project in the Project
Web Form project
painter. You can use the Edit>Properties menu of the Project painter or the
Properties toolbar icon to open the properties dialog box for the project. This
dialog box displays all the values you entered in the wizard and allows you to
modify them.
Figure 1-1 displays the General page of the Properties dialog box for a .NET
Web Form project.
About application style You can set the application to display in classic Web style or in classic
Windows style. In classic Web style, the application fills the browser frame,
and MDI sheet windows display as tabbed dialog boxes. In classic Windows
style, frame and sheet windows include separate title bars.
For SDI applications using classic Windows style, the main window is centered
in the browser, with its borders offset by the empty browser frame background.
However, the window is resizeable and can be moved.
Deploying and running When a .NET Web Form project is open in the Project painter and no other
the project from the painters are open, you can select Design>Deploy Project from the Project
PowerBuilder UI
painter to deploy the project. When all painters are closed, including the
Project painter, you can right-click a .NET Web Form project in the System
Tree and select Deploy from its pop-up menu.
The Output window displays the progress of the deployment and provides a list
of application functions, events, and properties that are not supported in the
Web Form version of the application. Most of these warnings are benign and
do not prevent users from running the application as a Web Form.
If the 2.0 version is the only version of the Microsoft .NET Framework
installed on the server, or if you configured the server to use the 2.0 version for
all Web sites by default, you can run the application immediately after you
deploy it. You can run the application from PowerBuilder by selecting
Design>Run Project from the Project painter menu or selecting the Run Project
toolbar icon from the Project painter toolbar. The System Tree pop-up menu for
the .NET Web Form project also has a Run Project menu item.
Running the project When you run the project from PowerBuilder, the Web browser that opens does
from a Web browser not include the browser menu and toolbar. This is because PowerBuilder does
not append the starting page, default.aspx, to the URL listed in the project. You
can see the application in a browser window that includes the browser menu
and toolbar by typing the URL in the browser location window or address bar.
The URL address is not case-sensitive.
If you do not include the starting page, default.aspx, in a URL that you type in
a browser address bar, or if you append default.htm as the starting page, IIS still
redirects you to the default.aspx page, but the browser menu and toolbar do not
display.
3 Click the ASP.NET tab and change the ASP.NET version to 2.0.50727 if
necessary.
4 Click Edit Configuration.
The ASP.NET Configuration dialog box displays for the current .NET
Web Form application. You can view its global properties in the list box at
the bottom of the General tab.
If you do not grant the ASPNET user appropriate permissions for Sybase
directories and your database configuration is set to start the database
automatically, your application will fail to connect to the database, because
ASA cannot access files unless the ASPNET user has the right to access them.
3 Click Locations and choose the server computer name from the Locations
dialog box and click OK.
4 Type ASPNET in the list box labeled “Enter the object names to select”
and click OK.
The ASP.NET machine account is created for the current directory.
5 Select the ASP.NET machine account in the top list box on the Security
tab, then select the “Full Control” check box under the Allow column in
the bottom list box.
6 Click the Advanced button.
The Advanced Security Settings dialog box displays for the current
directory.
7 Select the check box labeled “Replace permission entries on all child
objects with entries shown here that apply to child objects” and click OK.
A Security dialog box displays, warns you that it will remove current
permissions on child objects and propagate inheritable permissions to
those objects, and prompts you to respond.
8 Click Yes at the Security dialog box prompt, then click OK to close the
Properties dialog box for the current directory.
3 Type the following line at the command prompt, modifying the server IIS
root directory if you do not use the default c:\Inetpub\wwwroot directory:
xcopy /s /i .\build\Runtime
c:\Inetpub\wwwroot\webctrl_client\1_0 /y
4 Press Enter.
This creates the following directory structure under the root:
/webctrl_client/1_0
[images]
[treeimages]
The /webctrl_client/1_0 directory should contain the following files:
MultiPage.htc, TabStrip.htc, toolbar.htc, treeview.htc, webservice.htc, and
webserviced.htc
Coding restrictions
Although PowerScript is essentially a compiled language, it is quite tolerant.
For example, PowerScript allows narrow casting without raising warnings at
compile time, even though this might cause a runtime error. On the other hand,
C# and .NET are much more restrictive. If you want to do narrow casting, you
must explicitly express this in the code.
For the sake of performance, the PowerBuilder .NET compiler is not designed
to be as tolerant as the PowerBuilder native compiler. To be able to compile
your applications with .NET, you should avoid certain practices in your
PowerScript code.
The following language-level items apply when you plan to transform a
PowerBuilder application to a Windows Form or Web Form application.
Syntax issues Avoid the GoTo statement Jumping into a branch of a compound statement
is legal in PowerBuilder, because the concept of scope inside a function does
not exist in PowerScript. For example, the following code works well in
PowerBuilder:
if b = 0 then
label: …
else
…
end if
goto label
This PowerScript would translate conceptually into the following C# code:
if (b == 0)
{ // opening a new scope
label: …
}
else
{
…
}
goto label;
Since a GoTo statement is not allowed to jump to a label within a different
scope in .NET, the C# code would not compile. For this reason, you should
avoid using GoTo statements.
Avoid calling an indirect ancestor event in an override event Suppose
that there are three classes, W1, W2, and W3. W1 inherits from Window, W2
inherits from W1, and W3 inherits from W2. Each of these classes handles the
clicked event. In the clicked event of W3, it is legal to code the following in
PowerScript:
call w1::clicked
However, in C#, calling the base method of an indirect base class from an
override method is not allowed. The previous statement translates into the
following C# code, which might produce different behavior:
base.clicked();
Semantic issues Do not use narrow casting PowerScript allows you to caste a class to an
indirect ancestor. Although it does not represent good programming practice,
the following code is legal in PowerBuilder, where n_ds is a subclass of
DataStore:
n_ds ds
ds = create datastore //legal, but to be avoided!
Design-level considerations
Although stricter compiler enforcement for the .NET environment can catch
coding errors typically tolerated by the PowerScript compiler, the .NET
environment might also require changes in application design that are not
necessarily caught by the compiler.
Use PowerBuilder For a PowerBuilder .NET Web Form application, you should use
system functions PowerBuilder system functions instead of external functions whenever
possible. Some system functions, such as the functions for file operations, are
implemented differently for Windows Forms and Web Forms. If you always
use PowerBuilder system functions, you do not need to worry about these
differences.
Use GetCurrentDirectory Some applications use external DLL functions to
get the current directory. For PowerBuilder Web Form applications, you must
use the GetCurrentDirectory standard system function instead.
PowerBuilder Web Forms use a virtual file system to emulate a file system on
the server for each client. The virtual file system is actually a folder on the
server computer to which the ASP.NET user has write permission. Calling an
external function to get the current directory from the virtual file system will
fail.
Work around Avoid using Handle Some applications call the Handle function to get the
unsupported features window handle of a control and pass it to an external function. This does not
work in a Web Form application.
Restrict impact of unsupported events Since unsupported events are
never triggered, do not allow the logic in unsupported events to affect the logic
flow of other events or functions. For example, if the code in an unsupported
event changes the value of an instance variable, it can affect the logic flow in
a supported event that uses that variable. You should remove this type of
coding from unsupported events.
Avoid name conflicts PowerBuilder allows two objects to have the same
name if they are of different types. For example, you can use the name
s_address to define a structure and a static text control or a nonvisual object in
the same PowerBuilder application. The .NET environment does not allow two
classes to have the same name. To enable your application to compile in .NET,
you must not give the same name to multiple objects, even if they are of
different types.
AcceptText is redundant In the WebForm deployment version of the
DataWindow®, explicit invocations of AcceptText are redundant but harmless.
Any loss of focus of a DataWindow implicitly invokes AcceptText.
Avoid hindrances to Some functions and features that are fully supported can hinder application
application performance. These functions and features should be used sparingly and
performance
avoided where possible.
Although the QuickGo navigation control defaults to a drop-down list, you can
change this to a text box with an associated command button by setting the
PBDataWindowQuickGoPageNavigatorType property to “Button”. You can
edit the button label by setting the PBDataWindowGoToButtonText property.
You set the label for the text box or the drop-down list by modifying the
PBDataWindowGoToDescription property.
The code inside the #CLR-#ENDCLR blocks is passed to the Web browser
client from the server at runtime. You use this code to designate JavaScript
functions that handle events on client-side objects. Most events on client-side
objects cause a postback to controls on the server side, because the events have
server-side analogs that are written originally in PowerScript, then transformed
to run in the .NET environment.
If you write any JavaScript code for the client-side events, the postback to the
server is interrupted. To resume a postback, you can call the submit method for
a Web Form or one of the postback methods generated in the
PBDataWindow.JS file. The PBDataWindow.JS file is generated in the Scripts
subdirectory of the main project directory under the IIS virtual root.
The postback methods of the PBDataWindow.JS file are described in Chapter
2, “Client-Side Events and Default Event Handlers.”
DataWindow property for setting a customized event handler Properties
of the DataWindow class allow you to handle client-side events in JavaScript
code. The JavaScriptFile property specifies the JS file that contains JavaScript
functions for handling individual client-side events. You must make sure to
deploy the JavaScript file that contains your customized event handling code.
You assign the JavaScriptFile property in a #CLR-#ENDCLR code block:
#clr
dw_1.JavaScriptFile = “D:\Scripts\MyScriptFile.js”
#endclr
DataWindow properties for calling client-side events The following
DataWindow events can be handled on the client side in JavaScript code:
• Clicked
• ButtonClicking
• ButtonClicked
• ItemChanged
• ItemError
• ItemFocusChanged
• RowFocusChanged
• RowFocusChanging
The DoubleClicked and RButtonDown events are not handled on the client
side in the current CTP release.
For more information on client-side events, see Chapter 2, “Client-Side Events
and Default Event Handlers.”
To specify a JavaScript function for handling a client-side event, you must
indicate the function to call in the corresponding Web DataWindow property.
The name of the corresponding property consists of the name of the client-side
event with an “OnClient” prefix. For example, the property corresponding to
the ItemChanged event is OnClientItemChanged.
Troubleshooting tips
After successfully deploying a PowerBuilder .NET Web Form project, you
might encounter some of the following common, easy-to-fix issues at runtime:
Resource files might not be accessible if you change the default value for the
initial current directory of the virtual file system for the Web Form project. The
default value in the .NET Web Form project wizard is the current target path.
Modifying the PBCurrentDirectory global property in the project’s ASP.NET
configuration settings or directly in the Web.config file might also make the
resource files inaccessible.
Print failure
PowerScript print functions are not supported in the current CTP release. If
your applications saves or exports DataWindows as PDF or XSL-FO files,
make sure you read the instructions for installing the appropriate printing
software on the Web Form server.
For more information, see “Requirements for saving files in PDF or XSL
format” on page 49.
Log files
Log.txt A PowerBuilder application that compiles successfully with the
PowerBuilder native compiler might not compile successfully with the
PowerBuilder to .NET compiler. At deployment time, PowerBuilder logs all
compilation errors and warnings into the application’s log.txt file. The
PowerBuilder to .NET compiler is stricter than the PowerBuilder native
compiler, as described in “Best practices for C# and .NET coding” on page 13.
If deployment fails, or if issues occur at runtime, review the errors and
warnings in the log.txt file.
Pbtrace.log At runtime, a Web application logs all exceptions in the
pbtrace.log file located in the applicationName_root\log directory. You can
look into the call stack when an exception is thrown and map the call stack back
to PowerScript code, from which you might find the root cause of any runtime
errors.
About this chapter This chapter describes the client-side events available to Web Form
applications and the default JavaScript event handlers that post back to the
server.
Contents
Topic Page
About client-side programming 31
Default event handlers 33
Client-side support for the Web DataWindow control 35
Alphabetical list of Web DataWindow client-side events 37
Example code for an The following is an example of a customized, client-side JavaScript event
event handling script handler for the ItemChanged event of a DataWindow. The event handler
determines whether the item changed is in the first or second column of the
DataWindow. If the item is in one of the first two columns, this event handler
calls the default JavaScript event handler that rejects item changes. In this case,
the default event handler does not cause a postback. If the item changed is not
in the first or second column, no client-side action is taken, and the server-side
action is delayed until a postback is triggered by a different event or function
call:
//Start MyScriptFile.js
function MyItemChanged(sender, rowNumber, columnName,
newValue)
{
if(columnName == “column1” || columnName == “column2”)
{
// The default function is invoked
return PBDataWindow_ItemChangedReject(sender,
rowNumber, columnName, newValue)
}
else
{
//do nothing
}
}
//End MyScriptFile.js
The hook into the customized JavaScript event handler is added at design time
in a #CLR-#ENDCLR code block:
#clr
dw_1.JavaScriptFile = “MyScriptFile.js”
dw_1.OnClientItemChanged = “MyItemChanged”
#endclr
Default event handlers The default event handlers for the ItemChanged and ItemError events do not
and postbacks trigger postbacks. If active, the default ItemChanged event handler returns
immediately to reject the entered value or causes the Web Form application to
wait for a cascade of user events to occur before a postback is allowed. The
cascade of events that must occur before a postback is triggered is:
ItemChanged, Clicked, RowFocusChanging, RowFocusChanged, and
ItemFocusChanged.
Some versions of the default Clicked event handler set a timer for postbacks
because the DHTML DoubleClicked event also triggers the Clicked event.
About return values In client events, you can use a return statement as the last statement in the event
for DataWindow script. The datatype of the value is number.
events
For example, in the ItemChanged event, set the return code to 2 to reject an
empty string as a data value:
if (newValue = "") {
return 2;
}
This example prevents focus from changing if the user tries to go back to an
earlier row:
function dwCustomer_RowFocusChanging(sender,
currentRowNumber, newRowNumber)
{
if (newRowNumber < currentRowNumber)
{ return 1; }
}
This example displays a message box informing the user which column and
row number was clicked:
function dwCustomer_Clicked(sender, rowNumber,
objectName)
{
alert ("You clicked the " + objectName +
" column in row " + rowNumber)
}
Note that displaying an Alert message box for all clicked objects in a
DataWindow could prevent data entry or modification.
ButtonClicked
Description Occurs when the user clicks a button inside a DataWindow object.
Argument Description
sender String. Identifier for the button the user clicked.
row Number. The number of the current row when the user
clicked the button.
objectName String. The name of the control within the DataWindow
under the pointer when the user clicked.
This event is fired only if you have not selected Suppress Event Processing for
the button. If Suppress Event Processing is on, only the Clicked event and the
action assigned to the button are executed when the button is clicked.
If Suppress Event Processing is off, the Clicked event and the ButtonClicked
event are fired. If the return code of the ButtonClicking event is 0, the action
assigned to the button is executed and the ButtonClicked event is fired. If the
return code of the ButtonClicking event is 1, neither the action nor the
ButtonClicked event is executed.
See also ButtonClicking
ButtonClicking
Description Occurs when the user clicks a button. This event occurs before the
ButtonClicked event.
Argument Description
sender String. Identifier for the button the user clicked.
row Number. The number of the current row when the user
clicked the button.
objectName String. The name of the control within the DataWindow
under the pointer when the user clicked.
This event is fired only if you have not selected Suppress Event Processing for
the button.
The Clicked event is fired before the ButtonClicking event.
See also ButtonClicked
Clicked
Description Occurs when the user clicks anywhere in a DataWindow control.
Argument Description
sender Sting. Identifier for the client-side control.
row Number. The number of the row the user clicked.
objectName String. The name of the control within the DataWindow
under the pointer when the user clicked.
Examples This script in an .aspx file submits the value of the selected row in the
DataWindow to the server:
function objdwCustomers_Clicked(sender, rowNumber,
objectName) {
document.Form1.rownum.value = rowNumber;
document.Form1.submit();
}
See also ButtonClicked
ButtonClicking
ItemFocusChanged
RowFocusChanged
RowFocusChanging
ItemChanged
Description Occurs when a field in a DataWindow control has been modified and loses
focus (for example, the user presses Enter, the Tab key, or an arrow key or
clicks the mouse on another field within the DataWindow). It occurs before the
change is applied to the item. ItemChanged can also occur when the Update
function is called.
Argument Description
sender String. Identifier for the client-side control.
row Number. The number of the row containing the item whose
value is being changed.
columnName String. The name of the column containing the item.
newValue String. The new data the user has specified for the item.
ItemError
Description Occurs when a field has been modified, the field loses focus (for example, the
user presses Enter, Tab, or an arrow key or clicks the mouse on another field in
the DataWindow), and the data in the field does not pass the validation rules
for its column.
Argument Description
sender String. Identifier for the client-side control.
row Number. The number of the row containing the item whose
new value has failed validation.
columnName String. The name of the column containing the item.
newValue String. The new data the user has specified for the item.
ItemFocusChanged
Description Occurs when the current item in the control changes.
Argument Description
sender String. Identifier for the client-side control.
row Number. The number of the row containing the item that has just
gained focus.
columnName String. The name of the column containing the item.
RowFocusChanged
Description Occurs when the current row changes in the DataWindow.
Argument Description
sender String. Identifier for the client-side control.
newRow Number. The number of the row that has just become
current.
Examples This script in the .aspx file displays an alert message when the row focus
changes:
function objdw_RowFocusChanged(sender, newRowNumber) {
alert("Focus changed to row” " + newRowNumber);
}
See also ItemFocusChanged
RowFocusChanging
RowFocusChanging
Description Occurs when the current row is about to change in the DataWindow. (The
current row of the DataWindow is not necessarily the same as the current row
in the database.)
The RowFocusChanging event occurs just before the RowFocusChanged
event.
Argument Description
sender String. Identifier for the client-side control.
currentRow Number. The number of the row that is current (before the
row is deleted or its number changes). If the DataWindow
object is empty, currentrow is 0 to indicate there is no current
row.
newRow Number. The number of the row that is about to become
current. If the new row is going to be an inserted row,
newrow is 0 to indicate that it does not yet exist.
About this chapter This chapter describes the print, mail profile, and file managers that you
can use with a PowerBuilder .NET Web Form application.
Contents
Topic Page
Using the Web Form Print Manager 47
Using the Web Form File Manager 52
Using the Web Form Mail Profile Manager 58
Using the registry functions 61
You can also use the PowerScript SaveAs method to print DataWindows
and their data as PDF or XSL files. These files are not visible in the Web
Form Print Manager and cannot be printed on the client side without the
intervention of the IIS administrator.
The Print Manager icon automatically disappears on browser refresh after all
the printed files are removed from the Print Manager window.
The SessionID directory created under the Print directory uses the same session
ID number as the subdirectory created under the applicationName_root\File
directory when the user saves a DataWindow as a PDF or writes to a file from
the current application session, or when the PBWebFileProcessMode global
property has been set to Copy mode. The actual SessionID directory name is a
long 24-character string with letters and numbers such as
cdxgel554rkxxsbn1221uh55. The SessionID directories are deleted when the
Web Form session is ended.
The processor directory and the JRE must be in the same path as the
PowerBuilder runtime files. For example, if pbvm110.dll and the other
PowerBuilder runtime files are included in a server computer directory called
ServerPB, the Apache processor and the JRE must be copied to
ServerPB/fop-0.20.4 and ServerPB/jre. However, you do not need to place a
copy of the JRE in this location if the full JDK is installed on the server
computer and is in its classpath.
The following JAR files must be in the server computer’s classpath:
• fop-0.20.4\build\fop.jar
• fop-0.20.4\lib\batik.jar
• fop-0.20.4\lib\xalan-2.3.1.jar
• fop-0.20.4\lib\xercesImpl-2.1.0.jar
• fop-0.20.4\lib\xml-apis.jar
• fop-0.20.4\lib\avalon-framework-cvs-20020315.jar
DBCS platforms
If the Web Form server computer is a DBCS platform, you also need to include
a file that supports DBCS characters in the Windows font directory, for
example, C:\WINDOWS\fonts. For more information about configuring fonts,
see the Apache Web site at http://xml.apache.org/fop/fonts.html.
You must also make sure the default PostScript printer driver and related files
in Sybase\Shared\PowerBuilder\drivers are included in the IIS server path.
Figure 3-2: Virtual file system under the IIS root directory
File process mode There are two file process modes: Share mode and Copy mode. The
PBWebFileProcessMode global property defines the mode for the current Web
Form application. It is set to Share mode by default.
Share mode: Files are copied from the Common directory to the SessionID
directory only as needed.
Copy mode: In Copy mode, the first time a file operation is called, all folders
and files under the Common directory are copied to the SessionID directory. In
Copy mode, all file operations are handled in subdirectories of the SessionID
directory.
The File Manager presents a merged view of the files under the Common and
SessionID directories. If a read-only file in the Common directory has the same
name as a read-write file in the SessionID directory, only the SessionID file is
displayed.
Although users can delete and move folders or files that they create under the
SessionID directory, files and folders that are copied from the Common
directory to the SessionID directory cannot be deleted because the File
Manager presents a merged view of these virtual file paths, and removing a file
or folder from the SessionID directory does not cause its removal from the
Common directory.
The common dialog boxes for all file operations are supported regardless of
file process mode. You can display these dialog boxes with the
GetOpenFileName, GetSaveFileName and GetFolder functions.
Using the File Users can open the File Manager only if you choose to render the File Manager
Manager icon in your Web Form applications. Although you can choose to render the
File Manager icon at design time, you can change your selection after
deployment by modifying the application’s PBFileManager global property.
The File Manager icon displays in the upper right corner of the Web Form, just
to the right of the Mail Profile Manager icon when that icon is also rendered.
The File Manager opens in the current browser window when a user clicks the
File Manager icon.
Figure 3-3 shows the File Manager for a Web Form application.
Creating a directory The File Manager allows users to create directories, rename and delete selected
files or directories, and to upload and download selected files. It allows users
to view all files in the virtual file system for the Web Form application—unless
those files are located in a directory or subdirectory listed in the
PBDenyDownloadFolders global property.
The new directory is created in the SessionID path under the directory you
selected in Step 1. No other application user can use the Web Form File
Manager to see the new directory. When you leave the current session, the
directory and any files you uploaded to it are removed.
Closing the File Users can close the File Manager and return to the current Web Form window
Manager by selecting Frame from the Windows drop-down menu that displays in the
upper right corner of the manager frame. The close (x) button at the upper right
corner of the manager frame also has the same effect. This is a separate close
button from the one in the browser title bar. (The close button in the browser
title bar closes the browser and ends the current Web Form session.)
Figure 3-4 displays the Frame Manager’s drop-down menu.
Figure 3-4: Drop-down menu in the Frame Manager
Uploading files The files that a user uploads through the Web Form File Manager are saved
under the SessionID path. The uploaded files are copied from the client-side
computer. They are deleted from the server-side SessionID path at the end of
the Web Form session.
Figure 3-5 shows the PowerBuilder Upload File dialog box for a Web Form
application.
The Mail Profile Manager is divided into sections for user profile information,
outgoing mail parameters, incoming mail parameters, and account type.
Information that the application user enters in the Mail Profile Manager can be
saved in a profile that is available to the Web Form application.
Table 3-1 lists and describes the fields in the Web Form Mail Profile Manager.
Table 3-1: Mail Profile Manager fields
Section Field Description
User Profile Name Display name for the user.
User ID Alias used to log onto the e-mail server.
E-mail address E-mail address the Web Form user wants to use.
Password Password for the user ID. The password a user
enters is encoded using an MD5 algorithm.
Outgoing Mail Server address Address for the outgoing mail server, such as
smtp.sybase.com.
Port The default outgoing mail port is 25.
Requires Select this check box if the outgoing mail server
authentication requires authentication or a certificate file.
Requires SSL Select this check box if the outgoing mail
requires a secure sockets layer connection.
Incoming Mail Server type Select POP3 or IMAP for the incoming server
type. POP3 is the default.
Server address Address for the incoming mail server, such as
pop3.sybase.com.
Port The default incoming mail port is 110.
Requires SSL Select this check box if the incoming mail
requires a secure sockets layer connection.
Account Type Permanent Select this radio button to keep the mail profile
across Web Form sessions.
Temporary Select this radio button to delete the mail profile
when the current Web Form session is
terminated.
After entering all the Mail Profile Manager fields, the user should click Create
Profile to save the entries to a profile file in the applicationName_root\Mail
virtual file directory.
</k>
</k>
</k>
</k>
</RegistryRoot>
The first time the registry function is called, the system copies registry.xml
from the Common directory to the SessionID directory; after that, the system
uses the registry.xml copy under the SessionID directory.
About this chapter In this PowerBuilder 11.0 Community Technology Preview release, you
can use the .NET Web Form Application wizard to deploy PowerBuilder
applications that are suitable for use as Web applications to ASP.NET 2.0.
This chapter lists features of PowerBuilder and PowerScript that are not
supported in the current release.
Contents
Topic Page
About unsupported features 63
Unsupported nonvisual objects 64
Unsupported system functions 65
Restrictions on supported controls 66
Unsupported functions 73
Unsupported events 76
Unsupported properties 77
Category Objects
OLE OleStorage
OleStream
OmStorage
OmStream
EAServer integration RemoteObject
Category Functions
Profiling and tracing functions TraceBegin, TraceClose,
TraceDisableActivity, TraceDump,
TraceEnableActivity, TraceEnd,
TraceError, TraceOpen, TraceUser
Reflection functions FindClassDefinition,
FindFunctionDefinition,
FindTypeDefinition
System registry functions can read and write registry entries, keys, and values
on the server side, but do not perform these operations on the server computer’s
registry in the same way as they do on a client computer’s registry in a standard
PowerBuilder application.
For more information on system registry functions, see “Using the registry
functions” on page 61.
Table 4-4 lists the functions, events, and properties that are not supported on
some individual controls. Table 4-4 does not include the items listed in Table
4-3. The entry “No additional” in Table 4-4 indicates that all items except those
listed in Table 4-3 are supported for that control.
Table 4-4: Unsupported functions, events, and properties by control
Supported control Unsupported functions Unsupported events Unsupported properties
Animation Seek No additional OriginalSize
CommandButton SetFocus No additional No additional
CheckBox SetFocus No additional No additional
DataStore Same as DataWindow No additional No additional
Unsupported functions
Table 4-5 lists unsupported functions, the controls on which they are not
supported, and any notes that apply to specific controls. If your application
uses these functions, you should rework your application to avoid their use.
Unsupported events
Table 4-6 lists unsupported events, the controls on which they are not
supported, and any notes that apply to specific controls. If your application
uses these events, you should rework your application to avoid their use.
Table 4-6: Unsupported events for Web Form deployment
Event Controls Notes
BeginDrag ListView, TreeView
BeginLabelEdit ListView, TreeView
BeginRightDrag ListView, TreeView
Clicked PictureHyperLink, StaticHyperLink, Not working for PictureHyperLink,
TreeView, Window StaticHyperLink, and TreeView, not
supported for Window.
Deactivate Window
DeleteAllItems ListView
DoubleClicked HProgressBar, Picture, Not working for PictureHyperLink and
PictureHyperLink, StaticHyperLink, StaticHyperLink. Not currently
StaticText, Tab, TreeView, supported for client-side Web
VProgressBar, Window DataWindow control. Not supported for
progress bars. Working for other
controls, but the Clicked event is not
triggered on a double click in a Picture
or StaticText control.
DragDrop All controls
DragEnter All controls
DragLeave All controls
DragWithin All controls
EndLabelEdit ListView, TreeView
GetFocus All controls
Help All controls
Hide Window
HotLinkAlarm Window
ItemActivate ListView
Key All controls
Unsupported properties
Table 4-7 lists unsupported properties, the controls on which they are not
supported, and any notes that apply to specific controls. If your application
uses these properties, you should rework your application to avoid their use.
Table 4-7: Unsupported properties for Web Form deployment
Property Controls Notes
Accelerator All controls
AccessibleDescription All controls Works on some controls.
AccessibleName All controls Works on some controls.
AccessibleRole All controls
Alignment StaticHyperLink Not working.
AutoArrange ListView
5 Enter dba as the value for the user ID and sql as the password.
Upon successful login, an MDI frame window with a menu and toolbar
displays.
6 Test available menu options to make sure they are working, then
terminate the application.
Unless you plan to always start the tutorial database manually before your Web
Form application connects to the database, you must grant all ASP.NET users
full control of the directories containing the database and the ASA database
engine, and extend that permission to all the files in those directories.
If you want resource files to display in the browsers of Web Form clients, you
must make sure that the resource files use fully named paths rather than relative
paths. In this lesson you:
• Grant ASP.NET users full control over key directories and files
• Change a relative path to a hard-coded path
Grant ASP.NET users full control over key directories and files
You can grant ASP.NET users full control over the database and database
engine directories to enable the Web Form application to automatically start the
tutorial database. You must also propagate the directory permissions to all files
in these directories.
2 Right-click the directory and select Properties from the pop-up menu.
3 Select the Security tab of the Properties dialog box for the directory
and click the Add button.
The Select Users, Computers, or Groups dialog box displays.
4 Click Locations and choose the server computer name from the
Locations dialog box and click OK.
5 Type ASPNET in the list box labeled “Enter the object names to
select” and click OK.
The ASP.NET machine account is created for the current directory.
If you click the Check Names button, a message will be displayed if the
system does not recognize the ASPNET user name. If the name is not
recognized, you might have to reinstall the Microsoft 2.0 .NET
Framework.
The Select Users, Computers, or Groups dialog box closes after you click
OK and you return to the Security tab of the Properties dialog box for the
current directory.
6 Select the ASP.NET machine account in the top list box on the
Security tab, then select the “Full Control” check box under the Allow
column in the bottom list box.
8 Select the check box labeled “Replace permission entries on all child
objects with entries shown here that apply to child objects” and click
OK.
A Security dialog box displays, warns you that it will remove current
permissions on child objects and propagate inheritable permissions to
those objects, and prompts you to respond.
9 Click Yes at the Security dialog box prompt, then click OK to close the
Properties dialog box for the current directory.
3 Click the browse (...) button next to the PictureName text box on the
General tab of the Properties view for the picture control.
The Select Picture dialog box displays.
You use the PowerBuilder .NET Web Form project wizard to convert an
existing PowerBuilder application to a Web Form application.
2 Select the .NET Web Form Application Wizard icon and click OK.
The first page of the wizard displays about what the wizard is used for.
3 Click Next until the Specify Settings for .NET Web Form Application
page displays.
You accept the default values for the application library (pbtutor.pbl) and
the .NET Web Form project name (p_pbtutor_webform). The following
table shows default values for the fields on the .NET Web Form
Application page:
.NET Web Form parameter Default value
Web application name pbtutor
Application URL preview http://<ServerName>/pbtutor, where
<ServerName> is a placeholder for the name
of the IIS server
Initial current directory in virtual The path of the current directory, typically:
file system drive:\Program Files\Sybase\PowerBuilder
11.0\Tutorial\Solutions
Command line parameters — (blank)
Window style Classic Web style
Render file manager icon Not selected
Render mail manager icon Not selected
6 Select All Files from the Files of Type drop-down list and navigate
to the parent Tutorial directory.
7 Hold down the Ctrl key and select the tshirtw.jpg, tutsport.bmp,
and tutorial.ico files and click Open.
The selected resources are added to the page as shown below:
8 Click Next to include the selected resource files for deployment with
the tutorial Web Form application.
The “Specify External Modules” page of the wizard displays. The tutorial
application does not use any external modules.
11 Accept Localhost for the IIS server address or change this to the
formal name for the local IIS server, then click Next.
In this tutorial, you deploy the Web Form project directly to the local IIS
server. After you click Next, the Summary page of the wizard displays.
After you deploy the tutorial application to an IIS server, the pbtutor and
pbtutor_root directories are created under the IIS root directory. The IIS root
directory is c:\Inetpub\wwwroot by default.
In this lesson you change a global property for page navigation in the
DataWindow controls on tutorial application sheet windows.
2 Expand the nodes for your local computer, as well as those for Web
Sites and Default Web Sites.
You should see nodes labeled pbtutor and pbtutor_root.
The ASP.NET tab of the Properties dialog box displays, as shown below:
You are now ready to run the tutorial as a Web Form application. In this lesson
you start one application session from PowerBuilder and another session by
typing the application URL in a Web browser Address box.
The .NET Web Form Application dialog box opens to the Run in Browser
page.
4 Open an Internet Explorer (IE) browser from the Windows Start menu
or task bar.
You can open a browser on a different computer if you have one available.
You will next start a second session for the tutorial application.
6 Enter dba for the user ID and sql for the password.
After a successful login, the tutorial application’s Frame window displays
in the Web browser.
The following picture displays the tab page format used in the classic Web
style presentation.
Advanced topics
For more information on the File Manager and Mail Profile Manager, as
well as for information on printing to a PDF file and on using registry
functions, see Chapter 3, “Print, File, Mail, and Registry Operations in
Web Forms.” For information on coding client-side events, see Chapter 2,
“Client-Side Events and Default Event Handlers.”
A E
ASA database connection, setting up 11 Embedded, StaticHyperLink property 22
ASP.NET event handlers
configuring 7 and postback events 32
setting user permissions 11, 86 client-side 32
version 8 default 33
AutoPostBack property 22 events
ClientEvent properties 35
Web DataWindow client control 35
B
ButtonClicked event 38
ButtonClicking event 39 F
File Manager
creating a folder 55
downloading a file 57
C uploading a file 56
Clicked event 40 virtual file system 52
client-side, event handlers 32 file process mode 53
command-line parameters 7
Configuring
ASP.NET 7
IE Web Controls 12 G
conventions vi Ghostscript, installing 50
copy mode, global property 53 global properties 18, 22
D H
DataWindow HTMLGen.PagingMethod property 33
page navigation 19
pagination 19
saving as PDF 49
saving as XSL 49 I
deploy, Web Form project 6 IE Web Controls
downloading files 57 configuring 12
problem with toolbars and tab controls 27
IIS, directory structure 10
ItemChanged event 41
T
P Troubleshooting tips 26
PBDataWindow.JS file 33 typographical conventions vi
PBTrace.Log file 12
PDF
Apache FO printing method 49
postscript printing method 49 U
postback uploading files 56
and client-side events 20
W
Web browser
command-line parameters 7
default start page 7
Web DataWindow
client-side scripts 35
events for client control 35
Web Form applications
advantages 2
directory structure 10
global properties 9
sending and receiviing mail 58
start page 7
supported controls 67
unsupported features 63
using registry functions 61
virtual file system 52