Package org.glassfish.jersey.server.mvc
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 toViewableContext
which can override the default resolving behaviour.- Author:
- Paul Sandoz, Michal Gajdos
- See Also:
Template
,ViewableContext
,ResolvingViewableContext
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Object
getModel()
Get the model.String
getTemplateName()
Get the template name.boolean
isTemplateNameAbsolute()
Determines whether the template name is represented by an absolute path.
-
-
-
Constructor Detail
-
Viewable
public Viewable(String templateName) throws IllegalArgumentException
Construct a new viewable type with a template name. The model will be set tonull
.- Parameters:
templateName
- the template name, shall not benull
.- Throws:
IllegalArgumentException
- if the template name isnull
.
-
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 benull
.model
- the model, may benull
.- Throws:
IllegalArgumentException
- if the template name isnull
.
-
-
Method Detail
-
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.
-
-