Author: thomas.heute(a)jboss.com
Date: 2007-04-24 08:59:46 -0400 (Tue, 24 Apr 2007)
New Revision: 7038
Added:
trunk/common/src/main/org/jboss/portal/common/http/HttpServletRequestWrapper.java
trunk/common/src/main/org/jboss/portal/common/http/HttpServletResponseWriter.java
trunk/core/src/resources/portal-core-war/WEB-INF/jsp/header/
trunk/core/src/resources/portal-core-war/WEB-INF/jsp/header/header.jsp
trunk/core/src/resources/portal-core-war/WEB-INF/jsp/header/tabs.jsp
Modified:
trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java
trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml
Log:
PageCustomizerInterceptor now uses external JSPs for rendering, should help on basic
customization.
Added: trunk/common/src/main/org/jboss/portal/common/http/HttpServletRequestWrapper.java
===================================================================
--- trunk/common/src/main/org/jboss/portal/common/http/HttpServletRequestWrapper.java
(rev 0)
+++
trunk/common/src/main/org/jboss/portal/common/http/HttpServletRequestWrapper.java 2007-04-24
12:59:46 UTC (rev 7038)
@@ -0,0 +1,70 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.common.http;
+
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * Wrapper around a HTTPServletRequest to add attributes without
+ * affecting the actual request
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision: 1.1 $
+ */
+public class HttpServletRequestWrapper extends
+ javax.servlet.http.HttpServletRequestWrapper
+{
+
+ private Map attributes;
+
+
+ public HttpServletRequestWrapper(HttpServletRequest servletRequest)
+ {
+ super(servletRequest);
+ attributes = new HashMap();
+ }
+
+ public void setAttribute(String name, Object value)
+ {
+ attributes.put(name, value);
+ }
+
+ public Object getAttribute(String name)
+ {
+ Object value = attributes.get(name);
+ if (value == null)
+ {
+ value = getRequest().getAttribute(name);
+ }
+ return value;
+ }
+
+ public Enumeration getAttributeNames()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+}
Added: trunk/common/src/main/org/jboss/portal/common/http/HttpServletResponseWriter.java
===================================================================
--- trunk/common/src/main/org/jboss/portal/common/http/HttpServletResponseWriter.java
(rev 0)
+++
trunk/common/src/main/org/jboss/portal/common/http/HttpServletResponseWriter.java 2007-04-24
12:59:46 UTC (rev 7038)
@@ -0,0 +1,286 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.common.http;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+import java.util.Locale;
+
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * Redirection of the Writer
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision: 1.1 $
+ */
+public class HttpServletResponseWriter implements HttpServletResponse
+{
+
+ static class MockServletOutputStream extends ServletOutputStream
+ {
+ private ByteArrayOutputStream buffer;
+
+ private String encoding;
+
+ public MockServletOutputStream(int size, String encoding)
+ {
+ buffer = new ByteArrayOutputStream(size);
+ this.encoding = encoding;
+ }
+
+ public void setEncoding(String encoding)
+ {
+ this.encoding = encoding;
+ }
+
+ public void write(int value) throws IOException
+ {
+ buffer.write(value);
+ }
+
+ public String getContent() throws IOException
+ {
+ try {
+ buffer.flush();
+ return buffer.toString(encoding);
+ } catch (IOException e) {
+ throw e;
+ }
+ }
+
+ public byte[] getBinaryContent() throws IOException
+ {
+ try {
+ buffer.flush();
+ return buffer.toByteArray();
+ } catch (IOException e) {
+ throw e;
+ }
+ }
+
+ public void clearContent()
+ {
+ buffer = new ByteArrayOutputStream();
+ }
+
+ public String toString()
+ {
+ try {
+ return getContent();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ return super.toString();
+ }
+ }
+
+ private ServletOutputStream outputStream;
+ private PrintWriter writer;
+ private String characterEncoding;
+ private int bufferSize;
+
+ public HttpServletResponseWriter(HttpServletResponse response)
+ {
+ this.characterEncoding = response.getCharacterEncoding();
+ this.outputStream = new MockServletOutputStream(bufferSize,
this.characterEncoding);
+ this.bufferSize = response.getBufferSize();
+ }
+
+ public String getContent()
+ {
+ try {
+ return ((MockServletOutputStream)outputStream).getContent();
+ } catch (IOException e) {
+ return "test";
+ }
+ }
+
+ public void addCookie(Cookie arg0)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void addDateHeader(String arg0, long arg1)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void addHeader(String arg0, String arg1)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void addIntHeader(String arg0, int arg1)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean containsHeader(String arg0)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public String encodeRedirectURL(String arg0)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public String encodeRedirectUrl(String arg0)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public String encodeURL(String arg0)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public String encodeUrl(String arg0)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void sendError(int arg0) throws IOException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void sendError(int arg0, String arg1) throws IOException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void sendRedirect(String arg0) throws IOException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setDateHeader(String arg0, long arg1)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setHeader(String arg0, String arg1)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setIntHeader(String arg0, int arg1)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setStatus(int arg0)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setStatus(int arg0, String arg1)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void flushBuffer() throws IOException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public int getBufferSize()
+ {
+ return bufferSize;
+ }
+
+ public String getCharacterEncoding()
+ {
+ return characterEncoding;
+ }
+
+ public String getContentType()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public Locale getLocale()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public ServletOutputStream getOutputStream() throws IOException
+ {
+ return outputStream;
+ }
+
+ public PrintWriter getWriter() throws IOException
+ {
+ if (writer == null)
+ {
+ writer = new PrintWriter(new OutputStreamWriter(outputStream,
characterEncoding), true);
+ }
+ return writer;
+ }
+
+ public boolean isCommitted()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void reset()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void resetBuffer()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setBufferSize(int bufferSize)
+ {
+ this.bufferSize = bufferSize;
+ }
+
+ public void setCharacterEncoding(String characterEncoding)
+ {
+ this.characterEncoding = characterEncoding;
+ }
+
+ public void setContentLength(int arg0)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setContentType(String arg0)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setLocale(Locale arg0)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+}
Modified:
trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java 2007-04-24
01:58:12 UTC (rev 7037)
+++
trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java 2007-04-24
12:59:46 UTC (rev 7038)
@@ -22,9 +22,31 @@
******************************************************************************/
package org.jboss.portal.core.aspects.controller;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.log4j.Logger;
import org.jboss.portal.Mode;
import org.jboss.portal.WindowState;
import org.jboss.portal.api.node.PortalNode;
+import org.jboss.portal.common.http.HttpServletRequestWrapper;
+import org.jboss.portal.common.http.HttpServletResponseWriter;
import org.jboss.portal.core.controller.Controller;
import org.jboss.portal.core.controller.ControllerCommand;
import org.jboss.portal.core.controller.ControllerContext;
@@ -50,28 +72,17 @@
import org.jboss.portal.portlet.PortletParametersStateString;
import org.jboss.portal.security.PortalSecurityException;
import org.jboss.portal.security.spi.auth.PortalAuthorizationManagerFactory;
+import org.jboss.portal.server.ServerInvocationContext;
import org.jboss.portal.server.request.URLContext;
import org.jboss.portal.theme.ThemeConstants;
import org.jboss.portal.theme.impl.render.dynamic.DynaRenderOptions;
import org.jboss.portal.theme.page.Region;
import org.jboss.portal.theme.page.WindowContext;
import org.jboss.portal.theme.page.WindowResult;
-import org.apache.log4j.Logger;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
* @version $Revision: 1.1 $
*/
public class PageCustomizerInterceptor extends ControllerInterceptor
@@ -86,6 +97,12 @@
/** . */
private static final String RESOURCE_PREFIX = "PAGENAME_";
+ private String JSPContext;
+
+ private String headerJSP;
+
+ private String tabsJSP;
+
/** . */
private PortalAuthorizationManagerFactory portalAuthorizationManagerFactory;
@@ -159,155 +176,140 @@
{
StringBuffer sb = new StringBuffer();
ControllerContext controllerCtx = cc.getControllerContext();
+
+ ServerInvocationContext serverContext =
controllerCtx.getServerInvocation().getServerContext();
+ ServletContext servletContext =
serverContext.getClientRequest().getSession().getServletContext().getContext(JSPContext);
+
+ RequestDispatcher rd = servletContext.getRequestDispatcher(headerJSP);
+
+ HttpServletResponse response = new
HttpServletResponseWriter(serverContext.getClientResponse());
+ HttpServletRequest request = new
HttpServletRequestWrapper(serverContext.getClientRequest());
+
+ // Get user
Controller controller = controllerCtx.getController();
User user = controllerCtx.getUser();
-
- //
- if
(controllerCtx.getServerInvocation().getServerContext().getClientRequest().getRemoteUser()
== null)
+ request.setAttribute("org.jboss.portal.header.user", user);
+
+ // Edit dashboard page || Copy to dashboard link
+ boolean isDashboard = false;
+ if (cc instanceof RenderPageCommand)
{
- URLContext ctx =
controllerCtx.getServerInvocation().getServerContext().getURLContext();
- ctx = URLContext.newInstance(ctx.isSecure(), true);
- String loginURL = controllerCtx.renderURL(cc, ctx, null);
- sb.append("<a
href=\"").append(loginURL).append("\">Login</a>");
- }
- else
- {
- String dashboardActionURL = null;
- String dashboardActionLabel = null;
-
- boolean isDashboard = false;
- if (cc instanceof RenderPageCommand)
+ RenderPageCommand rpc = (RenderPageCommand)cc;
+ Page page = rpc.getPage();
+ String pageName = page.getName();
+ isDashboard = rpc.isDashboard();
+ //
+ if (isDashboard)
{
- RenderPageCommand rpc = (RenderPageCommand)cc;
- Page page = rpc.getPage();
- String pageName = page.getName();
- isDashboard = rpc.isDashboard();
-
+ // Edit page
+ PortletParametersStateString navState = new PortletParametersStateString();
+ navState.setValue("editPageSelect", pageName);
+ InvokePortletInstanceRenderCommand command = new
InvokePortletInstanceRenderCommand("DashboardConfigPortletInstance", navState);
+ request.setAttribute("org.jboss.portal.header.editDashboardURL",
controllerCtx.renderURL(command, null, null));
+ }
+ else
+ {
//
- if (isDashboard)
+ if (user != null)
{
- // Edit page
- PortletParametersStateString navState = new
PortletParametersStateString();
- navState.setValue("editPageSelect", pageName);
- InvokePortletInstanceRenderCommand command = new
InvokePortletInstanceRenderCommand("DashboardConfigPortletInstance", navState);
- dashboardActionURL = controllerCtx.renderURL(command, null, null);
- dashboardActionLabel = "Edit Content";
- }
- else
- {
- //
CustomizationManager cm = controller.getCustomizationManager();
Portal dashboard = cm.getDashboard(user);
if (dashboard.getChild(pageName) == null)
{
ImportPageToDashboardCommand iptdc = new
ImportPageToDashboardCommand(page.getId());
- dashboardActionURL = controllerCtx.renderURL(iptdc, null, null);
- dashboardActionLabel = "Add to dashboard";
+
request.setAttribute("org.jboss.portal.header.copyToDashboardURL",
controllerCtx.renderURL(iptdc, null, null));
}
}
+
}
+ }
- // Compute label
- String pageURL;
- String label;
- if (isDashboard)
- {
- ViewPageCommand _rpc = new ViewPageCommand(new PortalObjectId(new
String[]{"default", "default"}));
- pageURL = controllerCtx.renderURL(_rpc, null, null);
- label = "Portal";
- }
- else
- {
- //
- ViewDashboardCommand vdc = new ViewDashboardCommand();
- pageURL = controllerCtx.renderURL(vdc, null, null);
- label = "My Dashboard";
+ if (! isDashboard)
+ {
+ ViewDashboardCommand vdc = new ViewDashboardCommand();
+ request.setAttribute("org.jboss.portal.header.dashboardURL",
controllerCtx.renderURL(vdc, null, null));
+ }
+
+ boolean admin = false;
+ if (cc instanceof RenderPageCommand)
+ {
+ RenderPageCommand rpc = (RenderPageCommand)cc;
+ PortalObject portalObject = rpc.getPage().getPortal();
+ admin = "admin".equalsIgnoreCase(portalObject.getName());
+ }
- }
-
- // Link to admin/default portal
- String showadminURL = null;
- String showDefaultURL = null;
-
- // Recode me, it's not a good criteria
- boolean admin = false;
- if (cc instanceof RenderPageCommand)
+ if (!admin || isDashboard)
+ {
+ PortalObjectPermission perm = new PortalObjectPermission(new PortalObjectId(new
String[]{"admin"}), PortalObjectPermission.VIEW_MASK);
+ try
{
- RenderPageCommand rpc = (RenderPageCommand)cc;
- PortalObject portalObject = rpc.getPage().getPortal();
- admin = "admin".equalsIgnoreCase(portalObject.getName());
- }
-
- if (admin)
- {
- ViewPageCommand showDefault = new ViewPageCommand(new PortalObjectId(new
String[]{"default"}));
- showDefaultURL = controllerCtx.renderURL(showDefault, null, null);
- }
- else
- {
- PortalObjectPermission perm = new PortalObjectPermission(new
PortalObjectId(new String[]{"admin"}), PortalObjectPermission.VIEW_MASK);
- try
+ if
(controller.getPortalAuthorizationManagerFactory().getManager().checkPermission(perm))
{
- if
(controller.getPortalAuthorizationManagerFactory().getManager().checkPermission(perm))
- {
- ViewPageCommand showadmin = new ViewPageCommand(new PortalObjectId(new
String[]{"admin"}));
- showadminURL = controllerCtx.renderURL(showadmin, null, null);
- }
+ ViewPageCommand showadmin = new ViewPageCommand(new PortalObjectId(new
String[]{"admin"}));
+ request.setAttribute("org.jboss.portal.header.adminPortalURL",
controllerCtx.renderURL(showadmin, null, null));
}
- catch (PortalSecurityException e)
- {
- log.error("", e);
- }
}
-
- SignOutCommand cmd = new SignOutCommand();
- URLContext urlContext =
controllerCtx.getServerInvocation().getServerContext().getURLContext();
- String logoutURL = controllerCtx.renderURL(cmd, urlContext.asNonAuthenticated(),
null);
-
- //
- if (user != null)
+ catch (PortalSecurityException e)
{
- sb.append("Logged in as: ").append(user.getUserName());
+ log.error("", e);
}
- else
- {
- sb.append("Logged in");
- }
- sb.append("<br/><br/>");
+ }
+
+ if (admin || isDashboard)
+ {
+ // Link to default page of default portal
+ ViewPageCommand _rpc = new ViewPageCommand(new PortalObjectId(new
String[]{"default", "default"}));
+ request.setAttribute("org.jboss.portal.header.defaultPortalURL",
controllerCtx.renderURL(_rpc, null, null));
+ }
+
+ SignOutCommand cmd = new SignOutCommand();
+ URLContext urlContext =
controllerCtx.getServerInvocation().getServerContext().getURLContext();
+ String logoutURL = controllerCtx.renderURL(cmd, urlContext.asNonAuthenticated(),
null);
+ request.setAttribute("org.jboss.portal.header.signOutURL", logoutURL);
- //
- sb.append("<a
href=\"").append(pageURL).append("\">").append(label).append("</a>");
+
+ try
+ {
+ rd.include(request, response);
+ response.getWriter().flush();
+ }
+ catch (ServletException e1)
+ {
+ e1.printStackTrace();
+ }
+ catch (IOException e1)
+ {
+ e1.printStackTrace();
+ }
- //
- if (showadminURL != null)
- {
- sb.append(" | ");
- sb.append("<a
href=\"").append(showadminURL).append("\">Admin</a>");
- }
- else if (!isDashboard)
- {
- sb.append(" | ");
- sb.append("<a
href=\"").append(showDefaultURL).append("\">Main</a>");
- }
-
- // Dashboard action
- if (dashboardActionURL != null)
- {
- sb.append(" | ");
- sb.append("<a
href=\"").append(dashboardActionURL).append("\">").append(dashboardActionLabel).append("</a>");
- }
-
- //
- sb.append(" | ");
- sb.append("<a
href=\"").append(logoutURL).append("\">Logout</a>");
+ try
+ {
+ sb.append(response.getOutputStream().toString());
}
+ catch (IOException e1)
+ {
+ e1.printStackTrace();
+ }
- //
return sb;
}
public StringBuffer injectTabbedNav(RenderPageCommand rpc)
{
+ StringBuffer sb = new StringBuffer();
+ ControllerContext controllerCtx = rpc.getControllerContext();
+
+ ServerInvocationContext serverContext =
controllerCtx.getServerInvocation().getServerContext();
+ ServletContext servletContext =
serverContext.getClientRequest().getSession().getServletContext().getContext(JSPContext);
+
+ RequestDispatcher rd = servletContext.getRequestDispatcher(tabsJSP);
+
+ HttpServletResponse response = new
HttpServletResponseWriter(serverContext.getClientResponse());
+ HttpServletRequest request = new
HttpServletRequestWrapper(serverContext.getClientRequest());
+
+
+ Node root = new Node("root", null);
+
try
{
Page page = rpc.getPage();
@@ -325,15 +327,12 @@
}
sortTabs(navElements);
- StringBuffer html = new StringBuffer();
- html.append("<ul id=\"tabsHeader\">");
for (Iterator i = navElements.iterator(); i.hasNext();)
{
PortalObjectImpl navElement = (PortalObjectImpl)i.next();
// build up markup for the navigation , based on these nodes
String name = navElement.getName();
-
try
{
// localize node name
@@ -352,32 +351,21 @@
{
ViewPageCommand cmd = new ViewPageCommand(navElement.getId());
String childURL = rpc.getControllerContext().renderURL(cmd, null, null);
- html.append("<li");
- // if we were able to detect the selected node in the hierarchie level of
the nav elements,
- // then flag the node so the css can style it as the selected one
+ Node childNode = new Node(name, childURL);
if (page == navElement)
{
- html.append(" id=\"current\"");
+ childNode.current = true;
}
- html.append("
onmouseover=\"this.className='hoverOn'\"
onmouseout=\"this.className='hoverOff'\"><a
href='").append(childURL).append("'>").append(name);
+
+ root.addChild(childNode);
+ // if we were able to detect the selected node in the hierarchie level of
the nav elements,
+ // then flag the node so the css can style it as the selected one
List childPages = getAuthorizedChildrenPages(navElement);
- // ie 6 hack
- if (childPages.size() != 0)
- {
- html.append("<!--[if IE
7]><!--></a><!--<![endif]-->");
- html.append("<!--[if lte IE
6]><table><tr><td><![endif]-->");
- }
- else
- {
- html.append("</a>");
- }
-
// Submenu logic
if (childPages.size() != 0)
{
- html.append("<ul>");
for (Iterator j = childPages.iterator(); j.hasNext();)
{
PortalObject child = (PortalObject)j.next();
@@ -385,25 +373,54 @@
{
ViewPageCommand renderCmd = new ViewPageCommand(child.getId());
String subChildURL =
rpc.getControllerContext().renderURL(renderCmd, null, null);
-
- html.append("<li>").append("<a
href='").append(subChildURL).append("'>").append(child.getName()).append("</a></li>");
+ String childName = child.getName();
+ try
+ {
+ // localize node name
+ Locale requestLocale =
rpc.getControllerContext().getServerInvocation().getRequest().getLocale();
+ ResourceBundle rb =
ResourceBundle.getBundle("conf.bundles.Resource", requestLocale,
Thread.currentThread().getContextClassLoader());
+ childName = rb.getString(RESOURCE_PREFIX + childName);
+ }
+ catch (MissingResourceException e)
+ {
+ }
+ childNode.addChild(new Node(childName, subChildURL));
}
}
- html.append("</ul>");
- html.append("<!--[if lte IE
6]></td></tr></table></a><![endif]-->");
}
- html.append("</li>");
}
}
- html.append("</ul>");
-
- return html;
}
catch (Exception e)
{
log.error("", e);
- return null;
}
+
+ request.setAttribute("org.jboss.portal.header.root", root);
+
+ try
+ {
+ rd.include(request, response);
+ response.getWriter().flush();
+ }
+ catch (ServletException e1)
+ {
+ e1.printStackTrace();
+ }
+ catch (IOException e1)
+ {
+ e1.printStackTrace();
+ }
+
+ try
+ {
+ sb.append(response.getOutputStream().toString());
+ }
+ catch (IOException e1)
+ {
+ e1.printStackTrace();
+ }
+ return sb;
}
private List getAuthorizedChildrenPages(PortalObject portalObject)
@@ -478,4 +495,55 @@
}
return 4;
}
+
+ public class Node
+ {
+ public String name;
+ public List children;
+ public String url;
+ public boolean current;
+
+ public Node(String name, String url)
+ {
+ this.name = name;
+ this.url = url;
+ this.children = new ArrayList();
+ this.current = false;
+ }
+
+ public void addChild(Node node)
+ {
+ children.add(node);
+ }
+ }
+
+ public String getHeaderJSP()
+ {
+ return headerJSP;
+ }
+
+ public void setHeaderJSP(String headerJSP)
+ {
+ this.headerJSP = headerJSP;
+ }
+
+ public String getJSPContext()
+ {
+ return JSPContext;
+ }
+
+ public void setJSPContext(String context)
+ {
+ JSPContext = context;
+ }
+
+ public String getTabsJSP()
+ {
+ return tabsJSP;
+ }
+
+ public void setTabsJSP(String tabsJSP)
+ {
+ this.tabsJSP = tabsJSP;
+ }
}
Modified: trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml
===================================================================
--- trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml 2007-04-24
01:58:12 UTC (rev 7037)
+++ trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml 2007-04-24
12:59:46 UTC (rev 7038)
@@ -196,6 +196,9 @@
xmbean-dd=""
xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
<xmbean/>
+ <attribute name="JSPContext">/portal-core</attribute>
+ <attribute
name="HeaderJSP">/WEB-INF/jsp/header/header.jsp</attribute>
+ <attribute
name="TabsJSP">/WEB-INF/jsp/header/tabs.jsp</attribute>
<depends
optional-attribute-name="PortalAuthorizationManagerFactory"
proxy-type="attribute">portal:service=PortalAuthorizationManagerFactory</depends>
Added: trunk/core/src/resources/portal-core-war/WEB-INF/jsp/header/header.jsp
===================================================================
--- trunk/core/src/resources/portal-core-war/WEB-INF/jsp/header/header.jsp
(rev 0)
+++ trunk/core/src/resources/portal-core-war/WEB-INF/jsp/header/header.jsp 2007-04-24
12:59:46 UTC (rev 7038)
@@ -0,0 +1,53 @@
+<%@ page import="org.jboss.portal.identity.User" %>
+
+<%
+ User user = (User) request.getAttribute("org.jboss.portal.header.user");
+ String dashboardURL = (String)
request.getAttribute("org.jboss.portal.header.dashboardURL");
+ String defaultPortalURL = (String)
request.getAttribute("org.jboss.portal.header.defaultPortalURL");
+ String adminPortalURL = (String)
request.getAttribute("org.jboss.portal.header.adminPortalURL");
+ String editDashboardURL = (String)
request.getAttribute("org.jboss.portal.header.editDashboardURL");
+ String copyToDashboardURL = (String)
request.getAttribute("org.jboss.portal.header.copyToDashboardURL");
+ String signOutURL = (String)
request.getAttribute("org.jboss.portal.header.signOutURL");
+%>
+
+<%
+ if (user == null)
+ {
+%>
+ <a href="/portal/auth/portal/default/default">Login</a>
+<%
+ }
+ else
+ {
+%>
+Logged in as: <%= user.getUserName() %><br/><br/>
+
+<%
+ if (dashboardURL != null)
+ {
+%> <a href="<%= dashboardURL
%>">Dashboard</a> |<%
+ }
+
+ if (defaultPortalURL != null)
+ {
+%> <a href="<%= defaultPortalURL
%>">Portal</a> |<%
+ }
+
+ if (adminPortalURL != null)
+ {
+%> <a href="<%= adminPortalURL
%>">Admin</a> |<%
+ }
+
+ if (editDashboardURL != null)
+ {
+%> <a href="<%= editDashboardURL %>">Edit
page</a> |<%
+ }
+
+ if (copyToDashboardURL != null)
+ {
+%> <a href="<%= copyToDashboardURL %>">Copy
to my dashboard</a> |<%
+ }
+%> <a href="<%= signOutURL
%>">Logout</a>
+<%
+ }
+%>
\ No newline at end of file
Added: trunk/core/src/resources/portal-core-war/WEB-INF/jsp/header/tabs.jsp
===================================================================
--- trunk/core/src/resources/portal-core-war/WEB-INF/jsp/header/tabs.jsp
(rev 0)
+++ trunk/core/src/resources/portal-core-war/WEB-INF/jsp/header/tabs.jsp 2007-04-24
12:59:46 UTC (rev 7038)
@@ -0,0 +1,48 @@
+<%@ page
import="org.jboss.portal.core.aspects.controller.PageCustomizerInterceptor.Node"
%>
+<%@ page import="java.util.Iterator" %>
+
+<%
+ Node root = (Node) request.getAttribute("org.jboss.portal.header.root");
+%>
+
+<ul id="tabsHeader">
+<%
+ Iterator childrenIt = root.children.iterator();
+ while (childrenIt.hasNext())
+ {
+ Node child = (Node)childrenIt.next();
+%>
+ <li <% if(child.current) out.println(" id=\"current\"");
%> onmouseover="this.className='hoverOn'"
onmouseout="this.className='hoverOff'"><a href="<%=
child.url %>"><%= child.name %>
+<%
+ if (child.children.size() == 0)
+ {
+%>
+ </a>
+<%
+ }
+ else
+ {
+%>
+ <!--[if IE 7]><!--></a><!--<![endif]-->
+ <!--[if lte IE 6]><table><tr><td><![endif]-->
+ <ul>
+<%
+ for (Iterator j = child.children.iterator(); j.hasNext();)
+ {
+ Node subChild = (Node)j.next();
+%>
+ <li><a href='<%= subChild.url %>'><%=
subChild.name %></a></li>
+<%
+ }
+%>
+ </ul>
+ <!--[if lte IE
6]></td></tr></table></a><![endif]-->
+<%
+ }
+%>
+ </li>
+<%
+ }
+
+%>
+</ul>