Author: julien(a)jboss.com
Date: 2007-03-30 08:16:16 -0400 (Fri, 30 Mar 2007)
New Revision: 6876
Added:
trunk/theme/src/main/org/jboss/portal/theme/page/render/
trunk/theme/src/main/org/jboss/portal/theme/page/render/DecorationRenderContextImpl.java
trunk/theme/src/main/org/jboss/portal/theme/page/render/PageRenderContextImpl.java
trunk/theme/src/main/org/jboss/portal/theme/page/render/PortletRenderContextImpl.java
trunk/theme/src/main/org/jboss/portal/theme/page/render/RegionRenderContextImpl.java
trunk/theme/src/main/org/jboss/portal/theme/page/render/WindowRenderContextImpl.java
trunk/theme/src/main/org/jboss/portal/theme/render/PageRenderContext.java
Modified:
trunk/theme/src/main/org/jboss/portal/test/theme/servlet/TestThemeServlet.java
trunk/theme/src/main/org/jboss/portal/theme/LayoutServiceInfo.java
trunk/theme/src/main/org/jboss/portal/theme/PortalLayout.java
trunk/theme/src/main/org/jboss/portal/theme/impl/LayoutServiceImpl.java
trunk/theme/src/main/org/jboss/portal/theme/impl/render/div/DivRegionRenderer.java
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaRegionRenderer.java
trunk/theme/src/main/org/jboss/portal/theme/page/Region.java
trunk/theme/src/main/org/jboss/portal/theme/render/DecorationRenderContext.java
trunk/theme/src/main/org/jboss/portal/theme/render/RegionRenderContext.java
trunk/theme/src/main/org/jboss/portal/theme/render/RenderContext.java
trunk/theme/src/main/org/jboss/portal/theme/render/WindowRenderContext.java
trunk/theme/src/main/org/jboss/portal/theme/tag/PortletTagHandler.java
trunk/theme/src/main/org/jboss/portal/theme/tag/RegionTagHandler.java
Log:
decouple RenderContex from the page object model and use the XXXRenderContext instead
Modified: trunk/theme/src/main/org/jboss/portal/test/theme/servlet/TestThemeServlet.java
===================================================================
---
trunk/theme/src/main/org/jboss/portal/test/theme/servlet/TestThemeServlet.java 2007-03-29
23:49:25 UTC (rev 6875)
+++
trunk/theme/src/main/org/jboss/portal/test/theme/servlet/TestThemeServlet.java 2007-03-30
12:16:16 UTC (rev 6876)
@@ -39,6 +39,7 @@
import org.jboss.portal.theme.page.WindowContext;
import org.jboss.portal.theme.page.WindowResult;
import org.jboss.portal.theme.page.PageResult;
+import org.jboss.portal.theme.page.render.PageRenderContextImpl;
import org.jboss.portal.theme.render.PortalRenderSet;
import org.jboss.portal.theme.render.RenderContext;
@@ -128,7 +129,7 @@
}
// set the renderctx and req/res attr
- RenderContext renderCtx = new RenderContext(layout, markupInfo, pageResult,
serverRequest);
+ RenderContext renderCtx = new RenderContext(layout, markupInfo, new
PageRenderContextImpl(pageResult), serverRequest);
response.setContentType(renderCtx.getContentType().toString());
response.setCharacterEncoding(renderCtx.getCharset());
request.setAttribute(LayoutConstants.ATTR_RENDERCONTEXT, renderCtx);
Modified: trunk/theme/src/main/org/jboss/portal/theme/LayoutServiceInfo.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/LayoutServiceInfo.java 2007-03-29 23:49:25
UTC (rev 6875)
+++ trunk/theme/src/main/org/jboss/portal/theme/LayoutServiceInfo.java 2007-03-30 12:16:16
UTC (rev 6876)
@@ -91,5 +91,5 @@
*/
Collection getRenderSets();
- PortalRenderSet getRenderSet(LayoutInfo info, ContentInfo streamInfo, PageResult
result);
+ PortalRenderSet getRenderSet(LayoutInfo info, ContentInfo streamInfo, String
renderSetName);
}
Modified: trunk/theme/src/main/org/jboss/portal/theme/PortalLayout.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/PortalLayout.java 2007-03-29 23:49:25 UTC
(rev 6875)
+++ trunk/theme/src/main/org/jboss/portal/theme/PortalLayout.java 2007-03-30 12:16:16 UTC
(rev 6876)
@@ -24,9 +24,9 @@
import org.jboss.portal.server.ServerInvocation;
import org.jboss.portal.server.ServerRequest;
-import org.jboss.portal.common.util.ContentInfo;
import org.jboss.portal.common.util.MarkupInfo;
import org.jboss.portal.theme.render.RenderContext;
+import org.jboss.portal.theme.page.render.PageRenderContextImpl;
import org.jboss.portal.theme.page.PageResult;
import javax.servlet.ServletException;
@@ -103,6 +103,6 @@
*/
public RenderContext getRenderContext(MarkupInfo markupInfo, ServerRequest request,
PageResult markupResult)
{
- return new RenderContext(this, markupInfo, markupResult, request);
+ return new RenderContext(this, markupInfo, new PageRenderContextImpl(markupResult),
request);
}
}
Modified: trunk/theme/src/main/org/jboss/portal/theme/impl/LayoutServiceImpl.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/impl/LayoutServiceImpl.java 2007-03-29
23:49:25 UTC (rev 6875)
+++ trunk/theme/src/main/org/jboss/portal/theme/impl/LayoutServiceImpl.java 2007-03-30
12:16:16 UTC (rev 6876)
@@ -32,8 +32,6 @@
import org.jboss.portal.theme.PortalLayout;
import org.jboss.portal.theme.RuntimeContext;
import org.jboss.portal.theme.ServerRegistrationID;
-import org.jboss.portal.theme.ThemeConstants;
-import org.jboss.portal.theme.page.PageResult;
import org.jboss.portal.theme.metadata.PortalLayoutMetaData;
import org.jboss.portal.theme.metadata.RenderSetMetaData;
import org.jboss.portal.theme.metadata.RendererSetMetaData;
@@ -155,7 +153,6 @@
}
}
- /** @see LayoutService#setDefaultLayout(String) */
public void setDefaultLayoutName(String name) throws LayoutException
{
log.debug("setting default: " + name);
@@ -412,44 +409,14 @@
* specifically for a layout, a page, or a portal. The one defined for the layout
overwrites the one defined for the
* page, which in turn overwrites the one defined for the portal. The render set is
defined for a specific content
* type (media type), which will be determined from the provided
HttpStreamInfo.</p>
- *
- * @param info
- * @param result
- * @return a renderSet to decorate the markup fragments on the page with
*/
- public PortalRenderSet getRenderSet(LayoutInfo info, ContentInfo streamInfo,
PageResult result)
+ public PortalRenderSet getRenderSet(LayoutInfo info, ContentInfo streamInfo, String
renderSetName)
{
- if (info == null || result == null || streamInfo == null)
+ if (info == null || renderSetName == null || streamInfo == null)
{
- throw new IllegalArgumentException("No null arguments allowed [" +
info + "] [" + result + "] [" + streamInfo + "]");
+ throw new IllegalArgumentException("No null arguments allowed [" +
info + "] [" + renderSetName + "] [" + streamInfo + "]");
}
MediaType contentType = streamInfo.getContentType();
- PortalRenderSet renderSet = getRenderSetFromProperties(contentType,
result.getPageProperties());
- if (renderSet == null)
- {
- renderSet = getRenderSetFromProperties(contentType,
result.getPortalProperties());
- }
- return renderSet;
+ return getRenderSet(renderSetName, contentType);
}
-
- /**
- * Get the render set property from the provided properties (if one is present), and
then get the render set for that
- * property and media type from the layout service.
- *
- * @param contentType
- * @param properties
- * @return the PortalRenderSet that was defined for the provided params
- */
- private PortalRenderSet getRenderSetFromProperties(MediaType contentType, Map
properties)
- {
- if (properties != null)
- {
- String renderSetName =
(String)properties.get(ThemeConstants.PORTAL_PROP_RENDERSET);
- if (renderSetName != null)
- {
- return getRenderSet(renderSetName, contentType);
- }
- }
- return null;
- }
}
Modified:
trunk/theme/src/main/org/jboss/portal/theme/impl/render/div/DivRegionRenderer.java
===================================================================
---
trunk/theme/src/main/org/jboss/portal/theme/impl/render/div/DivRegionRenderer.java 2007-03-29
23:49:25 UTC (rev 6875)
+++
trunk/theme/src/main/org/jboss/portal/theme/impl/render/div/DivRegionRenderer.java 2007-03-30
12:16:16 UTC (rev 6876)
@@ -57,18 +57,21 @@
}
else
{
- if (renderContext.getRegionId() != null)
+ if (rrc.getCSSId() != null)
{
- markup.append("
id='").append(renderContext.getRegionId()).append("'>");
+ markup.append("
id='").append(rrc.getCSSId()).append("'>");
}
}
+
//
for (Iterator i = rrc.getWindowRenderContexts().iterator(); i.hasNext();)
{
WindowRenderContext wrc = (WindowRenderContext)i.next();
renderContext.render(wrc);
}
+
+ //
markup.append("</div>");
}
Modified:
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaRegionRenderer.java
===================================================================
---
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaRegionRenderer.java 2007-03-29
23:49:25 UTC (rev 6875)
+++
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaRegionRenderer.java 2007-03-30
12:16:16 UTC (rev 6876)
@@ -23,16 +23,12 @@
package org.jboss.portal.theme.impl.render.dynamic;
-import org.jboss.logging.Logger;
import org.jboss.portal.theme.ThemeConstants;
import org.jboss.portal.theme.render.RegionRenderer;
import org.jboss.portal.theme.render.RenderContext;
import org.jboss.portal.theme.render.RenderException;
import org.jboss.portal.theme.render.RegionRenderContext;
-import java.util.HashMap;
-import java.util.Map;
-
/**
* Implementation of a drag and drop Region renderer.
*
@@ -42,16 +38,13 @@
*/
public class DynaRegionRenderer implements RegionRenderer
{
- private Map portletPos = new HashMap(); //<String, Integer>
- private Map windowIds = new HashMap();
+ /** . */
+ private static final ThreadLocal enabledLocal = new ThreadLocal();
- private final static Logger log = Logger.getLogger(DynaRegionRenderer.class);
-
+ /** . */
private RegionRenderer delegate;
- private static final ThreadLocal enabledLocal = new ThreadLocal();
-
public static boolean isEnabled()
{
return Boolean.TRUE == enabledLocal.get();
@@ -65,17 +58,14 @@
}
/** @see RegionRenderer#render */
- public void render(RenderContext renderContext, RegionRenderContext rrc) throws
RenderException
+ public void render(RenderContext renderContext, final RegionRenderContext rrc) throws
RenderException
{
- Map pageProps = renderContext.getPageProperties();
-
-
StringBuffer markup = renderContext.getMarkupFragment();
- String jsBase = (String)pageProps.get(ThemeConstants.PORTAL_AJAX_JAVASCRIPT_BASE);
- String remoteURL = (String)pageProps.get(ThemeConstants.PORTAL_AJAX_REMOTE_URL);
+ String jsBase =
renderContext.getProperty(ThemeConstants.PORTAL_AJAX_JAVASCRIPT_BASE);
+ String remoteURL =
renderContext.getProperty(ThemeConstants.PORTAL_AJAX_REMOTE_URL);
//
- Object onPage =
renderContext.getPageProperties().get(ThemeConstants.PORTAL_AJAX_OBJECT_ENABLED);
+ Object onPage =
renderContext.getProperty(ThemeConstants.PORTAL_AJAX_OBJECT_ENABLED);
boolean pageEnabled = onPage != null && "true".equals(onPage);
//
@@ -216,9 +206,10 @@
//
if (regionEnabled)
{
+ // Keep a map of logical regions to div containers
markup.append("<script>").
append("regions_on_page[\"").
- append(renderContext.getRegionId()).
+ append(rrc.getCSSId()).
append("\"]=\"").
append(rrc.getId()).
append("\";").
@@ -237,12 +228,6 @@
{
enabledLocal.set(null);
}
-
- //
- if (portletPos.get(renderContext.getRegionId()) != null &&
((Integer)portletPos.get(renderContext.getRegionId())).intValue() > 0)
- {
- portletPos.put(renderContext.getRegionId(), new Integer(0));
- }
}
/** @see
org.jboss.portal.theme.render.ObjectRenderer#renderStart(org.jboss.portal.theme.render.RenderContext)
*/
@@ -256,22 +241,4 @@
{
delegate.renderEnd(ctx);
}
-
- public int getPortletNumber(String regionId)
- {
- int number = 0;
- if (portletPos.get(regionId) != null)
- {
- number = ((Integer)portletPos.get(regionId)).intValue();
- }
-
- portletPos.put(regionId, new Integer(++number));
-
- return number - 1;
- }
-
- public void setWindowId(String portletId, String windowId)
- {
- windowIds.put(portletId, windowId);
- }
}
Modified: trunk/theme/src/main/org/jboss/portal/theme/page/Region.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/page/Region.java 2007-03-29 23:49:25 UTC
(rev 6875)
+++ trunk/theme/src/main/org/jboss/portal/theme/page/Region.java 2007-03-30 12:16:16 UTC
(rev 6876)
@@ -22,8 +22,6 @@
******************************************************************************/
package org.jboss.portal.theme.page;
-import org.jboss.portal.theme.Orientation;
-
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
@@ -50,12 +48,6 @@
private final ArrayList windows;
/** . */
- private String cssId;
-
- /** . */
- private Orientation orientation;
-
- /** . */
private Map properties;
/**
@@ -66,27 +58,9 @@
*/
public Region(String name)
{
- this(name, null, null);
- }
-
- /**
- * Create a region with the provided properties.
- *
- * @param name the name of the region to create
- * @param cssId the id attribute value that can be used by css selectors to
identify this region
- * @param orientation arrange portlet windows inside this region in this orientation
- */
- public Region(String name, String cssId, Orientation orientation)
- {
- if (name == null)
- {
- throw new NullPointerException();
- }
this.name = name;
- windows = new ArrayList();
- sorted = false;
- this.cssId = (cssId == null ? name : cssId);
- this.orientation = (orientation == null ? Orientation.DEFAULT : orientation);
+ this.windows = new ArrayList();
+ this.sorted = false;
}
public String getProperty(String name)
@@ -116,29 +90,10 @@
return name;
}
- /** @return the attribute value to use in the markup to allow a css selector to select
this region */
- public String getCssId()
- {
- return cssId;
- }
-
- /** @return the orientation of this region */
- public Orientation getOrientation()
- {
- return orientation;
- }
-
/** @return if there are any portlet windows in this region */
public boolean isEmpty()
{
- if (windows == null)
- {
- return true;
- }
- else
- {
- return windows.isEmpty();
- }
+ return windows == null || windows.isEmpty();
}
/**
@@ -174,6 +129,6 @@
public String toString()
{
- return "Region: " + name + " [" + orientation + "] ["
+ cssId + "]";
+ return "Region[name" + name + "]";
}
}
Added:
trunk/theme/src/main/org/jboss/portal/theme/page/render/DecorationRenderContextImpl.java
===================================================================
---
trunk/theme/src/main/org/jboss/portal/theme/page/render/DecorationRenderContextImpl.java
(rev 0)
+++
trunk/theme/src/main/org/jboss/portal/theme/page/render/DecorationRenderContextImpl.java 2007-03-30
12:16:16 UTC (rev 6876)
@@ -0,0 +1,73 @@
+/******************************************************************************
+ * 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.theme.page.render;
+
+import org.jboss.portal.theme.render.DecorationRenderContext;
+import org.jboss.portal.theme.render.WindowRenderContext;
+
+import java.util.Collection;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class DecorationRenderContextImpl implements DecorationRenderContext
+{
+
+ final WindowRenderContextImpl wrc;
+
+ public DecorationRenderContextImpl(WindowRenderContextImpl wrc)
+ {
+ this.wrc = wrc;
+ }
+
+ public String getId()
+ {
+ return wrc.getId();
+ }
+
+ public String getTitle()
+ {
+ return wrc.result.getTitle();
+ }
+
+ public Collection getTriggerableActions(String familyName)
+ {
+ return wrc.result.getTriggerableActions(familyName);
+ }
+
+ public String getProperty(String name)
+ {
+ return wrc.getProperty(name);
+ }
+
+ public String getProperty(String name, int scope)
+ {
+ return getProperty(name);
+ }
+
+ public WindowRenderContext getWindow()
+ {
+ return wrc;
+ }
+}
Added: trunk/theme/src/main/org/jboss/portal/theme/page/render/PageRenderContextImpl.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/page/render/PageRenderContextImpl.java
(rev 0)
+++
trunk/theme/src/main/org/jboss/portal/theme/page/render/PageRenderContextImpl.java 2007-03-30
12:16:16 UTC (rev 6876)
@@ -0,0 +1,56 @@
+/******************************************************************************
+ * 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.theme.page.render;
+
+import org.jboss.portal.theme.page.PageResult;
+import org.jboss.portal.theme.render.PageRenderContext;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class PageRenderContextImpl implements PageRenderContext
+{
+
+ /** . */
+ final PageResult page;
+
+ public PageRenderContextImpl(PageResult page)
+ {
+ this.page = page;
+ }
+
+ public String getProperty(String name)
+ {
+ String s = (String)page.getPageProperties().get(name);
+
+ //
+ if (s == null)
+ {
+ s = (String)page.getPortalProperties().get(name);
+ }
+
+ //
+ return s;
+ }
+}
Added:
trunk/theme/src/main/org/jboss/portal/theme/page/render/PortletRenderContextImpl.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/page/render/PortletRenderContextImpl.java
(rev 0)
+++
trunk/theme/src/main/org/jboss/portal/theme/page/render/PortletRenderContextImpl.java 2007-03-30
12:16:16 UTC (rev 6876)
@@ -0,0 +1,61 @@
+/******************************************************************************
+ * 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.theme.page.render;
+
+import org.jboss.portal.theme.render.PortletRenderContext;
+import org.jboss.portal.theme.render.WindowRenderContext;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class PortletRenderContextImpl implements PortletRenderContext
+{
+
+ final WindowRenderContextImpl wrc;
+
+ public PortletRenderContextImpl(WindowRenderContextImpl wrc)
+ {
+ this.wrc = wrc;
+ }
+
+ public String getMarkup()
+ {
+ return wrc.result.getContent();
+ }
+
+ public String getProperty(String name)
+ {
+ return wrc.getProperty(name);
+ }
+
+ public String getProperty(String name, int scope)
+ {
+ return getProperty(name);
+ }
+
+ public WindowRenderContext getWindow()
+ {
+ return wrc;
+ }
+}
Added:
trunk/theme/src/main/org/jboss/portal/theme/page/render/RegionRenderContextImpl.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/page/render/RegionRenderContextImpl.java
(rev 0)
+++
trunk/theme/src/main/org/jboss/portal/theme/page/render/RegionRenderContextImpl.java 2007-03-30
12:16:16 UTC (rev 6876)
@@ -0,0 +1,101 @@
+/******************************************************************************
+ * 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.theme.page.render;
+
+import org.jboss.portal.theme.page.Region;
+import org.jboss.portal.theme.page.WindowContext;
+import org.jboss.portal.theme.page.WindowResult;
+import org.jboss.portal.theme.Orientation;
+import org.jboss.portal.theme.render.RegionRenderContext;
+import org.jboss.portal.theme.render.WindowRenderContext;
+import org.jboss.portal.theme.render.PageRenderContext;
+
+import java.util.Collection;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class RegionRenderContextImpl implements RegionRenderContext
+{
+
+ final PageRenderContextImpl page;
+ final Region region;
+ final Collection wrcs;
+ final String cssId;
+ final Orientation orientation;
+
+ public RegionRenderContextImpl(PageRenderContextImpl page, Region region, String
cssId, Orientation orientation)
+ {
+ this.page = page;
+ this.region = region;
+ this.cssId = cssId;
+ this.orientation = orientation;
+
+ this.wrcs = new ArrayList(region.getWindows().size());
+ for (Iterator i = region.getWindows().iterator(); i.hasNext();)
+ {
+ WindowContext wc = (WindowContext)i.next();
+ WindowResult wr = page.page.getWindowResult(wc.getId());
+ WindowRenderContext wrc = new WindowRenderContextImpl(this, wc, wr);
+ wrcs.add(wrc);
+ }
+ }
+
+ public String getId()
+ {
+ return region.getId();
+ }
+
+ public Collection getWindowRenderContexts()
+ {
+ return wrcs;
+ }
+
+ public String getProperty(String name)
+ {
+ return region.getProperty(name);
+ }
+
+ public String getProperty(String name, int scope)
+ {
+ return getProperty(name);
+ }
+
+ public PageRenderContext getPage()
+ {
+ return page;
+ }
+
+ public Orientation getOrientation()
+ {
+ return orientation;
+ }
+
+ public String getCSSId()
+ {
+ return cssId;
+ }
+}
Added:
trunk/theme/src/main/org/jboss/portal/theme/page/render/WindowRenderContextImpl.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/page/render/WindowRenderContextImpl.java
(rev 0)
+++
trunk/theme/src/main/org/jboss/portal/theme/page/render/WindowRenderContextImpl.java 2007-03-30
12:16:16 UTC (rev 6876)
@@ -0,0 +1,98 @@
+/******************************************************************************
+ * 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.theme.page.render;
+
+import org.jboss.portal.theme.page.WindowContext;
+import org.jboss.portal.theme.page.WindowResult;
+import org.jboss.portal.theme.render.WindowRenderContext;
+import org.jboss.portal.theme.render.DecorationRenderContext;
+import org.jboss.portal.theme.render.PortletRenderContext;
+import org.jboss.portal.theme.render.RegionRenderContext;
+import org.jboss.portal.WindowState;
+import org.jboss.portal.Mode;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class WindowRenderContextImpl implements WindowRenderContext
+{
+
+ final RegionRenderContextImpl region;
+ final WindowContext context;
+ final WindowResult result;
+ private final DecorationRenderContextImpl drc = new
DecorationRenderContextImpl(this);
+ private final PortletRenderContextImpl prc = new PortletRenderContextImpl(this);
+
+ public WindowRenderContextImpl(RegionRenderContextImpl region, WindowContext context,
WindowResult result)
+ {
+ this.region = region;
+ this.context = context;
+ this.result = result;
+ }
+
+ public String getId()
+ {
+ return context.getId().toString();
+ }
+
+ public int getOrder()
+ {
+ return context.getOrder();
+ }
+
+ public WindowState getWindowState()
+ {
+ return result.getWindowState();
+ }
+
+ public Mode getMode()
+ {
+ return result.getMode();
+ }
+
+ public DecorationRenderContext getDecoration()
+ {
+ return drc;
+ }
+
+ public PortletRenderContext getPortlet()
+ {
+ return prc;
+ }
+
+ public String getProperty(String name)
+ {
+ return (String)result.getWindowProperties().get(name);
+ }
+
+ public String getProperty(String name, int scope)
+ {
+ return getProperty(name);
+ }
+
+ public RegionRenderContext getRegion()
+ {
+ return region;
+ }
+}
Modified: trunk/theme/src/main/org/jboss/portal/theme/render/DecorationRenderContext.java
===================================================================
---
trunk/theme/src/main/org/jboss/portal/theme/render/DecorationRenderContext.java 2007-03-29
23:49:25 UTC (rev 6875)
+++
trunk/theme/src/main/org/jboss/portal/theme/render/DecorationRenderContext.java 2007-03-30
12:16:16 UTC (rev 6876)
@@ -36,5 +36,4 @@
String getTitle();
Collection getTriggerableActions(String familyName);
-
}
Added: trunk/theme/src/main/org/jboss/portal/theme/render/PageRenderContext.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/render/PageRenderContext.java
(rev 0)
+++ trunk/theme/src/main/org/jboss/portal/theme/render/PageRenderContext.java 2007-03-30
12:16:16 UTC (rev 6876)
@@ -0,0 +1,31 @@
+/******************************************************************************
+ * 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.theme.render;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface PageRenderContext extends ObjectRenderContext
+{
+}
Modified: trunk/theme/src/main/org/jboss/portal/theme/render/RegionRenderContext.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/render/RegionRenderContext.java 2007-03-29
23:49:25 UTC (rev 6875)
+++ trunk/theme/src/main/org/jboss/portal/theme/render/RegionRenderContext.java 2007-03-30
12:16:16 UTC (rev 6876)
@@ -22,6 +22,8 @@
******************************************************************************/
package org.jboss.portal.theme.render;
+import org.jboss.portal.theme.Orientation;
+
import java.util.Collection;
/**
@@ -35,4 +37,7 @@
Collection getWindowRenderContexts();
+ Orientation getOrientation();
+
+ String getCSSId();
}
Modified: trunk/theme/src/main/org/jboss/portal/theme/render/RenderContext.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/render/RenderContext.java 2007-03-29
23:49:25 UTC (rev 6875)
+++ trunk/theme/src/main/org/jboss/portal/theme/render/RenderContext.java 2007-03-30
12:16:16 UTC (rev 6876)
@@ -28,19 +28,9 @@
import org.jboss.portal.theme.LayoutInfo;
import org.jboss.portal.theme.PortalLayout;
import org.jboss.portal.theme.ThemeConstants;
-import org.jboss.portal.theme.Orientation;
-import org.jboss.portal.theme.page.Region;
-import org.jboss.portal.theme.page.WindowContext;
-import org.jboss.portal.theme.page.WindowResult;
-import org.jboss.portal.theme.page.PageResult;
-import org.jboss.portal.WindowState;
-import org.jboss.portal.Mode;
import java.util.List;
import java.util.Locale;
-import java.util.Map;
-import java.util.Collection;
-import java.util.Iterator;
import java.util.ArrayList;
/**
@@ -54,48 +44,55 @@
public final class RenderContext
{
+ /** . */
private PortalRenderSet renderSet;
+
+ /** . */
private ServerRequest request;
- private PageResult pageResult;
- private PortalLayout layout;
- private String regionCssId;
- private Orientation orientation;
+ /** . */
+ private PageRenderContext pageRenderContext;
+ /** . */
+ private PortalLayout layout;
+
+ /** . */
private StringBuffer markup;
- private Object fragment;
+
+ /** . */
+ private ObjectRenderContext targetRenderContext;
+
+ /** . */
private MarkupInfo markupInfo;
+ /** . */
+ private ArrayList stack;
+
// initialize
- private void init(PortalLayout layout, Object fragment, MarkupInfo markupInfo,
PageResult result, ServerRequest request)
+ private void init(PortalLayout layout, ObjectRenderContext fragment, MarkupInfo
markupInfo, PageRenderContext pageRenderContext, ServerRequest request)
{
- this.renderSet = layout.getServiceInfo().getRenderSet(layout.getLayoutInfo(),
markupInfo, result);
+ String renderSetName =
pageRenderContext.getProperty(ThemeConstants.PORTAL_PROP_RENDERSET);
+ PortalRenderSet renderSet =
layout.getServiceInfo().getRenderSet(layout.getLayoutInfo(), markupInfo, renderSetName);
if (renderSet == null)
{
throw new IllegalStateException("No RenderSet determined");
}
- markup = new StringBuffer();
-
+ //
+ this.renderSet = renderSet;
this.layout = layout;
- this.pageResult = result;
+ this.pageRenderContext = pageRenderContext;
this.request = request;
- this.fragment = fragment;
+ this.targetRenderContext = fragment;
this.markupInfo = markupInfo;
+ this.stack = new ArrayList(6);
+ this.markup = new StringBuffer();
- if (fragment != null && fragment instanceof Region)
- {
- orientation = ((Region)fragment).getOrientation();
- regionCssId = ((Region)fragment).getCssId();
- }
- else
- {
- orientation = null;
- regionCssId = null;
- }
+ //
+ stack.add(pageRenderContext);
}
- private RenderContext(PortalLayout layout, Object markupContainer, MarkupInfo
streamInfo, PageResult result, ServerRequest request)
+ private RenderContext(PortalLayout layout, ObjectRenderContext markupContainer,
MarkupInfo streamInfo, PageRenderContext result, ServerRequest request)
{
init(layout, markupContainer, streamInfo, result, request);
}
@@ -109,7 +106,7 @@
* @param result the rendered result(s) from the portlet container (PageResult,
RegionResult, WindowResult)
* @param request the current server request
*/
- public RenderContext(PortalLayout layout, MarkupInfo markupInfo, PageResult result,
ServerRequest request)
+ public RenderContext(PortalLayout layout, MarkupInfo markupInfo, PageRenderContext
result, ServerRequest request)
{
if (layout == null)
{
@@ -133,27 +130,12 @@
}
/**
- * copy constructor. <p>Get a render context for a region, based on the state of
this render context, but with the
+ * Copy constructor. <p>Get a render context for a region, based on the state of
this render context, but with the
* provided css id and orientation (which overwrite the values in the provided
region)</p>
- *
- * @param region the region to get the render context for
- * @param cssId the id attribute value to generate for this region (needs to be
unique in the page for the css
- * to be able to select this region to style)
- * @param orientation the orintation of multiple windows in this region (arranged
horizontally or vertically)
- * @return a new render context for the provided region
*/
- public RenderContext getContext(Region region, String cssId, Orientation orientation)
+ public RenderContext getContext(RegionRenderContext region)
{
- RenderContext context = new RenderContext(this.layout, region, this.markupInfo,
this.pageResult, this.request);
- if (cssId != null)
- {
- context.regionCssId = cssId;
- }
- if (orientation != null)
- {
- context.orientation = orientation;
- }
- return context;
+ return new RenderContext(this.layout, region, this.markupInfo,
this.pageRenderContext, this.request);
}
/**
@@ -163,9 +145,9 @@
* @param windowContext the window (context) to get the render context for
* @return a render context that can render the markup for the provided window
context
*/
- public RenderContext getContext(WindowContext windowContext)
+ public RenderContext getContext(WindowRenderContext windowContext)
{
- return new RenderContext(layout, windowContext, markupInfo, pageResult, request);
+ return new RenderContext(layout, windowContext, markupInfo, pageRenderContext,
request);
}
/** @return a markup fragment */
@@ -186,12 +168,6 @@
return markupInfo.getCharset();
}
- /** @return the region orientation */
- public Orientation getRegionOrientation()
- {
- return orientation;
- }
-
/** @return metadata about the layout used for this render context */
public LayoutInfo getLayoutInfo()
{
@@ -243,32 +219,51 @@
* name for the window renderer to use
* @return a window renderer
*/
- public WindowRenderer getWindowRenderer(WindowResult result)
+ public WindowRenderer getWindowRenderer(WindowRenderContext result)
{
String renderSetName = null;
if (result != null)
{
- renderSetName =
(String)result.getWindowProperties().get(ThemeConstants.PORTAL_PROP_WINDOW_RENDERER);
+ renderSetName = result.getProperty(ThemeConstants.PORTAL_PROP_WINDOW_RENDERER);
}
+ //
if (result != null && renderSetName == null)
{
- renderSetName =
(String)pageResult.getPageProperties().get(ThemeConstants.PORTAL_PROP_WINDOW_RENDERER);
+ renderSetName = getProperty(ThemeConstants.PORTAL_PROP_WINDOW_RENDERER);
}
+ //
if (renderSetName != null)
{
PortalRenderSet renderSet = layout.getServiceInfo().getRenderSet(renderSetName,
markupInfo.getContentType());
+ //
if (renderSet != null)
{
return renderSet.getWindowRenderer();
}
}
+ //
return getWindowRenderer();
}
+ public String getProperty(String propertyName)
+ {
+ for (int i = stack.size() - 1;i >= 0;i--)
+ {
+ ObjectRenderContext ctx = (ObjectRenderContext)stack.get(i);
+ String propertyValue = ctx.getProperty(propertyName);
+ if (propertyValue != null)
+ {
+ return propertyValue;
+ }
+ }
+ return null;
+ }
+
+
/** @return a decoration renderer from the determined render set */
public DecorationRenderer getDecorationRenderer()
{
@@ -284,30 +279,34 @@
* name for the decoration renderer to use
* @return a decoration renderer
*/
- public DecorationRenderer getDecorationRenderer(WindowResult result)
+ public DecorationRenderer getDecorationRenderer(DecorationRenderContext result)
{
String renderSetName = null;
if (result != null)
{
- renderSetName =
(String)result.getWindowProperties().get(ThemeConstants.PORTAL_PROP_DECORATION_RENDERER);
+ renderSetName =
result.getProperty(ThemeConstants.PORTAL_PROP_DECORATION_RENDERER);
}
+ //
if (result != null && renderSetName == null)
{
- renderSetName =
(String)pageResult.getPageProperties().get(ThemeConstants.PORTAL_PROP_DECORATION_RENDERER);
+ renderSetName = getProperty(ThemeConstants.PORTAL_PROP_DECORATION_RENDERER);
}
+ //
if (renderSetName != null)
{
PortalRenderSet renderSet = layout.getServiceInfo().getRenderSet(renderSetName,
markupInfo.getContentType());
+ //
if (renderSet != null)
{
return renderSet.getDecorationRenderer();
}
}
+ //
return getDecorationRenderer();
}
@@ -330,74 +329,44 @@
* portlet renderer from
* @return a portlet renderer
*/
- public PortletRenderer getPortletRenderer(WindowResult result)
+ public PortletRenderer getPortletRenderer(PortletRenderContext result)
{
String renderSetName = null;
+ //
if (result != null)
{
- renderSetName =
(String)result.getWindowProperties().get(ThemeConstants.PORTAL_PROP_PORTLET_RENDERER);
+ renderSetName =
result.getProperty(ThemeConstants.PORTAL_PROP_PORTLET_RENDERER);
}
+ //
if (result != null && renderSetName == null)
{
- renderSetName =
(String)pageResult.getPageProperties().get(ThemeConstants.PORTAL_PROP_PORTLET_RENDERER);
+ renderSetName = getProperty(ThemeConstants.PORTAL_PROP_PORTLET_RENDERER);
}
+ //
if (renderSetName != null)
{
PortalRenderSet renderSet = layout.getServiceInfo().getRenderSet(renderSetName,
markupInfo.getContentType());
+ //
if (renderSet != null)
{
return renderSet.getPortletRenderer();
}
}
+ //
return getPortletRenderer();
}
- /** @return the region CSS id */
- public String getRegionId()
- {
- return regionCssId;
- }
-
- /** @return the page properties */
- public Map getPageProperties()
- {
- return pageResult.getPageProperties();
- }
-
/** @return the names of all the regions as defined in the layout */
public List getLayoutRegionNames()
{
return layout.getLayoutInfo().getRegionNames();
}
- /**
- * Get the proerty value that matches the property with the provided key in the
provided window properties
- *
- * @param result the window result containing the window properties to introspect
- * @param key the property key
- * @return a property value or null if the property is not present
- */
- public String getProperty(WindowResult result, String key)
- {
- String value = null;
- if (result != null)
- {
- value = (String)result.getWindowProperties().get(key);
- }
-
- if (result != null && value == null)
- {
- value = (String)pageResult.getPageProperties().get(key);
- }
-
- return value;
- }
-
public Locale getLocale()
{
return request.getLocale();
@@ -418,61 +387,48 @@
*/
public void render() throws RenderException
{
- if (fragment != null)
+ render(targetRenderContext);
+ }
+
+
+ public void render(ObjectRenderContext ctx) throws RenderException
+ {
+ stack.add(ctx);
+
+ //
+ try
{
- if (fragment instanceof WindowContext)
+ if (ctx instanceof WindowRenderContext)
{
- WindowContext wc = (WindowContext)fragment;
- WindowResult windowResult = pageResult.getWindowResult(wc.getId());
- WindowRenderContext wrc = new WindowRenderContextImpl(wc, windowResult);
- render(wrc);
+ WindowRenderContext wrc = (WindowRenderContext)ctx;
+ WindowRenderer renderer = getWindowRenderer(wrc);
+ renderer.render(this, wrc);
}
- else if (fragment instanceof Region)
+ else if (ctx instanceof RegionRenderContext)
{
- RegionRenderContext rrc = new RegionRenderContextImpl(pageResult,
(Region)fragment);
- render(rrc);
+ RegionRenderContext rrc = (RegionRenderContext)ctx;
+ RegionRenderer renderer = getRegionRenderer();
+ renderer.render(this, rrc);
}
- else
+ else if (ctx instanceof PortletRenderContext)
{
- throw new UnsupportedOperationException("Markup fragment of unknown
type: " + fragment);
+ PortletRenderContext prc = (PortletRenderContext)ctx;
+ PortletRenderer renderer = getPortletRenderer(prc);
+ renderer.render(this, prc);
}
+ else if (ctx instanceof DecorationRenderContext)
+ {
+ DecorationRenderContext drc = (DecorationRenderContext)ctx;
+ DecorationRenderer renderer = getDecorationRenderer(drc);
+ renderer.render(this, drc);
+ }
}
- else
+ finally
{
- // for full page rendering the fragment is set to null!
- throw new IllegalStateException("This context can only render page
fragments, not the entire page");
+ stack.remove(stack.size() - 1);
}
}
-
- public void render(ObjectRenderContext ctx) throws RenderException
- {
- if (ctx instanceof WindowRenderContext)
- {
- WindowRenderContextImpl wrc = (WindowRenderContextImpl)ctx;
- WindowRenderer renderer = getWindowRenderer(wrc.result);
- renderer.render(this, wrc);
- }
- else if (ctx instanceof RegionRenderContext)
- {
- RegionRenderContext rrc = (RegionRenderContext)ctx;
- RegionRenderer renderer = getRegionRenderer();
- renderer.render(this, rrc);
- }
- else if (ctx instanceof PortletRenderContext)
- {
- PortletRenderContextImpl prc = (PortletRenderContextImpl)ctx;
- PortletRenderer renderer = getPortletRenderer(prc.wrc.result);
- renderer.render(this, prc);
- }
- else if (ctx instanceof DecorationRenderContext)
- {
- DecorationRenderContextImpl drc = (DecorationRenderContextImpl)ctx;
- DecorationRenderer renderer = getDecorationRenderer(drc.wrc.result);
- renderer.render(this, drc);
- }
- }
-
public ServerRequest getRequest()
{
return request;
@@ -482,143 +438,4 @@
{
this.request = request;
}
-
- private static class RegionRenderContextImpl implements RegionRenderContext
- {
-
- private final Region region;
- private final Collection wrcs;
-
- public RegionRenderContextImpl(PageResult page, Region region)
- {
- this.region = region;
-
- this.wrcs = new ArrayList(region.getWindows().size());
- for (Iterator i = region.getWindows().iterator();i.hasNext();)
- {
- WindowContext wc = (WindowContext)i.next();
- WindowResult wr = page.getWindowResult(wc.getId());
- WindowRenderContext wrc = new WindowRenderContextImpl(wc, wr);
- wrcs.add(wrc);
- }
- }
-
- public String getId()
- {
- return region.getId();
- }
-
- public Collection getWindowRenderContexts()
- {
- return wrcs;
- }
-
- public String getProperty(String name)
- {
- return region.getProperty(name);
- }
- }
-
- private static class WindowRenderContextImpl implements WindowRenderContext
- {
-
- private final WindowContext context;
- private final WindowResult result;
- private final DecorationRenderContextImpl drc = new
DecorationRenderContextImpl(this);
- private final PortletRenderContextImpl prc = new PortletRenderContextImpl(this);
-
- public WindowRenderContextImpl(WindowContext context, WindowResult result)
- {
- this.context = context;
- this.result = result;
- }
-
- public String getId()
- {
- return context.getId().toString();
- }
-
- public int getOrder()
- {
- return context.getOrder();
- }
-
- public WindowState getWindowState()
- {
- return result.getWindowState();
- }
-
- public Mode getMode()
- {
- return result.getMode();
- }
-
- public DecorationRenderContext getDecoration()
- {
- return drc;
- }
-
- public PortletRenderContext getPortlet()
- {
- return prc;
- }
-
- public String getProperty(String name)
- {
- return (String)result.getWindowProperties().get(name);
- }
- }
-
- private static class DecorationRenderContextImpl implements DecorationRenderContext
- {
-
- final WindowRenderContextImpl wrc;
-
- public DecorationRenderContextImpl(WindowRenderContextImpl wrc)
- {
- this.wrc = wrc;
- }
-
- public String getId()
- {
- return wrc.getId();
- }
-
- public String getTitle()
- {
- return wrc.result.getTitle();
- }
-
- public Collection getTriggerableActions(String familyName)
- {
- return wrc.result.getTriggerableActions(familyName);
- }
-
- public String getProperty(String name)
- {
- return wrc.getProperty(name);
- }
- }
-
- private static class PortletRenderContextImpl implements PortletRenderContext
- {
-
- final WindowRenderContextImpl wrc;
-
- public PortletRenderContextImpl(WindowRenderContextImpl wrc)
- {
- this.wrc = wrc;
- }
-
- public String getMarkup()
- {
- return wrc.result.getContent();
- }
-
- public String getProperty(String name)
- {
- return wrc.getProperty(name);
- }
- }
-
}
\ No newline at end of file
Modified: trunk/theme/src/main/org/jboss/portal/theme/render/WindowRenderContext.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/render/WindowRenderContext.java 2007-03-29
23:49:25 UTC (rev 6875)
+++ trunk/theme/src/main/org/jboss/portal/theme/render/WindowRenderContext.java 2007-03-30
12:16:16 UTC (rev 6876)
@@ -44,4 +44,6 @@
PortletRenderContext getPortlet();
+ RegionRenderContext getRegion();
+
}
Modified: trunk/theme/src/main/org/jboss/portal/theme/tag/PortletTagHandler.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/tag/PortletTagHandler.java 2007-03-29
23:49:25 UTC (rev 6875)
+++ trunk/theme/src/main/org/jboss/portal/theme/tag/PortletTagHandler.java 2007-03-30
12:16:16 UTC (rev 6876)
@@ -26,8 +26,13 @@
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.Region;
import org.jboss.portal.theme.render.RenderContext;
import org.jboss.portal.theme.render.RenderException;
+import org.jboss.portal.theme.page.render.PageRenderContextImpl;
+import org.jboss.portal.theme.render.RegionRenderContext;
+import org.jboss.portal.theme.page.render.RegionRenderContextImpl;
+import org.jboss.portal.theme.render.WindowRenderContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.JspException;
@@ -131,19 +136,28 @@
}
WindowContext windowContext = page.getWindowContext(windowID);
- RenderContext renderContext = (RenderContext) request
- .getAttribute(LayoutConstants.ATTR_RENDERCONTEXT);
+ RenderContext renderContext =
(RenderContext)request.getAttribute(LayoutConstants.ATTR_RENDERCONTEXT);
- renderContext = renderContext.getContext(windowContext);
-
- try {
- renderContext.render();
- out.write(renderContext.getMarkupFragment().toString());
- out.flush();
- } catch (RenderException e) {
- throw new JspException(e);
+ PageRenderContextImpl prc = new PageRenderContextImpl(page);
+ String regionName = windowContext.getRegionName();
+ Region region = page.getRegion(regionName);
+ RegionRenderContext rrc = new RegionRenderContextImpl(prc, region, null, null);
+ for (Iterator i = rrc.getWindowRenderContexts().iterator();i.hasNext();)
+ {
+ WindowRenderContext wrc = (WindowRenderContext)i.next();
+ if (wrc.getId().equals(windowContext.getId()))
+ {
+ try {
+ renderContext.render(wrc);
+ out.write(renderContext.getMarkupFragment().toString());
+ out.flush();
+ } catch (RenderException e) {
+ throw new JspException(e);
+ }
+ break;
+ }
}
- }
+ }
public String getWindowName()
{
Modified: trunk/theme/src/main/org/jboss/portal/theme/tag/RegionTagHandler.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/tag/RegionTagHandler.java 2007-03-29
23:49:25 UTC (rev 6875)
+++ trunk/theme/src/main/org/jboss/portal/theme/tag/RegionTagHandler.java 2007-03-30
12:16:16 UTC (rev 6876)
@@ -27,8 +27,12 @@
import org.jboss.portal.theme.Orientation;
import org.jboss.portal.theme.page.PageResult;
import org.jboss.portal.theme.page.Region;
+import org.jboss.portal.theme.page.render.PageRenderContextImpl;
import org.jboss.portal.theme.render.RenderContext;
import org.jboss.portal.theme.render.RenderException;
+import org.jboss.portal.theme.render.RegionRenderContext;
+import org.jboss.portal.theme.page.render.RegionRenderContextImpl;
+import org.jboss.portal.theme.render.PageRenderContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.JspException;
@@ -36,6 +40,8 @@
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.SimpleTagSupport;
import java.io.IOException;
+import java.util.Collection;
+import java.util.Collections;
/**
* Tag handler for the region tag. <p>A region represents a subsection of a portal
page. A region can host several
@@ -52,7 +58,8 @@
{
private static Logger log = Logger.getLogger(RegionTagHandler.class);
//default to vertical
- private Orientation orientation = Orientation.DEFAULT;
+
+ private Orientation regionOrientation;
private String regionName = null;
private String regionCssId = null;
@@ -68,7 +75,7 @@
{
regionCssId = regionName;
}
- log.debug("rendering " + regionName + " [" + orientation +
"] cssId[" + regionCssId + "]");
+ log.debug("rendering " + regionName + " [" + regionOrientation
+ "] cssId[" + regionCssId + "]");
// get page and region
PageContext app = (PageContext)getJspContext();
@@ -84,15 +91,45 @@
out.flush();
return;
}
+
+ final String cssId = regionCssId == null ? regionName : regionCssId;
+ final Orientation orientation = this.regionOrientation == null ?
Orientation.DEFAULT : this.regionOrientation;
+
if (page.getRegion(regionName) == null) // non-window display of content
{
- // create a new region obj, based on region name
- Region newRegion = new Region(regionName, regionCssId, Orientation.DEFAULT);
+ // Create a dummy region obj, based on region name
+ RegionRenderContext rrc = new RegionRenderContext()
+ {
+ public String getId()
+ {
+ return regionName;
+ }
+ public Collection getWindowRenderContexts()
+ {
+ return Collections.EMPTY_LIST;
+ }
+ public PageRenderContext getPage()
+ {
+ return null;
+ }
+ public Orientation getOrientation()
+ {
+ return orientation;
+ }
+ public String getCSSId()
+ {
+ return cssId;
+ }
+ public String getProperty(String name)
+ {
+ return null;
+ }
+ };
+
RenderContext renderContext =
(RenderContext)request.getAttribute(LayoutConstants.ATTR_RENDERCONTEXT);
- renderContext = renderContext.getContext(newRegion, regionCssId, orientation);
try
{
- renderContext.render();
+ renderContext.render(rrc);
out.write(renderContext.getMarkupFragment().toString());
out.flush();
}
@@ -100,31 +137,41 @@
{
throw new JspException(e);
}
- return;
+ finally
+ {
+ renderContext.getMarkupFragment().setLength(0);
+ }
}
-
- // window-centric display of content
- RenderContext renderContext =
(RenderContext)request.getAttribute(LayoutConstants.ATTR_RENDERCONTEXT);
- if (renderContext == null)
+ else
{
- log.debug("no render context available in request");
- return;
- }
+ // window-centric display of content
+ RenderContext renderContext =
(RenderContext)request.getAttribute(LayoutConstants.ATTR_RENDERCONTEXT);
+ if (renderContext == null)
+ {
+ log.debug("no render context available in request");
+ return;
+ }
- Region region = page.getRegion(regionName);
- renderContext = renderContext.getContext(region, regionCssId, orientation);
- try
- {
- renderContext.render();
- out.write(renderContext.getMarkupFragment().toString());
- out.flush();
+ Region region = page.getRegion(regionName);
+ PageRenderContextImpl prc = new PageRenderContextImpl(page);
+ RegionRenderContext rrc = new RegionRenderContextImpl(prc, region, cssId,
orientation);
+ try
+ {
+ renderContext.render(rrc);
+ out.write(renderContext.getMarkupFragment().toString());
+ out.flush();
+ }
+ catch (RenderException e)
+ {
+ throw new JspException(e);
+ }
+ finally
+ {
+ renderContext.getMarkupFragment().setLength(0);
+ }
+
+ log.debug("done rendering page region [" + regionName +
"]");
}
- catch (RenderException e)
- {
- throw new JspException(e);
- }
-
- log.debug("done rendering page region [" + regionName + "]");
}
// ------ attribute handlers
@@ -143,12 +190,12 @@
try
{
- this.orientation = Orientation.parse(orientation);
+ this.regionOrientation = Orientation.parse(orientation);
}
catch (IllegalArgumentException e)
{
log.error(e);
- this.orientation = Orientation.DEFAULT;
+ this.regionOrientation = Orientation.DEFAULT;
}
}