Controller annotations
The @Controller, @Request, @View and @Event annotations, with a real example from the setup application.
Source: framework/webapp/src/com/ilscipio/scipio/ce/webapp/control/def/.
@Controller#
Marks the class that groups a webapp’s requests, views and events. It carries no request data of its own.
| Attribute | Type | Default | Meaning |
|---|---|---|---|
controller | String | required | Controller location, as a controller:// URL or a webapp name. "default" names the default webapp’s controller. |
@Request#
Defines one request mapping. On a class it applies to every event method
inside; on a method it uses that method as the event with default event
options, unless the method also carries an @Event.
| Attribute | Type | Default | Meaning |
|---|---|---|---|
uri | String | required | Request URI. |
controller | String | "" | Controller location. Defaults to the default webapp’s controller. |
method | String | "all" | HTTP method allowed: "get", "post" or "all". |
trackVisit | String | "" | Whether to track first visit. |
trackServerHit | String | "" | Whether to track statistics. |
secure | String | "true" | Whether to redirect an insecure request to HTTPS. |
auth | String | "false" | Whether to forward to the login page when the user is not logged in. |
authCheckEvent | String | "" | Alternative request URI whose event does the login check. Defaults to "checkLogin". |
cert | String | "false" | Whether to require HTTPS client (x.509) security. |
externalView | String | "true" | Whether to allow overriding the view through the URL’s uri/view switch. |
directRequest | String | "true" | Whether to allow direct public access, as opposed to internal chaining only. |
overrideMode | String | "replace" | "replace" or "merge", for a request that overrides one already defined. |
description | String | "" | Request description. |
metric | Metric[] | {} | Performance metrics to record. |
@View#
Defines one view mapping.
| Attribute | Type | Default | Meaning |
|---|---|---|---|
name | String | required | View name. |
description | String | "" | View description. |
controller | String | "" | Controller location. Defaults to the default webapp’s controller. |
type | String | "default" | View handler: "screen", "screenfop", and so on. |
page | String | "" | Page location the handler renders. |
info | String | "" | Free-form info string. |
contentType | String | "" | Response content type. Defaults to "text/html". |
encoding | String | "" | Character encoding. "none" sends no charset. |
noCache | String | "false" | Whether to send no-cache headers. |
xFrameOptions | String | "sameorigin" | Clickjacking protection header value. |
strictTransportSecurity | String | "" | HSTS header value. Has a server default except on localhost. |
access | String | "" | "public" or "internal". |
@Event#
Sets custom event options on a @Request method, beyond the defaults.
| Attribute | Type | Default | Meaning |
|---|---|---|---|
name | String | "" | Event name. |
controller | String | "" | Controller location. Defaults to the default webapp’s controller. |
section | String | "" | Section this event runs in. Defaults to "request". |
sequence | String | "" | Run order among events in the same section. |
type | String | "" | Event type: "java", "service", and so on. Defaults to "java". |
invoke | String | "" | Method or entry-point name to invoke. |
transactionTimeout | String | "" | Event transaction timeout in seconds. Defaults to "60". |
abortTransaction | String | "" | "on-error-result", "on-exception" or "on-any-error". |
globalTransaction | String | "" | For service-multi, whether to wrap in a transaction. Defaults to "true". |
transaction | String | "" | General transaction enable/disable. Defaults to "true". |
synchronizedValues | String[] | {} | Values to synchronize the event call on. |
metric | Metric[] | {} | Performance metrics to record. |
path | String | "" | Script path, for a script-type event. |
properties | EventProperty[] | {} | Extra properties passed to the event. |
paramToAttr | ParamToAttr[] | {} | Parameters copied to request attributes before the event runs. |
script | String | "" | Inline script body, for a script-type event. |
@Handler#
Registers a custom event or view handler type.
| Attribute | Type | Default | Meaning |
|---|---|---|---|
name | String | required | Handler name, referenced from @Event(type=...) or @View(type=...). |
type | String | "request" | Handler kind. |
controller | String | "" | Controller location. Defaults to the default controller. |
triggers | String | "all" | When the handler applies. |
@ControllerConfig#
Sets controller-level settings: error page, status code, default request.
| Attribute | Type | Default | Meaning |
|---|---|---|---|
controller | String | "" | Controller this configures. |
description | String | "" | Description. |
owner | String | "" | Owner note. |
errorpage | String | "" | Error page location. |
statusCode | String | "" | Default HTTP status code. |
defaultRequest | String | "" | Request URI used when none is given. |
protectView | String | "" | View protection setting. |
includes | Include[] | {} | Other controllers to include. |
viewAsJson | ViewAsJson | @ViewAsJson(enabled = "") | View-as-JSON support settings. |
commonSettings | CommonSettings | @CommonSettings | Shared request/view/map defaults. |
inputOutputFilters | InputOutputFilters | @InputOutputFilters | Parameter filter settings. |
@CommonSettings#
Sets shared defaults for request, response and view mappings, inside
@ControllerConfig(commonSettings = ...).
| Attribute | Type | Default | Meaning |
|---|---|---|---|
requestMapSettings | RequestMapSettings | @RequestMapSettings | Shared request mapping defaults. |
viewMapSettings | ViewMapSettings | @ViewMapSettings | Shared view mapping defaults. |
@ResponseProcessor#
Marks a method as a response processor for @Request. The method takes
(Object, HttpServletRequest, HttpServletResponse) or (Object, ServiceContext), where the first parameter is the event result. It carries
no attributes.
Example: the main request#
applications/setup/src/com/ilscipio/scipio/setup/controller/Controller.java,
lines 337-345.
@Request(
uri = "main",
controller = "setup",
secure = "true",
auth = "true"
)
@Response(name = "success", type = "request", value = "setupWizardStart")
public interface Main {}This maps the main request URI on the setup controller, requires HTTPS
and a logged-in user, and on success chains to the setupWizardStart
request.