Author: chris.laprun(a)jboss.com
Date: 2011-08-05 18:13:09 -0400 (Fri, 05 Aug 2011)
New Revision: 7002
Modified:
portal/branches/api/examples/portlets/api/src/main/java/org/gatein/portal/samples/api/ContentRegistryPortlet.java
Log:
- Improved output of ContentRegistryPortlet.
Modified:
portal/branches/api/examples/portlets/api/src/main/java/org/gatein/portal/samples/api/ContentRegistryPortlet.java
===================================================================
---
portal/branches/api/examples/portlets/api/src/main/java/org/gatein/portal/samples/api/ContentRegistryPortlet.java 2011-08-05
22:12:23 UTC (rev 7001)
+++
portal/branches/api/examples/portlets/api/src/main/java/org/gatein/portal/samples/api/ContentRegistryPortlet.java 2011-08-05
22:13:09 UTC (rev 7002)
@@ -24,6 +24,8 @@
import org.gatein.api.GateIn;
import org.gatein.api.content.Category;
+import org.gatein.api.content.ManagedContent;
+import org.gatein.api.util.IterableCollection;
import org.gatein.api.util.IterableIdentifiableCollection;
import javax.portlet.GenericPortlet;
@@ -57,8 +59,31 @@
IterableIdentifiableCollection<Category> categories =
gateIn.getDefaultPortal().getContentRegistry().getAllCategories();
for (Category category : categories)
{
- writer.println("<li>" + category + "</li>");
+ writer.println("<li>");
+ outputCategory(category, writer);
+ writer.println("</li>");
}
writer.println("</ul>");
}
+
+ private void outputCategory(Category category, PrintWriter writer) throws IOException
+ {
+ writer.println("<h2>" + category.getDisplayName() +
"</h2>");
+ writer.println("<ul>");
+
+ final IterableCollection<ManagedContent> managedContents =
category.getManagedContents();
+ for (ManagedContent managedContent : managedContents)
+ {
+ outputManagedContent(managedContent, writer);
+ }
+
+ writer.println("</ul><br/>");
+ }
+
+ private void outputManagedContent(ManagedContent content, PrintWriter writer) throws
IOException
+ {
+ writer.println("<h3>" + content.getDisplayName() +
"</h3>");
+ writer.println("Content: " + content.getContent());
+ writer.println("<br/>");
+ }
}
Show replies by date