Hi @gautamg99016783
In order to achieve required changes, you will have to implement the existing Adobe WCM list Model Interface in your own List model. Follow these steps:
- If you look at the core component list.html file, it uses the Adobe List Model
<ul data-sly-list.item="${list.items}"
data-sly-use.list="com.adobe.cq.wcm.core.components.models.List"
data-sly-use.template="core/wcm/components/commons/v1/templates.html"
data-sly-use.itemTemplate="item.html">
<li data-sly-call="${itemTemplate.item @ list = list, item = item}"></li>
</ul>
<sly data-sly-call="${template.placeholder @ isEmpty=list.items.size == 0}"></sly>
Here, com.adobe.cq.wcm.core.components.models.List is an Interface, you do not need to overlay this file as we will provide our own implementation of List.java interface
- In your code base, add dependency to core components in pom.xml
<dependency>
<artifactId>core.wcm.components.core</artifactId>
<version>2.2.0</version>
<groupId>com.adobe.cq</groupId>
<scope>provided</scope>
</dependency>
Make sure to change version as per your running AEM instance
- Create your new model Class which implements com.adobe.cq.wcm.core.components.models.List
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.models.annotations.Model;
import com.adobe.cq.wcm.core.components.models.List;
@Model(adaptables = SlingHttpServletRequest.class, adapters = List.class,
resourceType = "my-project/components/content/my-list")
public class MyList implements List{
//Give your own implementations of the methods
}
The resourceType here must be the resourceType of your list component
- We can not change/use/extend List implemetation of adobe as it is not exported by Core components bundle but since it is open source, we can create our own implementation.
https://github.com/adobe/aem-core-wcm-components/blob/master/bundles/core/src/main/java/com/adobe/cq... is the WCM core components internal implementation. You can copy everything and make changes. Make sure to use implementation as per core components version. This one is for v1. - Deploy and test if your own list implementaion is getting picked up.
Try out and let me know.
Thanks,
Nupur