Adding Guests to the Guest List
Now, when the user submits the form, you'll add the information to the allGuests array rather than displaying it directly.-
Switch to the code for Main.java.
-
In the submit method, add the following code before the return statement:
((Application)application()).addGuest(currentGuest);
This code calls the application's addGuest method, which adds an object (in this case, currentGuest) to the end of the array. Then it creates a new Guest object to hold the next guest's data.
currentGuest = new Guest();Note: The addGuest method is defined in the class Application, which is a subclass of WOApplication. The component's application method (called in the above statement) returns an object of type WOApplication, so you must cast it to Application in order to access its addGuest method.
© 1999 Apple Computer, Inc. (Last Updated 24 Aug 99)