Implement Application.java
In the previous section, you implemented a class named RegistrationManager, which maintains the list of registrants. You need to create an instance of RegistrationManager. Create the instance in Application.java.
- In WebObjects Builder, open the Registration application window.
- Click the Application tab.
- Choose Tools Script Scripts to open the Script window.
- Implement Application.java as shown below. (Don't change the main method.)
Instead of displaying a script, this window displays the Application.java file. Application.java defines an class named Application to be a subclass of WebApplication, and it shows the main method that WebObjects Builder provided for you.
import next.util.*; import next.wo.*; public class Application extends WebApplication { private protected RegistrationManager manager; public static void main (String args[]) { ProcessInfo.setCommandLineArguments(args); Application application = new Application(); application.run(); } public Application() { super(); manager = new RegistrationManager(); } public RegistrationManager manager() { return manager; } }
You can edit the file Application.java in Project Builder, but you must be careful if you do. WebObjects Builder does not detect if files have been edited externally. If you make a change in Application.java using Project Builder and then edit it in WebObjects Builder, WebObjects Builder will overwrite the previous changes. If you want to edit files externally, make sure that you only have the file open in one application at a time, and always close the file as you move from one application to the next. To avoid the problem entirely, it's a good rule of thumb to edit custom objects in Project Builder and edit component logic in WebObjects Builder.
Table of Contents Next Section