Expand my Community achievements bar.

SOLVED

Extending Content Fragment List Component with a Custom Sling Model

Avatar

Level 4

I'm trying to figure out if if I can use a custom Sling Model to extend the Content Fragment List component to inject additional tags into the component properties without essentially recreating the entire structure. I have done this with lists to create what we refer to as a Smart List component by creating my own query and building the list. The structure of the Content Fragments is a bit more complex than a list, however, and I'm not as adept at building that. I've been able to rebuild the query pulling from the Java in core from com.adobe.cq.wcm.core.components.internal.models.v1.contentfragment.ContentFragmentList however everything blows up with DAMContentFragmentImpl. When I try to import com.adobe.cq.wcm.core.components.internal.models.v1.contentfragment.DAMContentFragmentImpl, my core bundle compiles but won't activate. 

 

jetate_0-1641596629651.png

 

All I'm essentially trying to do is pull tags from a page property and add them into the tags array for the component properties to generate a Content Fragment List. 

jetate_1-1641596756639.png

 

I've used custom sling models to extend other components to modify the titles being output in lists or breadcrumbs but this is more trying to enhance the current function rather than fully overriding it with a new option. I don't know if this is possible, but maybe someone with more experience with Java can understand what I'm trying to do and if it's possible.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

We can minimize the code while extending WCM core components via delegation. The following link explains it with example.

https://www.initialyze.com/insights/spice-up-your-sling-models-with-lombok

 

Despite this, if we are trying to use any internal classes from WCM core components, then we might need to copy them over.

 

In general, the delegation will help copying over a lot of code.


Aanchal Sikka

View solution in original post

1 Reply

Avatar

Correct answer by
Community Advisor

We can minimize the code while extending WCM core components via delegation. The following link explains it with example.

https://www.initialyze.com/insights/spice-up-your-sling-models-with-lombok

 

Despite this, if we are trying to use any internal classes from WCM core components, then we might need to copy them over.

 

In general, the delegation will help copying over a lot of code.


Aanchal Sikka