Expand my Community achievements bar.

SOLVED

Why is this sightly script not working?

Avatar

Level 5

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>

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

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

 

aanchalsikka_0-1700552739091.png

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

aanchalsikka_1-1700552835656.png

 

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

 


Aanchal Sikka

View solution in original post

3 Replies

Avatar

Correct answer by
Community Advisor

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

 

aanchalsikka_0-1700552739091.png

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

aanchalsikka_1-1700552835656.png

 

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

 


Aanchal Sikka

Avatar

Level 5

The interface is exported from the bundle.

Also, model classes are present.

Avatar

Community Advisor

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