By Rob Gravelle
Part 1: Making Use of Free Development Tools
The Autocomplete Function
The autocomplete function is especially helpful where there are many options, as in a country or city list. In some cases, the user might know exactly what to type, such as when searching for an employee. They may know the person's ID number, but not the full name. By using an autocomplete text field, the user can quickly narrow the number of items down to a manageable quantity. There's also the issue of bandwidth. Downloading a list of hundreds or even thousands of entries is impractical even if you could filter them on the client-side. That's where AJAX comes to the rescue. As with the URPMs, retrieving a limited number of items greatly eases the server load.
Our Autocomplete Text Field
The autocomplete text field that we're going to construct will behave much like the one on the Yahoo Finance Web site. Their excellent autocomplete text field matches either the symbol or company name to the text field's value. Items displayed in the list contain the symbol, full name and the market where the stock is traded. The icing on the cake is the bold match highlighting.
We'll be borrowing some of the features of the Yahoo site by including a couple of fields in the list, match highlighting and even arrow key support.
Today's Task: Configure the Development Environment
What You'll Need
JDK SE 1.5+
To develop Web applications, you need the full Java Standard Edition Development Kit (JDK SE) and not just the Java Runtime Environment (JRE). You can get the latest JDK from Sun.
Tomcat is the official reference implementation for the Java Servlet and Java Server Pages (JSP), which makes it the perfect choice for developing Java Web applications. Tomcat is available from the Apache site. You can substitute your own server as long as it supports servlets and JSP pages.
You'll also need the jstl-1.2.jar, available at the java.net site. It contains classes to parse tags from the Java Server Pages Standard Tag Library (JSTL). The JSTL tags are used to perform common programming tasks such as iteration and conditionals, manipulating XML documents, internationalization and locale-sensitive formatting and working with SQL:
Web Tools Platform (WTP) project
The WTP project allows you to develop, test and deploy Web applications in the full-featured Eclipse IDE. It's got all the bells and whistles that you'd expect in a Brand name IDE except that it's open source. You can download the WTP from the Eclipse Webtools Platform Download page. There are several different packages available, depending on your needs. The easiest to download is the all-in-one package. It contains the latest version of Eclipse (3.3 at the time of writing) and all the required plug-ins. Be forewarned, the file is over 250 Megabytes. Don't try it over a dial-up modem connection!
If you already have Eclipse, you can download the "Web Tools Platform Complete" package instead. It contains the plug-ins for the WTP, j2ee Standard Tools Project (STP) and Java Server Faces (JSF) projects. The WTP also uses the following components from other eclipse projects:
- The Eclipse Modeling Framework, EMF, Java emf model, JEM, are used to define models for artifacts defined in many Java, w3c, xml and j2ee standards.
- The Graphical Editing Framework, GEF, is used to provide graphical editing capabilities for xml, xsd and wsdl editors.
- The Data Tools Platform, DTP, is only required if you intend on doing EJB or JPT development.
You can download these components separately at the top of the page if you want to break down the downloading into smaller chunks of data. Here are the home pages for each of these projects:
- The Eclipse Modeling Framework (EMF)
- The Graphical Editing Framework (GEF)
- The Data Tools Platform (DTP)
If you don't have the capability or inclination to download huge files, you can always forego the Eclipse and WTP entirely and use the old school approach: Create the files in your favorite text editor and use the Java via the command line to compile the Java classes. To save yourself the hassle of copying the files to your server you can work on them in place! For a more moderate approach, TextPad has the capability to compile Java files from the Tools menu.
The JSON Java Utility Classes
The folks at the JSON Project have written some helpful classes for converting your classes to JSON Objects. We'll be making use of these.
Go to the www.JSON.org Java page and download the seven Java source files at the top of the page. They are: