Indicates that an object belongs to the UI/application layer and is intended to be used as a view-model.Naturally this also allows for the idiom of passing in the ServiceInjector as an argument and programmatically resolve any field-style injection points via ServiceInjector#injectServicesInto(Object) , that is, if already required during construction .

Instances of ViewModel must include (at least) one public constructor.


  • there is either exactly one public constructor or if there are more than one, then only one of these is annotated with any of @Inject or @Autowired(required=true) (meta-annotations are also considered)

  • the constructor may have arbitrary many arguments of arbitrary type

  • first String argument found is passed in the view-model’s memento

  • any other arguments are resolved via the ServiceRegistry - if no Bean can be found a NoSuchElementException is thrown

  • there is no support for Spring programming model specific annotations on constructor arguments (perhaps future work)

After a view-model got new-ed up by the framework (or programmatically via the FactoryService ), ServiceInjector#injectServicesInto(Object) is called on the viewmodel instance, regardless of what happened during construction .

interface ViewModel {
  String viewModelMemento()     (1)
1 viewModelMemento()

Obtain a memento of the view-model. (Optional)



Obtain a memento of the view-model. (Optional)

Captures the state of this view-model as String , which can be passed in to this view-model’s constructor for later re-construction.

The framework automatically takes care of non-URL-safe strings, by passing them through / for encoding and decoding respectively.