Why is this sightly script not working? | Community
Skip to main content
November 21, 2023
Solved

Why is this sightly script not working?

  • November 21, 2023
  • 2 replies
  • 957 views

Hi, the model classes in my below mentioned sightly script are not loading. What is wrong with it?

<sly data-sly-use.model="com.cbdt.core.models.AddToCart class="aem-add-to-cart-wrapper standalone-add-to-cart">
<sly data-sly-use.info="com.cbdt.core.models.ConfigModel">
<a class="aem-add-to-cart" href="/search/${model.skuList @ join=' OR '}" target="_blank">
<img alt="add-to-cart" src="${info.iconPath}/add-to-cart.svg"/>${properties.buttonlabel}
</a>
</sly>
</sly>

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by aanchal-sikka

Hello @goyalkritika 

 

You would first need to confirm following:

  • Sling Model is deployed and recognized
    • Go to the bundle and verify that Sling Model is available

 

  • The interface is exported from bundle. In your case, "com.cbdt.core.models" should be exported. Example:

 

If the package isn't exported, create a package-info.java in corresponding directory of the core bundle. Example:

https://github.com/adobe/aem-guides-wknd/blob/main/core/src/main/java/com/adobe/aem/guides/wknd/core/models/package-info.java

 

2 replies

aanchal-sikka
Community Advisor
aanchal-sikkaCommunity AdvisorAccepted solution
Community Advisor
November 21, 2023

Hello @goyalkritika 

 

You would first need to confirm following:

  • Sling Model is deployed and recognized
    • Go to the bundle and verify that Sling Model is available

 

  • The interface is exported from bundle. In your case, "com.cbdt.core.models" should be exported. Example:

 

If the package isn't exported, create a package-info.java in corresponding directory of the core bundle. Example:

https://github.com/adobe/aem-guides-wknd/blob/main/core/src/main/java/com/adobe/aem/guides/wknd/core/models/package-info.java

 

Aanchal Sikka
November 21, 2023

The interface is exported from the bundle.

Also, model classes are present.

A_H_M_Imrul
Community Advisor
Community Advisor
November 21, 2023

@goyalkritika 

What error are you getting?

I see two sling models are there in the sightly snippet you provided. Make sure the dependencies (if any) injected in the model classed are resolved properly. Since its getting registered properly I assume annotations references from correct package. 

To troubleshoot that, you can disable them by commenting out and pass static/hardcoded data (just to see the life cycle execution end to end).

Please let me know you findings.