dw.experience
Class PageMgr
Object
dw.experience.PageMgr
Provides functionality for getting and rendering page designer managed pages.

The basic flow is to initiate page rendering by ID via renderPage(String, String). This will trigger page rendering from a top level perspective, i.e. the page serves as entry point and root container of components. As a related page or component template will likely want to trigger rendering of nested components within its regions it can do this by first fetching the desired region by ID via Page.getRegion(String) or Component.getRegion(String) and then call to renderRegion(Region, RegionRenderSettings) with the recently retrieved region (and optionally provide RegionRenderSettings for customized rendering of region and component wrapper elements).

Various attributes required for rendering in the corresponding template can be accessed with the accordant methods of Page and Component.

See Also:
Constructor Summary
This class does not have a constructor, so you cannot create it directly.
Method Summary
static getCustomEditor(customEditorTypeID : String, configuration : Map) : CustomEditor

Initialize the custom editor of given type id using the passed configuration.

static getPage(pageID : String) : Page
Returns the page identified by the specified id.
static renderPage(pageID : String, parameters : String) : String
Render a page.
static renderRegion(region : Region, regionRenderSettings : RegionRenderSettings) : String

Renders a region by triggering rendering of all visible components within this region.

static renderRegion(region : Region) : String

Renders a region by triggering rendering of all visible components within this region.

Methods inherited from class Object
Method Detail
getCustomEditor
static getCustomEditor(customEditorTypeID : String, configuration : Map) : CustomEditor

Initialize the custom editor of given type id using the passed configuration. The initialization will trigger the init function of the respective custom editor type for which the passed custom editor object is being preinitialized with the given configuration (similar to what would happen through the editor_definition reference by any component type attribute definition).

This method is useful to obtain any custom editor instance you want to reuse within the init method of another custom editor, e.g. as dependent breakout element.

Parameters:
customEditorTypeID - the reference to a custom editor type, e.g. 'com.foo.bar'
configuration - the data structure used for preinitialization of the custom editor (also see CustomEditor.getConfiguration()). Be aware that this configuration will have to be serializable to JSON itself as it will be passed to Page Designer for processing in the UI. So you must not add any values in this map that are not properly serializable. Do not use complex DWScript classes that do not support JSON serialization like for instance Product.
Returns:
the initialized custom editor instance

getPage
static getPage(pageID : String) : Page
Returns the page identified by the specified id.
Parameters:
pageID - the id of the page
Returns:
the page, or null if not found.

renderPage
static renderPage(pageID : String, parameters : String) : String
Render a page. All of this is going to happen in two layers of remote includes, therefore pagecaching of page rendering is separated from the pagecache lifecycle of the caller. The first one is going to be returned by this method.
  • layer 1 - determines visibility fingerprint for the page and all its nested components driven by scheduling and customer segmentation. This remote include will not be pagecached. It will then delegate to layer 2.
  • layer 2 - does the actual rendering of the page by invoking its render function. This remote include will factor the previously determined visibility fingerprint in to the pagecache key, in case you decide to use pagecaching.

The layer 1 remote include is what is returned when calling this method.

The provided parameters argument is passed through till the layer 2 remote include which does the actual rendering so that it will be available for the render function of the invoked page as part of PageScriptContext.getRenderParameters(). You probably want to provide caller parameters from the outside in shape of a json String to the inside of the page rendering, e.g. to loop through query parameters.

The layer 2 remote include performs the rendering of the page and all its nested components within one request. Thus data sharing between the page and its nested components can happen in scope of this request.

The rendering of a page invokes the render function of the respective page type.

     String : render( PageScriptContext context)
 
The return value of the render function finally represents the markup produced by this page type.

Nesting of renderPage(String, String), i.e. rendering a page within a page (or respectively its components), is not a supported use case.

Parameters:
pageID - the ID of the page that will be rendered
parameters - the optional parameters passed to page rendering
Returns:
the remote include that will yield the markup as produced by page rendering

renderRegion
static renderRegion(region : Region, regionRenderSettings : RegionRenderSettings) : String

Renders a region by triggering rendering of all visible components within this region. For each of these components the render function of the respective component type is invoked.

     String : render( ComponentScriptContext context)
 
The return value of the render function will be wrapped by an HTML element - this finally represents the markup produced by this component type. The markup of the region accordingly represents the concatenation of all the components markup within an own wrapper element.
In order to provide styling for these wrapper elements of the components and the region some render settings can optionally be provided, which basically allows to configure which kind of tag is used for the wrapper element and which attributes the wrapper element contains. A sample output could look like this if RegionRenderSettings are applied with customized tag names and attributes for the region and component wrapper elements.


 <p class="myRegionCssClass">
     <span class="myComponentCssClass myComponentCssClass1" data-foo="bar">
         ...
     </span>
     <span class="myComponentCssClass myComponentCssClass2">
         ...
     </span>
 </p>
 

In order to go with the default settings for the wrapper elements see renderRegion(Region).

You must NOT call this method outside of the processing induced by renderPage(String, String).

Parameters:
region - the region that will be rendered
regionRenderSettings - the render settings that drive how the region and its components is rendered
Returns:
the markup as produced by region rendering

renderRegion
static renderRegion(region : Region) : String

Renders a region by triggering rendering of all visible components within this region. For each of these components the render function of the respective component type is invoked.

     String : render( ComponentScriptContext params)
 
The return value of the render function will be wrapped by an HTML element - this finally represents the markup produced by this component type. The markup of the region accordingly represents the concatenation of all the components markup within an own wrapper element.
The following sample shows how this would look like for a 'pictures' region that contains two components of type 'assets.image'.


 <div class="experience-region experience-pictures">
     <div class="experience-component experience-assets-image">
         ...
     </div>
     <div class="experience-component experience-assets-image">
         ..
     </div>
 </div>
 

The system default for region render settings are:

  • tag_name : div
  • attributes : {"class":"experience-region experience-[REGION_ID]"}

The system default for component render settings are:

  • tag name : div
  • attributes : {"class":"experience-component experience-[COMPONENT_TYPE_ID]"}
As the [COMPONENT_TYPE_ID] can contain dots due to its package like naming scheme (e.g. assets.image) any occurrences of these dots will be replaced by dashes (e.g. assets-image) so that CSS selectors do not have to be escaped.

In order to provide your own settings for the wrapper elements see renderRegion(Region, RegionRenderSettings).

You must NOT call this method outside of the processing induced by renderPage(String, String).

Parameters:
region - the region that will be rendered
Returns:
the markup as produced by region rendering