Association views

Association views are very similar to entity views and are specified through an AssociationConfiguration on an EntityConfiguration. For each association the default entity views are automatically configured, which can be further customized. Aside of the default views, additional list and form views can be configured as well. Depending on the link type of the association, the behaviour of links on the association views will differ.

Views that are configured on an EntityAssociation are created on the source configuration for the entity, prefixed with the name of the association. The entry point for these views is by default an additional menu item on the navigation bar for the owning side of the association.

Association views are always rendered within the EntityViewContext of the entity they are configured on. This means that, given an entity Book which has a @ManyToOne relationship with the entity Author, an association will be configured on the Author entity named book.author. Whenever a view is rendered for the book.author association, the available EntityViewContext will be for the Book entity that is rendered, and will have a parent EntityViewContext holding the Author entity.

Linked associations

Linked associations are associations which are of the AssocationType.Type.LINKED type, which is the default association type for any association that is created. They, as their name says, link to views for the associated entity configuration. This means that, when navigating to the association, a :building-views/list-view.adoc will be provided which links to entity views of the target entity configuration.

Embedded associations

Embedded associations are entities that are managed within the context of the owning entity. As such, when navigating to an associated entity, its view will always be rendered within a view of the owning entity. The association will then link to the views configured for the association itself.

Associations can be turned into an embedded association by specifying the associationType as EntityAssociation.Type.EMBEDDED.

Setting the associationType on an association
@Override
public void configure( EntitiesConfigurationBuilder entities ) {
	entities.withType( Author.class )
               .association(
	                ab -> ab.name( "blogPost.author" ) (1)
	                        .associationType( EntityAssociation.Type.EMBEDDED )
               );
}
1 The name of the association is blogPost.author because blogPost is the owner of the association.

Association header

An association header is supported for associated entities. These header are similar to the entity form headers and consist of:

  • a title

  • a subtitle

  • Navigation bar

Table 1. Presence of header content
Item Availability

Title

Always if the header is present. If no value can be found for the titleMessageCode of the view, an empty string will be rendered. The default value for the titleMessageCode is EntityMessages.PAGE_TITLE_VIEW.

Subtitle

Available if a value can be found for the titleMessageCode suffixed with .subText can be found.

Navigation bar

Available if there is more than one menu item or when the advanced options menu item is not empty.

The association header is added via the AssociationHeaderViewProcessor, which builds the menu that should be rendered.

Table 2. Configurable options on an AssociationHeaderViewProcessor
Option Description Default value

addEntityMenu

Whether a navigation bar should be available or not.

false

titleMessageCode

Message code to resolve as the title of the view

EntityMessages.PAGE_TITLE_VIEW;

Even though the default value for addEntityMenu is false, when an AssociationHeaderViewProcessor is initialized for a view, this is set to true.

To remove the association header in it’s entirety, simply remove the AssociationHeaderViewProcessor from the configured view(s).