Override data-sly-use java class | Community
Skip to main content
Level 2
October 9, 2023

Override data-sly-use java class

  • October 9, 2023
  • 2 replies
  • 916 views

Hello! Can I override the data-sly-use attribute in the parent resourceSuperType with a new class? as of now I can't override it with the new java class

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

2 replies

A_H_M_Imrul
Community Advisor
Community Advisor
October 9, 2023

@aemstarternewbie 

Though I am not 100% sure what do you mean by Overriding data-sly-use java class, but I think you are trying to override the class that is invoked using data-sly-use. To achieve that you can simply overlay the markup where the data-sly-use is placed and in the new markup you can put your own implementation.

Similar scenario: https://stackoverflow.com/questions/28571842/display-different-markup-in-sightly-based-on-a-sling-selector

Kamal_Kishor
Community Advisor
Community Advisor
January 9, 2024

Hi @aemstarternewbie :

Please refer- https://experienceleague.adobe.com/docs/experience-manager-core-components/using/developing/customizing.html?lang=en#customizing-the-logic-of-a-core-component
Here it is clearly mentioned how in a custom/extended component, behavior/method from a parent component is overridden.

 

The Business logic for the core components is implemented in Sling Models. This logic can be extended by using a Sling delegation pattern. For example, the title core component uses the jcr:title property of the requested resource to provide the title text. If no jcr:title property is defined, a fallback to the current page title is implemented. We want to change the behavior so that the title of the current page is always displayed. Because the implementation of the Core Components’ models are private, they must be extended with a delegation pattern.

 

Please let me know if this is what you are trying to do.
Thanks.