Injection with Components
Wiki Markup |
---|
{float:right|background=#eee} {infocontentbylabel:title=Related Articles} [Injection FAQ] {info|showLabels=false|showSpace=false|space=@self|labels=injection} {float} |
A key concept in Tapestry is the use of injection. The term Injection in Tapestry is used in several related ways. The Tapestry IoC container makes use of one form of injection, via parameters to service builder methods (see Injection in Detail).
For components, however, Tapestry takes a completely different tack: injection directly into instance variables.
@Inject Annotation
The @Inject @Inject annotation is used to identify fields that will contain injected services and other resources.
...
For field type Block, the value of the Inject annotation is the id of the <block> element within the component's template. Normally, the id of the block is determined from the field name (after stripping out leading "_" and "$" characters). Where that is not appropriate, an @Id @Id annotation can be supplied:
...
Here, a specific object is requested. A @Service @Service annotation is used to identify the service name.
...