creating existing component and slingmodel with different name | Community
Skip to main content
Level 3
February 28, 2025
Solved

creating existing component and slingmodel with different name

  • February 28, 2025
  • 4 replies
  • 764 views

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

Best answer by konstantyn_diachenko

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.

4 replies

konstantyn_diachenko
Community Advisor
Community Advisor
February 28, 2025

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.

Kostiantyn Diachenko, Community Advisor, Certified Senior AEM Developer, creator of free AEM VLT Tool, maintainer of AEM Tools plugin.
Level 3
February 28, 2025

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
konstantyn_diachenko
Community Advisor
konstantyn_diachenkoCommunity AdvisorAccepted solution
Community Advisor
March 3, 2025

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.
SreenivasBr
Level 4
March 2, 2025

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

 

giuseppebaglio
Level 10
March 3, 2025

Refer to this guide: Delegation Pattern for Sling ModelsThe 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.

 

kautuk_sahni
Community Manager
Community Manager
March 5, 2025

@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!

Kautuk Sahni