Navigation DataCollecttionRenderer um Ausgabe des langen Datumsformat ergänzt (wie in c.a.domain.DomainObjectXMLRenderer)

git-svn-id: https://svn.libreccm.org/ccm/trunk@1805 8810af33-2d31-482b-a856-94f89814c4df
master
quasi 2012-08-08 04:49:29 +00:00
parent 9b3eb396bc
commit ff506516c6
1 changed files with 17 additions and 14 deletions

View File

@ -105,7 +105,8 @@ public class DataCollectionRenderer extends LockableImpl {
/** /**
* Sets the context of the traversal adapter used the render the objects * Sets the context of the traversal adapter used the render the objects
* if {@link #m_specializeObjects} is set to <code>true</code> * if {@link #m_specializeObjects} is set to
* <code>true</code>
* *
* @param context The adapter context. * @param context The adapter context.
*/ */
@ -125,6 +126,7 @@ public class DataCollectionRenderer extends LockableImpl {
/** /**
* @param objects * @param objects
* @param pageNumber current page, starting from 1 * @param pageNumber current page, starting from 1
*
* @return * @return
*/ */
public Element generateXML(DataCollection objects, public Element generateXML(DataCollection objects,
@ -140,7 +142,7 @@ public class DataCollectionRenderer extends LockableImpl {
// Quasimodo: End // Quasimodo: End
Element content = Navigation.newElement("objectList"); Element content = Navigation.newElement("objectList");
//Return the empty nav:item & nav:paginator tags. //Return the empty nav:item & nav:paginator tags.
// Quasimodo: Why should I??? There is no need for a paginator if there aren't any elements // Quasimodo: Why should I??? There is no need for a paginator if there aren't any elements
if (!m_navItems) { if (!m_navItems) {
@ -203,9 +205,9 @@ public class DataCollectionRenderer extends LockableImpl {
paginator.addAttribute("objectCount", new Long(objectCount).toString()); paginator.addAttribute("objectCount", new Long(objectCount).toString());
content.addContent(paginator); content.addContent(paginator);
int index = 0; int index = 0;
while (objects.next()) { while (objects.next()) {
DataObject dobj = objects.getDataObject(); DataObject dobj = objects.getDataObject();
ACSObject object = null; ACSObject object = null;
if (m_specializeObjects) { if (m_specializeObjects) {
@ -216,8 +218,8 @@ public class DataCollectionRenderer extends LockableImpl {
} else { } else {
s_log.debug("Specializing successful."); s_log.debug("Specializing successful.");
} }
} }
Element item = Navigation.newElement(content, "item"); Element item = Navigation.newElement(content, "item");
Iterator attributes = m_attributes.iterator(); Iterator attributes = m_attributes.iterator();
while (attributes.hasNext()) { while (attributes.hasNext()) {
@ -225,13 +227,13 @@ public class DataCollectionRenderer extends LockableImpl {
String[] paths = StringUtils.split(name, '.'); String[] paths = StringUtils.split(name, '.');
outputValue(item, dobj, name, paths, 0); outputValue(item, dobj, name, paths, 0);
} }
Iterator properties = m_properties.iterator(); Iterator properties = m_properties.iterator();
while (properties.hasNext()) { while (properties.hasNext()) {
DataCollectionPropertyRenderer property = (DataCollectionPropertyRenderer) properties.next(); DataCollectionPropertyRenderer property = (DataCollectionPropertyRenderer) properties.next();
property.render(objects, item); property.render(objects, item);
} }
Element path = Navigation.newElement(item, "path"); Element path = Navigation.newElement(item, "path");
path.setText(getStableURL(dobj, object)); path.setText(getStableURL(dobj, object));
//item.addContent(path); //item.addContent(path);
@ -239,9 +241,9 @@ public class DataCollectionRenderer extends LockableImpl {
generateItemXML(item, dobj, object, index); generateItemXML(item, dobj, object, index);
index++; index++;
//content.addContent(item); //content.addContent(item);
} }
return content; return content;
} }
@ -300,12 +302,13 @@ public class DataCollectionRenderer extends LockableImpl {
// Quasimodo: BEGIN // Quasimodo: BEGIN
// Add attributes for date and time // Add attributes for date and time
Locale negLocale = com.arsdigita.globalization.GlobalizationHelper.getNegotiatedLocale(); Locale negLocale = com.arsdigita.globalization.GlobalizationHelper.getNegotiatedLocale();
DateFormat dateFormatter = DateFormat.getDateInstance( DateFormat dateFormatter = DateFormat.getDateInstance(DateFormat.MEDIUM, negLocale);
DateFormat.MEDIUM, negLocale); DateFormat longDateFormatter = DateFormat.getDateInstance(DateFormat.LONG, negLocale);
DateFormat timeFormatter = DateFormat.getTimeInstance( DateFormat timeFormatter = DateFormat.getTimeInstance(DateFormat.SHORT, negLocale);
DateFormat.SHORT, negLocale);
attribute.addAttribute("date", dateFormatter.format(date)); attribute.addAttribute("date", dateFormatter.format(date));
attribute.addAttribute("longDate", longDateFormatter.format(date));
attribute.addAttribute("time", timeFormatter.format(date)); attribute.addAttribute("time", timeFormatter.format(date));
attribute.addAttribute("monthName", calDate.getDisplayName(Calendar.MONTH, Calendar.LONG, negLocale));
// Quasimodo: END // Quasimodo: END
} }