Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Adobe Summit 2023 [19th to 23rd March, Las Vegas and Virtual] | Complete AEM Session & Lab list
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
Level 5

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

6 Replies

Avatar

Level 5

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 ! 

Avatar

Level 4

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

Avatar

Level 5

In place of cmp.exPath :

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

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
Level 5

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

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.