Problem with PORTAL_NODE
sschult Mar 12, 2009 10:52 AMHello,
I am trying to show the tab navigation in a portlet
I created a standard portlet and used the content of tabs.jsp (from JBoss 2.7.1) ind my navigation_view.jsp
<%@ page import="java.util.Iterator" %> <%@ page import="org.jboss.portal.api.node.PortalNode" %> <%@ page import="java.util.Locale" %> <%@ page import="java.util.ArrayList" %> <%@ page import="org.jboss.portal.api.PortalRuntimeContext" %> <% PortalNode root = (PortalNode)request.getAttribute("org.jboss.portal.api.PORTAL_NODE"); PortalNode portal = root; PortalNode mainPage = portal; while (portal.getType() != PortalNode.TYPE_PORTAL) { mainPage = portal; portal = portal.getParent(); } PortalRuntimeContext context = (PortalRuntimeContext)request.getAttribute("org.jboss.portal.api.PORTAL_RUNTIME_CONTEXT"); // Get a locale Locale locale = request.getLocale(); if (locale == null) { locale = Locale.getDefault(); } %> <ul id="tabsHeader"> <% ArrayList tmp = new ArrayList(10); Iterator childrenIt = portal.getChildren().iterator(); while (childrenIt.hasNext()) { PortalNode child = (PortalNode)childrenIt.next(); // Get the list of child pages tmp.clear(); for (Iterator i = child.getChildren().iterator(); i.hasNext();) { PortalNode childChild = (PortalNode)i.next(); if (childChild.getType() == PortalNode.TYPE_PAGE) { tmp.add(childChild); } } %> <li <% if (child == mainPage) { out.println(" id=\"current\""); } %> onmouseover="this.className='hoverOn'" onmouseout="this.className='hoverOff'"><a href="<%= child.createURL(context) %>"><%= child.getDisplayName(locale) %><% if (tmp.size() == 0) { %></a> <% } else { %> <!--[if IE 7]><!--></a><!--<![endif]--> <!--[if lte IE 6]> <table><tr><td><![endif]--> <ul> <% for (Iterator j = tmp.iterator(); j.hasNext();) { PortalNode childChild = (PortalNode)j.next(); %> <li><a href='<%= childChild.createURL(context) %>'><%= childChild.getDisplayName(locale) %> </a></li> <% } %> </ul> <!--[if lte IE 6]></td></tr></table></a><![endif]--> <% } %> </li> <% } %> </ul>
In my navigation.java is used
import javax.portlet.PortletException; import java.io.IOException; import javax.portlet.PortletMode; import javax.portlet.PortletRequestDispatcher; import javax.portlet.UnavailableException; import javax.portlet.filter.FilterChain; import org.jboss.portlet.JBossActionRequest; import org.jboss.portlet.JBossActionResponse; import org.jboss.portlet.JBossPortlet; import org.jboss.portlet.JBossRenderRequest; import org.jboss.portlet.JBossRenderResponse; import org.jboss.portlet.filter.JBossPortletFilter; /** * navigation Portlet Class */ public class navigation extends JBossPortlet { private static final String VIEW = "/WEB-INF/jsp/navigation_view.jsp"; @Override public void processAction(JBossActionRequest request, JBossActionResponse response) throws PortletException, IOException { response.setPortletMode(PortletMode.VIEW); return; } @Override protected void doView(JBossRenderRequest request, JBossRenderResponse response) throws PortletException, IOException, UnavailableException { response.setContentType("text/html"); PortletRequestDispatcher prd = getPortletContext().getRequestDispatcher(VIEW); prd.include(request, response); } }
Deploying of the Portlet works great with no errors, if I start teh Portlet I get an exception
15:41:44,394 ERROR The portlet threw an exception javax.portlet.PortletException: org.apache.jasper.JasperException: An exception occurred processing JSP page /WEB-INF/jsp/navigation_view.jsp at line 12 9: PortalNode portal = root; 10: PortalNode mainPage = portal; 11: 12: while (portal.getType() != PortalNode.TYPE_PORTAL) 13: { 14: mainPage = portal; 15: portal = portal.getParent();
Where is my fault ? Is anyone able to help me ?
Thanks,
Stephan