[gatein-commits] gatein SVN: r2086 - in portal/trunk: web/portal/src/main/webapp/WEB-INF/conf/portal/portal/template/classic and 1 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Wed Mar 10 04:48:30 EST 2010


Author: hoang_to
Date: 2010-03-10 04:48:29 -0500 (Wed, 10 Mar 2010)
New Revision: 2086

Modified:
   portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/portal/portal/classic/navigation.xml
   portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/portal/portal/template/classic/navigation.xml
   portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageActionListener.java
Log:
GTNPORTAL-168: Problem when delete all nodes in portal navigation

Modified: portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/portal/portal/classic/navigation.xml
===================================================================
--- portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/portal/portal/classic/navigation.xml	2010-03-10 09:24:00 UTC (rev 2085)
+++ portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/portal/portal/classic/navigation.xml	2010-03-10 09:48:29 UTC (rev 2086)
@@ -60,5 +60,13 @@
       <visibility>SYSTEM</visibility>
 	    <page-reference>portal::classic::register</page-reference>	    
 	  </node>
+	  
+	  <!-- NOT FOUND node -->
+	  <node>
+	    <uri>notfound</uri>
+	    <name>notfound</name>
+	    <label>NotFound</label>
+      <visibility>SYSTEM</visibility>
+	  </node>
   </page-nodes>
 </node-navigation>

Modified: portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/portal/portal/template/classic/navigation.xml
===================================================================
--- portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/portal/portal/template/classic/navigation.xml	2010-03-10 09:24:00 UTC (rev 2085)
+++ portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/portal/portal/template/classic/navigation.xml	2010-03-10 09:48:29 UTC (rev 2086)
@@ -54,5 +54,12 @@
       <visibility>SYSTEM</visibility>
 	   <page-reference>portal::@owner@::register</page-reference>	    
 	 </node>
+	 
+	 <node>
+	   <uri>notfound</uri>
+	   <name>notfound</name>
+	   <label>NotFound</label>
+      <visibility>SYSTEM</visibility>
+	 </node>
   </page-nodes>
 </node-navigation>

Modified: portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageActionListener.java
===================================================================
--- portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageActionListener.java	2010-03-10 09:24:00 UTC (rev 2085)
+++ portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageActionListener.java	2010-03-10 09:48:29 UTC (rev 2086)
@@ -40,6 +40,7 @@
 import org.exoplatform.webui.core.UIComponent;
 import org.exoplatform.webui.event.Event;
 import org.exoplatform.webui.event.EventListener;
+import org.exoplatform.webui.event.Event.Phase;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -101,6 +102,14 @@
          PageNode targetPageNode = getTargetedNode(targetedNav, targetPath);
          List<PageNode> targetedPathNodes = findPath(targetedNav, targetPath);
          
+         //If targetPageNode is null, which happens only if the navigation contains only 'notfound' node,
+         //we send a change page node event for redirecting to 'notfound' node
+         if(targetPageNode == null)
+         {
+            redirectToNotFoundNode(showedUIPortal);
+            return;
+         }
+         
          if(formerNavType.equals(newNavType) && formerNavId.equals(newNavId))
          {
             //Case 1: Both navigation type and id are not changed, but current page node is changed
@@ -245,6 +254,8 @@
        * Fetch the currently selected pageNode under a PageNavigation. It is the last node encountered
        * while descending the pathNodes
        * 
+       * This method returns <code>null</code> iff only 'notfound' node remains in the navigation
+       * 
        * @param targetedNav
        * @param pathNodes
        * @return
@@ -254,13 +265,13 @@
          //Case users browses to a URL of the form  */portal/public/classic
          if(pathNodes.length == 0)
          {
-            return targetedNav.getNodes().get(0);
+           return getDefaultNode(targetedNav);
          }
          
          PageNode currentNode = targetedNav.getNode(pathNodes[0]);
          if(currentNode == null)
          {
-            return null;//Not found any node here
+            return getDefaultNode(targetedNav);
          }
          
          PageNode tempNode = null;
@@ -277,15 +288,46 @@
                currentNode = tempNode;
             }
          }
-         
          return currentNode;
       }
       
+      /**
+       * Default node of a navigation. This method returns
+       * 
+       * 1. The first node in the list of 'nav' 's children if the list contains
+       * at least one child other than 'notfound'
+       * 
+       * 2. <code>null</code> otherwise
+       * 
+       * @param nav
+       * @return
+       */
+      private static PageNode getDefaultNode(PageNavigation nav)
+      {
+         PageNode defaultNode;
+         try
+         {
+            defaultNode = nav.getNodes().get(0);
+         }
+         catch (IndexOutOfBoundsException ex)
+         {
+            return null;
+         }
+         if (defaultNode != null && !("notfound".equals(defaultNode.getName())))
+         {
+            return defaultNode;
+         }
+         else
+         {
+            return null;
+         }
+      }
+      
       private static List<PageNode> findPath(PageNavigation nav, String[] pathNodes)
       {
          List<PageNode> nodes = new ArrayList<PageNode>(4);
          
-         //That happens when user browses to a URL like */portal/public/classic
+         //That happens when user browses to a URL like /portal/public/classic
          if(pathNodes.length == 0)
          {
             nodes.add(nav.getNodes().get(0));
@@ -331,6 +373,12 @@
          PortalDataMapper.toUIPortal(uiPortal, userPortalConfig);
          return uiPortal;
       }
+      
+      private static void redirectToNotFoundNode(UIPortal uiPortal) throws Exception
+      {
+         PageNodeEvent<UIPortal> changePageNodeEvent = new PageNodeEvent<UIPortal>(uiPortal, PageNodeEvent.CHANGE_PAGE_NODE, "/notfound");
+         uiPortal.broadcast(changePageNodeEvent, Event.Phase.PROCESS);
+      }
    }
 
   



More information about the gatein-commits mailing list