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


   

Implementing an Action Method

When the user clicks the Submit button, your application will respond by redisplaying the page with the submitted information shown at the bottom. To make this happen, you implement an action method and bind that method to the action attribute of the WOSubmitButton.

  1. From the Edit Source menu at the bottom of the object browser, choose Add Action.

  2. Enter submit as the name of your action method.

  3. From the "Page returned" combo box, select null.

    The value returned by an action method represents the next page (component) to be displayed. When you return null (or nil if using WebScript), the current page is redrawn. In a later task, you'll see how to return a new component.

  4. Click Add.

    The submit action appears below a horizontal line in the first column of the object browser.

  5. Make a connection from the submit action in the object browser to the Submit button (press the mouse button down on the action, drag to the button, and release the mouse button).

    A menu appears with the Submit button's attributes.

  6. Choose action.

    You just bound the submit method you created to the action attribute of the WOSubmitButton. You don't need to write any additional code, so your application is now ready to run. However, you may want to look at your source file.

  7. From the pull-down list at the bottom of the window, choose View Source File.

    Project Builder becomes active and displays the code for your component (in Main.java). You'll notice that this file contains declarations for the variables you created earlier, as well as a declaration for the submit action method.

    // Generated by the WebObjects Wizard ...

    import com.apple.yellow.foundation.*;
    import com.apple.yellow.webobjects.*;
    import com.apple.yellow.eocontrol.*;
    import com.apple.yellow.eoaccess.*;

    public class Main extends WOComponent {
       protected String guestName;
       protected String email;
       protected String comments;

       public WOComponent submit() {
         return null;
       }
    }


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