Deligate design pattern | Community
Skip to main content
New Participant
January 24, 2024
Solved

Deligate design pattern

  • January 24, 2024
  • 2 replies
  • 769 views

For our requirement, I am creating a class called ListDelegate and implementing the List component interface. because i want to add extra functionlity sortBy ranking  (which i added in page properties) ,like sortBy asc and desc present in list, how to solve this thing or any other solution?

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 Mahesh_Gunaje

Hi @knki 

 

These links might help you. check the solutions given by @veenavikraman 

You are utilizing the Out of the box core component feature. Plus you are adding your own customization by utilizing the Sling delegation pattern.

 

https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/delegation-pattern-for-sling-models-doesn-t-populate-all-the/m-p/435498

 

https://github.com/adobe/aem-core-wcm-components/wiki/Delegation-Pattern-for-Sling-Models

 

2 replies

VeenaVikraman
New Participant
January 24, 2024

@knki Check this https://github.com/adobe/aem-core-wcm-components/wiki/Delegation-Pattern-for-Sling-Models .also read https://medium.com/@veena.vikraman19/aem-avoiding-delegation-pattern-pitfalls-with-core-components-973c93a59fc7 

 

If you are using everything from List https://github.com/adobe/aem-core-wcm-components/blob/main/bundles/core/src/main/java/com/adobe/cq/wcm/core/components/models/List.java as is , you can just add @delegate annotation.

 

But I assume you are going to add one more option for sorting . That means you will need to override https://github.com/adobe/aem-core-wcm-components/blob/main/bundles/core/src/main/java/com/adobe/cq/wcm/core/components/internal/models/v4/ListImpl.java the `getListItems` to modify the logic of `getStaticListItems` method to add the sorting mechanism. 

 

Mahesh_GunajeAccepted solution
New Participant
January 24, 2024

Hi @knki 

 

These links might help you. check the solutions given by @veenavikraman 

You are utilizing the Out of the box core component feature. Plus you are adding your own customization by utilizing the Sling delegation pattern.

 

https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/delegation-pattern-for-sling-models-doesn-t-populate-all-the/m-p/435498

 

https://github.com/adobe/aem-core-wcm-components/wiki/Delegation-Pattern-for-Sling-Models