Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Experience Fragment Path - org.apache.sling.api.request.RecursionTooDeepException error

Avatar

Level 4

Actually, I am not able to show the Experience Fragment through HTL from the Node Properties. When I include the below HTL in the HTML file, I am getting this error "org.apache.sling.api.request.RecursionTooDeepException:"

 

<div data-sly-test="${item.innerBannerType == 'with-badges'}" class="badge-wrapper position-relative">
<sly data-sly-resource="${item.fragmentPath}"></sly>
</div>

 

But when I hard code the path like below, it's working

<sly data-sly-resource="${@path='/content/experience-fragments/we-retail/equipment/master', selectors='content', wcmmode='disabled'}"></sly>

 

Looking for a solution. Please help!

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @Ameen_Dev ,

Use this line of code :

<sly data-sly-resource="${@path=item.fragmentPath, selectors='content', wcmmode='disabled'}"></sly>

In place of below line of code in your sightly:

<sly data-sly-resource="${item.fragmentPath}"></sly>

Final sightly code should be like :

<div data-sly-test ="${item.innerBannerType == 'with-badges'}" class ="badge-wrapper position-relative">
<sly data-sly-resource="${@path=item.fragmentPath, selectors='content', wcmmode='disabled'}"></sly>
</div>

Please remove below line of code :

<sly data-sly-use.cmp="com.mysite.models.component.MyCustomComponent"></sly>

I think you have used the above section as well but MyCustomComponent Model class is not available in your codebase.

Instead of MyCustomComponent, you are using a different model class to get path that are stored in item and you are fetching as ${item.fragmentPath}.

Shiv Prakash

View solution in original post

6 Replies

Avatar

Community Advisor

Hi @Ameen_Dev ,

Can you try as below :

<sly data-sly-use.cmp="com.mysite.models.component.MyCustomComponent"></sly>
<sly data-sly-resource="${@path=cmp.exPath, selectors='content', wcmmode='disabled'}"></sly>

https://sourcedcode.com/blog/aem/dynamically-include-an-experience-fragment-in-sightly 

Hope this could help you.

Regards ! 

Shiv Prakash

Avatar

Level 4

Where would I give this node property -> ${item.fragmentPath} in the above code?

Avatar

Community Advisor

In place of cmp.exPath :

<sly data-sly-resource="${@path=item.fragmentPath, selectors='content', wcmmode='disabled'}"></sly>
Shiv Prakash

Avatar

Level 4

@Shiv_Prakash_Patel 

It's not working. getting a different error.

"com.mysite.models.component.MyCustomComponent cannot be correctly instantiated by the Use API"

 

Any other way to solve this issue?

Avatar

Correct answer by
Community Advisor

Hi @Ameen_Dev ,

Use this line of code :

<sly data-sly-resource="${@path=item.fragmentPath, selectors='content', wcmmode='disabled'}"></sly>

In place of below line of code in your sightly:

<sly data-sly-resource="${item.fragmentPath}"></sly>

Final sightly code should be like :

<div data-sly-test ="${item.innerBannerType == 'with-badges'}" class ="badge-wrapper position-relative">
<sly data-sly-resource="${@path=item.fragmentPath, selectors='content', wcmmode='disabled'}"></sly>
</div>

Please remove below line of code :

<sly data-sly-use.cmp="com.mysite.models.component.MyCustomComponent"></sly>

I think you have used the above section as well but MyCustomComponent Model class is not available in your codebase.

Instead of MyCustomComponent, you are using a different model class to get path that are stored in item and you are fetching as ${item.fragmentPath}.

Shiv Prakash

Avatar

Level 4

Yeah, you're right. I was using the entire code. By the way, MyCustomComponent doesn't exist that's the reason I was getting that error.