DBMS

Plugging into the Web

By Marcia Gulesian
DBMS, December 1996

Using Plug-Ins to Rehost a Client/Server Application for Running on a Web Browser.


The Internet is still maturing in the area of business applications and development technologies. The tools market is very fragmented: De facto standards such as plug-ins, ActiveX controls, Java, and HTML are vying to become the development environment of choice for extending data-driven applications toward full Internet capability. One of these contenders -- browser plug-ins --provides a way to speed the deployment of highly functional, visually sophisticated Web applications. A new arrival, the PowerBuilder Window Plug-In, enables complete PowerBuilder applications to run within a plug-in-enabled Web browser such as Netscape Navigator (2.0 or later) or Microsoft Internet Explorer (3.0 or later).

Browser Plug-Ins

The focus of the user interface, as seen in Figure 1, has changed from the window to the browser. Plug-ins provide a seamless way for applications to display information and interact with the user of a browser. In short, these modules are software programs that you install on your hard disk to extend the capabilities of your Web browser. After installation, the browser uses the plug-ins' capabilities like other browser features. Plug-ins are associated with a Mime data type that the browser does not natively support. When it encounters an unknown data type from a server (the server not only returns a document but also includes the content type in the header information), the browser looks for and then loads a plug-in associated with that Mime type.

Plug-ins can have one of three modes of operation: embedded, full-screen, or hidden. An embedded plug-in is a part of a larger HTML document, visible as a rectangular frame within a page (embedded plug-ins are specified in HTML with the EMBED tag). A full-screen plug-in is a self-contained viewer, completely filling the content area of your browser window. A hidden plug-in runs in the background. Figure 2 shows how my application uses the EMBED tag. The plug-in appears as a window on the displayed form. You interact with the window as you would any other control on an HTML form.

The PowerBuilder Window as a Plug-In Application

Before describing how the PowerBuilder Window Plug-In (hereafter referred to as Window Plug-In) works, it is important to explain just what this plug-in can and cannot do. First of all, the Window Plug-In makes it possible for a developer to build a PowerBuilder application that can run in a plug-in-enabled browser. This plug-in capability is limited to a specific type of window called a "Child." Using a Child window gives you most of the features available to a "Main" window, such as standard PowerBuilder tab controls, tree views, graphs, and OCXs; a Child window also gives you the DataWindow interface, which provides connections to a large list of data sources using Powersoft's native and ODBC drivers. In this Child window, however, you are restricted to a Single Document Interface (SDI) style of application. As such, this Window Plug-In technology is not applicable to an existing PB application that was built as a complex, menu-driven Multiple Document Interface (MDI), which lets the user move from sheet to sheet. But an SDI application can be fairly robust despite the Child constraint, giving the user the tab control that is one way of simulating multiple windows.

Figure 3 shows that the PowerBuilder runtime and PowerBuilder plug-in DLL must be installed on the client workstation in order to reference a PowerBuilder window. The plug-in-enabled browser starts my plug-in application (file name: inventory.pbd) when it is referenced by special tags in the HTML page (file name: inventory.htm) retrieved from an Internet server. PowerBuilder windows and the objects they reference are downloaded in a PBD file (PowerBuilder dynamic library) when the client requests them. Dynamic libraries are self-contained units that are similar to DLLs in that they are linked to the application at execution.

Once sent to the browser, the HTML form references the PowerBuilder child window w_inventory, which was compiled into inventory.pbd. Scripts attached to events for objects/controls on the window are executed on the client machine (that is, on the browser), as with any other PowerBuilder application. When the page (or form) is unloaded, the PowerBuilder window is closed.

Additionally, your Window Plug-In application can interface with a Distributed PowerBuilder application that may reside on another platform, such as Unix. You can now distribute PowerBuilder objects across the network for increased scalability and centralized management. The Window Plug-In exists as part of Netscape's Application Programming Interface (API). As a DLL, the Window Plug-In is called as necessary into memory, where it will stay until termination of all the applications that use its services.

The Application

A PowerBuilder application is a collection of windows that perform related activities, such as order entry, accounting, or manufacturing. I developed my application for a fictitious company called Newco, which sells and delivers food materials to the kitchens of colleges, corporations, and other institutions scattered throughout a six-state area. The company, to which the kitchens have outsourced their inventory management operations, provides the kitchens with the software to run my Windows Plug-In application. The kitchens must acquire their own PCs and data communication channels independently. Newco provides the support necessary to install the software and link it to Newco's servers.

