Apache Sling loop repeating

ALMOBDE3

New Member
Complete newb to sling and java in general so bare with me. Does anyone know why the code below is outputting 2 of each navigation element.\[code\]//get the full path to the current pageString home = Text.getAbsoluteParent(currentPage.getPath(), 2); int absParent = currentStyle.get("absParent", 1);//checks for invalid and hidden pages.PageFilter filter = new PageFilter(request);//utility class that provides an iterator over navigation elementsNavigation nav = new Navigation(currentPage, absParent, filter, 1);for (Navigation.Element i: nav) { %><li <%= i.hasChildren() %>><a href="http://stackoverflow.com/questions/15736273/<%= i.getPath() %>.html"><%= i.getTitle() %></a> <% break; }\[/code\]But if I add in a switch statement within the for loop it displays 1 of each navigation element like it should.\[code\]for (Navigation.Element i: nav) { switch (i.getType()) { case ITEM_BEGIN: %><li <%= i.hasChildren() %>><a href="http://stackoverflow.com/questions/15736273/<%= i.getPath() %>.html"><%= i.getTitle() %></a><% break; } }\[/code\]This is driving me crazy, any help is greatly appreciated! Thanks!
 
Back
Top