dw.experience
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.

getID() : String
Returns the id of this component.
getName() : String
Returns the name of this component
getRegion(id : String) : Region
Returns the component region that matches the given id.
getTypeID() : String
Returns the type id of this component.
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 -> boolean
  • category -> string representing a catalog category ID
  • custom -> Map that originates from a stringified curly brackets {} JSON object
  • cms_record -> Map that originates from a stringified curly brackets {} JSON object whose entries must adhere to the cmsrecord.json schema
  • enum -> either string or integer
  • file -> string representing a file path within a library
  • image -> Map that originates from a stringified curly brackets {} JSON object whose entries must adhere to the content/schema/image.json schema
  • integer -> integer
  • markup -> string representing HTML markup
  • page -> string representing a page ID
  • product -> string representing a product SKU
  • string -> string
  • text -> string
  • url -> 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