2

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.

  1. Summary page displays dynamic component presentations, which are retrieved by using getEntityModel method of DXA DefaultContentProvider.

  2. 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:

EntityModeData values

As it can beeb seen, linkUrl is also empty.

4
  • Can you provide the DXA R2 Data Model as retrieved from the DXA Model Service for both scenarios? In particular: I’m interested in the presence of an EntityModelData.LinkUrl property; this property is used to map Component Links, including the _self mapping. Jun 22, 2020 at 18:12
  • I have added screenshot with data from the DXAModel Service, LInkUrl is also empty here. Aug 31, 2021 at 8:44
  • Wow, some delayed feedback! :-) So, if I understand correctly, the linkUrl (and url 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 a getEntityModel call? Sep 1, 2021 at 10:52
  • well, the issue became irrelevant due to implementation changes. However, for some other project it is once again relevant - hence the delay in the response :) To answer your question, I have not tested with the page context but it is definitely the case with the DCPs (using indeed getEntityModel. Sep 1, 2021 at 11:25

1 Answer 1

1

IIRC, the DXA Model Service/Extension only sets EntityModelData.linkUrl for linked Components (nested Entity Models). However, when this property is not set, the DXA Web Application Framework should use the CD link resolving API to resolve the link.

If I look at the DXA.NET implementation (which I'm most familiar with), I see it checks if EntityModelData.LinkUrl is null to determine whether the property is set by the DXA Model Service/Extension or not. However, looking at your screenshot, it seems it returns an empty string instead of null.

2
  • Thanks for your answer. In other words, it is a bug in DXA Framework, isn't it? Sep 1, 2021 at 14:23
  • 1
    Yeah, or in DXA Model Service/Extension. At least, there seems to be a mismatch between the two. Sep 1, 2021 at 15:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.