Sitting in front of the client-side GUI, the kitchen's production manager selects a recipe from the list in the upper left-hand corner and types in the number of servings ("Enter Production Quantity:") in the edit box below. When the manager presses the command button ("Request Production-Scale Information") at the bottom, the data window in the center is repopulated with data retrieved from the DBMS after the quantity and units data have been converted to values appropriate to the scale requested. For example, if the basic recipe table specifies three teaspoons of sugar for four servings, and the customer requires ingredients for 16 servings, the data window will display 1/4 cup of sugar. For still larger runs, the units value might be listed as, for example, 10-pound bag. If no rescaling is required, the program retrieves the recipe information exactly as it is stored in the recipe table of the database.

Also after pressing the command button, the contents of the three-page tab control located in the upper right-hand section of the form are updated. The full-size Formula One spreadsheet (an OCX that is included in PowerBuilder 5.0 Enterprise Edition) in the first page provides seamless integration between SQL and spreadsheet data. In my application, this Excel-compatible spreadsheet gives the manager cost breakdown and other accounting information related to the order being placed. As a component, this spreadsheet requires a fraction of the resources consumed by standalone spreadsheets.

The second tab contains an invoice for the current (but not yet submitted) order for the manager to examine. The third tab contains information needed for a production run of the selected recipe. When satisfied with the details of the report, the manager presses the "Send Purchase Order" button. This last step can be modified: If, say, the invoice indicated two-day delivery when the manager required next-day delivery, the "E-Mail" button could be used to initiate a change. At the Newco DBMS, procedures (and, alternatively, triggers) query database tables that contain data on recipes, customers (the kitchens), and inventory, in addition to the accounting system of New England Food Services (Bridgeport, Conn.).

At the Newco DBMS, the client's queries are examined and the size of the requested stock is compared with current inventory levels. After a procedure examines reorder lead-times and other factors, the algorithm decides which information to send to the customer who placed the order. Moreover, a number of other Transact-SQL scripts run at the DBMS: When there is a need to replenish inventory levels, scripts use string functions to create and send email messages to vendors that the food service company's inventory department uses. When a purchase order is received by the food service company, the inventory table is credited and the accounts receivable table is debited.

Stored Procedures

Database stored procedures enable you to define procedural SQL statements in the database for use by applications. Using stored procedures to perform database updates, inserts, and so on lets you enhance database security, integrity, and performance. Because stored procedures provide for conditional execution, you can also use them to enforce additional business rules as described in the preceding section.

Stored procedures differ from ordinary SQL statements and from batches of SQL statements in that they are precompiled. The first time you run a procedure, SQL Server's query processor analyzes it and prepares an execution plan that is ultimately stored in a system table (also known as the data dictionary). The procedure is then executed according to the stored plan -- almost instantaneously, because most of the query processing work has already been performed.

Overall System Design

The overall design of a distributed client/server system is not conducted in a vacuum. Any effective design must use the available technology and human resources in a way that achieves a stated business objective at as low a cost as possible. Let's look at the different resources available to the various business users of my application.

Glancing at the design of my application (as seen in Figure 3), you can see where performance gains or losses can occur: in the client workstations, at the two servers, or in any of the data communication channels that connect these nodes. What you can't see is how the scheduling of server access can also be a factor that determines system performance. If all of the clients try to connect to the Web server or to the DBMS at the same time, performance will suffer. But if you spread out these access times, the servers will be able to handle their loads much more effectively. Charging less for connections made during off-peak hours usually works.

My PowerBuilder application (inventory.pbd) is downloaded from the Web server to the Web browser. From there, it connects to the DBMS. These connections frequently involve two physically distinct data communication channels. One channel is indicated in Figure 3 by the solid lines between the Web server and the individual clients; the other channel is indicated by the dashed lines between the DBMS and the individual clients. Naturally, the two servers could run on the same workstation, but they would each compete for the resources of a single hardware platform.

