Documentation Archive Developer
Search
Table of Contents Previous Section

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:

  1. Inside the form, add three image buttons below the Role Name text field.

  2. Inspect the first active image element.

  3. Bind the filename attribute to the text (including the quotes) "DBWizardInsert.gif".

  4. Follow the same procedure to set the second image's filename attribute to the text (including the quotes) "DBWizardUpdate.gif".

  5. Set the last image's filename attribute to the text (including the quotes) "DBWizardDelete.gif".

    The DisplayGroup class defines the actions insert and delete that 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.

  6. 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;
        }
    }
    

  7. Bind movieRoleDisplayGroup.insert to the Insert/New image's action attribute.

  8. Bind the saveChanges method to the "Save to database" image's action attribute.

  9. Bind movieRoleDisplayGroup.delete to the Delete image's action attribute.

Table of Contents Next Section