Builds the AssetView instances used by content-type scripts to control how a matched request is rendered. An instance of this class is bound into the content-type script engine as the "views" variable, so a content-type script calls views.jsonView(...), views.editView() and so on when configuring an asset type's default view or a path mapping's view. The views produced range from plain JSON responses through to HTML rendered from an MVEL template or a page path.
Group: Builders
Methods
jsonView(String attribute)
Returns: JsonAssetView
Builds a view that renders the named request attribute as JSON. The attribute is looked up on the current request at render time, so it must already have been set (for example by a controller) before this view is used.
| Parameter | Description |
|---|---|
attribute | the name of the request attribute holding the object to serialise as JSON |
jsonView(boolean status, String message)
Returns: JsonAssetView
Builds a view that renders a simple JSON status result with a message, without reading a request attribute.
| Parameter | Description |
|---|---|
status | true if the result represents success, false for failure |
message | the message to include in the JSON result |
jsonObjectView(Object o)
Returns: JsonAssetView
Builds a view that renders the given object directly as JSON, without looking it up from a request attribute.
| Parameter | Description |
|---|---|
o | the object to serialise as JSON, such as a list, map or other JSON-convertible object |
editView()
Returns: EditContentItemView
Builds the default HTML edit form view for a content item.
editFormView()
Returns: EditFormContentItemAssetView
Builds the standard asset edit form view, rendered from the shared asset edit form template.
jsFunctionView(String functionName)
Returns: JsContentItemAssetView
Builds a view that renders by invoking the named function in the content type's own script, passing it the request parameters, the asset item, the byte range and the output stream to write to.
| Parameter | Description |
|---|---|
functionName | the name of the script function to invoke when the view is rendered |
mvelTemplateView(String templateText)
Returns: MvelTemplateContentItemAssetView
Builds a view that renders an HTML page from the given path treated as an MVEL template.
| Parameter | Description |
|---|---|
templateText | the path to the MVEL template to render |
pageTemplateView(String pagePath)
Returns: PageTemplateContentItemAssetView
Builds a view that renders an HTML page using the given path as the page template.
| Parameter | Description |
|---|---|
pagePath | the path of the page template to render |