I am getting below error when add the component in the AEM new page. Kindly suggest the correction, if anyone have the idea for code changes.
ERROR:
Cannot serve request to /content/project/path/test.html in /apps//project/path/webhelp-header/webhelp-header.html
org.apache.sling.scripting.sightly.SightlyException: org.apache.sling.api.SlingException: Cannot get DefaultSlingScript: org.apache.sling.api.SlingException: Cannot get DefaultSlingScript: org.apache.sling.a
My code in html:
Solved! Go to Solution.
Topics help categorize Community content and increase your ability to discover relevant content.
Views
Replies
Total Likes
Hi @MohanasundaramMo
where is the your file named field and have you create a model class for it because what i can see you are using resource.path, in Sightly refers to the absolute path of the current resource within the AEM content repository
If your component is included on a page located at /content/mysite/en/products/myproduct, then resource.path would return /content/mysite/en/products/myproduct
what i would suggest that If the script file (field) is located within the same folder as your component, use a relative path:
data-sly-use.multifield="./field" // "./" refers to the current component's folder
If you're using a Sling Model for the multifield functionality, the attribute should reference the model class path:
data-sly-use.multifield="com.your.package.FieldModel" // Replace with your actual model class path
feel free to reply if you need further clarifications.
Hope this helps!
Views
Replies
Total Likes
Hi @MohanasundaramMo
AEM cannot find the script associated with the data-sly-use.multifield, In your case, it's looking for a script with the identifier /_header/field also i noticed
The data-sly-list attribute should be enclosed in double quotes.
You have nested <sly> tags, which is not necessary in this case. You can simplify it by removing the inner <sly> tag.
Check below blog to see the use case of HTL Java Use-API
https://experienceleague.adobe.com/en/docs/experience-manager-htl/content/java-use-api
Views
Replies
Total Likes
Hi Abhishek,
Thanks for the quick response.
After mode the changes also based on you suggestion still getting same error. i thought "<sly data-sly-use.multifield="${resource.path}/field">" multifield need to change i am not sure how to change that. This same used some components for existing our project but all component not working with this check.
corrected code:
<sly data-sly-use.multifield="${resource.path}/field">
<sly data-sly-list.item="${multifield.listChildren}">
<a class="grayButton" data-sly-element="${!item.enableLink? 'span':'a'}" href="${item.link @Extension='html'}" >${item.button} </a>
</sly>
</sly>
Thanks,
Mohan
Views
Replies
Total Likes
Hi @MohanasundaramMo
where is the your file named field and have you create a model class for it because what i can see you are using resource.path, in Sightly refers to the absolute path of the current resource within the AEM content repository
If your component is included on a page located at /content/mysite/en/products/myproduct, then resource.path would return /content/mysite/en/products/myproduct
what i would suggest that If the script file (field) is located within the same folder as your component, use a relative path:
data-sly-use.multifield="./field" // "./" refers to the current component's folder
If you're using a Sling Model for the multifield functionality, the attribute should reference the model class path:
data-sly-use.multifield="com.your.package.FieldModel" // Replace with your actual model class path
feel free to reply if you need further clarifications.
Hope this helps!
Views
Replies
Total Likes
Thanks for suggestion. after implement new sling model changes works good.
It seems you are just trying to iterate over some composite multifield set in your component. If I have to take a guess your content structure looks something like
componentNode
field
item0
item1
So to get the multifield properties and iterate, you could possibly do something like
<sly data-sly-list.childResource="${resource.children}">
<sly data-sly-test="${childResource.name =='field'}" data-sly-list="${childResource.children}">
<a class="grayButton" data-sly-element="${!item.enableLink? 'span':'a'}" href="${item.link @ extension='html'}" >${item.button} </a>
</sly>
</sly>
Ofcourse this is just sample, you can do it better in a sling model as Abhishek suggested.
Hope this helps
Views
Replies
Total Likes
To retrieve values from multiple fields, we typically use Sling Model. You can refer to the article for step-by-step instructions.
https://ms-29.com/aem/sites/fetch-multifield-values-using-sling-model
Views
Replies
Total Likes