Strongly Typed Topic Builder (Java)

DXA's Model Builder pipeline handles content from Tridion Docs by automatically converting Generic Topic Models to Strongly Typed Topic Models. You can also use the public API to convert generic Topics to Strongly Typed Topic Models.

Model Builder Pipeline

DXA automatically includes the Strongly Typed Topic Builder in the Model Builder Pipeline. You can, however, disable it by enabling the dxa.generictopic.disabled Spring profile.

The Model Builder Pipeline uses StronglyTypedTopicBuilder only when both of the following are true:

  • A generic Topic is encountered
  • A Strongly Typed Topic Model has been registered

Strongly Typed Topic Conversion API

You can also use the StronglyTypedTopicBuilder class from the API to convert generic Topics to Strongly Typed Topic Models. The class exposes the following public method for this purpose:

public <T extends EntityModel> T tryConvertToStronglyTypedTopic(GenericTopic genericTopic, Class<T> ofType) throws DxaException

These APIs facilitate two use cases:

  • The Strongly Typed Model Class should be data-driven. In this case, the method should be used with one parameter and the second set to null.
  • The Strongly Typed Model Class is known up front (for example, the View is known up front and an associated View Model is needed). In this case, the method can be used with two parameters.