6

We have a Page with Component A (a container Component) associated with a static template which has another Component B as a Linked Component field. In the associated model for B, I have created a field to serve URL like:

@SemanticProperty("_self")
private String url; 

URL field is always empty, even if the Page containing parent Component A is published. There is a dynamic Component Template present for the Component B. Here is the diagram of page AB where B is present as a linked component:

enter image description here

I am mapping model for page CD where B is also present which has the url field with empty value:

enter image description here

Can anyone suggest if I am missing anything?

  • is B also attached to some page? – Raj Kumar Apr 19 '17 at 10:51
  • @Raj, I have updated my question with information. – Mukesh Kumar Apr 19 '17 at 11:01
  • Can you edit your question and explain some more detail about the actual Schemad and models for the Components C, D and B? – Bart Koopman Apr 19 '17 at 12:05
  • Mukesh, your link property is set to _self. This means that this link will be resolved as a link of the component itself (not as a link to the component you are linking to). What happens if you change "_self" to the actual schema field name of the componentlink field ? – Harald Hoffelinck Apr 19 '17 at 12:22
  • Harald, in main model A it is added as actual schema field name as a type of view model of B and in view model url is defind with "_self" semantic property. – Mukesh Kumar Apr 19 '17 at 13:14
3

Despite your pictures, the structure of your View Models (and how they map to Components in CM) is not quite clear to me. For example: what does "Component as embedded field" mean? Do you mean you have an embedded View Model mapped to an embedded field?

Regardless, it seems to me you want to get a link to Component B resolved. DXA link resolving will resolve a Component link to a URL of a published Page which contains a Component Presentation for the linked Component.

In your description, I don't see that you have such a Page, which could explain why the link does not resolve.

In case Component B is a Multimedia Component, you may want to resolve a link to its published Binary content instead. In that case, you should make the property of type MediaItem (or a subclass).

  • Hi Rick, this sounds a answer for my question. I was also suspecting that without a direct component presentation with the component it can't be resolved. – Mukesh Kumar Apr 20 '17 at 6:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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