Expand my Community achievements bar.

SOLVED

creating existing component and slingmodel with different name

Avatar

Level 3

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

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

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



Check out AEM VLT Intellij plugin


View solution in original post

6 Replies

Avatar

Community Advisor

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



Check out AEM VLT Intellij plugin


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

Avatar

Correct answer by
Community Advisor

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



Check out AEM VLT Intellij plugin


Avatar

Level 5

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/understan...

 

Avatar

Level 9

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.

 

Avatar

Administrator

@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