You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

There's a lot of documentation scattered about describing the various annotations and methods you will add to a page. This is not an exhaustive list, but describes some typical things.

Field Injection Annotations

@Inject

@Inject is the Swiss-Army Knife of annotation; it's designed to connect your component to services, resources, and other objects.

Service Injection

In most cases, the injected value is a service; the service is located by type. If there are ambiguities, caused by multiple services implementing the same interface, you'll see injection exceptions. You can resolve those exceptions by adding marker annotations to select a specific service, or by adding @Service to specify the specific service id you want.

Use of @Service is discouraged. If marker annotations are available, that is preferred.

@InjectComponent

Injects a component from this component's template into this component's class. Injecting a component is based on the component's id, which should match the field name. However, the value attribute of the @InjectComponent annotation can be specified as well, this takes precedence over the field name.

It is common to inject a component in order to obtain its client-side id (used when generating client-side JavaScript).

@InjectContainer

Injects the container of a component or, when used in a mixin, injects the component the mixin is attached to.

@InjectPage

Injects a page of the application. Normally, the page to inject is identified based on the field type. The value attribute can be specified, in which case the page to be injected is identified by name.

@Environmental

Injects an environmental object; such objects are request scoped but may be overridden at any time using the methods of the Environment service. Environmental objects are used to allow outer components to communicate with components they enclose.

Most often, @Environmental is used with type JavaScriptSupport, which is used to add JavaScript code and libraries to the rendered page.

Field Behavior Annotations

@PageActivationContext

@Parameter

@Persist

@Property

@SessionState

@ActivationRequestParameter

Method Annotations

@OnEvent

@Log

@CommitAfter

@Cached

Type Annotations

@Events

@Import

@AllowsInformalParameters

Render Phase Methods

Page Lifecycle Methods

  • No labels