Script: Class dw.experience.Component
Class Component
- Object
- dw.experience.Component
This class represents a page designer managed component as part of a page. A component comprises of multiple regions that again hold components, thus spanning a hierarchical tree of components. Using the PageMgr.renderRegion(Region) or PageMgr.renderRegion(Region, RegionRenderSettings) a region can be rendered which implicitly includes rendering of all contained visible components. All content attributes (defined by the corresponding component type) can be accessed, reading the accordant persisted values as provided by the content editor who created this component.
See Also:
Properties
ID : String Read Only
The id of this component.
name : String Read Only
The name of this component
typeID : String Read Only
The type id of this component.
Constructor Summary
This class does not have a constructor, so you cannot create it directly.
Method Summary
getAttribute(attributeID : String) : Object
Returns the raw attribute value identified by the specified attribute id.
Returns the id of this component.
Returns the name of this component
getRegion(id : String) : Region
Returns the component region that matches the given id.
Returns the type id of this component.
Methods inherited from class Object
assign, create, create, defineProperties, defineProperty, entries, freeze, fromEntries, getOwnPropertyDescriptor, getOwnPropertyNames, getOwnPropertySymbols, getPrototypeOf, hasOwnProperty, is, isExtensible, isFrozen, isPrototypeOf, isSealed, keys, preventExtensions, propertyIsEnumerable, seal, setPrototypeOf, toLocaleString, toString, valueOf, values
Method Detail
getAttribute
getAttribute(attributeID : String) : Object
Returns the raw attribute value identified by the specified attribute id. By raw attribute value we denote the unprocessed value as provided for the attribute driven by the type of the respective attribute definition:
boolean
-> booleancategory
-> string representing a catalog category IDcustom
-> Map that originates from a stringified curly brackets {} JSON objectcms_record
-> Map that originates from a stringified curly brackets {} JSON object whose entries must adhere to thecmsrecord.json
schemaenum
-> either string or integerfile
-> string representing a file path within a libraryimage
-> Map that originates from a stringified curly brackets {} JSON object whose entries must adhere to thecontent/schema/image.json
schemainteger
-> integermarkup
-> string representing HTML markuppage
-> string representing a page IDproduct
-> string representing a product SKUstring
-> stringtext
-> stringurl
-> string representing a URL
There is two places an attribute value can come from - either it was persisted at design time (e.g. by the merchant by editing a component in Page Designer) or it was injected in shape of an aspect attribute at rendering time through the execution of code. The persistent value, if existing, takes precedence over the injected aspect attribute one. Injection of a value through an aspect attribute will only occur if the component attribute's attribute definition was declared using the "dynamic_lookup"
property and its aspect attribute alias matches the ID of the respective aspect attribute.
Accessing the raw value can be helpful if render and serialization logic of the component needs to operate on these unprocessed values. An unprocessed value might be fundamentally different from its processed counterpart, the latter being provided through the content dictionary (see ComponentScriptContext.getContent()) when the render/serialize function of the component is invoked.
Parameters:
attributeID - the id of the desired attribute
Returns:
the unprocessed raw value of the desired attribute, or null if not found
getID
getID() : String
Returns the id of this component.
Returns:
the component id
getName
getName() : String
Returns the name of this component
Returns:
the component name
getRegion
getRegion(id : String) : Region
Returns the component region that matches the given id.
Parameters:
id - the id of the desired component region
Returns:
the region, or null if not found.
getTypeID
getTypeID() : String
Returns the type id of this component.
Returns:
the component type id