Field stereotypes
Mateu infers the UI control for each field from its Java type. @Stereotype overrides that inference when the default is not what you want.
Default inference
Section titled “Default inference”| Java type | Default control |
|---|---|
String | Text field |
int / long / double | Number input |
boolean | Checkbox |
LocalDate | Date picker |
LocalDateTime | Datetime picker |
enum | Combobox |
List<String> | Multi-select |
This means a basic form requires no annotations beyond field declarations:
public class ProductForm {
String name; Status status; // enum → combobox boolean active; LocalDate releaseDate;
}Overriding with @Stereotype
Section titled “Overriding with @Stereotype”Use @Stereotype when the inferred control is not the right choice for that field’s presentation intent.
enum Status { Available, OutOfStock }
@Stereotype(FieldStereotype.radio)Status status; // radio group instead of combobox@Stereotype(FieldStereotype.textarea)String description; // multi-line instead of single-line@Stereotype(FieldStereotype.toggle)boolean active; // toggle switch instead of checkbox@Stereotype(FieldStereotype.password)String apiKey; // masked input@Stereotype(FieldStereotype.richText)String body; // rich text editor@Stereotype(FieldStereotype.markdown)String notes; // markdown editor@Stereotype(FieldStereotype.email)String contactEmail; // email input with built-in format hint@Stereotype(FieldStereotype.money)double price; // currency-formatted number@Stereotype(FieldStereotype.stars)int rating; // star rating control@Stereotype(FieldStereotype.color)String themeColor; // color pickerFull list of stereotypes
Section titled “Full list of stereotypes”Defined in io.mateu.uidl.data.FieldStereotype:
regular, radio, checkbox, textarea, toggle, combobox, select, email, password, richText, listBox, html, markdown, image, icon, link, money, grid, color, choice, popover, slider, button, stars
Why “stereotype” and not “component”
Section titled “Why “stereotype” and not “component””Mateu does not ask you to pick a low-level UI component. It asks you to express presentation intent.
The data type says what the field holds. The stereotype says how it should be presented. The framework maps that combination to the appropriate component in the active UI technology.
This separation means the same ViewModel can be rendered with different frontend technologies without changing the Java code.
Mental model
Section titled “Mental model”inference-first, override-when-needed
Define the data. Mateu chooses the control. Override with @Stereotype only when the inference is wrong.