teaserDelegate resource returning null | Community
Skip to main content
New Participant
January 25, 2022
Solved

teaserDelegate resource returning null

  • January 25, 2022
  • 1 reply
  • 1608 views

 

I have defined teaserDelegate on list component node

-- sling:resourceSuperType="core/wcm/components/list/v2/list"

 --   teaserDelegate="core/wcm/components/teaser/v1/teaser"

 

My page in the list item has teaser image, however when I call item

${item.teaserResource} there is no resource, it is coming as null. How do we configure list component to use teaserDelegate? Is there any step I am missing?

 

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by lukasz-m

So if I good understand, you would like to get data from teaser that is located on different page. In that case you will probably need some custom component/solution, teaser delegate will show page metadata as teaser but it will not look for the teaser component on that page.

1 reply

lukasz-m
New Participant
January 25, 2022

Hi @mohammedsahmed, to use teaserDelegate list feature you need to use v3 of list component and v2 of teaser.

<my-list
    jcr:primaryType="cq:Component"
    componentGroup="My Group"
    cq:isContainer="{Boolean}false"
    jcr:title="My List Component"
    sling:resourceSuperType="core/wcm/components/list/v3/list"
    teaserDelegate="core/wcm/components/teaser/v2/teaser"/>

If your component is configured correctly you will see additional option that will allow to display list items as teaser.

I am not sure which version of Core Compnents you are using but I would suggest to use the latest one. You can observe that v2 of list component is using following ListItem implementation https://github.com/adobe/aem-core-wcm-components/blob/development/bundles/core/src/main/java/com/adobe/cq/wcm/core/components/internal/models/v1/PageListItemImpl.java - which is not providing any implementation of getTeaserResource() method so default value - null is returned.

You can also check ListItem implementation used by v3 list https://github.com/adobe/aem-core-wcm-components/blob/development/bundles/core/src/main/java/com/adobe/cq/wcm/core/components/internal/models/v2/PageListItemImpl.java - as you can see this version contains getTeaserResource() method fully implemented.

New Participant
January 25, 2022

Thank you @lukasz-m

I do see the option now. I am more interested in the image path on the teaser item. I am getting the resource now with the path --/content/mysite/mypage1/jcr:content however my teaser is at -- /content/mysite/mypage1/jcr:content/root/container/container/teaser

Is there any OOTB api we can use to get this path or we have to write some additional class to get the resource and appropriate field.

 

 

lukasz-m
lukasz-mAccepted solution
New Participant
January 26, 2022

So if I good understand, you would like to get data from teaser that is located on different page. In that case you will probably need some custom component/solution, teaser delegate will show page metadata as teaser but it will not look for the teaser component on that page.