Although loaded with functionality, inventory.pbd is only 75 kilobytes in size. A file of this size can be downloaded by most industrial users in just a few seconds, but users with an analog modem will wait for as long as 30 seconds. The amount of data returned to the client depends on the query selected. Other influential factors include whether the raw materials that the user has requested are available in inventory, whether the order is below a minimum level, whether the user account is in default, and whether an email message must be generated by the DBMS, on-the-fly, as part of its response to the query.

In addition to the time it takes for the .pbd file, queries, and result sets to travel through their respective data communication channels, you must also consider the application processing time of the client and server workstations. You will suffer poor performance when you run a full-featured application on anemic workstations and operating systems. On the other hand, to improve performance, you could either get along with fewer features or upgrade your computer resources.

So what's the bottom line? Do you have to go through a lengthy analysis to find out whether or not you'll be happy rehosting your present PowerBuilder application to run in a browser, across the Internet? The answer is a qualified "no." If your application already works over a WAN, you should see similar performance after modifying it to operate in this new browser-centric environment. If, on the other hand, your application currently runs over a LAN, you'll have to do your own computations to get estimates of the additional time imposed by your new data connection channel.

What if you're a PowerBuilder developer who wants to leverage PB skills and develop a brand new application to run in a Web browser? This is an extremely good reason to use the Window Plug-In, because the process involves little more than installing a few additional files. Before the plug-in, developers couldn't deploy a PowerBuilder application to run in a browser; they had to deal with HTML pages or Common Gateway Interface programming.

DataWindow Plug-Ins

PowerBuilder has another object called the DataWindow. When placed on a window, it provides a quick and easy means to retrieve, display, and manipulate data from an RDBMS or text file and present the data to the user in a familiar format. This same DataWindow can be stored on a Web server in a centralized location and be run from Web browsers using Powersoft's DataWindow Plug-In. In this context, the DataWindow must be saved in PowerBuilder as a Powersoft Report (.psr) file. Alternatively, you could generate a native .psr file using Powersoft InfoMaker, which comes with the PowerBuilder Enterprise Edition. The DataWindow Plug-In gives you a view of the data in sophisticated display formats such as crosstabs, charts, graphics, and business forms, overcoming the limitation of HTML. So if your goal is to publish detailed database reports to your Web users, the DataWindow Plug-In is a good solution because it has the added benefit of being a self-contained DLL that does not require the PowerBuilder 5.0 runtime.

A Plug for Plug-Ins

The application I presented in this article works well when deployed with the Windows Plug-In. Even if it hadn't worked so well, however, I would be wrong to fault plug-in technology without first considering the question of whether I had chosen a Web technology -- from among the many now available -- that was a good match for my business objectives. Powersoft plug-ins make it relatively easy to gain transparent access to feature-rich client/server applications from within the ubiquitous Web browser. The plug-in is only one of the Web-enabling technologies provided by Powersoft. The two plug-ins discussed in this article are included, along with several other complementary tools for building Web applications, in Powersoft's Internet Developers Toolkit for PowerBuilder 5. But before you get too carried away, don't forget the pre-Web stuff at the back end of your business application, lest the tail wag the dog.


Marcia Gulesian is author of over 50 articles on various aspects of distributed client/server technology. Her development work spans a host of environments (PowerBuilder, SQL Server, DB2, Notes, and so on) and networks (WWW, NT, NetWare, and Warp). You can email Marcia at mg@world.std.com.


Powersoft Division, Sybase Inc., 561 Virginia Rd., Concord, MA 01742; 508-287-1500 or fax 508-369-3997; http://www.powersoft.com.


Figure 1.


--A PowerBuilder application rehosted for running from a Web browser. The PowerBuilder Window appears on the displayed HTML form.


Figure 2.


--An HTML page that references the application window using the EMBED tag.


Figure 3.


--The architecture (simplified) of a client/server application run from a Web browser.



Subscribe to DBMS and Internet Systems -- It's free for qualified readers in the United States
December 1996 Table of Contents | Other Contents | Article Index | Search | Site Index | Home

DBMS and Internet Systems (http://www.dbmsmag.com)
Copyright © 1996 Miller Freeman, Inc. ALL RIGHTS RESERVED
Redistribution without permission is prohibited.
Please send questions or comments to dbms@mfi.com
Updated Monday, November 18, 1996