LayoutService
Provides the ability to obtain the serialized layout (eg. XML) for a single domain object or for all domain objects, as well as the serialized layout for the application’s menu-bars.
API
interface LayoutService {
EnumSet<CommonMimeType> supportedObjectLayoutFormats() (1)
String objectLayout(Class<?> domainClass, LayoutExportStyle style, CommonMimeType format) (2)
byte[] toZip(LayoutExportStyle style, CommonMimeType format) (3)
EnumSet<CommonMimeType> supportedMenuBarsLayoutFormats() (4)
String menuBarsLayout(MenuBarsService.Type type, CommonMimeType format) (5)
}
1 | supportedObjectLayoutFormats()
Supported format(s) for #objectLayout(Class, LayoutExportStyle, CommonMimeType) and #toZip(LayoutExportStyle, CommonMimeType) . |
2 | objectLayout(Class, LayoutExportStyle, CommonMimeType)
Obtains the serialized form of the object layout (grid) for the specified domain class. |
3 | toZip(LayoutExportStyle, CommonMimeType)
Obtains a zip file of the serialized layouts (grids) of all domain entities and view models. |
4 | supportedMenuBarsLayoutFormats()
Supported format(s) for #menuBarsLayout(org.apache.causeway.applib.services.menu.MenuBarsService.Type, CommonMimeType) . |
5 | menuBarsLayout(MenuBarsService_Type, CommonMimeType)
Obtains the serialized form of the menu bars layout ( MenuBarsService ). |
Members
supportedObjectLayoutFormats()
Supported format(s) for #objectLayout(Class, LayoutExportStyle, CommonMimeType) and #toZip(LayoutExportStyle, CommonMimeType) .
objectLayout(Class, LayoutExportStyle, CommonMimeType)
Obtains the serialized form of the object layout (grid) for the specified domain class.
toZip(LayoutExportStyle, CommonMimeType)
Obtains a zip file of the serialized layouts (grids) of all domain entities and view models.
supportedMenuBarsLayoutFormats()
Supported format(s) for #menuBarsLayout(org.apache.causeway.applib.services.menu.MenuBarsService.Type, CommonMimeType) .
menuBarsLayout(MenuBarsService_Type, CommonMimeType)
Obtains the serialized form of the menu bars layout ( MenuBarsService ).
Implementation
The Core Metamodel module provides a default implementation, LayoutServiceDefault.
Related Mixins and Menus
The service’s functionality is exposed in the UI through a mixin (per object) and a menu action (for all objects):
-
the Object mixin provides the ability to download the XML layout for any domain object (entity or view model).
-
the
LayoutServiceMenu
provides the ability to download all XML layouts as a single ZIP file (in any of the three styles).
The XML can then be copied into the codebase of the application, and annotations in the domain classes removed as desired.
Styles
Each of these actions take as a parameter an instance of LayoutExportStyle. As a developer, you have a choice as to how you provide the metadata required for customised layouts:
-
COMPLETE
... for if you want all layout metadata to be read from the
.layout.xml
file. Copy the file alongside the domain class.You can then remove all
@ActionLayout
,@PropertyLayout
and@CollectionLayout
annotations from the source code of the domain class. -
MINIMAL
... for if you want to use layout XML file ONLY to describe the grid.
The grid regions will be empty in this version, and the framework will use the
@PropertyLayout#fieldSetId
,@ActionLayout#fieldSetId
,@ActionLayout#associateWith
and@Action#choicesFrom
annotation attributes to bind object members to those regions.
In practice, you will probably find yourself somewhere in between these two extremes, deciding which metadata you prefer to define using annotations, and which you like to specify using layout file.
See also
The functionality of LayoutService
is surfaced in the user interface through a related mixin and menu action.
See also LayoutExportStyle, which determines how much data is included in the downloaded XML.
The GridService is responsible for loading and normalizing layout XML for a domain class. It in turn uses the GridLoaderService and GridSystemService services.