Documentation Archive Developer
Search
PATH  Documentation > WebObjects 4.5 > Getting Started With WebObjects


   

Clearing the Guest List

While developing your application, you may find it useful to be able to remove all guests from the list. (Typically, you wouldn't allow users to remove all guests from the list.)

  1. In WebObjects Builder, make the GuestList component window active.

  2. Choose Add Action from the pull-down list at the bottom of the window. In the panel, enter clearGuestList as the name of the action and set the page returned to nil. Click Add.

  3. Choose View Source File from the pull-down list.

    Project Builder displays the code for GuestList.wos. GuestList.wos is your script file, the WebScript equivalent of Main.java in the Main component. You'll notice that there is a skeleton of the clearGuestList action method, using WebScript syntax, as well as the declaration for currentGuest that you created previously.

  4. Enter the following code before the return statement in clearGuestList:

    [[self application] clearGuests];

    This code calls the application's clearGuests method, which removes all the Guest objects from the array.

  5. Save GuestList.wos by choosing Save from the File menu.

  6. Go back to WebObjects Builder.

  7. Place the cursor below the table and press shift-Enter.

  8. Click to add a WOForm element to contain the button you'll create in the next step.

  9. Click .

    This creates a submit button that the user will click to clear the guest list.

  10. Using the Inspector, double-click in the binding column next to the value attribute and type "Clear Guest List".

    This changes the title of the button. Note that the quotes are necessary to indicate that you're binding a string, not a variable.

  11. Bind the action attribute to clearGuestList.

    When the user clicks the button, the clearGuestList action method is called, which causes the guest list to be cleared and the page to be redrawn.


© 1999 Apple Computer, Inc. – (Last Updated 24 Aug 99)