This is the portlet I threw together. There are many other pages and windows deployed.
Only the PageLinkWindow and its parent are printed. Exceptions are thrown for every other
node the code attempts to access, but they don't propogate into the portlet doView
method. They are just printed to console.
Output:: context
| -DemoPortal: portal
| --ipc: page
| ---PageLinkWindow: window
Portlet code:
import java.io.IOException;
| import java.util.Collection;
|
| import javax.portlet.PortletException;
|
| import org.jboss.portal.api.node.PortalNode;
| import org.jboss.portlet.JBossPortlet;
| import org.jboss.portlet.JBossRenderRequest;
| import org.jboss.portlet.JBossRenderResponse;
|
| public class PageLinkPortlet extends JBossPortlet
| {
| protected void doView(JBossRenderRequest request, JBossRenderResponse response)
throws IOException, PortletException
| {
| try
| {
| response.setContentType("text/html");
| StringBuffer html = new StringBuffer();
|
| PortalNode baseNode = request.getPortalNode();
| while (baseNode.getParent() != null)
| baseNode = baseNode.getParent();
|
| list(html, baseNode);
| listchildren(html, baseNode, 1);
|
| response.getWriter().write(html.toString());
| }
| catch(Exception e)
| {
| //e.printStackTrace();
| }
| }
|
| private void list(StringBuffer html, PortalNode pn)
| {
| String type = "";
| if (pn.getType() == PortalNode.TYPE_CONTEXT)
| type = "context";
| else if (pn.getType() == PortalNode.TYPE_PORTAL)
| type = "portal";
| if (pn.getType() == PortalNode.TYPE_PAGE)
| type = "page";
| if (pn.getType() == PortalNode.TYPE_WINDOW)
| type = "window";
|
| html.append(pn.getName() + ": " + type + "<br>");
| }
|
| private void listchildren(StringBuffer html, PortalNode pn, int depth)
| {
| Collection<PortalNode> c = (Collection<PortalNode>)
pn.getChildren();
|
| for (PortalNode node : c)
| {
| for (int i = 0; i < depth; i++)
| html.append("-");
|
| list(html, node);
| listchildren(html, node, depth + 1);
| }
| }
| }
|
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4131177#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...