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.

AttributeTypeDefaultMeaning
controllerStringrequiredController 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.

AttributeTypeDefaultMeaning
uriStringrequiredRequest URI.
controllerString""Controller location. Defaults to the default webapp’s controller.
methodString"all"HTTP method allowed: "get", "post" or "all".
trackVisitString""Whether to track first visit.
trackServerHitString""Whether to track statistics.
secureString"true"Whether to redirect an insecure request to HTTPS.
authString"false"Whether to forward to the login page when the user is not logged in.
authCheckEventString""Alternative request URI whose event does the login check. Defaults to "checkLogin".
certString"false"Whether to require HTTPS client (x.509) security.
externalViewString"true"Whether to allow overriding the view through the URL’s uri/view switch.
directRequestString"true"Whether to allow direct public access, as opposed to internal chaining only.
overrideModeString"replace""replace" or "merge", for a request that overrides one already defined.
descriptionString""Request description.
metricMetric[]{}Performance metrics to record.

@View#

Defines one view mapping.

AttributeTypeDefaultMeaning
nameStringrequiredView name.
descriptionString""View description.
controllerString""Controller location. Defaults to the default webapp’s controller.
typeString"default"View handler: "screen", "screenfop", and so on.
pageString""Page location the handler renders.
infoString""Free-form info string.
contentTypeString""Response content type. Defaults to "text/html".
encodingString""Character encoding. "none" sends no charset.
noCacheString"false"Whether to send no-cache headers.
xFrameOptionsString"sameorigin"Clickjacking protection header value.
strictTransportSecurityString""HSTS header value. Has a server default except on localhost.
accessString"""public" or "internal".

@Event#

Sets custom event options on a @Request method, beyond the defaults.

AttributeTypeDefaultMeaning
nameString""Event name.
controllerString""Controller location. Defaults to the default webapp’s controller.
sectionString""Section this event runs in. Defaults to "request".
sequenceString""Run order among events in the same section.
typeString""Event type: "java", "service", and so on. Defaults to "java".
invokeString""Method or entry-point name to invoke.
transactionTimeoutString""Event transaction timeout in seconds. Defaults to "60".
abortTransactionString"""on-error-result", "on-exception" or "on-any-error".
globalTransactionString""For service-multi, whether to wrap in a transaction. Defaults to "true".
transactionString""General transaction enable/disable. Defaults to "true".
synchronizedValuesString[]{}Values to synchronize the event call on.
metricMetric[]{}Performance metrics to record.
pathString""Script path, for a script-type event.
propertiesEventProperty[]{}Extra properties passed to the event.
paramToAttrParamToAttr[]{}Parameters copied to request attributes before the event runs.
scriptString""Inline script body, for a script-type event.

@Handler#

Registers a custom event or view handler type.

AttributeTypeDefaultMeaning
nameStringrequiredHandler name, referenced from @Event(type=...) or @View(type=...).
typeString"request"Handler kind.
controllerString""Controller location. Defaults to the default controller.
triggersString"all"When the handler applies.

@ControllerConfig#

Sets controller-level settings: error page, status code, default request.

AttributeTypeDefaultMeaning
controllerString""Controller this configures.
descriptionString""Description.
ownerString""Owner note.
errorpageString""Error page location.
statusCodeString""Default HTTP status code.
defaultRequestString""Request URI used when none is given.
protectViewString""View protection setting.
includesInclude[]{}Other controllers to include.
viewAsJsonViewAsJson@ViewAsJson(enabled = "")View-as-JSON support settings.
commonSettingsCommonSettings@CommonSettingsShared request/view/map defaults.
inputOutputFiltersInputOutputFilters@InputOutputFiltersParameter filter settings.

@CommonSettings#

Sets shared defaults for request, response and view mappings, inside @ControllerConfig(commonSettings = ...).

AttributeTypeDefaultMeaning
requestMapSettingsRequestMapSettings@RequestMapSettingsShared request mapping defaults.
viewMapSettingsViewMapSettings@ViewMapSettingsShared 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.

java
@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.

Ask the people who wrote it.

Support, development and training from the team that builds Scipio ERP.