Skip to main content
Level 3
Feb 28, 2025 8:15 PM UTC
Solved

creating existing component and slingmodel with different name

Hi Team,

We're currently using a Sling Model for an existing component and are attempting to create an identical component under a different name. Although the JSON data from the Sling Model is being printed(tried with add extra log) correctly according to the code logic, accessing the JSON data through the URL jcr:content/root/container/container/container_copy_copy_/column1_copy/container_2045280733/component-name.list.json results in a 400 Bad Request error. Could you please advise on how to resolve this issue?

 

Thanks

konstantyn_diachenko
konstantyn_diachenkoAccepted solution
Community Advisor
Mar 3, 2025 4:56 PM UTC

Please provide components definitions (node with jcr:primaryType="cq:Component") as well.

 

Why do you request "JSON data" (Sling Exporter of Sling Model) with list selector? Usually a "model" is used. Try jcr:content/root/container/container/container_copy_copy_/column1_copy/container_2045280733/component-name.model.json.

Kostiantyn Diachenko, Community Advisor, Certified Senior AEM Developer, creator of free AEM VLT Tool, maintainer of AEM Tools plugin.

6 replies

konstantyn_diachenko
Community Advisor
Community Advisor
Feb 28, 2025 9:43 PM UTC

Hi @neo-silicon ,

 

Could you please provide more details like Sling Models mapping (definition), 2 components definitions? It will have to identify a problem.

 

However, I would assume that your new component doesn't have sling:resourceSuperType to old component. Why do you request "JSON data" (Sling Exporter of Sling Model) with list selector? Usually a "model" is used. Try jcr:content/root/container/container/container_copy_copy_/column1_copy/container_2045280733/component-name.model.json.

 

Best regards,

Kostiantyn Diachenko.

Translate
Kostiantyn Diachenko, Community Advisor, Certified Senior AEM Developer, creator of free AEM VLT Tool, maintainer of AEM Tools plugin.
Level 3
Feb 28, 2025 10:02 PM UTC

Hi ,

new component calling new sling model: data-sly-use.cardList="com.abc.core.models.new.component.BList"

Old component calling Old sling model: : data-sly-use.cardList="com.abc.core.models.old.component.List"

 

@Model(
        adaptables = Resource.class,
        defaultInjectionStrategy = OPTIONAL,
        resourceType = {"abc/components/new/list"})
 
 
 
@Model(
        adaptables = Resource.class,
        defaultInjectionStrategy = OPTIONAL,
        resourceType = {"abc/components/old/list"})
 
Thanks
Translate
konstantyn_diachenko
Community Advisor
konstantyn_diachenkoCommunity AdvisorAccepted solution
Community Advisor
Mar 3, 2025 4:56 PM UTC

Please provide components definitions (node with jcr:primaryType="cq:Component") as well.

 

Why do you request "JSON data" (Sling Exporter of Sling Model) with list selector? Usually a "model" is used. Try jcr:content/root/container/container/container_copy_copy_/column1_copy/container_2045280733/component-name.model.json.

Translate
Kostiantyn Diachenko, Community Advisor, Certified Senior AEM Developer, creator of free AEM VLT Tool, maintainer of AEM Tools plugin.
SreenivasBr
Level 4
Mar 2, 2025 9:26 PM UTC

For exporting the sling model json, the path should be <resourcepath>.model.json

 

Refer - https://experienceleague.adobe.com/en/docs/experience-manager-learn/foundation/development/understand-sling-model-exporter

 

Translate
giuseppebaglio
Level 10
Mar 3, 2025 11:17 AM UTC

Refer to this guide: Delegation Pattern for Sling Models. The use case for the Title component in this guide closely resembles your own.

Pay particular attention to the sling:resourceSuperType directive in the XML definition of the component, as well as the adapter directive in the Sling Model definition.

 

Translate
kautuk_sahni
Level 9
Mar 5, 2025 8:24 AM UTC

@neo-silicon Did you find the suggestions helpful? Please let us know if you need more information. If a response worked, kindly mark it as correct for posterity; alternatively, if you found a solution yourself, we’d appreciate it if you could share it with the community. Thank you!

Translate
Kautuk Sahni