Could you post your jsp code? Particularly the part where you iterate
over the pages to create the menu. There may be a way to determine last
page with the content iterator you are using. Also, what version of
magnolia.
--David
Amir Mistric wrote:
Hi
I have a jsp that creates a menu and in order to do so I need to know if the
page is the last child.
So I wrote a method (see below) and was wondering if there is an alternative,
better way to do this?
Here is my method
public static boolean isLastChild(Content page)
throws AccessDeniedException, PathNotFoundException, RepositoryException {
Content parent = page.getParent();
int parentChildCount = parent.getChildren(ItemType.CONTENT).size();
// page is the only child
if (parentChildCount == 1) {
System.out.println(page.getHandle() + " is the only and the last child
of " + parent.getHandle());
return true;
}
Iterator i = parent.getChildren(ItemType.CONTENT).iterator();
int count = 1;
while (i.hasNext()) {
Content c = (Content) i.next();
if (count == parentChildCount && c.getUUID().equals(page.getUUID())
) {
System.out.println(page.getHandle() + " is the last child of "
+ parent.getHandle());
return true;
}
count++;
}
return false;
} //end isLastChild
----------------------------------------------------------------
for list details see
http://www.magnolia.info/en/developer.html
----------------------------------------------------------------
----------------------------------------------------------------
for list details see
http://www.magnolia.info/en/developer.html
----------------------------------------------------------------