You must allow the mapping of your custom content type to the page type. To do
this, implement the
InfoDisplayContributor
interface. Follow the steps below to complete this for the custom User content
type.
-
Inside your custom model project, create a new Java package and add a class named
UserInfoDisplayContributor
. -
Implement the
InfoDisplayContributor
interface and pass theUser
model as the type parameter. Then add the@Component
annotation:@Component(immediate = true, service = InfoDisplayContributor.class) public class UserInfoDisplayContributor implements InfoDisplayContributor<User> { }
The
@Component
annotation registers the class as an info display contributor in the OSGi service registry. Set theservice
property to the interface you’re implementing. -
Implement the methods. For the example User content type, three methods are crucial to mapping its model to the Display Page Template framework:
@Override public String getClassName() { return User.class.getName(); } @Override public String getInfoURLSeparator() { return "/user/"; } @Override public String getLabel(Locale locale) { return "Users"; }
- The class name is used to link the Display Page Template to the User model.
- The URL separator is used to generate friendly URLs for the Display Page Template.
- The label is the display name for the new content type.
Figure 1: After creating the `*InfoDisplayContributor` class, you can create Display Page Templates and map them to your custom model.
Great! You’ve mapped your custom content type to the Display Page Template framework. Next, you’ll provide your content type’s fields.