Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Overview

This page contains a draft definition of the functionality that would be required to related to binding CMS data to View Models.

Current Implementations

DXA uses a IModelBuilder interface as follows, IModelBuilders are chained together in a ModelBuilderPipeline, to allow additional processing to be done after the basic model is built from CMS data (this is for example how the model is enriched with data from SmartTarget queries)

Code Block
languagec#
public interface IModelBuilder
{
    void BuildPageModel(ref PageModel pageModel, IPage page, IEnumerable<IPage> includes, Localization localization);
    void BuildEntityModel(ref EntityModel entityModel, IComponentPresentation cp, Localization localization);
    void BuildEntityModel(ref EntityModel entityModel, IComponent component, Type baseModelType, Localization localization);
}

DD4T.NET

TODO 

DD4T.Java

TODO

Required Functionality

The View Models page contains an audit of existing DXA and DD4T functionality. This is distilled below into the following requirements table:

RefPrioDescription

Must haveThe ModelBinder can bind Page and Entity (Component Presentation) Models from DD4T JSON

Must haveThe ModelBinder can resolve regions from the set of CPs on the page

Must haveThe logic for resolving regions is extensible using a IPageRegionResolver. The default behaviour is to resolve everything into a single region

Must haveA IPageRegionResolver which implements the DXA Region resolving logic will be provided

Must haveThe ModelBinder can resolve fields which are component links into URLs

Must haveThe logic for resolving links is extensible using an ILinkResolver

Must haveModel properties can be marked as 'dynamic' to prevent the link being resolved when the model is built

Must haveThe ModelBinder can resolve Rich Text fields (resolving links and binaries)

Must haveThe logic for resolving rich text is extensible using an IRichTextResolver

Must haveAn implementation of the IRichTextResolver which implements the DXA Rich text resolving will be provided (splitting the RTF into a list of entities/html blocks)