Features Banner

Connecting VisualAge for Smalltalk to the Web

By Bob Brodd, Hatteras Software, Inc.

Introduction

f you are already a user of IBM's VisualAge for Smalltalk products, you are probably already sold on the power and benefits that they provide. Not only do you gain the benefits of developing in a pure object-oriented Smalltalk environment, you also have access to the extensive support for databases, communication services (APPC, CS ECI, CPI-C ,HLLAPI, MQseries, NetBIOS, RPC, TCP/IP), AS/400 Connection, CICS and IMS Connection, Lotus Notes, and many other services that are available. Given the meteoric rise in the popularity of the Internet, and in particular, the World Wide Web (Web), wouldn't it be great if you could leverage this power to serve up web-based Smalltalk applications on the Internet, or even on your own intranet?

IBM's response to this desire is the VisualAge Web Connection Feature, an add-on to their VisualAge for Smalltalk product. The Web Connection provides a new set of visual and non-visual parts for VisualAge that are specifically designed for creating Web-based applications. Additionally, it provides the interface between your VisualAge application and Web server, eliminating most of the complexity of using the Common Gateway Interface (CGI), which is a standard protocol through which Web clients can execute programs residing on your Web server.

How it works

A typical Web session involving a Web Connection application works in the following manner:

Step 1: A client Web browser requests a Web Connection page by specifying the transfer protocol and Uniform Resource Locator (URL) (ex. http://www.server.com/cgi-bin/abtcgil.exe/PartName). In addition to specifying the server address (www.server.com), the URL also includes the path to the Web Connection CGI Link program (/cgi-bin/abtcgil.exe) as well as the VisualAge part name that designates the page to retrieve (PartName).

Step 2: The Web server receives the URL request and invokes the Web Connection CGI Link program (abtcgil.exe)..

Step 3: The CGI Link program relays this request to a pre-assigned TCP/IP socket where the Web Connection CGI Link Server, a process running in your VisualAge application, is waiting to service requests. Note: Your VisualAge application can be running on any computer that is accessible from your Web server via TCP/IP.

Step 4: The CGI Link Server receives the request and creates a new Smalltalk process to handle the request. It then creates a new instance of the Web Connection part (page) requested and asks the new part to generate its HTML.

Step 5: As part of generating its HTML, the part may potentially interact with model objects within the image to perform computations or provide data to display in the page. The resulting HTML code is passed back through the CGI Link Server, CGI Link, and your Web server to the Web browser, which renders the page to the client.

Not just another web page layout program

Before going on much further, I would like to emphasize that Web Connection is not a replacement for a Web page layout program. Its purpose is to provide support for building applications capable of running on the Web. As a result, you are not going to find support for every aspect of HTML. In fact, only the controls and features that have merit in the area of application construction are included or are even under consideration to be included. The components listed in the Supported HTML Components table are represented in Web Connection as visual parts in the composition editor. They have the ability to translate themselves into HTML code at runtime so that a client's Web browser can re-create the GUI. They also have the knowledge to align themselves on the VisualAge composition editor based on the rules of HTML. This provides the web page developer with visual feedback as to what the page is going to look like in a Web browser as they are developed (see before and after examples). None of the standard VisualAge for Smalltalk visual parts can be used on Web Connection pages (non-visual parts do not have this restriction).

The Web Connection parts do a good job of surfacing most of the features available for the HTML component they represent. For parts that do not, Web Connection typically provides the ability to add raw HTML to the part definition. Notable exceptions are the Table and Table Column parts. Although they are very useful for generating variable-length tables of static (string) information, they do not handle the nesting of other Web Connection parts. This is a rather serious deficiency given the enormous formatting and alignment benefits that HTML tables provide in an otherwise primitive and rigid environment. Not all is lost however. The HTML Text part can be created as a 'literal' string which allows you to add raw HTML code to your pages. You can interleave literal HTML Text parts with your other Web Connection parts to create tables on your own (of course you will have to learn about all of the HTML tags associated with tables first).

Advanced Application Development Support

Creating interactive applications to run over the World Wide Web is a major challenge given the standard mechanisms provided by HTML and HTTP. HTML was originally designed to support information retrieval by providing a mechanism for linking words or phrases in one document to associated text in the same document or other documents elsewhere on the Internet. HTTP was designed to be a very quick and simple transfer protocol. One of its major design points is that the connection made between the client and server is temporary; therefore, every request generated by the client results in a new connection. While they do a fine job at what they were originally designed for, they do not provide all the support necessary for developing serious Internet-based applications. To aid in building web-based applications, Web Connection provides several important non-visual parts to the palette.

HTML Form Data part webands1.gif

The HTML Form Data part provides access to the components defined within an HTML Form. In particular, it provides easy access to all of the data entered in fields, items selected in lists, as well as events such as button-clicks. These values and events can be connected to other appropriate parts via the standard VisualAge connection mechanism.

HTML Composite part webands2.gif

The HTML Composite part is a part holder that contains other Web Connection visual components. Once defined, the composite part can be included in any of your Web Connection page definitions. The advantage of this feature is that you can define common pieces of your user interface in one place and use it in many places. If changes are made to the composite part, all Web pages including the part will incorporate the changes. This part is an obvious choice for creating standardized headers and footers for your Web pages.

CGI Link Session Data part webands3.gif

As noted above, every request made by a client results in a new connection between the client and server. This causes a major problem for designing Web applications because there are no simple ways to maintain persistent information over the many connections a client creates while running an application. The CGI Link Session Data part is the Web Connection's answer to this problem.

The first time a client accesses a Web Connection part, the Web Connection generates a unique session key that is passed back to the client in a hidden HTML field. Each time the client posts a new request, the hidden session key is passed back with the request in the hidden HTML field allowing the Web Connection to identify the request as belonging to an 'existing' client. Using the session key, the Web Connection can identify the instance of the CGI Link Session Data part that belongs to the client. The value associated with a CGI Link Session Data is persistent and can contain any Smalltalk object required; therefore, any information that needs to persist during a particular client session can be stored.

An additional benefit of the CGI Link Session Data part is that your application can keep track of multiple sessions from different clients at the same time. In fact, since VisualAge for Smalltalk supports running multiple concurrent Smalltalk processes, these requests can occur simultaneously.

HTML Page Wrapper part webands4.gif

The HTML Page Wrapper part is an integral part of a mechanism designed to make it easy to transfer a client's request from one page to another. The HTML Page Wrapper is a part that represents a Web Connection page. When a request is posted to a Web Connection page, it can conditionally transfer the request to any of the HTML Page Wrappers that it defines.

As an example, let's assume that a page defines a form containing a push button that should display a new page when pressed. The button-clicked event of the form connects to the transferRequest action of the page wrapper which represents the new page. When the user presses the button, the client sends a request to the current Web Connection part which generates the button-clicked event. This event causes the transferRequest action of the page wrapper part to fire, transferring control to the new page. The new page then generates its HTML and returns it to the client; thereby becoming the new current page.

An additional feature of this part is the ability to pass any Smalltalk object along with the transfer request. Building on the previous example, let's add a list to the original page. Instead of connecting the button-clicked event to the transferRequest action, we will connect it to the transferRequest: action. Then we can connect the selected item of the list to the transferRequest: action as the parameter. When the new page receives control, it will have access to the object selected on the previous page (see CGI Link Request part below).

CGI Link Request part webands5.gif

The CGI Link Request part provides access to all of the information available in an incoming request including the CGI variables and form data (which is useful if the form submitting the request was not built with Web Connection). It also provides access to the transferred object in situations such as the one described in the previous example (see HTML Page Wrapper part). In addition, this part has the ability to signal an event each time a new request is received. When a page containing a CGI Link Request part receives a new request, the part signals a requestReceived event which can be connected to any page initialization tasks that are required.

Getting more out of Java webands6.gif

In order to tap into the potential benefits existing in Java applets, Netscape recently defined a new extension in JavaScript v1.1 called LiveConnect. It provides a mechanism that allows a web page and a Java applet on that page to interact with each other. JavaConnect is a new part for the Web Connection palette which is designed to take advantage of the LiveConnect technology. It inherits all of the features associated with the standard HTML Applet part and then adds the additional functionality required to interact with an applet.

There are two ways that Java applets and an HTML page can interact:

  1. HTML pages can initiate message sends to Java applets and save the results
  2. Java applets can query and set values on the HTML page where it resides.

The first item infers that the Java applet plays a passive role in the interaction. In this situation, JavaConnect allows you to define the message that should be sent to the Java applet to get the desired results. You also make a connection between the JavaConnect part and any another appropriate visual part, such as a button, to define the trigger for sending the message to the applet. The second item requires that the Java applet assumes the responsibility of setting the results in the HTML page itself, thereby taking an active role in the interaction. The applet does not need to be told when to write results to the page, so there is no need to define a trigger event in this case. In either situation, the results of the applet can be accessed by connecting the JavaConnect part result to any appropriate VisualAge part.

Some key benefits of using JavaConnect are that you can build sophisticated web pages capable of client-based data validation as well as include interactive graphical components capable of returning valuable information to the server. The movement of responsibilities from the server to the client reduces the load on the server and network. This also provides a more responsive user interface.

Note: As of the writing of this article, the only Web browser capable of supporting JavaScript v1.1 is Navigator 3.0+.

Conclusions

IBM's approach to interfacing VisualAge with the Web is to provide a set of VisualAge parts that support the needs of Web application developers without burdening them with all of the details of HTML. The Web Connection represents a good start at a framework for developing robust Web-based applications in this environment. The CGI Link executable and the related Smalltalk-based CGI Link Server framework hide almost all of the complexities of working with the Common Gateway Interface (CGI). The advanced application development support parts succeed in providing a set of tools necessary for building complex applications. In particular, the CGI Link Session Data part provides a solution to the HTML design limitation of linking otherwise unconnected pages of an application. The HTML wrapper parts also provide a well-rounded set of components that are useful for developing interactive applications (although it would be nice to see additional table support added to the product). The combination of all of these features provide an environment suitable for building complex web-based Smalltalk applications.

Enjoy the article? Subscribe to Eye on Objects!

Download the Web Connection demo!

Bob Brodd is Vice President of Products at Hatteras Software, Inc. He has over seven years experience building applications in Smalltalk. In addition to his product development responsibilities at Hatteras, Bob also works as a consultant to Fortune 500 companies. On his most recent engagement, he was lead designer and developer for the VisualAge-based client portion of the E-Mail system used in the 1996 Olympic Games.

Navigator Bar

Home Page

Hatteras Software - JavaConnect