swati
swati

Reputation: 1

accessing nodes of NodeIterator through sightly

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 html file I want to check hasNext() condition

Upvotes: 0

Views: 500

Answers (1)

Sujith Patil
Sujith Patil

Reputation: 50

As far as I think , hasNext() condition is used to check whether the next element exists or not (This condition is used to iterate all the elements).In sightly if you use data-sly-list tag , there is no need to check as it iterates only through the existing elements.Hope this helps.

Upvotes: 1

Related Questions