Providing Default Values in MovieRole
As discussed in "Specifying Default Values for New Enterprise Objects", there are two main ways to specify default values for new enterprise objects without making explicit assignments:
- Assign default values in the enterprise object class.
- Specify default values using a display group.
- Open MovieRole.java in Project Builder.
- Add the method, awakeFromInsertionInEditingContext, as follows.
public void awakeFromInsertionInEditingContext(EditingContext context) { super.awakeFromInsertionInEditingContext(context); roleName = "New Role"; }
This method is automatically invoked right after your enterprise object class creates a new MovieRole and inserts it into an editing context, which happens when you use a display group to insert.
Running Movies
Be sure that all your project's files are saved (including your model file), and build and run your application. Now when a user clicks the Insert/New button on the MovieDetails page, a new MovieRole is inserted, with "New Role" already displayed as the role name.