This is the HTML code that calls the above example:
Homer Simpson 555-6528 Lisa Simpson 555-6528 ..... Stuff deleted ...... Dr. Nick Riviera 555-6022 Pr. John Frink 555-6024
This example defines only one field for each line. This is the simplist way to use the applet- because you don't need to put field separators in your data. The drawback is that you can only search the entire line of data for matches. The "APPLET CODE" tag loads the "Lookup.class" Java applet and runs it. The "param name" tags supply information to the applet about where your file with the names and phone numbers is, and how to search and display the data. In the example above the line "Homer Simpson 555-6528" defines one record with that will be searched and displayed as a whole. The parameter "UrlOfDataFile" is set to the same html file that calls the applet. The applet will ignore any lines in the data file that are blank or that contain at least one HTML tags. You can therefore put HTML code above, and below your data. The parameter "fieldNames" specifies how the text box where search strings are entered is labeled. The "foregroundColor" and "backgroundColor" parameters define what color the applet should be. These should be the same as those defined in the HTML "BODY TEXT="#000000" BGCOLOR="#FFFFFF"" tag if you want the applet to blend into the page. The parameter "fieldSeparatorCharacter" is ignored in this case.
Heres an complex phone book example
where you can search
individual fields, like first name or last name separately.
This is the HTML code that calls the above example:
Homer,Simpson,555-6528 Lisa,Simpson,555-6528 ..... Stuff deleted ...... Dr. Nick,Riviera,555-6022 Pr. John,Frink,555-6024
This example requires that the file has one record per line, and the fields in each line are delimited with a field separator character (like comma or "|"). The line "Homer,Simpson,555-6528" defines one record with three fields separated by a comma. The parameter "fieldNames" specifies that the first field is labeled "First Name", the second "Last Name", and the third "Phone #". The number following each name determines how many characters of that field will display on screen before truncating. Set this number to the maximum expected field size unless things are getting squeezed. The number of field names, and lengths specified in the "fieldNames" parameter has to match whats in your data or the Applet won't work. The parameter "fieldSeparatorCharacter" tells the applet that the fields are separated by commas.
Copy the two required Java "*.class" files to the same directory on your web server as the HTML page that is going to call them. The class files are Lookup .class and Field.class
Create the HTML page that will have the applet embedded in it. Create the file that will have your data. These two can be the same if you wish. Make sure the "UrlOfDataFile" parameter points to the full URL of your data file. Adjust the APPLET WIDTH, and HEIGHT tags so that all the GUI components fit, without too much empty space in the middle.