Restlet Framework 2.2.3
Java Enterprise Edition

org.restlet.ext.thymeleaf
Class TemplateRepresentation

java.lang.Object
  extended by org.restlet.representation.Variant
      extended by org.restlet.representation.RepresentationInfo
          extended by org.restlet.representation.Representation
              extended by org.restlet.representation.CharacterRepresentation
                  extended by org.restlet.representation.WriterRepresentation
                      extended by org.restlet.ext.thymeleaf.TemplateRepresentation

public class TemplateRepresentation
extends WriterRepresentation

Thymeleaf template representation. Useful for dynamic string-based representations.

Author:
Grzegorz Godlewski
See Also:
Thymeleaf home page

Field Summary
protected  org.thymeleaf.context.IContext context
          The template's data model.
 
Fields inherited from class org.restlet.representation.Representation
UNKNOWN_SIZE
 
Constructor Summary
TemplateRepresentation(String templateName, Locale locale, Map<String,Object> dataModel, MediaType mediaType)
          Constructor.
TemplateRepresentation(String templateName, Locale locale, MediaType mediaType)
          Constructor.
TemplateRepresentation(String templateName, org.thymeleaf.TemplateEngine engine, Locale locale, Map<String,Object> dataModel, MediaType mediaType)
          Constructor.
TemplateRepresentation(String templateName, org.thymeleaf.TemplateEngine engine, Locale locale, MediaType mediaType)
          Constructor.
TemplateRepresentation(TemplateRepresentation templateRepresentation, Locale locale, MediaType mediaType)
          Constructor based on a Thymeleaf 'encoded' representation.
TemplateRepresentation(TemplateRepresentation templateRepresentation, org.thymeleaf.TemplateEngine engine, Locale locale, MediaType mediaType)
          Constructor based on a Thymeleaf 'encoded' representation.
 
Method Summary
static org.thymeleaf.TemplateEngine createTemplateEngine()
          Returns a new instance of TemplateEngine based by default on a TemplateResolver returned by calling createTemplateResolver().
static org.thymeleaf.TemplateEngine createTemplateEngine(org.thymeleaf.templateresolver.ITemplateResolver resolver)
          Returns a new instance of TemplateEngine based by default on a TemplateResolver returned by calling createTemplateResolver().
