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.
- From the Edit Main.java menu at the bottom of the object browser, choose Add Action.
- Enter submit as the name of your action method.
- From the "Page returned" pop-up menu, select null.
- Click Add.
- Click submit in the object browser and drag the cursor to the submit button.
- Click Connect Variable.
- From the pull-down menu at the bottom of the window, choose View Source File.
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.
The submit action appears below a horizontal line in the first column of the object browser.
The Inspector opens with the button's action attribute selected.
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.
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.
Table of Contents Next Section