Table of Contents Previous Section

Create a second component

When users click the Show All Registrants button, the Registration application displays a second page containing the list of registrants. You'll now create the second page of the application.

  1. In the Registration application window, click the plus sign to add a new component.

  2. Type Registrants as the name of the component and press Enter.

    A new component window is displayed.

Create the component's interface

The Registrants component uses a repetition to display the information in the list of registrants.

  1. Drag a WORepetition element from the Abstract Elements palette to the Registrants component window.

  2. Drag three WOStrings from the Abstract Elements palette into the WORepetition.

Create variables

Now Registrants needs a variable that will contain the list the WORepetition is to display.

  1. Create a variable in the Registrants component, name it myNameList, and make it an array of type aPerson.

Bind elements to the script

  1. Bind myNameList to the repetition's list attribute.

    WebObjects Builder creates a variable named aPerson and binds to the repetition's item attribute. aPerson is an aPerson dictionary.

  2. Bind the three WOStrings to the three attributes in aPerson as shown below:

Implement Registrants

  1. Open the Script window, and change the Registrants implementation to look like this:
    	import next.util.*;
    	import next.wo.*;
    
    	public class Registrants extends Component {
    		ImmutableHashtable aPerson;
    		ImmutableVector myNameList;
    
    		public void awake() {
    			myNameList = ((Application) 
    				application()).manager().registrants();
    		}
    
    		public void setAPerson(ImmutableHashtable newPerson) {
    			aPerson = newPerson;
    		}
    	}
    

    In the awake method, Registrants accesses the list of all registered people through the Application object's manager instance variable and assigns it to the myNameList instance variable. This is done in awake so that Registrants retrieves the list before the page is displayed.

    setAPerson is invoked when the WORepetition iterates through myNameList. It assigns the aPerson variable to the method's argument.

    Note: Be sure to change the declarations of myNameList and aPerson as shown above.

  2. You're done implementing Registrants, so save and close the component. Choose File Save All to make sure that the entire application is saved.

Add Registrants.wo to the project

As a final step before compiling, you need to add Registrants.wo to the project in Project Builder. Project Builder must know about Registrants.wo so that the file Registrants.java is compiled during the build. If you had written Registrants.wo in WebScript, it wouldn't be necessary to add the component to the file because WebScript files are not needed during the build cycle.

  1. Double-click the word Interfaces in Project Builder's browser.

  2. Select Registrants.wo and click Open.

Table of Contents Next Section