Copyright© 2008-2026 Sitevision AB, all rights reserved.
public interface TextModuleUpdater
Required configuration:
Usage example:
import createContentFactory from '@sitevision/api/server/CreateContentFactory';
// Script module and legacy apps would typically use the require function:
// const createContentFactory = require('CreateContentFactory');
const updater = createContentFactory.getTextModuleUpdater();
updater
.setTextModule(existingTextModuleNode)
.setMarkdownContent('# Updated Title\n\nThis content has been **updated**.');
// Optionally check if configuration is valid before executing
if (updater.isValid()) {
const node = updater.execute();
}
Important notes:
Permission requirements:
The current user must have permission to update the parent page. An exception will be
thrown during execute() if the user lacks the necessary permissions.
An instance of the Sitevision class implementing this interface can be obtained via
CreateContentFactory.getTextModuleUpdater().
See CreateContentFactory for how to
obtain an instance of the CreateContentFactory interface.
| Modifier and Type | Method and Description |
|---|---|
Node |
execute()
Updates the text module with the new configured content.
|
boolean |
isValid()
Best-effort validation of the current builder configuration.
|
TextModuleUpdater |
setContent(String aContent,
ContentFormat aContentFormat)
Sets the new content for the text module with an explicit format.
|
TextModuleUpdater |
setMarkdownContent(String aMarkdownContent)
Sets the new content for the text module using Markdown format.
|
TextModuleUpdater |
setTextModule(Node aTextModule)
Sets the text module to be updated.
|
TextModuleUpdater setTextModule(Node aTextModule)
The node must be an existing text module sv:portlet (portlet ID "text") that is
on a page. The entire content of this text module will be replaced when
execute() is called.
This is a required configuration parameter.
aTextModule - the text module node to update, must be a valid text portletTextModuleUpdater setMarkdownContent(String aMarkdownContent)
This is a convenience method equivalent to calling
setContent(aMarkdownContent, ContentFormat.MARKDOWN).
The Markdown content will be parsed and converted to rich text elements,
replacing the existing content.
See ContentFormat.MARKDOWN for details on supported syntax.
aMarkdownContent - The new Markdown content, must not be null or emptyTextModuleUpdater setContent(String aContent, ContentFormat aContentFormat)
This method allows you to specify the new content and its format explicitly. The content will be parsed according to the specified format and converted to rich text elements, replacing the existing content.
aContent - The new text content. Must not be null or emptyaContentFormat - The format of the content. Must not be nullboolean isValid()
Checks if all required parameters are set and valid:
Node execute() throws IllegalStateException, ConstraintViolationException, RepositoryException
Important: This method modifies VersionUtil.OFFLINE_VERSION
of the page content and saves the changes. The operation is performed under a lock to ensure consistency. The entire existing
content of the text module is replaced.
IllegalStateException - If the configuration is invalidConstraintViolationException - If the targeted textModule is invalid,
or the user lacks permission to update the page,
or the page is trashedRepositoryException - If something else goes wrongSitevision - 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.