Class Viewable

java.lang.Object
org.glassfish.jersey.server.mvc.Viewable
Direct Known Subclasses:
ResolvedViewable

public class Viewable extends Object
A viewable type referencing a template by name and a model to be passed to the template. Such a type may be returned by a resource method of a resource class. In this respect the template is the view and the controller is the resource class in the Model View Controller pattern.

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. If the template name is relative then the class of the last matching resource is utilized to create an absolute path by default. However, the responsibility of resolving the absolute template name is up to ViewableContext which can override the default resolving behaviour.

Author:
Paul Sandoz, Michal Gajdos
See Also:
  • Constructor Details

    • Viewable

      public Viewable(String templateName) throws IllegalArgumentException
      Construct a new viewable type with a template name.

      The model will be set to null.

      Parameters:
      templateName - the template name, shall not be null.
      Throws:
      IllegalArgumentException - if the template name is null.
    • Viewable

      public Viewable(String templateName, Object model) throws IllegalArgumentException
      Construct a new viewable type with a template name and a model.
      Parameters:
      templateName - the template name, shall not be null.
      model - the model, may be null.
      Throws:
      IllegalArgumentException - if the template name is null.
  • Method Details

    • getTemplateName

      public String getTemplateName()
      Get the template name.
      Returns:
      the template name.
    • getModel

      public Object getModel()
      Get the model.
      Returns:
      the model.
    • isTemplateNameAbsolute

      public boolean isTemplateNameAbsolute()
      Determines whether the template name is represented by an absolute path.
      Returns:
      true if the template name is absolute, and starts with a '/' character, false otherwise.