Skip to content

Routing and parameters

Mateu binds URL parameters directly to ViewModel fields. There are no controllers, no manual parsing, and no mapping layer.

The URL is just another input to your UI state.


Define placeholders in the route using :name syntax. Mateu maps them to fields with matching names.

@Route("/products/:id")
public class ProductForm {
String id; // receives the value from the URL
}

Navigating to /products/abc-123 sets id = "abc-123" before any action runs.


Fields not covered by path parameters are populated from the query string automatically.

@Route("/products/:id")
public class ProductForm {
String id; // from path
int version; // from query string
}

Navigating to /products/abc-123?version=2 sets:

  • id = "abc-123"
  • version = 2

Mateu handles type conversion. A missing parameter uses the field’s default Java value.


@Route("/products/:id")
public class ProductForm {
String id;
int version;
@NotBlank
String name;
@Stereotype(FieldStereotype.radio)
Status status;
@ReadOnly
String audit;
@Button
void inspect() {
audit = "id=" + id + ", version=" + version + ", name=" + name;
}
}

URL:

http://localhost:8080/products/abc-123?version=2

Result before the user acts:

  • id = "abc-123"
  • version = 2
  • name and status are populated from whatever the browser sent as form state

Traditional architectures require:

  1. Controller receives request
  2. Controller parses parameters
  3. Controller maps to a DTO
  4. DTO is passed to the UI layer

With Mateu:

  1. URL maps directly to the ViewModel

No intermediate layer. No boilerplate.


  • Field names must match parameter names exactly (case-sensitive)
  • Type conversion is automatic for primitives and common types (String, int, long, boolean, LocalDate, etc.)
  • Missing parameters leave fields at their Java default value