Author: thomas.heute(a)jboss.com
Date: 2008-08-28 05:05:23 -0400 (Thu, 28 Aug 2008)
New Revision: 11754
Added:
branches/JBoss_Portal_Branch_2_7/theme/src/main/org/jboss/portal/theme/tag/TitleTagHandler.java
Modified:
branches/JBoss_Portal_Branch_2_7/core-cms/src/main/org/jboss/portal/core/cms/ui/CMSPortlet.java
branches/JBoss_Portal_Branch_2_7/core-cms/src/resources/portal-cms-war/WEB-INF/portlet.xml
branches/JBoss_Portal_Branch_2_7/core/.classpath
branches/JBoss_Portal_Branch_2_7/core/src/bin/portal-core-war/layouts/1column/index.jsp
branches/JBoss_Portal_Branch_2_7/core/src/bin/portal-core-war/layouts/3columns/index.jsp
branches/JBoss_Portal_Branch_2_7/core/src/bin/portal-core-war/layouts/generic/index.jsp
branches/JBoss_Portal_Branch_2_7/core/src/bin/portal-core-war/layouts/generic/maximized.jsp
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/impl/model/content/InternalContentProvider.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/instance/command/render/RenderPortletInstanceCommand.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/response/MarkupResponse.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/control/portal/DefaultPortalControlPolicy.java
branches/JBoss_Portal_Branch_2_7/core/src/resources/portal-core-sar/conf/theme/portal-layout.tld
branches/JBoss_Portal_Branch_2_7/theme/src/main/org/jboss/portal/test/theme/DynaTestContext.java
branches/JBoss_Portal_Branch_2_7/theme/src/main/org/jboss/portal/test/theme/tmp/TestHelper.java
branches/JBoss_Portal_Branch_2_7/theme/src/main/org/jboss/portal/theme/page/WindowResult.java
branches/JBoss_Portal_Branch_2_7/theme/src/main/org/jboss/portal/theme/tag/HeaderContentTagHandler.java
Log:
JBPORTAL-2144: Let a portlet defines the browser title
Modified: branches/JBoss_Portal_Branch_2_7/core/.classpath
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core/.classpath 2008-08-27 20:59:49 UTC (rev 11753)
+++ branches/JBoss_Portal_Branch_2_7/core/.classpath 2008-08-28 09:05:23 UTC (rev 11754)
@@ -48,7 +48,7 @@
<classpathentry kind="lib"
path="/thirdparty/jbossas/core-libs/lib/jbossha.jar"/>
<classpathentry kind="lib"
path="/thirdparty/jboss-portal/modules/test/lib/portal-test-lib.jar"/>
<classpathentry kind="lib"
path="/thirdparty/jboss-portal/modules/portlet/lib/portal-portlet-federation-lib.jar"
sourcepath="/module-portlet-trunk"/>
- <classpathentry kind="lib"
path="/thirdparty/jboss-portal/modules/portlet/lib/portal-portlet-lib.jar"
sourcepath="/module-portlet-trunk"/>
+ <classpathentry kind="lib"
path="/thirdparty/jboss-portal/modules/portlet/lib/portal-portlet-lib.jar"
sourcepath="/module-portlet"/>
<classpathentry kind="lib"
path="/thirdparty/portlet/lib/portlet-api.jar"/>
<classpathentry kind="lib"
path="/thirdparty/jboss-portal/modules/portlet/lib/portal-portlet-controller-lib.jar"
sourcepath="/module-portlet-2.0.0.CR2"/>
<classpathentry kind="lib"
path="/thirdparty/jboss/cache/lib/jboss-cache-jdk50.jar"/>
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/bin/portal-core-war/layouts/1column/index.jsp
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core/src/bin/portal-core-war/layouts/1column/index.jsp 2008-08-27
20:59:49 UTC (rev 11753)
+++
branches/JBoss_Portal_Branch_2_7/core/src/bin/portal-core-war/layouts/1column/index.jsp 2008-08-28
09:05:23 UTC (rev 11754)
@@ -6,7 +6,7 @@
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
xmlns="http://www.w3.org/1999/xhtml">
<head>
- <title><%= PortalConstants.VERSION.toString() %></title>
+ <title><p:title default="<%= PortalConstants.VERSION.toString()
%>"/></title>
<meta http-equiv="Content-Type" content="text/html;"/>
<!-- to correct the unsightly Flash of Unstyled Content. -->
<script type="text/javascript"></script>
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/bin/portal-core-war/layouts/3columns/index.jsp
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core/src/bin/portal-core-war/layouts/3columns/index.jsp 2008-08-27
20:59:49 UTC (rev 11753)
+++
branches/JBoss_Portal_Branch_2_7/core/src/bin/portal-core-war/layouts/3columns/index.jsp 2008-08-28
09:05:23 UTC (rev 11754)
@@ -6,7 +6,7 @@
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
xmlns="http://www.w3.org/1999/xhtml">
<head>
- <title><%= PortalConstants.VERSION.toString() %></title>
+ <title><p:title default="<%= PortalConstants.VERSION.toString()
%>"/></title>
<meta http-equiv="Content-Type" content="text/html;"/>
<!-- to correct the unsightly Flash of Unstyled Content. -->
<script type="text/javascript"></script>
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/bin/portal-core-war/layouts/generic/index.jsp
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core/src/bin/portal-core-war/layouts/generic/index.jsp 2008-08-27
20:59:49 UTC (rev 11753)
+++
branches/JBoss_Portal_Branch_2_7/core/src/bin/portal-core-war/layouts/generic/index.jsp 2008-08-28
09:05:23 UTC (rev 11754)
@@ -6,7 +6,7 @@
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
xmlns="http://www.w3.org/1999/xhtml">
<head>
- <title><%= PortalConstants.VERSION.toString() %></title>
+ <title><p:title default="<%= PortalConstants.VERSION.toString()
%>"/></title>
<meta http-equiv="Content-Type" content="text/html;"/>
<!-- to correct the unsightly Flash of Unstyled Content. -->
<script type="text/javascript"></script>
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/bin/portal-core-war/layouts/generic/maximized.jsp
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core/src/bin/portal-core-war/layouts/generic/maximized.jsp 2008-08-27
20:59:49 UTC (rev 11753)
+++
branches/JBoss_Portal_Branch_2_7/core/src/bin/portal-core-war/layouts/generic/maximized.jsp 2008-08-28
09:05:23 UTC (rev 11754)
@@ -6,7 +6,7 @@
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
xmlns="http://www.w3.org/1999/xhtml">
<head>
- <title><%= PortalConstants.VERSION.toString() %></title>
+ <title><p:title default="<%= PortalConstants.VERSION.toString()
%>"/></title>
<meta http-equiv="Content-Type" content="text/html;"/>
<!-- to correct the unsightly Flash of Unstyled Content. -->
<script type="text/javascript"></script>
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/impl/model/content/InternalContentProvider.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/impl/model/content/InternalContentProvider.java 2008-08-27
20:59:49 UTC (rev 11753)
+++
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/impl/model/content/InternalContentProvider.java 2008-08-28
09:05:23 UTC (rev 11754)
@@ -376,22 +376,13 @@
windowTitle = window.getName();
}
- String header = "";
+ List<Element> headElements = null;
ResponseProperties properties = fragment.getProperties();
if (properties != null)
{
// header handling
MultiValuedPropertyMap<Element> headers =
properties.getMarkupHeaders();
- List<Element> headElements =
headers.getValues(MimeResponse.MARKUP_HEAD_ELEMENT);
- if (headElements != null)
- {
- StringBuffer buffer = new StringBuffer(124 * headElements.size());
- for (Element element : headElements)
- {
- buffer.append(element);
- }
- header = buffer.toString();
- }
+ headElements = headers.getValues(MimeResponse.MARKUP_HEAD_ELEMENT);
// deal with partial refresh
MultiValuedPropertyMap<String> transport =
properties.getTransportHeaders();
@@ -416,7 +407,7 @@
}
//
- cr = new MarkupResponse(windowTitle, contentChars, header);
+ cr = new MarkupResponse(windowTitle, contentChars, headElements);
}
else if (response instanceof ErrorResponse)
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/instance/command/render/RenderPortletInstanceCommand.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/instance/command/render/RenderPortletInstanceCommand.java 2008-08-27
20:59:49 UTC (rev 11753)
+++
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/instance/command/render/RenderPortletInstanceCommand.java 2008-08-28
09:05:23 UTC (rev 11754)
@@ -87,7 +87,7 @@
// For now let the controller handle non fragment response
String content;
- String header = "";
+ List<Element> headElements = null;
if (response instanceof FragmentResponse)
{
FragmentResponse fragment = (FragmentResponse)response;
@@ -97,16 +97,7 @@
{
// header handling
MultiValuedPropertyMap<Element> headers =
properties.getMarkupHeaders();
- List<Element> headElements =
headers.getValues(MimeResponse.MARKUP_HEAD_ELEMENT);
- if (headElements != null)
- {
- StringBuffer buffer = new StringBuffer(124 * headElements.size());
- for (Element element : headElements)
- {
- buffer.append(element);
- }
- header = buffer.toString();
- }
+ headElements = headers.getValues(MimeResponse.MARKUP_HEAD_ELEMENT);
}
}
else if (response instanceof ErrorResponse)
@@ -134,7 +125,7 @@
windowProps.put(ThemeConstants.PORTAL_PROP_PORTLET_RENDERER,
"emptyRenderer");
//
- WindowResult res = new WindowResult("", content,
Collections.EMPTY_MAP, windowProps, header, WindowState.MAXIMIZED, Mode.VIEW);
+ WindowResult res = new WindowResult("", content,
Collections.EMPTY_MAP, windowProps, headElements, WindowState.MAXIMIZED, Mode.VIEW);
WindowContext blah = new WindowContext("BILTO", "maximized",
"0", res);
result.addWindowContext(blah);
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/response/MarkupResponse.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/response/MarkupResponse.java 2008-08-27
20:59:49 UTC (rev 11753)
+++
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/response/MarkupResponse.java 2008-08-28
09:05:23 UTC (rev 11754)
@@ -22,7 +22,10 @@
******************************************************************************/
package org.jboss.portal.core.model.portal.command.response;
+import java.util.List;
+
import org.jboss.portal.core.controller.ControllerResponse;
+import org.w3c.dom.Element;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -38,9 +41,9 @@
private final String content;
/** . */
- private final String headerContent;
+ private final List<Element> headerContent;
- public MarkupResponse(String title, String content, String headerContent)
+ public MarkupResponse(String title, String content, List<Element>
headerContent)
{
this.title = title;
this.content = content;
@@ -57,7 +60,7 @@
return content;
}
- public String getHeaderContent()
+ public List<Element> getHeaderContent()
{
return headerContent;
}
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/control/portal/DefaultPortalControlPolicy.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/control/portal/DefaultPortalControlPolicy.java 2008-08-27
20:59:49 UTC (rev 11753)
+++
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/control/portal/DefaultPortalControlPolicy.java 2008-08-28
09:05:23 UTC (rev 11754)
@@ -173,7 +173,7 @@
windowProps.put(ThemeConstants.PORTAL_PROP_PORTLET_RENDERER,
"emptyRenderer");
//
- WindowResult res = new WindowResult("", rd.getMarkup(),
Collections.EMPTY_MAP, windowProps, "", WindowState.MAXIMIZED, Mode.VIEW);
+ WindowResult res = new WindowResult("", rd.getMarkup(),
Collections.EMPTY_MAP, windowProps, null, WindowState.MAXIMIZED, Mode.VIEW);
WindowContext blah = new WindowContext("BILTO",
"maximized", "0", res);
result.addWindowContext(blah);
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/resources/portal-core-sar/conf/theme/portal-layout.tld
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core/src/resources/portal-core-sar/conf/theme/portal-layout.tld 2008-08-27
20:59:49 UTC (rev 11753)
+++
branches/JBoss_Portal_Branch_2_7/core/src/resources/portal-core-sar/conf/theme/portal-layout.tld 2008-08-28
09:05:23 UTC (rev 11754)
@@ -65,4 +65,13 @@
<tag-class>org.jboss.portal.theme.tag.HeaderContentTagHandler</tag-class>
<body-content>empty</body-content>
</tag>
+ <tag>
+ <name>title</name>
+ <tag-class>org.jboss.portal.theme.tag.TitleTagHandler</tag-class>
+ <body-content>empty</body-content>
+ <attribute>
+ <name>default</name>
+ <rtexprvalue>true</rtexprvalue>
+ </attribute>
+ </tag>
</taglib>
Modified:
branches/JBoss_Portal_Branch_2_7/core-cms/src/main/org/jboss/portal/core/cms/ui/CMSPortlet.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core-cms/src/main/org/jboss/portal/core/cms/ui/CMSPortlet.java 2008-08-27
20:59:49 UTC (rev 11753)
+++
branches/JBoss_Portal_Branch_2_7/core-cms/src/main/org/jboss/portal/core/cms/ui/CMSPortlet.java 2008-08-28
09:05:23 UTC (rev 11754)
@@ -38,10 +38,12 @@
import org.jboss.portal.server.request.URLContext;
import org.jboss.portal.server.request.URLFormat;
import org.jboss.portlet.JBossRenderRequest;
+import org.w3c.dom.Element;
import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import javax.portlet.GenericPortlet;
+import javax.portlet.MimeResponse;
import javax.portlet.PortletConfig;
import javax.portlet.PortletException;
import javax.portlet.PortletMode;
@@ -188,17 +190,40 @@
// Only the editor uses it for now, so just forward
hack.processAction(request, response);
}
-
- protected void doView(RenderRequest req, RenderResponse resp) throws PortletException,
PortletSecurityException, IOException
+
+ private File getFile(String path, Locale locale, PortletPreferences prefs)
{
- String path = req.getParameter(RENDER_PARAMETER_PATH);
if (path == null)
{
- PortletPreferences prefs = req.getPreferences();
path = prefs.getValue("indexpage", "/default/index.html");
}
+ File file = null;
+
+ // Get the file from the CMS, localized.
+ Command fileGet = CMSService.getCommandFactory().createFileGetCommand(path,
locale);
+ file = (File)CMSService.execute(fileGet);
+
//
+ if (file == null)
+ {
+ fileGet = CMSService.getCommandFactory().createFileGetCommand(path, new
Locale(CMSService.getDefaultLocale()));
+ file = (File)CMSService.execute(fileGet);
+ }
+ return file;
+ }
+
+ protected void doView(RenderRequest req, RenderResponse resp) throws PortletException,
PortletSecurityException, IOException
+ {
+ // Get the file obtain from doHeaders
+ File file = (File)req.getAttribute("file");
+
+ if (file == null)
+ {
+ String path = req.getParameter(RENDER_PARAMETER_PATH);
+ file = getFile (path, req.getLocale(), req.getPreferences());
+ }
+ //
URLFactory textURLFactory = null;
if (InternalCMSContentProvider.useGlobalURL())
{
@@ -211,22 +236,10 @@
//
URLFactory resourceURLFactory = new
GlobalURLFactory(((JBossRenderRequest)req).getControllerContext());
-
- //
+ String path = file.getBasePath();
+
try
{
-
- // Get the file from the CMS, localized.
- Command fileGet = CMSService.getCommandFactory().createFileGetCommand(path,
req.getLocale());
- File file = (File)CMSService.execute(fileGet);
-
- //
- if (file == null)
- {
- fileGet = CMSService.getCommandFactory().createFileGetCommand(path, new
Locale(CMSService.getDefaultLocale()));
- file = (File)CMSService.execute(fileGet);
- }
-
// Translate links to resources.
String sHTML = null;
resp.setContentType("text/html");
@@ -357,6 +370,20 @@
PortletRequestDispatcher prd =
getPortletContext().getRequestDispatcher(CMS_JSP_PATH + "/edit.jsp");
prd.include(req, resp);
}
+
+ public void doHeaders(RenderRequest req, RenderResponse resp)
+ {
+ String path = req.getParameter(RENDER_PARAMETER_PATH);
+ File file = getFile (path, req.getLocale(), req.getPreferences());
+
+ req.setAttribute("file", file);
+ if
("true".equals(req.getPreferences().getValue("setBrowserTitle",
"false").toLowerCase()) && file.getContent().getTitle() != null)
+ {
+ Element element = resp.createElement("title");
+ element.setTextContent(file.getContent().getTitle());
+ resp.addProperty(MimeResponse.MARKUP_HEAD_ELEMENT, element);
+ }
+ }
/**
*
@@ -372,8 +399,6 @@
content = h.group(2);
}
}
-
-
return content;
}
Modified:
branches/JBoss_Portal_Branch_2_7/core-cms/src/resources/portal-cms-war/WEB-INF/portlet.xml
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core-cms/src/resources/portal-cms-war/WEB-INF/portlet.xml 2008-08-27
20:59:49 UTC (rev 11753)
+++
branches/JBoss_Portal_Branch_2_7/core-cms/src/resources/portal-cms-war/WEB-INF/portlet.xml 2008-08-28
09:05:23 UTC (rev 11754)
@@ -54,9 +54,17 @@
<name>indexpage</name>
<value>/default/index.html</value>
</preference>
+ <!-- Set the Web Browser title with the CMS content title
+ Note that if there are two portlets on a page defining the title
+ It will randomly pick one of them.
+ -->
+ <preference>
+ <name>setBrowserTitle</name>
+ <value>false</value>
+ </preference>
</portlet-preferences>
+ <supported-publishing-event
xmlns:x="urn:jboss:portal:content">x:select</supported-publishing-event>
<supported-public-render-parameter>uri</supported-public-render-parameter>
- <supported-publishing-event
xmlns:x="urn:jboss:portal:content">x:select</supported-publishing-event>
</portlet>
<portlet>
@@ -122,4 +130,9 @@
<qname xmlns:c="urn:jboss:portal:content">c:uri</qname>
</public-render-parameter>
+ <public-render-parameter>
+ <identifier>title</identifier>
+ <qname xmlns:jbp="urn:jboss:portal:page">jbp:title</qname>
+ </public-render-parameter>
+
</portlet-app>
Modified:
branches/JBoss_Portal_Branch_2_7/theme/src/main/org/jboss/portal/test/theme/DynaTestContext.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/theme/src/main/org/jboss/portal/test/theme/DynaTestContext.java 2008-08-27
20:59:49 UTC (rev 11753)
+++
branches/JBoss_Portal_Branch_2_7/theme/src/main/org/jboss/portal/test/theme/DynaTestContext.java 2008-08-28
09:05:23 UTC (rev 11754)
@@ -330,7 +330,7 @@
wrc.getPortlet().getMarkup(),
new HashMap(),
wrc.getProperties(),
- "",
+ null,
wrc.getWindowState(),
wrc.getMode());
WindowContext wc = new WindowContext(wrc.getId(), rrc.getId(),
Integer.toString(j.getIndex()), wr);
Modified:
branches/JBoss_Portal_Branch_2_7/theme/src/main/org/jboss/portal/test/theme/tmp/TestHelper.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/theme/src/main/org/jboss/portal/test/theme/tmp/TestHelper.java 2008-08-27
20:59:49 UTC (rev 11753)
+++
branches/JBoss_Portal_Branch_2_7/theme/src/main/org/jboss/portal/test/theme/tmp/TestHelper.java 2008-08-28
09:05:23 UTC (rev 11754)
@@ -123,8 +123,7 @@
{
// setup the window result
Map actionsMap = Collections.EMPTY_MAP;
- String headerChars = null;
- return new WindowResult(title, content, actionsMap, windowProps, headerChars, null,
null);
+ return new WindowResult(title, content, actionsMap, windowProps, null, null,
null);
}
public static RenderSetMetaData createRenderSetMD() throws Exception
Modified:
branches/JBoss_Portal_Branch_2_7/theme/src/main/org/jboss/portal/theme/page/WindowResult.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/theme/src/main/org/jboss/portal/theme/page/WindowResult.java 2008-08-27
20:59:49 UTC (rev 11753)
+++
branches/JBoss_Portal_Branch_2_7/theme/src/main/org/jboss/portal/theme/page/WindowResult.java 2008-08-28
09:05:23 UTC (rev 11754)
@@ -25,9 +25,11 @@
import org.jboss.portal.Mode;
import org.jboss.portal.WindowState;
import org.jboss.portal.theme.render.renderer.ActionRendererContext;
+import org.w3c.dom.Element;
import java.util.Collection;
import java.util.Collections;
+import java.util.List;
import java.util.Map;
/**
@@ -50,7 +52,7 @@
private Map actions;
/** . */
- private final String headerContent;
+ private final List<Element> headerContent;
/** . */
private Map properties;
@@ -78,14 +80,14 @@
String content,
Map actions,
Map windowProperties,
- String headerChars,
+ List<Element> headerContent,
WindowState windowState,
Mode mode)
{
this.title = title;
this.content = content;
this.actions = actions;
- this.headerContent = headerChars;
+ this.headerContent = headerContent;
this.properties = windowProperties;
this.windowState = windowState;
this.mode = mode;
@@ -101,7 +103,7 @@
return content;
}
- public String getHeaderContent()
+ public List<Element> getHeaderContent()
{
return headerContent;
}
Modified:
branches/JBoss_Portal_Branch_2_7/theme/src/main/org/jboss/portal/theme/tag/HeaderContentTagHandler.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/theme/src/main/org/jboss/portal/theme/tag/HeaderContentTagHandler.java 2008-08-27
20:59:49 UTC (rev 11753)
+++
branches/JBoss_Portal_Branch_2_7/theme/src/main/org/jboss/portal/theme/tag/HeaderContentTagHandler.java 2008-08-28
09:05:23 UTC (rev 11754)
@@ -26,6 +26,7 @@
import org.jboss.portal.theme.page.PageResult;
import org.jboss.portal.theme.page.WindowContext;
import org.jboss.portal.theme.page.WindowResult;
+import org.w3c.dom.Element;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.JspException;
@@ -34,6 +35,7 @@
import javax.servlet.jsp.tagext.SimpleTagSupport;
import java.io.IOException;
import java.util.Iterator;
+import java.util.List;
import java.util.Map;
/**
@@ -70,9 +72,18 @@
{
WindowContext wc = (WindowContext)i.next();
WindowResult result = wc.getResult();
- if (result.getHeaderContent() != null)
+ List<Element> headElements = result.getHeaderContent();
+ if (headElements != null)
{
- out.println(result.getHeaderContent());
+ StringBuffer buffer = new StringBuffer(124 * headElements.size());
+ for (Element element : headElements)
+ {
+ if (!"title".equals(element.getNodeName().toLowerCase()))
+ {
+ buffer.append(element);
+ }
+ }
+ out.println(buffer.toString());
}
}
out.flush();
Added:
branches/JBoss_Portal_Branch_2_7/theme/src/main/org/jboss/portal/theme/tag/TitleTagHandler.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/theme/src/main/org/jboss/portal/theme/tag/TitleTagHandler.java
(rev 0)
+++
branches/JBoss_Portal_Branch_2_7/theme/src/main/org/jboss/portal/theme/tag/TitleTagHandler.java 2008-08-28
09:05:23 UTC (rev 11754)
@@ -0,0 +1,102 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, 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.theme.tag;
+
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.JspWriter;
+import javax.servlet.jsp.PageContext;
+import javax.servlet.jsp.tagext.SimpleTagSupport;
+
+import org.jboss.portal.theme.LayoutConstants;
+import org.jboss.portal.theme.page.PageResult;
+import org.jboss.portal.theme.page.WindowContext;
+import org.jboss.portal.theme.page.WindowResult;
+import org.w3c.dom.Element;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class TitleTagHandler extends SimpleTagSupport
+{
+
+ private String defaultTitle = "JBoss Portal";
+
+ public void doTag() throws JspException, IOException
+ {
+ // Get page and region
+ PageContext app = (PageContext)getJspContext();
+ HttpServletRequest request = (HttpServletRequest)app.getRequest();
+
+ //
+ PageResult page = (PageResult)request.getAttribute(LayoutConstants.ATTR_PAGE);
+ JspWriter out = this.getJspContext().getOut();
+ if (page == null)
+ {
+ out.write("<p bgcolor='red'>No page to
render!</p>");
+ out.write("<p bgcolor='red'>The page to render (PageResult)
must be set in the request attribute '" + LayoutConstants.ATTR_PAGE +
"'</p>");
+ out.flush();
+ return;
+ }
+
+ //
+ Map results = page.getWindowContextMap();
+ String title = defaultTitle;
+ for (Iterator i = results.values().iterator(); i.hasNext();)
+ {
+ WindowContext wc = (WindowContext)i.next();
+ WindowResult result = wc.getResult();
+ List<Element> headElements = result.getHeaderContent();
+ if (headElements != null)
+ {
+ for (Element element : headElements)
+ {
+ if ("title".equals(element.getNodeName().toLowerCase())
&& element.getFirstChild() != null)
+ {
+ title = element.getFirstChild().getTextContent();
+ break;
+ }
+ }
+ }
+ }
+ out.println(title);
+ out.flush();
+ }
+
+ public void setDefault(String defaultTitle)
+ {
+ this.defaultTitle = defaultTitle;
+ }
+
+ public String getDefault()
+ {
+ return defaultTitle;
+ }
+}
+