Extending the data model in the web application
The DXA data model is not only extensible on the Content Manager side (by building or extending TBBs), but also on the web application side. For example, if you extend the data model in the Content Manager, you can add supporting extensions on the web application side.
.NET
With a DXA Java web application, data model extensions are typically classes that get serialized in the ExtensionData of the page or entity models. If you add non-native types, you need to create a custom data model builder so that the web application will deserialize the classes.
Create a custom data model builder in your web application that implements the following interface:
Sdl.Web.Common.Interfaces.IDataModelExtension
Implementing this interface will provide the model deserialization knowledge of how to resolve types that exist outside the core data model. For details, refer to the .NET API documentation.
Java
With a DXA Java web application, you can add any custom class, and it will be automatically added to DXA's polymorphic mapping. For detailed instructions and example code for extending the data model, refer to the following summary for the following package:
com.sdl.dxa.api.datamodel
This package contains the R2 model and its related classes.