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
----------------------------------------------------------------