Author: chris.laprun(a)jboss.com
Date: 2011-08-02 17:46:56 -0400 (Tue, 02 Aug 2011)
New Revision: 6983
Modified:
portal/branches/api/examples/portlets/api/src/main/java/org/gatein/portal/samples/api/NavigationPortlet.java
Log:
- Modified so that it is more similar to what the current navigation portlet displays.
Modified:
portal/branches/api/examples/portlets/api/src/main/java/org/gatein/portal/samples/api/NavigationPortlet.java
===================================================================
---
portal/branches/api/examples/portlets/api/src/main/java/org/gatein/portal/samples/api/NavigationPortlet.java 2011-08-02
20:30:24 UTC (rev 6982)
+++
portal/branches/api/examples/portlets/api/src/main/java/org/gatein/portal/samples/api/NavigationPortlet.java 2011-08-02
21:46:56 UTC (rev 6983)
@@ -51,25 +51,46 @@
@Override
protected void doView(RenderRequest request, RenderResponse response) throws
PortletException, IOException
{
- Id groupId = gateIn.groupId("platform", "administrators");
+ Id userId = gateIn.userId("root");
- Site adminSite = gateIn.getGroupSite(groupId);
- Navigation navigation = adminSite.getNavigation();
+ PrintWriter writer = response.getWriter();
+ writer.println("<h1>Portal Sites</h1>");
+ IterableIdentifiableCollection<? extends Site> sites =
gateIn.getPortalSites(userId);
+ for (Site site : sites)
+ {
+ outputSite(site, writer);
+ }
+
+ writer.println("<h1>Group Sites</h1>");
+ sites = gateIn.getGroupSites(userId);
+ for (Site site : sites)
+ {
+ outputSite(site, writer);
+ }
+
+ writer.println("<h1>Dashboard</h1>");
+ outputSite(gateIn.getDashboard(userId), writer);
+ }
+
+ private void outputSite(Site site, PrintWriter writer) throws IOException
+ {
+ Navigation navigation = site.getNavigation();
+
IterableIdentifiableCollection<Navigation> adminNodes = navigation.getAll();
- PrintWriter writer = response.getWriter();
+ writer.println("<h2>" + site.getDisplayName() +
"</h2>");
writer.println("<ul>");
for (Navigation adminNode : adminNodes)
{
- outputNode(writer, adminNode);
+ outputNode(adminNode, writer);
}
- writer.println("</ul>");
+ writer.println("</ul><br/>");
}
- private void outputNode(PrintWriter writer, Navigation node)
+ private void outputNode(Navigation node, PrintWriter writer)
{
IterableIdentifiableCollection<Navigation> children = node.getAll();
int size = children.size();
@@ -84,7 +105,7 @@
writer.println("<ul>");
for (Navigation child : children)
{
- outputNode(writer, child);
+ outputNode(child, writer);
}
writer.println("</ul>");
}