Layout
Object Layout
The org.apache.isis.applib.layout.grid
and org.apache.isis.applib.layout.component
packages together define a number of classes that allow the layout of domain objects (entities and view models) to be customized.
These classes fall into two main categories:
-
grid classes, that define a grid structure of rows, columns, tab groups and tabs, and;
-
common component classes, that capture the layout metadata for an object’s properties, collections and actions. These are bound (or associated) to the regions of the grid
The framework provides an implementation of the grid classes modelled closely on Bootstrap 3, along with Web UI (Wicket viewer) components capable of rendering that grid system. In principle it is also possible to extend the layout architecture for other grid systems. The component classes, though, are intended to be reusable across all grid systems.
The component classes, meanwhile, are broadly equivalent to the "layout" annotations (@PropertyLayout, @CollectionLayout, @ActionLayout and @DomainObjectLayout
All of the classes in this package are JAXB-annotated, meaning that they can be serialized to/from XML (the component
classes in the http://isis.apache.org/applib/layout/component
XSD namespace, the bootstrap 3 grid classes in the http://isis.apache.org/applib/layout/grid/bootstrap3
XSD namespace).
This ability to serialize to/from XML is used by the GridLoaderService, the default implementation of which reads the grid layout for a domain class from a .layout.xml
file on the classpath.
It also allows the grid to be exposed through the REST API provided by the REST API (Restful Objects viewer), as either XML or JSON.
The various components (properties, collections, actions and domain object) also allow a link to be associated with each. These links are populated by the framework automatically when exposing the object layout grid through the REST API, pointing back to the standard Restful Objects resources. This design greatly assists in the implementation of generic REST clients.
Component
The component classes reside in the org.apache.isis.applib.layout.component
package, and consist of:
-
FieldSet
A fieldset (sometimes also called a property group or member group) of a number of the domain object’s properties (along with any associationed actions of those properties).
-
layout data classes, which correspond to the similarly named annotations:
-
PropertyLayoutData
, corresponding to the @PropertyLayout annotation; -
CollectionLayoutData
, corresponding to the @CollectionLayout annotation; -
ActionLayoutData
, corresponding to the @ActionLayout annotation; -
DomainObjectLayoutData
, corresponding to the @DomainObjectLayout annotation.
-
In addition, the component package includes Grid
, representing the top level container for a custom layout for a domain object.
Grid
itself is merely an interface, but it also defines the visitor pattern to make it easy for validate and normalize the grid layouts.
The GridAbstract
convenience superclass provides a partial implementation of this visitor pattern.
The XSD for these classes is available at http://isis.apache.org/applib/layout/component/component.xsd.
Bootstrap3 Grid
The bootstrap3 grid classes are modelled closely on Bootstrap 3. Bootstrap’s grid system divides the page width equally into 12 columns, and so each column spans 1 or more of these widths. Thus, a column with a span of 12 is the full width, one with a span of 6 is half the width, one with a span of 4 is a third of the width, and so on.
When specifying the span of a column, Bootstrap also allows a size to be specified (XS
, SM
, MD
, LG
).
The size determines the rules for responsive design.
Apache Isis defaults to MD
but this can be overridden.
It is also possible to specify multiple size/spans for a given column.
The grid classes provided by Apache Isis reside in the org.apache.isis.applib.layout.grid.bootstrap3
package, and consist of:
-
BS3Grid
Consists of a number of
BS3Row
s.This class is the concrete implementation of
Grid
interface, discussed previously. As such, it extends theGrid.Visitor
to iterate over all of theRow
s of the grid. -
BS3Row
A container of
BS3Col
s. This element is rendered as<div class="row">
. -
BS3Col
A container of almost everything else. A column most commonly contains properties (grouped into
FieldSet
s, described above) or collections (specified byCollectionLayoutData
, also above). However, aCol
might instead contain aBS3TabGroup
(described below) in order that the object members is arranged into tabs.It is also possible for a
Col
to contain the object’s title/icon (usingDomainObjectLayoutData
) or indeed arbitrary actions (using`ActionLayoutData
).Finally, a
BS3Col
can also contain otherBS3Row
s, allowing arbitrarily deep hierarchies of containers as required.This element is rendered as, for example,
<div class="col-md-4">
(for a sizeMD
, span of 4). -
BS3TabGroup
A container of
BS3Tab
s. -
BS3Tab
A container of
BS3Row
s, which will in turn containBS3Col
s and thence ultimately the object’s members.
There are also two close cousins of Col
, namely ClearFixVisible
and ClearFixHidden
.
These map to Bootstrap’s responsive utility classes, and provide greater control for responsive designs.
As you can probably guess, the BS3Grid
is the top-level object (that is, it is JAXB @XmlRootElement
); this is the object that is serialized to/from XML.
All of these classes also allow custom CSS to be specified; these are added to the CSS classes for the corresponding <div
> in the rendered page.
The application.css file can then be used for application-specific CSS, allowing arbitrary fine-tuning of the layout of the page.
The XSD for these classes is available at http://isis.apache.org/applib/layout/menubars/bootstrap3/menubars.xsd.
Link
The link classes reside in the org.apache.isis.applib.layout.links
package, and consist of just the Link
class:
import lombok.Getter;
public class Link {
@Getter
private String rel; (1)
@Getter
private String method; (2)
@Getter
private String href; (3)
@Getter
private String type; (4)
...
}
1 | a "rel" (as defined by section 2.7.1.2 of the RO spec v1.0), identifying the nature of the link. |
2 | the HTTP method to access the link. This is always "GET". |
3 | The (absolute) URL to access the Restful Objects resource. |
4 | The media type (Accept header) that will be returned by the URL. |
The XSD for these classes is available at http://isis.apache.org/applib/layout/links/links.xsd.
MenuBars Layout
The org.apache.isis.applib.layout.menubars
package and subpackages define a number of interfaces classes that allow the layout of domain service actions to be organised across menu bars, menus and menu sections.
The classes define a hierarchical structure of menu bars, menus and menu sections. Similar to the object layout classes, the concrete menu classes support bootstrap3; support for other layout systems is possible.
The component class ServiceActionLayoutData
defines action metadata, being broadly equivalent to the "layout" annotations for actions, ie @ActionLayout.
This is similar to the ActionLayoutData
component class used for object layouts, but also captures the identity of the "owning" domain service.
Service actions are grouped into menu sections.
All of the classes in this package are JAXB-annotated, meaning that they can be serialized to/from XML (in the http://isis.apache.org/applib/layout/menubars/bootstrap3
XSD namespace).
This ability to serialize to/from XML is used by the MenuBarsLoaderService, the default implementation of which reads the grid layout for a domain class from a .layout.xml
file on the classpath.
It also allows the menu bars to be exposed through the REST API provided by the REST API (Restful Objects viewer), as either XML or JSON.
The service action component also allows a link to be associated with it. Each such link is populated by the framework automatically when exposing the menu bars layout through the REST API, pointing back to the standard Restful Objects resources. This design greatly assists in the implementation of generic REST clients.
Menus
The menu classes reside in the org.apache.isis.applib.layout.menubars.bootstrap3
package, consisting of:
-
BS3MenuBars
The top-level structure that define three fields: a primary
BS3MenuBar
, secondaryBS3MenuBar
and tertiaryBS3MenuBar
. The Web UI (Wicket viewer) places the primary bar to the left, the secondary bar aligned right, and the tertiary bar (expected to consist of just oneBS3Menu
) under the user names. -
BS3MenuBar
consisting of one or many
BS3Menu
s. -
BS3Menu
consisting of one or many
BS3MenuSection
s. The Web UI (Wicket viewer) renders a separator between each section. -
BS3MenuSection
consisting of one or many actions (
ServiceActionLayoutData
s)
Components
The service action class reside in the org.apache.isis.applib.layout.component
package, consisting of just:
-
ServiceActionLayoutData
classwhich correspond to the @ActionLayout annotation.
This is similar to ActionLayoutData
(of the object layout classes), however it also identifies the domain service to which it belongs.
(This isn’t required for the object layouts because the owner in that case is implicit).
Link
The link classes reside in the org.apache.isis.applib.layout.links
package, and consist of just the Link
class.
The XSD for these classes is available at http://isis.apache.org/applib/layout/links/links.xsd.