static org.thymeleaf.templateresolver.ITemplateResolver createTemplateResolver()
          Returns a new instance of ITemplateResolver with default configuration (XHTML template model, templates located inside "/WEB-INF/templates/", suffixed by ".html".
 Locale getLocale()
          Returns the representation's locale.
 String getTemplateName()
          Returns the template's name.
protected  void setContext(org.thymeleaf.context.IContext context)
          Sets the Thymeleaf context.
 void setDataModel(Map<String,Object> dataModel)
          Sets the template's data model.
 void setDataModel(Request request, Response response)
          Sets the template's data model from a request/response pair.
 void setDataModel(Resolver<Object> resolver)
          Sets the template's data model from a resolver.
 void setTemplateName(String templateName)
          Sets the template's name.
 void write(Writer writer)
          Writes the datum as a stream of characters.
 
Methods inherited from class org.restlet.representation.WriterRepresentation
getReader
 
Methods inherited from class org.restlet.representation.CharacterRepresentation
getChannel, getStream, write, write
 
Methods inherited from class org.restlet.representation.Representation
append, exhaust, getAvailableSize, getDigest, getDisposition, getExpirationDate, getRange, getRegistration, getSize, getText, hasKnownSize, isAvailable, isEmpty, isSelectable, isTransient, release, setAvailable, setDigest, setDisposition, setExpirationDate, setListener, setRange, setSize, setTransient
 
Methods inherited from class org.restlet.representation.RepresentationInfo
getModificationDate, getTag, setModificationDate, setTag
 
Methods inherited from class org.restlet.representation.Variant
createClientInfo, equals, getCharacterSet, getEncodings, getLanguages, getLocationRef, getMediaType, includes, isCompatible, setCharacterSet, setEncodings, setLanguages, setLocationRef, setLocationRef, setMediaType, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

context

protected volatile org.thymeleaf.context.IContext context
The template's data model.

Constructor Detail

TemplateRepresentation

public TemplateRepresentation(String templateName,
                              Locale locale,
                              Map<String,Object> dataModel,
                              MediaType mediaType)
Constructor.

Parameters:
templateName - The Thymeleaf template's name. The actual template is retrieved using the Thymeleaf configuration.
locale - The locale of the template.
dataModel - The Thymeleaf template's data model.
mediaType - The representation's media type.

TemplateRepresentation

public TemplateRepresentation(String templateName,
                              Locale locale,
                              MediaType mediaType)
Constructor.

Parameters:
templateName - The Thymeleaf template's name. The full path is resolved by the configuration.
locale - The locale of the template.
mediaType - The representation's media type.

TemplateRepresentation

public TemplateRepresentation(String templateName,
                              org.thymeleaf.TemplateEngine engine,
                              Locale locale,
                              Map<String,Object> dataModel,
                              MediaType mediaType)
Constructor.

Parameters:
templateName - The Thymeleaf template's name. The actual template is retrieved using the Thymeleaf configuration.
engine - The template engine.
locale - The locale of the template.
dataModel - The Thymeleaf template's data model.
mediaType - The representation's media type.

TemplateRepresentation

public TemplateRepresentation(String templateName,
                              org.thymeleaf.TemplateEngine engine,
                              Locale locale,
                              MediaType mediaType)
Constructor.

Parameters:
templateName - The Thymeleaf template's name. The full path is resolved by the configuration.
locale - The locale of the template
mediaType - The representation's media type.

TemplateRepresentation

public TemplateRepresentation(TemplateRepresentation templateRepresentation,
                              Locale locale,
                              MediaType mediaType)
                       throws IOException
Constructor based on a Thymeleaf 'encoded' representation.

Parameters:
templateRepresentation - The representation to 'decode'.
locale - The locale of the template.
mediaType - The representation's media type.
Throws:
IOException
ParseErrorException
ResourceNotFoundException

TemplateRepresentation

public TemplateRepresentation(TemplateRepresentation templateRepresentation,
                              org.thymeleaf.TemplateEngine engine,
                              Locale locale,
                              MediaType mediaType)
                       throws IOException
Constructor based on a Thymeleaf 'encoded' representation.

Parameters:
templateRepresentation - The representation to 'decode'.
engine - The template engine.
locale - The locale of the template.
mediaType - The representation's media type.
Throws:
IOException
ParseErrorException
ResourceNotFoundException
Method Detail

createTemplateEngine

public static org.thymeleaf.TemplateEngine createTemplateEngine()
Returns a new instance of TemplateEngine based by default on a TemplateResolver returned by calling createTemplateResolver().

Returns:
A new instance of TemplateEngine

createTemplateEngine

public static org.thymeleaf.TemplateEngine createTemplateEngine(org.thymeleaf.templateresolver.ITemplateResolver resolver)
Returns a new instance of TemplateEngine based by default on a TemplateResolver returned by calling createTemplateResolver().

Returns:
A new instance of TemplateEngine

createTemplateResolver

public static org.thymeleaf.templateresolver.ITemplateResolver createTemplateResolver()
Returns a new instance of ITemplateResolver with default configuration (XHTML template model, templates located inside "/WEB-INF/templates/", suffixed by ".html".

Returns:
A new instance of ITemplateResolver.

getLocale

public Locale getLocale()
Returns the representation's locale.

Returns:
The representation's locale.

getTemplateName

public String getTemplateName()
Returns the template's name.

Returns:
The template's name.

setContext

protected void setContext(org.thymeleaf.context.IContext context)
Sets the Thymeleaf context.

Parameters:
context - The Thymeleaf context

setDataModel

public void setDataModel(Map<String,Object> dataModel)
Sets the template's data model.

Parameters:
dataModel - The template's data model.
locale -

setDataModel

public void setDataModel(Request request,
                         Response response)
Sets the template's data model from a request/response pair. This default implementation uses a Resolver.

Parameters:
request - The request where data are located.
response - The response where data are located.
See Also:
Resolver, Resolver.createResolver(Request, Response)

setDataModel

public void setDataModel(Resolver<Object> resolver)
Sets the template's data model from a resolver.

Parameters:
resolver - The resolver.

setTemplateName

public void setTemplateName(String templateName)
Sets the template's name.

Parameters:
templateName - The template's name.

write

public void write(Writer writer)
           throws IOException
Writes the datum as a stream of characters.

Specified by:
write in class Representation
Parameters:
writer - The writer to use when writing.
Throws:
IOException

Restlet Framework 2.2.3
Java Enterprise Edition

Copyright © 2005-2014 Restlet.