[opencms-dev] Is there an easier way to get the dateLastModified for a resource than this?
Chris Todd
chris at christophertodd.com
Mon Mar 29 08:14:01 CEST 2004
What's the easiest way to determine (from within a JSP) the dateLastModified
for a page stored in OpenCMS?
For example, I have a JSP page that iterates over all the pages in a certain
directory (using a CmsJspNavBuilder object), then prints the Title, author,
etc. from the properties of the CmsJspNavElement object (see the code
snippet below), but I'd like to also be able to print when the page was last
modified. CmsJspNavElement only has a getProperties() method, but that
doesn't give me the date last modified.
I noticed that com.opencms.file.CmsFile has a getDateLastModified() method,
and that CmsJspActionElement has a method called readFile(String name) that
returns a CmsFile, but I was wondering if there's a simpler way.
Any help pointing me to a simpler class and/or method would be greatly
appreciated. I've only been using OpenCMS for about a week, so this may
simply be a case of not knowing where to look.
Regards,
Chris
P.S. Here is the code I described above:
CmsJspActionElement cms = new CmsJspActionElement(pageContext, request,
response);
CmsObject cmsObj = cms.getCmsObject();
ArrayList list = cms.getNavigation().getNavigationForFolder();
Iterator i = list.iterator();
while (i.hasNext()) {
CmsJspNavElement ne = (CmsJspNavElement)i.next();
out.println("<p><a href=\"" + cms.link(ne.getResourceName()) + "\">");
out.println(ne.getTitle() + "</a> by ");
out.println("<a href=mailto:" + ne.getProperty("authoremail") + ">");
out.println(ne.getProperty("author") + "</a> <br/><i>updated ");
CmsFile cmsFile = cmsObj.readFile(ne.getResourceName());
java.util.Date date = new java.util.Date(cmsFile.getDateLastModified());
out.println(date + "</i><br />");
out.println(ne.getProperty("Description"));
out.println("</p>");
}
More information about the opencms-dev
mailing list