...
Note | ||
---|---|---|
| ||
Never initialize an instance field to a mutable object at the point of declaration. If this is done, the instance created from that initializer becomes the default value for that field and is reused inside the component on every request. This could cause state to inadvertently be shared between different sessions in an application. |
...
Tapestry will instantiate your class using the default, no arguments constructor. Other constructors will be ignored.
Injection
Main Article: Injection
Injection of dependencies occurs at the field level, via additional annotations. At runtime, fields that contain injections become read-only.
Code Block |
---|
@Inject // inject a resource
private ComponentResources componentResources;
@Inject // inject a block
private Block foo;
@Inject // inject an asset
@Path("context:images/top_banner.png")
private Asset banner;
@Inject // inject a service
private AjaxResponseRenderer ajaxResponseRenderer;
|
Parameters
Main Article: Component Parameters
Component parameters are also identified using private fields of your component class , annotated with the @Parameter annotation. Component parameters represent a two-way binding of a field of your component and a property or resource of its containing component or page.
Persistent Fields
Main Article: Persistent Page Data
...