I have two different view model for the same schema, one view is to display a Summary page and other view is meant for a Details page.
Summary page displays dynamic component presentations, which are retrieved by using
getEntityModel
method of DXA DefaultContentProvider.Detail page displays a regular static component presentation.
On Summary page, I want to display a (resolved) link to a detail page for every Component presentation, to achieve this I've added a field 'url' with annotation _self as described on SDL docs.
My Entity view model is defined as follows:
public class MyArticle extends AbstractEntityModel {
private String titel;
private RichTekst intro;
private Date date;
@SemanticProperty("_self")
private String url;
}
My both views are displayed as expected, except I encounter a following issue:
On my Summary view, url
field is empty as component link is not resolved/populated in my entity model (I can verify this in a debug mode). Other fields of the DCP do get populated and displayed as expected.
Whereas Details view with static component presentation can display url
with resolved link(but obviously I don't need a resolved link here as I'm already on this page).
It seems like semantic property _self is not being recognized for the dynamic component presentations.
Or am I missing anything? any thoughts?
Update:
Below is EntityModelData
values retrieved from the DXA Model Service:
As it can beeb seen, linkUrl is also empty.
EntityModelData.LinkUrl
property; this property is used to map Component Links, including the_self
mapping.linkUrl
(andurl
property on your View Model) is properly set when reading a CP in context of a Page, but not when reading a DCP separately using agetEntityModel
call?getEntityModel
.