Renders a Velocity template as plain text under a caller-chosen content type, for output such as CSV, XML, JSON or an email body. Created via ViewsBuilder.textTemplateView(...) from server-side JS and returned from a controller as the view for a request. Rendering is delegated to TextTemplater rather than the HTML templater, so none of the page chrome a theme adds is applied. The content type is whatever was passed in, and any byte range on the request is ignored - the whole output is written.
Group: Views
Implements: View
Properties
| Property | Returns | Description |
|---|---|---|
| contentType | String | The content type supplied at construction, sent as the response's content type. |
| description | String | Short, user-facing label for this view, naming the template path it renders and the content type it sends. |
| template | String | The path of the text template this view renders, as supplied at construction. |
Methods
getDescription()
Returns: String
Short, user-facing label for this view, naming the template path it renders and the content type it sends.
render(CommonResource page, OutputStream out, Range range, Map<String,String> params, String contentType)
Returns: void
Renders the template to the response through TextTemplater, with the given resource as the page model.
| Parameter | Description |
|---|---|
page | the resource the view is being rendered for, passed to the templater as the page model |
out | the stream the rendered text is written to |
range | not used by this view; the whole output is always written |
params | request parameters, made available to the template |
contentType | not used by this view; getContentType() supplies the response content type |
getContentType()
Returns: String
The content type supplied at construction, sent as the response's content type.
getTemplate()
Returns: String
The path of the text template this view renders, as supplied at construction.