portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tay...@apache.org
Subject svn commit: r891567 - in /portals/jetspeed-2/applications/j2-admin/trunk/src/main: java/org/apache/jetspeed/portlets/spaces/BreadcrumbMenu.java java/org/apache/jetspeed/portlets/spaces/PageNavigator.java webapp/WEB-INF/view/spaces/page-navigator.jsp
Date Thu, 17 Dec 2009 07:11:44 GMT
Author: taylor
Date: Thu Dec 17 07:11:44 2009
New Revision: 891567

URL: http://svn.apache.org/viewvc?rev=891567&view=rev
Log:
http://issues.apache.org/jira/browse/JS2-1057
Start of new Page Navigator: Replacing demo PSML-Union implementation with a real meat-eating
programmer's Site Menu implementation
Still TODO: 
* remove Space Services, doesn't seem needed 
* add styles
* menu operations (add,rename, delete), expand to submenus

Modified:
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/spaces/BreadcrumbMenu.java
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/spaces/PageNavigator.java
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/spaces/page-navigator.jsp

Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/spaces/BreadcrumbMenu.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/spaces/BreadcrumbMenu.java?rev=891567&r1=891566&r2=891567&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/spaces/BreadcrumbMenu.java
(original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/spaces/BreadcrumbMenu.java
Thu Dec 17 07:11:44 2009
@@ -82,15 +82,18 @@
             if (breadcrumbsMenu != null)
             {
                 List<MenuElement> breadcrumbsMenuElements = breadcrumbsMenu.getElements();
-                for (MenuElement breadcrumbMenuElement : breadcrumbsMenuElements)
+                if (breadcrumbsMenuElements != null)
                 {
-                    if (breadcrumbMenuElement instanceof MenuOption)
-                    {
-                        MenuOption breadcrumbMenuOption = (MenuOption)breadcrumbMenuElement;
-                        String title = breadcrumbMenuOption.getTitle(preferredLocale);
-                        String url = admin.getPortalURL(request, response, breadcrumbMenuOption.getUrl());
-                        breadcrumbs.add(new BreadcrumbMenuItem(title, url));
-                    }
+	                for (MenuElement breadcrumbMenuElement : breadcrumbsMenuElements)
+	                {
+	                    if (breadcrumbMenuElement instanceof MenuOption)
+	                    {
+	                        MenuOption breadcrumbMenuOption = (MenuOption)breadcrumbMenuElement;
+	                        String title = breadcrumbMenuOption.getTitle(preferredLocale);
+	                        String url = admin.getPortalURL(request, response, breadcrumbMenuOption.getUrl());
+	                        breadcrumbs.add(new BreadcrumbMenuItem(title, url));
+	                    }
+	                }
                 }
             }
         }

Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/spaces/PageNavigator.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/spaces/PageNavigator.java?rev=891567&r1=891566&r2=891567&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/spaces/PageNavigator.java
(original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/spaces/PageNavigator.java
Thu Dec 17 07:11:44 2009
@@ -26,11 +26,16 @@
 import javax.portlet.PortletException;
 import javax.portlet.RenderRequest;
 import javax.portlet.RenderResponse;
+import javax.servlet.http.HttpServletRequest;
 
 import org.apache.jetspeed.CommonPortletServices;
+import org.apache.jetspeed.Jetspeed;
 import org.apache.jetspeed.administration.PortalAdministration;
+import org.apache.jetspeed.container.url.BasePortalURL;
+import org.apache.jetspeed.om.page.Link;
 import org.apache.jetspeed.om.page.Page;
 import org.apache.jetspeed.page.PageManager;
+import org.apache.jetspeed.request.RequestContext;
 import org.apache.jetspeed.spaces.Space;
 import org.apache.jetspeed.spaces.Spaces;
 import org.apache.portals.bridges.common.GenericServletPortlet;
@@ -46,7 +51,8 @@
 {
     private Spaces spacesService;
     private PortalAdministration admin;
-    protected PageManager pageManager;    
+    protected PageManager pageManager;
+    private BasePortalURL baseUrlAccess = null;
 
     public void init(PortletConfig config) throws PortletException
     {
@@ -64,7 +70,16 @@
         if (null == pageManager)
         {
             throw new PortletException("Failed to find the Page Manager on portlet initialization");
-        }                       
+        }
+        try
+        {
+        	baseUrlAccess = (BasePortalURL) Jetspeed.getComponentManager().getComponent("BasePortalURL");
+        }
+        catch (Exception e)
+        {
+        	baseUrlAccess = null; // optional
+        }
+        
     }
 
     @SuppressWarnings("unchecked")
@@ -76,6 +91,7 @@
         {
             request.getPortletSession().removeAttribute("spaces");
             request.getPortletSession().removeAttribute("pages");
+            request.getPortletSession().removeAttribute("links");
             request.getPortletSession().removeAttribute("space");
         }
         List<Space> spaces = (List<Space>)request.getPortletSession().getAttribute("spaces");
@@ -101,15 +117,9 @@
                 }
             }
             request.getPortletSession().setAttribute("space", space);        
