Components that are registered in the Enkan system is injected to an annotated field with Inject
of a controller.
public class UserController {
@Inject
private TemplateEngine templateEngine;
@Inject
private DomaProvider daoProvider;
}
Arguments of a controller method are available as follows:
If they are in the controller method parameters, ControllerInvokerMiddleware
injects to the arguments.
They are in random order.
public class ArgumentInjectionController {
public String method1(Parameters params, UserPrincipal principal, Session session) {
}
}
Parameters
is a map represents a query string and a url encoded form.
UserPrincipal
represents an authenticated user. It is available when AuthenticationMiddleware
is used.
Flash is a short time session.
Kotowari supports validation of the request body object using JSR 303 Bean validation.
@Data
@EqualsAndHashCode(callSuper = false)
public class CustomerForm extends FormBase {
@NotBlank
@Size(max = 10)
private String name;
@NotBlank
private String password;
@Email
private String email;
@Pattern(regexp = "[MF]")
private String gender;
private String birthday;
}