Extend AEM OOTB Core List Sling Model to add an extra field through dialog
Hi All,
I have a requirement where I have to extend List core component dialog & sling model to add one extra filed to be added along with other 3 fields available under OOTB core list component. I have added a text field under "Fixed List" section along with other 3 existing fields. Last field in the below screenshot -

These highlighted fields in yellow, I need to get them added within the list result beings provided by OOTB list sling model. I tried to achieve the same by Sling Delegation Pattern but unable to get it working. I created a class "PageListImpl" implementing the List class & tried to override Collection<ListItem> getListItems(). Since I just needed to add an extra fields within the existing list item, I didn't intend to rewrite everything again but rely on the core List implementation. I planned to create an implementation of ListItem class (class PageListItemImpl implements ListItem), add the extra required field being passed through dialog. Prepare a list of this custom PageListItemImpl and return it back from the PageListImpl class. But I am seeing errors while trying to return this list from the overriden function.
This is how my PageListImpl looks like -
@Model(adaptables = SlingHttpServletRequest.class, adapters = List.class, resourceType = "test/components/core/list",
defaultInjectionStrategy = DefaultInjectionStrategy.OPTIONAL)
public class PageListImpl implements List {
static final Logger LOG = LoggerFactory.getLogger(PageListImpl.class);
@Self
@Via(type = ResourceSuperType.class)
@Delegate(excludes = DelegationExclusion.class)
private List listModel;
@Getter
@ChildResource(name = "static")@Via("resource")
private java.util.List<StaticList> staticList;
private interface DelegationExclusion {
Collection<ListItem> getListItems();
}
private java.util.List<PageListItemImpl> pageListItemList = new ArrayList<>();
private Map<String, String> map = new HashMap<>();
@Override
public @NotNull
Collection<ListItem> getListItems() {
for(StaticList str : staticList){
if(str != null){
map.put(str.getLinkURL(), str.getProductTracking());
}
}
for(ListItem item : listModel.getListItems()){
PageListItemImpl pageListItem = new PageListItemImpl();
pageListItem.setLink(item.getLink());
pageListItem.setDescription(item.getDescription());
pageListItem.setPath(item.getPath());
pageListItem.setName(item.getName());
pageListItem.setTeaserResource(item.getTeaserResource());
pageListItem.setTitle(item.getTitle());
pageListItem.setData(item.getData());
pageListItem.setId(item.getId());
pageListItem.setURL(item.getDescription());
pageListItem.setProductTracking(map.get(item.getPath()));
pageListItemList.add(pageListItem);
}
if(pageListItemList != null && pageListItemList.size() > 0){
//return pageListItemList;
}
return listModel.getListItems();
}
}
Any pointers would be highly appreciated. Thank you.
@kautuk_sahni @arunpatidar @kiran51 @lukasz-m @briankasingli @tushaarsr