Delete view

The delete view allows the deletion of an instance for an entity type. If the AllowableAction.DELETE is present for the instance, it may be removed via a confirmation page. The delete view can by default be accessed through the garbage bin at the bottom right of the detail or update view and provides the following:

links to associated entities

By default, tabs are generated for properties that are ManyToOne / OneToMany and ManyToMany relationships.

ability to delete the current instance

A delete button is provided which modifies the current entity.

Table 1. Default settings

View name

deleteView

Required action

AllowableAction.DELETE

Whether the instance can be deleted depends on other factors (usually associations) of the entity type. If associated items are detected, the form settings depend on the ParentDeleteMode settings of the association. This can be customized by either specifying the ParentDeleteMode on the association configuration or catching the BuildEntityDeleteViewEvent.

Setting the parentDeleteMode on an association
private void configure( EntitiesConfigurationBuilder entities ){
    entities.withType( Author.class )
            .association( ab -> ab.name( "book.author" )
                .parentDeleteMode( EntityAssociation.ParentDeleteMode.WARN ) (1)
            );
}
1 A warning will be shown when attempting to delete an Author which is linked in other books.
Table 2. ParentDeleteMode settings

ParentDeleteMode.IGNORE

item information is not printed nor influences the ability to delete

ParentDeleteMode.WARN

item information is printed on the form but does not influence the ability to delete

ParentDeleteMode.SUPPRESS

item information is printed on the form and disables the ability to delete, this is the default setting

The BuildEntityDeleteViewEvent, which is published after the initial association information has been set, allows you to customize the following:

  • suppress the ability to delete (by hiding the delete button)

  • add associations to the form

  • add custom feedback messages to the form (and optionally remove the associations block)

The initial BuildEntityDeleteViewEvent is configured based on the EntityAssociation list of the entity. If associated items are detected, they influence the form settings depending on the parentDeleteMode property of the EntityAssociation.

Example BuildEntityDeleteEvent
@EventListener
void modifyDeleteOptions( BuildEntityDeleteViewEvent<Book> deleteEvent ) {
	deleteEvent.setDeleteDisabled( false ); (1)
}
1 Allow the instance to be deleted

Via the BuildEntityDeleteViewEvent, the page can also be customized depending on the actual instance that the user attempts to delete.

The EntityModule simply calls the delete method of the EntityModel, usually a direct call to a repository delete(). You will have to take care yourself of complex delete scenarios - like deleting the associations - by either modifying the EntityModel or using another mechanism like the EntityInterceptor.
  • To learn more about configuring a form view, please see CRUD views