Adding Insert, Save, and Delete Buttons
Now add the buttons that let users insert, save, and delete MovieRoles. When you're done, it should look like the following:-
Inside the form, add three image buttons below the Role Name text field.
-
Inspect the first active image element.
-
Bind the filename attribute to the text (including the quotes) "DBWizardInsert.gif".
-
Follow the same procedure to set the second image's filename attribute to the text (including the quotes) "DBWizardUpdate.gif".
-
Set the last image's filename attribute to the text (including the quotes) "DBWizardDelete.gif".
The WODisplayGroup class defines the actions insert and delete, which you'll bind to the Insert/New and Delete buttons. It doesn't, however, provide a save method. You'll have to provide that yourself.
-
Copy the saveChanges method from the Main.java class and paste it into the MovieDetails.java class:
public void saveChanges() throws Exception {
try {
this.session().defaultEditingContext().saveChanges();
}
catch (Exception exception) {
System.err.println("Cannot save changes ");
throw exception;
}
}
-
Bind movieRoleDisplayGroup.insert to the Insert/New image's action attribute.
-
Bind the saveChanges method to the "Save to database" image's action attribute.
-
Bind movieRoleDisplayGroup.delete to the Delete image's action attribute.
© 1999 Apple Computer, Inc. (Last Updated 24 Aug 99)