You could write an action method for the Insert/New button instead of binding it directly to the display group insert action method. In the custom action, you would create a new Movie object, assign default values to it, and then insert the new object into the display group. However, there are two additional ways to specify default values for new enterprise objects, without making explicit assignments:
On the other hand, if the default values are specific to an application or to a particular user interface, explicitly initialize the object in code or specify the default values using a display group. In the Movies application, the need for default values is motivated by Main's user interface: you need to provide a default value so users can tell when a newly inserted record is selected. In another situation, you might not want a new movie to have a default title; you might instead want a new movie's title to be blank.
public Main() { super(); MutableHashtable defaultValues = new MutableHashtable(); defaultValues.put("title", "New Movie Title"); movieDisplayGroup.setInsertedObjectDefaultValues(defaultValues); }
This method assigns the value "New Movie Title" as the default value for a new movie's title attribute. When movieDisplayGroup inserts a new movie (as it does when a user clicks the Insert button), it creates a new movie and assigns this default value to that movie.
Table of Contents Next Section