The @HomePage annotation allows a single (no-arg, query-only) action on a single domain service to be nominated as the action to invoke for the default home page. This often returns a view model that acts as some sort of dashboard, presenting key information and makeing the most commonly used actions easy to invoke.

For example, a todo app could use @HomePage to return a dashboard of todo items to complete:


The corresponding code is:

import org.springframework.stereotype.Service;

public class TodoAppDashboardService  {
            semantics = SemanticsOf.SAFE
    public TodoAppDashboard lookup() {
        return serviceRegistry.injectServicesInto(new TodoAppDashboard());
    ServiceRegistry serviceRegistry;

where TodoAppDashboard is:

@DomainObject(nature = Nature.VIEW_MODEL)
public class TodoAppDashboard {
    public String title() { return "Dashboard"; }

    public List<ToDoItem> getNotYetComplete() { /* ... */ }
    public List<ToDoItem> getComplete() { /* ... */ }

    public Blob exportToWordDoc() { /* ... */ }  (1)
1 associated using file-based layout with the notYetComplete collection.

The other two actions shown in the above screenshot — exportAsXml and downloadLayout — are actually contributed to the TodoAppDashboard through various domain services, as is the downloadLayout action.