<%@ page import="info.magnolia.cms.core.Content,
java.util.Iterator,
java.util.Vector,
java.util.Calendar,
java.text.SimpleDateFormat,
info.magnolia.cms.core.HierarchyManager,
info.magnolia.cms.util.Resource"%>
<%--
This gets the active page's children pages and gets their data.
From this data, it puts several collections into the request, so the calling JSP can use them:
- 'titles' with the title of every child
- 'summaries' with the summaries of every child. This may or may not exist!
- 'dates' with the date of every child. This may or may not exist!
- 'handles' with the handle of every child, which is used to create a link to that page
--%>
<%
Content activePage = Resource.getActivePage(request);
Vector dates = new Vector();
Vector titles = new Vector();
Vector summaries = new Vector();
Vector handles = new Vector();
SimpleDateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy");
Iterator childIterator = activePage.getChildren().iterator();
while (childIterator.hasNext()) {
Content childPage = (Content)childIterator.next();
String dateString = childPage.getNodeData("date").getString();
if (dateString.length() > 0) {
Calendar date = childPage.getNodeData("date").getDate();
dates.add(dateFormat.format(date.getTime()));
}
else {
dates.add(null);
}
titles.add(childPage.getNodeData("title").getString());
summaries.add(childPage.getNodeData("summary").getString());
handles.add(childPage.getHandle());
}
request.setAttribute("dates", dates);
request.setAttribute("titles", titles);
request.setAttribute("summaries", summaries);
request.setAttribute("handles", handles);
%>