|
SYS-CON.TV Webcasts
Comments
Did you read today's front page stories & breaking news?
SYS-CON.TV
|
Top Links You Must Click On
Product Reviews Project X
Project X
By: Alan Williamson
Aug. 1, 1997 12:00 AM
Last month, we started this column by looking at the development tool, Visual Café Pro. Visual Café Pro makes the perfect companion for the developer, giving instant access to the editor, on-line help and runtime environments. The main goal of this column will be to teach the reader the power behind Java by using Visual Café Pro, one of the most popular integrated development environments in use today. There are many ways to teach Java. Some are good, some bad. I have always felt the best way to learn about anything is through example. Show somebody how it works and suddenly a lot of confusion is eliminated. For this reason, this column will develop a complete client/server application that can be deployed to both Internet and Intranet scenarios. Each installment will take the application a stage further, adding more and more functionality to it. Eventually, you will have successfully developed a full working application that may be deployed to a user base of thousands. First, I will outline the application in question! I spent quite some time thinking about how I could demonstrate the workings of Java, but still come out with a piece of software that would actually be useful. As time went on, I rejected all of my ideas on the grounds that some were too big, some too complicated, too small, too easy. It looked bleak for a while. Then a colleague asked for an address for one of our clients, and I said, "It's in the company card file in the cupboard." A bolt of inspiration struck me. How many other people are in the same situation in an office environment; needing vital contact information held by only a handful of personnel? What is needed is a global contact database application. OK, some of you may argue that this isn't exactly a revolutionary idea and, on the face of it, you would be right. But in reality, how many companies actually deploy such a facility to their staff? Excluding external contact information, internal contact information is invaluable and very often overlooked. Applications such as Lotus Notes, Microsoft's Outlook and Pegasus Mail offer such functionality, but are very rarely used. Reasons for their non-deployment range from bulky client side front-ends to speed of use. What is required is something that is lightweight, easy to use, straightforward to install and operates on a global database. Other benefits could include the ability to run on any platform and to be able to access it from outside of the office. Bit of a tall order, some might say, but look at what our requirement is. We want to have something that people can have instant access to, no matter what machine they are using, and it has to be small so that it doesn't irritate the user base: Java.
Project X' Specification Each applet will connect to the main database of contacts back at one central server, from which the applet will be downloaded, as shown in Figure 1. From a database point of view, information stored about a particular person can be seen in Table 1. The database that this information will actually be held in will not matter too much. Since we will be using the dbAnywhere tool from Visual Café, the actual database is irrelevant. But, to show how easy it is to use, we will use an MS-Excel spreadsheet for the user records. In reality, this would be very inefficient for a large number of users. In future extensions, we will upgrade to an Oracle or Ingres database. The very fact that we can design the application like this shows the power Java holds: no restriction on platform and no restriction on the final database. By using dbAnywhere, or even the JDBC (Java Database Connectivity) API, upgrading the database does not require any code rewrites or modifications. Storing this information in an Excel spreadsheet can be achieved by having each row represent a new contact name, with the first row describing the field names. Let's leave the database design for a moment and concentrate on what the user front end is going to look like. Anyone who has designed any type of GUI (graphical user interface) using Java and the standard AWT package will know only too well the pitfalls that layout managers can be. "The devil's own creation!" some have been reported to say. Fortunately, Visual Café Pro has taken over the responsibility of that particular nightmare and has made creating front ends a much easier task. For the remainder of this article, we will look at how Visual Caf Pro can really help us design a front end applet for our Informer without writing a single line of code.
Informer Interface With implementation being in an applet, we have two options to choose from; it can run within an HTML page, fixed inside a browser, or it can be in a floating window of its own. For this application, the floating window will be employed so the user does not have to keep their browser window open to use the applet once it has loaded. But, in order to keep presentation of the applet simple for the user, the applet that will be placed in the HTML page will consist only of a button that will open up the main Informer window. Setting this applet up is very easy. Insert a new applet component by selecting it from the menu option Insert'. This will bring up a small dialog box consisting of at least two icons. Choose the Applet icon. Clicking on the new applet component will bring the Form designer window for that applet. Here, we simply drag a new button to the center of the window and change the name of it by selecting the Label' properties field in the Properties window. Next, we need to create the shell window for which all of the user information will be displayed. The class on which the popup window is based is the java.awt.Frame from the AWT package. Creating a new frame class is as simple as creating the first applet window. Select the Insert menu option and this time select the Component..' item. This will bring up a small dialog window that contains a list of all of the different types of GUI objects that can be inserted. Move down the list until you get to the Forms section and select the Frame option. This will create a new frame object and display the Form designer window for it. Using the Form designer, objects can be dropped into the window and placed to your heart's content.
Interaction First, open up the form with the button on it which will be used to open up the window. Next, click on the icon with the two electrical plugs; this will change the mouse cursor. When you move the cursor over various objects, they will highlight. You need to select the origin object from which the activity or event will take place. In this case, click on the button in the main applet window. This will anchor a line from this object. You have to select which object the interaction will work with. We want the frame to be displayed so we drag the line from our cursor to the frame object in the Project window. Having successfully chosen both objects, the dialog window shown in Figure 3 is displayed. From here, the nature of the interaction is described. As you can see, many different events can happen for a button, but in this instance we only wish to assign an interaction to the on click event. Having selected the event from which the event will be caught, we need to determine what will happen. This is selected from the bottom half of the window. In this instance we want to display the window, which we can choose from the list. Now, close the dialog box. The interaction has been created. We can test this by hitting the play button on the toolbar or by selecting the Run command from the menu. This will run the applet with the button and, by clicking the button, if all is well, the blank frame window will be displayed. All this occurs without your looking at a single line of code. Looking at the code Visual Café Pro produced won't do any harm at this point. This can be done by selecting the object, pressing the right hand mouse button and choosing the edit source menu option. This will open up the editor window, from which you can see how the Java code is working to produce the effect. You will notice how the code is also documented. How much better can it get? Not only does it write the code, but it documents the file as well!
Conclusion Reader Feedback: Page 1 of 1
Enterprise Open Source Magazine Latest Stories . . .
Subscribe to the World's Most Powerful Newsletters
Subscribe to Our Rss Feeds & Get Your SYS-CON News Live!
|
SYS-CON Featured Whitepapers
Most Read This Week |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||