org.glassfish.jersey.server.mvc
Annotation Type Template


@Inherited
@Target(value={TYPE,METHOD})
@Retention(value=RUNTIME)
public @interface Template

Used to annotate JAX-RS resources and resource methods to provide reference to a template for MVC support.

In case a resource class is annotated with Template annotation then an instance of this class is considered to be the model. Producible media types are determined from the resource classes Produces annotation.

In case a resource method is annotated with Template annotation then the return value of the method is the model. Otherwise the processing of such a method is the same as if the return type of the method was Viewable class. If a method is annotated with Template and also returning a Viewable instance then the values (resolvingClass) from the viewable take precedence over those defined by the annotation. Producible media types are determined from the method's Produces annotation.

To see how templates are being resolved, see viewable.

Author:
Michal Gajdos (michal.gajdos at oracle.com)
See Also:
Viewable

Optional Element Summary
 java.lang.String name
          The template name that should be used to output the entity.
 java.lang.Class<?> resolvingClass
          The class to be used to resolve the template name if the template name is not absolute.
 

name

public abstract java.lang.String name
The template name that should be used to output the entity. The template name may be declared as absolute template name if the name begins with a '/', otherwise the template name is declared as a relative template name.

Default:
""

resolvingClass

public abstract java.lang.Class<?> resolvingClass
The class to be used to resolve the template name if the template name is not absolute. If the value is Object.class then the resolving class will be obtained from the last matching resource.

Defaults to Object.

Default:
java.lang.Object.class


Copyright © 2007-2013, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.