-        }            
-        
-        List<Page> pages = (List<Page>)request.getPortletSession().getAttribute("pages");
-        if (pages == null)
-        {
-            pages = spacesService.listPages(space);
-            request.getPortletSession().setAttribute("pages", pages);
-        }        
-        request.setAttribute("pages", pages);
+        }                    
+        request.setAttribute("space", space);
+        request.setAttribute("pageNavigator", this);
         
         try
         {
@@ -124,12 +134,6 @@
     public void processAction(ActionRequest actionRequest, ActionResponse actionResponse)
throws PortletException,
     IOException
     {
-        String page = actionRequest.getParameter("page");
-        if (page != null)
-        {
-            String path = admin.getPortalURL(actionRequest, actionResponse, page);
-            actionResponse.sendRedirect(path);            
-        }
         String addPage = actionRequest.getParameter("addPage");
         if (addPage != null)
         {
@@ -147,6 +151,7 @@
                     pageManager.updatePage(newPage);
                     
                     actionRequest.getPortletSession().removeAttribute("pages");
+                    actionRequest.getPortletSession().removeAttribute("links");
                     String redirect = admin.getPortalURL(actionRequest, actionResponse, path);
                     actionResponse.sendRedirect(redirect);                              
         
                 }
@@ -156,5 +161,33 @@
                 }
             }
         }
-    }    
+    }
+    
+    public String getAbsoluteUrl(String relativePath, RenderResponse renderResponse, RequestContext
rc)
+    {
+        // only rewrite a non-absolute url
+        if (relativePath != null && relativePath.indexOf("://") == -1 &&
relativePath.indexOf("mailto:") == -1)            
+        {
+            HttpServletRequest request = rc.getRequest();
+            StringBuffer path = new StringBuffer();
+            if ( !rc.getPortalURL().isRelativeOnly() )
+            {
+                if (this.baseUrlAccess == null)
+                {
+                    path.append(request.getScheme()).append("://").append(request.getServerName()).append(":").append(request.getServerPort());
+                }
+                else
+                {
+                    path.append(baseUrlAccess.getServerScheme()).append("://").append(baseUrlAccess.getServerName()).append(":").append(baseUrlAccess.getServerPort());
+                }
+            }
+            return renderResponse.encodeURL(path.append(request.getContextPath()).append(request.getServletPath()).append(relativePath).toString());
+              
+        }
+        else
+        {
+            return relativePath;
+        }
+    }
+    
 }
