Hi,
Is there any way to check NodeIterator hasNext() condition in sightly.
For instance:
Resource resource = resolver.getResource("/etc/xyz"); Node node = resource .adaptTo(Node.class); NodeIterator iterator = node .getNodes(); while (iterator.hasNext()) { Node child = iterator.nextNode(); }
Here I am getting NodeIterator from sightly helper class.Now in sightly html file I want to check hasNext() condition
Solved! Go to Solution.
Views
Replies
Total Likes
Hi,
In sightly file you cannot use java code like you are trying as they are .html files. You can do one thing, put all data in array then you can iterate the array in sightly file .
Here one sample @ https://helpx.adobe.com/experience-manager/using/domparser.html
Views
Replies
Total Likes
Hi,
In sightly file you cannot use java code like you are trying as they are .html files. You can do one thing, put all data in array then you can iterate the array in sightly file .
Here one sample @ https://helpx.adobe.com/experience-manager/using/domparser.html
Views
Replies
Total Likes
did you try using 'data-sly-list' ??
Views
Replies
Total Likes
Hi,
@edubey- I am placing my java code in sightly helper java class not in html files.
@bsloki- I worked with "data-sly-list" to iterate over the list of data.
But here I am trying to achieve "while condition' check through sightly syntax.
As we have couple of sightly blocking statements for if condition check(data-sly-test), etc.Similarly is there any way to check while condition.
Thanks,
swati
Views
Replies
Total Likes
This might help:
<sly data-sly-list="${resource.listChildren}">
<div data-sly-test="${item}"> <!-- this is something similar to hasNext() -->
<!-- ONLY if there are items -->
</div>
</sly>
Good Luck...
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies