Open chintan97 opened 2 years ago
@chintan97 , unless your container component has a super type of one of the panel containers (accordion, carousel, tabs), this won't work as the super-type delegate will not resolve to an implementation.
As you noted in your edit, the LayoutContainer can be used when using sling:resourceSuperType="core/wcm/components/container/v1/container"
and you can get the children through getExportedItems
.
See https://aemcomponents.dev/content/core-components-examples/library/container/container.html for example:
What is the reason for not being able to customize the container object itself? Because it is re-used in panel components?
Our use case would be to customize the container component in order to force a specific rendition when using the background image, as right now, it pulls the raw source, which can be large.
Bug Report
Current Behavior A custom container component extends container component by extending Java logic using Sling model delegation pattern. I created ContainerModel interface that extends Container interface from com.adobe.cq.wcm.core.components.models and implementing ContainerModel in ContainerModelImpl.class. I am using Model and Exporter annotations for exporting json through model.json.
My RESOURCE_TYPE is set to 'mysite/components/container'. I am delegating Container as below.
Upon using delegate.getId() or any other methods to delegate to Container component, it ends up with NullPointerException after warning as below.
Expected behavior/code In the above example delegate.getId() and other delegated methods should deliver data.
Environment
EDIT There is a way to get it implemented through LayoutContainer. However, that option does not return child data in model.json. For reproducing the issue, add text component underneath container component and check model.json output with custom sling model implemented through LayoutContainer and without any custom sling model. The one without custom sling model returns all child json data as well in model.json and that data is populated when custom sling model is used even with delegating methods.