utils
General utility functions for working with Sitevision APIs and converting Java collections to JavaScript arrays.
iteratorToArray(iterator) ⇨ T[]
Section titled “iteratorToArray(iterator) ⇨ T[]”Converts an Iterator to a JavaScript array.
Param | Type | Description |
---|---|---|
iterator | Iterator | The Iterator to convert. |
Returns: T[]
- Array containing all items from the iterator.
import { iteratorToArray } from '@soleil-se/app-util/server';
// Convert a Java Iterator to arrayconst someIterator = getSomeIterator();const array = iteratorToArray(someIterator);
nodeIteratorToArray(nodeIterator) ⇨ Node[]
Section titled “nodeIteratorToArray(nodeIterator) ⇨ Node[]”Converts a NodeIterator to an array of Nodes.
Param | Type | Description |
---|---|---|
nodeIterator | NodeIterator | The NodeIterator to convert. |
Returns: Node[]
- Array containing all nodes from the iterator.
import { nodeIteratorToArray } from '@soleil-se/app-util/server';
// Convert NodeIterator to arrayconst nodeIterator = node.getNodes();const nodes = nodeIteratorToArray(nodeIterator);
listToArray(list) ⇨ T[]
Section titled “listToArray(list) ⇨ T[]”Converts a Java List to a JavaScript array.
Param | Type | Description |
---|---|---|
list | List | The List to convert. |
Returns: T[]
- Array containing all items from the list.
import { listToArray } from '@soleil-se/app-util/server';
// Convert List to arrayconst javaList = PropertyUtil.getStrings(node, 'someProperty');const array = listToArray(javaList);
setToArray(set) ⇨ T[]
Section titled “setToArray(set) ⇨ T[]”Converts a Java Set to a JavaScript array.
Param | Type | Description |
---|---|---|
set | Set | The Set to convert. |
Returns: T[]
- Array containing all items from the set.
import { setToArray } from '@soleil-se/app-util/server';
// Convert Java Set to arrayconst javaSet = getSomeSet();const array = setToArray(javaSet);
nativeRequire(module)
Section titled “nativeRequire(module)”Require a module natively, bypassing Webpack bundling. This function behaves like a native require()
in Rhino and is used to import system packages where Webpack bundling interferes with native module resolution.
Param | Type | Description |
---|---|---|
module | string | The module identifier to require. |
Returns: any
- The exported module.
import { nativeRequire } from '@soleil-se/app-util/server';
// Import a Sitevision API packageconst PortletContextUtil = nativeRequire('PortletContextUtil');const PropertyUtil = nativeRequire('PropertyUtil');