DemonstrationExample of Using fetchNextRecord()
This applet demonstrates using fetchNextRecord() to step through the records being returned to the JavaCGIBridgeExtension object as it parses it. This differs from the Observer interface in that you do not have to set up an observer interface which can be easier for simple applets. However, it definately blocks while waiting for the next record of data to come in, so it is not quite as nice as the Observer interface if you want your applet to do some sort of processing inbetween received records.
This applet does the same thing as the previous Observer interface applet example. It updates a progress bar as records are retrieved. However, there is an interesting twist to this applet that shows how Observer can be a nicer means of doing things. If you look at the source code, you will see that the clicked event for the CGI button starts the JavaCGIBridge. However, the while loop that goes through fetchNextRecord cannot be placed inside the clicked event directory. The reason is that there is only ONE AWT thread in Java. With the clicked event fetching rows, there is no way for the AWT to perform repaint() since it is busy. Thus, the applet had to be written so that the fetchNextRecord was done in a spawned thread within the clicked event so that the AWT thread would be freed up to do repaints while fetchNextRecord was taking place in another thread.
PROGRAMMER NOTE: fetchNextRecord() is part of the JavaCGIBridgeExtension API and is not in the core JavaCGIBridge object.
NOTE: In order to make the progress bar painting simulate a longer download time, I added a delay of 10 milliseconds for each update of the progress bar.
Example Applet Using fetchNextRecord()
View The Source To Example8Applet.java
View The Source To Example8ProgressPanel.java
View The Source To JavaCGI Bridge.java
View The JavaCGIBridge JavaDoc File
View The Source To JavaCGIBridgeExtension.java
View The JavaCGIBridgeExtension JavaDoc File
View The Source To JavaCGIBridgeTimeOutException.java
View The JavaCGIBridgeTimeOutException JavaDoc File
View The Source To get_100_records.cgi
Plain CGI script retrieving 100 records
Run get_100_records.cgi CGI/Perl Script