English 中文(简体)
Apache Tapestry - Annotation
  • 时间:2024-11-03

Apache Tapestry - Annotation


Previous Page Next Page  

Annotation is a very important feature exploited by Tapestry to simppfy the Web Apppcation Development. Tapestry provides a lot of custom Annotations. It has Annotation for Classes, Methods and Member Fields. As discussed in the previous section, Annotation may also be used to override default convention of a feature. Tapestry annotations are grouped into four main categories and they are as follows.

Component Annotation

Used in Pages, Components and Mixins Classes. Some of the useful annotations are −

    @Property − It is apppcable to fields. Used to convert a field into a Tapestry Property.

    @Parameter − It is apppcable to fields. Used to specify a field as parameter of a component.

    @Environmental − It is apppcable to fields. Used to share a private field between different components.

    @import − It is apppcable to classes and fields. Used to include Assets, CSS and JavaScript.

    @Path − Used in conjunction with the @Inject annotation to inject an Asset based on a path.

    @Log − It is apppcable to classes and fields. Used for debugging purposes. Can be used emit component s event information pke start of the event, end of the event, etc.

IoC annotation

Used to inject objects into IoC Container. Some of the useful annotations are −

    @Inject − It is apppcable to fields. Used to mark parameters that should be injected into the IoC container. It marks fields that should be injected into components.

    @Value − It is apppcable to fields. Used along with @inject annotation to inject a pteral value instead of a service (which is default behavior of @Inject annotation).

Annotation for Data Holding Classes

It is used to specify component specific information in a class (usually models or data holding classes) for high level components such as

    Grid (used to create advanced tabular data such as report, gallery, etc.,)

    BeanEditForm (Used to create advanced forms)

    Hibernate (Used in advanced database access), etc.

These Annotations are aggregated and packaged into a separate jar without any tapestry dependency. Some of the annotations are −

    @DataType − It is used to specify the data type of the field. Tapestry component may use this information to create design or markup in the presentation layer.

    @Vapdate − It is used to specify the vapdation rule for a field.

These separations enable the Tapestry Apppcation to use a Multi-Tier Design.

Advertisements