3 Replies Latest reply on Mar 25, 2009 4:49 PM by Bruno Machado

    Problem with PORTAL_NODE

    Stephan Schult Newbie

      Hello,

      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

        • 1. Re: Problem with PORTAL_NODE
          Stephan Schult Newbie

          sorry, forgot this part..

          Environment:
          JBoss Portal 2.7.1 bundeled with JBoss AS Server 4.2.3.GA
          Using included hsqldb
          OS Win XP SP3

          portlet.xml

          <?xml version='1.0' encoding='UTF-8' ?>
          <portlet-app xmlns='http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd' version='2.0'>
           <filter>
           <filter-name>JBoss Portlet Filter</filter-name>
           <filter-class>org.jboss.portlet.filter.JBossPortletFilter</filter-class>
           <lifecycle>ACTION_PHASE</lifecycle>
           <lifecycle>RENDER_PHASE</lifecycle>
           </filter>
           <filter-mapping>
           <filter-name>JBoss Portlet Filter</filter-name>
           <portlet-name>navigation</portlet-name>
           </filter-mapping>
          
           <portlet>
           <description>navigation</description>
           <portlet-name>navigation</portlet-name>
           <display-name>navigation</display-name>
           <portlet-class>de.infotech.portlet.navigation.navigation</portlet-class>
           <expiration-cache>0</expiration-cache>
           <supports>
           <mime-type>text/html</mime-type>
           <portlet-mode>VIEW</portlet-mode>
           </supports>
           <resource-bundle>de.infotech.portlet.navigation.messages</resource-bundle>
           <portlet-info>
           <title>navigation</title>
           <short-title>navigation</short-title>
           </portlet-info>
           </portlet>
          </portlet-app>
          
          


          Thanks,
          Stephan


          • 2. Re: Problem with PORTAL_NODE
            Wesley Hales Master

            Check for null on your request attribute, and do you have this filter defined http://docs.jboss.org/jbportal/v2.7.0.B1/referenceGuide/html/changelog.html

            • 3. Re: Problem with PORTAL_NODE
              Bruno Machado Newbie

              SSchult,

              In your case, you don't have the org.jboss.portal.api.PORTAL_NODE attribute set in your request. So, try to get it from Navigation.getCurrentNode() or in case of using JBossRenderRequest you can use request.getPortalNode() (is the same).

              public PortalNode getPortalNode()
               {
               return Navigation.getCurrentNode();
               }


              Bruno Rossetto
              http://brmachado.blogspot.com/
              http://jbossbrasil.ning.com/