Rabbtor provides metadata for the model ( command ) objects through a customizable Model Metadata API.
Model metadata contains information about model properties, their message keys and default display names, whether the property is readonly, writeonly, primitive, collection, map and more.
Currently metadata API is used by Rabbtor for displaying form labels for the properties and also easy rendering of localized display names in error messages. But the API itself brings new possibilities for scaffolding solutions and in addition
there is work going on to provide a generic validation constraint API on top of it to enhance scaffolding solutions while also providing client side validation capabilities.
Model metadata API depends on metadata providers which provide metadata for bean classes. Right now, Rabbtor provides a annotation metadata provider which collects metadata from model classes using specific model annotations.
For specific bean classes, additional metadata providers can be registered to the ApplicationContext and Rabbtor's metadata registry detects these providers and run them in a sorted order. If a provider is able to provide metadata for a bean class,
then other providers are not used and the returned metadata is cached in memory for later usages.
Annotation Metadata Provider
Rabbtor by default provides a annotation based metadata provider which currently uses just one annotation : @DisplayName ( com.rabbtor.model.annotation.DisplayName ) which is primarly used for labeling and localization which is described later in this chapter.
In the future, there will be more annotations for other types of solutions.
DisplayName annotation helps define default display names for properties which are not specified in message localization files. This is very similar to the [ DisplayName ] attribute of ASP .NET MVC framework.
This way, you define your default display names on your model properties and later on you localize them using messages files.
Property Display Names
With the help of the Metadata API, Rabbtor enables developers to resolve display names of model properties in a much better way than Spring's current display name generation strategy.
- Example Command Object and Form
- Property Display Names During Validation
- Data Bound Form Labels
- Default Display Names with @DisplayName
- Default Model Names with @Model annotation
- Model Attribute Name has the Highest Priority
- Configuring Model Metadata