We have a Download
entity which extends MediaItem
. The download link is used inside RichText
component.
This is how the class looks like:
@Data
public class Download extends MediaItem {
@Override
public HtmlElement toHtmlElement(String s) {
return null;
}
@Override
public HtmlElement toHtmlElement(String s, double v, String s1, int i) {
return null;
}
@Override
public HtmlElement toHtmlElement(String s, double v, String s1, int i, String s2) {
return null;
}
@Override
public MvcData getDefaultMvcData() {
return MvcDataCreator.creator()
.fromQualifiedName("basis:Entity:DownloadLink")
.defaults(DefaultsMvcData.ENTITY)
.create();
}
}
We also have have a RichText component wrapper component with RichText as part of its variable. My questions are:
- Why do I need to declare my view inside
getDefaultMvcData()
? I see thatYoutubeVideo
fromdxa-core:2.0.3
entity also use the same structure. Other entity registrations are done in module initializer (@RegisteredViewModel
notation), but why does it have to differ for Media Item entities? - What is the purpose of
toHtmlElement()
? In my case it seems not being used at all, as it uses the view registered ingetDefaultMvcData()