Renders an HTML page from a Velocity template, using the current resource as the model. Created via ViewsBuilder.templateView(...) from server-side JS and returned from a controller as the view for a request. Rendering is delegated to HtmlTemplater, the response is always sent as text/html with a UTF-8 charset, and any byte range on the request is ignored - the whole page is written. The class is also configurable in XML under the alias "template".

Group: Views

Implements: View, TitledView, Serializable


Properties

PropertyReturnsDescription
contentTypeStringThe content type sent with the response, always HTML with a UTF-8 charset.
descriptionStringShort, user-facing label for this view, naming the template path it renders.
templateStringThe path of the template this view renders, as supplied at construction or from XML. Null if the view was created with the no-arg constructor and never populated.
titleStringThe page title for this view, taken from the title of the template file itself. The lookup resolves the template path against the current root folder's resource tree, so it costs a resource lookup on first call, then caches the result on the request keyed by template path. Null if there is no current root folder, if the template cannot be found, or if the current user is not allowed to read it.

Methods

getDescription()

Returns: String

Short, user-facing label for this view, naming the template path it renders.

getTemplate()

Returns: String

The path of the template this view renders, as supplied at construction or from XML. Null if the view was created with the no-arg constructor and never populated.

render(CommonResource page, OutputStream out, Range range, Map<String,String> params, String contentType)

Returns: void

Renders the template to the response through HtmlTemplater, with the given resource as the page model.

ParameterDescription
pagethe resource the view is being rendered for, passed to the templater as the page model
outthe stream the rendered HTML is written to
rangenot used by this view; the whole page is always written
paramsrequest parameters, made available to the template
contentTypenot used by this view; getContentType() supplies the response content type

getContentType()

Returns: String

The content type sent with the response, always HTML with a UTF-8 charset.

getTitle()

Returns: String

The page title for this view, taken from the title of the template file itself. The lookup resolves the template path against the current root folder's resource tree, so it costs a resource lookup on first call, then caches the result on the request keyed by template path. Null if there is no current root folder, if the template cannot be found, or if the current user is not allowed to read it.

To get full access to the Kademi Hub existing customers can login here, or new customers can register here.