Is it possible to extend core aem models or extending core models restricted to core aem project ? | Community
Skip to main content
sreenu539
New Participant
July 1, 2022
Solved

Is it possible to extend core aem models or extending core models restricted to core aem project ?

  • July 1, 2022
  • 1 reply
  • 771 views
public class ListImpl extends com.adobe.cq.wcm.core.components.internal.models.v1.ListImpl implements List

 

Is it possible to do same in a client aem project or extending core models restricted to core aem project ?

 

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 lukasz-m

Hi @sreenu539,

All models located under internal package are not exported by core components bundles. This means you cannot use them directly, this is done by design.

The proper way to extend Core Components model is to use delegation pattern. Here you can find some information with examples:

@Model(adaptables = SlingHttpServletRequest.class, adapters = List.class, resourceType = "myproject/components/list") public class ListImpl implements List { @Self @Via(type = ResourceSuperType.class) private List list; /** * using original implementation */ @Override public String getDateFormatString() { // place for custom implementation that will be different comparing to orignal one } /** * using original implementation */ @Override public boolean linkItems() { // simply run method from Core Components List implementation return list.linkItems(); } // place for other methods from List interface }

1 reply

lukasz-m
lukasz-mAccepted solution
New Participant
July 1, 2022

Hi @sreenu539,

All models located under internal package are not exported by core components bundles. This means you cannot use them directly, this is done by design.

The proper way to extend Core Components model is to use delegation pattern. Here you can find some information with examples:

@Model(adaptables = SlingHttpServletRequest.class, adapters = List.class, resourceType = "myproject/components/list") public class ListImpl implements List { @Self @Via(type = ResourceSuperType.class) private List list; /** * using original implementation */ @Override public String getDateFormatString() { // place for custom implementation that will be different comparing to orignal one } /** * using original implementation */ @Override public boolean linkItems() { // simply run method from Core Components List implementation return list.linkItems(); } // place for other methods from List interface }