Copyright© 2008-2026 Sitevision AB, all rights reserved.
public interface ContentRenderer
This rendering utility is a page content-specific sibling to OutputUtil.getNodeOutput(Node, Node, int)
but it has some nifty advantages:
OutputUtil for subsequent rendering of page content.
ContentRendererBuilder).
Note! This renderer has generic support for page content (i.e. modules, layouts etc.)
but if you should render Text modules - you should use TextModuleRenderer instead!
The TextModuleRenderer is much, much more efficient and provides more versatile behaviour when rendering text modules.
Using the ContentRenderer is pretty straightforward, if you remember that it is stateful and it adheres to an immutable page
determined at creation time.
Conceptually you would typically use it like this:
ContentRendererBuilder.When you have rendered once, you can re-use the ContentRenderer until you are done. Something like:
Usage example:
import rendererBuilderFactory from '@sitevision/api/server/RendererBuilderFactory';
// Script module and legacy apps would typically use the require function:
// const rendererBuilderFactory = require('RendererBuilderFactory');
const contentRendererBuilder = rendererBuilderFactory.getContentRendererBuilder();
// Example Use Case: render a search module on a given page using specific request parameters used by the search module
const page = ...
const pageParams = { query:"*:*" };
const searchModule = ...
// 1. Create renderer with page context
const contentRenderer = contentRendererBuilder
.setPage(page)
.setParameters(pageParams)
.build();
// 2. Load the renderer with the page content part and render
contentRenderer.update(searchModule);
const output = contentRenderer.renderHtml();
An instance of the Sitevision class implementing this interface can be obtained via
ContentRendererBuilder.build() .
See ContentRendererBuilder for how to obtain an instance of the ContentRendererBuilder interface.
ContentRendererBuilder| Modifier and Type | Method and Description |
|---|---|
boolean |
isLoaded()
Whether this renderer has been updated with a renderable content Node.
|
String |
renderHtml()
Renders html for the loaded content node.
|
void |
update(Node aContentNode)
Updates the state of this renderer using a content Node.
|
void |
updateByContentIdentifier(String aContentIdentifier)
Updates the state of this renderer using the content identifier of a content Node.
|
void |
updateByIdentifier(String aNodeIdentifier)
Updates the state of this renderer using the identifier of a content Node.
|
void update(Node aContentNode)
Note! If this state update fails (i.e. argument was null or not specifying a supported content part that exists on the page
this renderer was created for) there will be nothing to render. The state can always be checked via the
isLoaded() method.
aContentNode - the content node, typically a sv:portlet, sv:layout or sv:referenceLayoutvoid updateByIdentifier(String aNodeIdentifier)
The "identifier" is the JCR Node identifier (also the jcr:uuid property) of the content node.
Note! If this state update fails (i.e. argument was null or not specifying a supported content part that exists on the page
this renderer was created for) there will be nothing to render. The state can always be checked via the
isLoaded() method.
aNodeIdentifier - the node identifier that specifies the content node (typically a sv:portlet, sv:layout or sv:referenceLayout)void updateByContentIdentifier(String aContentIdentifier)
The "content identifier" is the contentIdentifier property for the sv:portlet on the context page.
Note! If this state update fails (i.e. argument was null or not specifying a supported content part that exists on the page
this renderer was created for) there will be nothing to render. The state can always be checked via the
isLoaded() method.
aContentIdentifier - the content identifier that specifies the content node (i.e. a sv:portlet)boolean isLoaded()
String renderHtml()
Note! The returned value will always be empty string if the isLoaded() state is false
when invoking this render method (i.e. you would typically always check the loaded state before calling this method).
Sitevision - Content Management Made Easy
Sitevision is an advanced Java enterprise portal product that implements Java Content Repository (JSR 283).
Copyright© 2008-2026 Sitevision AB, all rights reserved.