\ No newline at end of file

Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/spaces/page-navigator.jsp
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/spaces/page-navigator.jsp?rev=891567&r1=891566&r2=891567&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/spaces/page-navigator.jsp
(original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/spaces/page-navigator.jsp
Thu Dec 17 07:11:44 2009
@@ -16,26 +16,83 @@
 
 --%>
 <%@page import="java.util.List"%>
+<%@page import="java.util.Locale"%>
 <%@page import="java.text.DecimalFormat"%>
 <%@page import="java.text.NumberFormat"%>
 <%@page import="org.apache.jetspeed.spaces.Space"%>
 <%@page import="org.apache.jetspeed.om.page.Page"%>
+<%@page import="org.apache.jetspeed.om.page.Link"%>
+<%@page import="org.apache.jetspeed.portalsite.Menu"%>
+<%@page import="org.apache.jetspeed.portalsite.MenuElement"%>
+<%@page import="org.apache.jetspeed.portalsite.MenuOption"%>
 <%@page import="org.apache.jetspeed.CommonPortletServices"%>
+<%@page import="org.apache.jetspeed.request.RequestContext"%>
+<%@page import="org.apache.jetspeed.portalsite.PortalSiteRequestContext"%>
+<%@page import="org.apache.jetspeed.portlets.spaces.PageNavigator"%>
+
 <%@ page contentType="text/html" %>
 <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
 <%@ taglib uri="http://java.sun.com/portlet" prefix="portlet"%>
 
 <portlet:defineObjects/>
+<%
+RequestContext rc = (RequestContext)request.getAttribute(RequestContext.REQUEST_PORTALENV);
+PortalSiteRequestContext psrc = (PortalSiteRequestContext)rc.getAttribute("org.apache.jetspeed.portalsite.PortalSiteRequestContext");
+Space space = (Space)renderRequest.getAttribute("space");
+Locale locale = renderRequest.getLocale();
+PageNavigator pageNavigator = (PageNavigator)renderRequest.getAttribute("pageNavigator");
+%>
 <table>
+	<tr><td class="portlet-section-body"><b><%=space.getName() %> Space</b></td>
</tr>
+<%
+Menu spaceMenu = psrc.getMenu("pages");
+for (MenuElement element : (List<MenuElement>)spaceMenu.getElements())
+{
+	if (element.getElementType().equals(MenuElement.OPTION_ELEMENT_TYPE))
+	{
+		MenuOption option = (MenuOption)element;
+		String url = pageNavigator.getAbsoluteUrl(option.getUrl(), renderResponse, rc);
+	%>     
+	     <tr>
+	       <td class="portlet-section-body"><a href="<%=url%>"><%=element.getTitle(locale)
%></a></td>
+	     </tr>
+	<%
+		}
+		else
+		{
+	%>
+	     <tr>
+	       <td class="portlet-section-body">---</td>
+	     </tr>
+	<%
+	}
+}
+%>
+    <tr>
+        <th class="portlet-section-header" colspan="1"></th>
+    </tr>
 <%
-List<Page> pages = (List<Page>)renderRequest.getAttribute("pages");
-for (Page pg : pages)
+Menu linksMenu = psrc.getMenu("additional-links");
+for (MenuElement element : (List<MenuElement>)linksMenu.getElements())
 {
+	if (element.getElementType().equals(MenuElement.OPTION_ELEMENT_TYPE))
+	{
+		MenuOption option = (MenuOption)element;
+		String url = pageNavigator.getAbsoluteUrl(option.getUrl(), renderResponse, rc);	
 %>     
      <tr>
-       <td class="portlet-section-body"><a href="<portlet:actionURL><portlet:param
name='page' value='<%=pg.getPath()%>'/></portlet:actionURL>"><%=pg.getTitle()
%></a></td>
+       <td class="portlet-section-body"><a href="<%=url%>"><%=element.getTitle(locale)
%></a></td>
+     </tr>
+<%
+	}
+	else
+	{
+%>
+     <tr>
+       <td class="portlet-section-body">---</td>
      </tr>
 <%
+	}
 }
 %>
     <tr>



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message