Sling Delegation Pattern not working for Breadcrumb Commerce Component | Community
Skip to main content
January 11, 2022
Solved

Sling Delegation Pattern not working for Breadcrumb Commerce Component

  • January 11, 2022
  • 1 reply
  • 1656 views

We had a requirement wherein it was required for us to do the customization of OOTB Breadcrumb CIF component. As OOTB Breadcrumb CIF component internally inherits Breadcrumb Core component, it was using Sling Delegation Pattern for the same. 

But now, when we tried to using the same logic and use Delegation Pattern for our custom breadcrumb component which inherits OOTB Breadcrumb CIF component, it has started to give us a Null object for the same. 

Below are the levels of inheritance we are following:

CustomBreadcrumbImpl <- CIF BreadcrumbImpl <- WCM BreadcrumbImpl

 

Below is the code snippet through which I am trying to access the object.

import com.adobe.cq.commerce.core.components.models.breadcrumb.Breadcrumb;

@Model(adaptables = SlingHttpServletRequest.class, adapters = { Breadcrumb.class,
CustomBreadcrumb.class }, defaultInjectionStrategy = DefaultInjectionStrategy.OPTIONAL, resourceType = "project/components/commerce/breadcrumb")
public class CustomBreadcrumbImpl implements CustomBreadcrumb {

@1961677
@2434638(type = ResourceSuperType.class)
private Breadcrumb customBreadcrumb;

 

Has anyone faced any such issues? Any idea how we can manage these kind of issues where three layers of inheritance is observed? 

Help would be much appreciated. Thanks. 

 

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 Vijayalakshmi_S

Hi @jatin-verma 

Try to use Lombok @Delegate for Sling Model Delegation. Sample usage - https://www.initialyze.com/blog/2020/11/simplify-extending-sling-models-with-lombok/

 

1 reply

Vijayalakshmi_S
Vijayalakshmi_SAccepted solution
Level 10
January 12, 2022

Hi @jatin-verma 

Try to use Lombok @Delegate for Sling Model Delegation. Sample usage - https://www.initialyze.com/blog/2020/11/simplify-extending-sling-models-with-lombok/

 

January 24, 2022

Hi @vijayalakshmi_s , Thank you for your response. I have tried implementing @Delegate for Sling model as mentioned by you but still I am not able to extend CIF Core Breadcrumb Component.

 

import com.adobe.cq.commerce.core.components.models.breadcrumb.Breadcrumb;

 

@Delegate(types = Breadcrumb.class)
@Self@Via(type = ResourceSuperType.class)
private Breadcrumb customBreadcrumb;

 

Please suggest. Thanks!

Vijayalakshmi_S
Level 10
January 24, 2022

@hanish_imandi2 

Could you please let know the issue - is the customBreadcrumb reference is null or you have issue in extending the methods