Author: julien(a)jboss.com
Date: 2007-04-26 13:06:10 -0400 (Thu, 26 Apr 2007)
New Revision: 7083
Added:
trunk/theme/src/main/org/jboss/portal/test/theme/DynaMergeBehaviorTestCase.java
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaMergeBehavior.java
trunk/theme/src/main/org/jboss/portal/theme/render/PropertyFetch.java
Modified:
trunk/core-samples/src/resources/portal-samples-war/WEB-INF/jboss-portlet.xml
trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxInterceptor.java
trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxResponseHandler.java
trunk/core/src/main/org/jboss/portal/core/model/instance/command/render/RenderPortletInstanceCommand.java
trunk/core/src/main/org/jboss/portal/core/model/portal/command/render/RenderPageCommand.java
trunk/theme/build.xml
trunk/theme/src/main/org/jboss/portal/test/theme/DynaTestContext.java
trunk/theme/src/main/org/jboss/portal/test/theme/tmp/TestHelper.java
trunk/theme/src/main/org/jboss/portal/test/theme/tmp/render/TestRenderedMarkup.java
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaDecorationRenderer.java
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaPortletRenderer.java
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaRegionRenderer.java
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaRenderOptions.java
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaRenderStatus.java
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaWindowRenderer.java
trunk/theme/src/main/org/jboss/portal/theme/page/PageResult.java
trunk/theme/src/main/org/jboss/portal/theme/render/RendererContext.java
Log:
improve how ajax configuration works between portal/pages/windows
Modified: trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxInterceptor.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxInterceptor.java 2007-04-26
17:00:29 UTC (rev 7082)
+++
trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxInterceptor.java 2007-04-26
17:06:10 UTC (rev 7083)
@@ -63,7 +63,7 @@
//
PageRendition rendition = (PageRendition)response;
- Map pageProps = rendition.getPageResult().getPageProperties();
+ Map pageProps = rendition.getPageResult().getProperties();
//
PortalObjectNavigationalStateContext ctx =
(PortalObjectNavigationalStateContext)controllerContext.getAttributeResolver(ControllerCommand.NAVIGATIONAL_STATE_SCOPE);
Modified:
trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxResponseHandler.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxResponseHandler.java 2007-04-26
17:00:29 UTC (rev 7082)
+++
trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxResponseHandler.java 2007-04-26
17:06:10 UTC (rev 7083)
@@ -283,7 +283,7 @@
UpdatePageStateResponse updatePage = new
UpdatePageStateResponse(ctx.getViewId());
// Call to the theme framework
- PageResult res = new PageResult(page.getName(), page.getProperties(),
portal.getProperties());
+ PageResult res = new PageResult(page.getName(), page.getProperties());
//
ServerInvocation invocation = controllerContext.getServerInvocation();
Modified:
trunk/core/src/main/org/jboss/portal/core/model/instance/command/render/RenderPortletInstanceCommand.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/model/instance/command/render/RenderPortletInstanceCommand.java 2007-04-26
17:00:29 UTC (rev 7082)
+++
trunk/core/src/main/org/jboss/portal/core/model/instance/command/render/RenderPortletInstanceCommand.java 2007-04-26
17:06:10 UTC (rev 7083)
@@ -99,10 +99,9 @@
LayoutService ls = ps.getLayoutService();
PortalLayout layout = ls.getLayout("generic", true);
Map pageProperties = new HashMap();
- Map portalProperties = new HashMap();
- portalProperties.put("theme.renderSetId", "divRenderer");
- portalProperties.put("theme.id", "renaissance");
- PageResult result = new PageResult("BILTO", pageProperties,
portalProperties);
+ pageProperties.put("theme.renderSetId", "divRenderer");
+ pageProperties.put("theme.id", "renaissance");
+ PageResult result = new PageResult("BILTO", pageProperties);
//
Map windowProps = new HashMap();
Modified:
trunk/core/src/main/org/jboss/portal/core/model/portal/command/render/RenderPageCommand.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/model/portal/command/render/RenderPageCommand.java 2007-04-26
17:00:29 UTC (rev 7082)
+++
trunk/core/src/main/org/jboss/portal/core/model/portal/command/render/RenderPageCommand.java 2007-04-26
17:06:10 UTC (rev 7083)
@@ -181,10 +181,7 @@
}
// Call the portlet container to create the markup fragment(s) for each portlet
that needs to render itself
- PageResult pageResult = new PageResult(
- getPage().getName(),
- new HashMap(getPage().getDeclaredProperties()),
- new HashMap(getPage().getPortal().getDeclaredProperties()));
+ PageResult pageResult = new PageResult(getPage().getName(), new
HashMap(getPage().getProperties()));
// Render the windows
for (Iterator i = windows.iterator(); i.hasNext();)
Modified: trunk/core-samples/src/resources/portal-samples-war/WEB-INF/jboss-portlet.xml
===================================================================
---
trunk/core-samples/src/resources/portal-samples-war/WEB-INF/jboss-portlet.xml 2007-04-26
17:00:29 UTC (rev 7082)
+++
trunk/core-samples/src/resources/portal-samples-war/WEB-INF/jboss-portlet.xml 2007-04-26
17:06:10 UTC (rev 7083)
@@ -86,7 +86,7 @@
<portlet>
<portlet-name>AsyncURLPortlet</portlet-name>
<ajax>
- <partial-refresh>false</partial-refresh>
+ <partial-refresh>true</partial-refresh>
</ajax>
</portlet>
<portlet>
Modified: trunk/theme/build.xml
===================================================================
--- trunk/theme/build.xml 2007-04-26 17:00:29 UTC (rev 7082)
+++ trunk/theme/build.xml 2007-04-26 17:06:10 UTC (rev 7083)
@@ -307,7 +307,8 @@
-->
</x-sysproperty>
<x-test>
- <test todir="${test.reports}"
name="org.jboss.portal.test.theme.ThemeTestRunner"/>
+ <!--<test todir="${test.reports}"
name="org.jboss.portal.test.theme.ThemeTestRunner"/>-->
+ <test todir="${test.reports}"
name="org.jboss.portal.test.theme.DynaMergeBehaviorTestCase"/>
</x-test>
<x-classpath>
<path refid="jboss/jbossretro.rt.classpath"/>
Added: trunk/theme/src/main/org/jboss/portal/test/theme/DynaMergeBehaviorTestCase.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/test/theme/DynaMergeBehaviorTestCase.java
(rev 0)
+++
trunk/theme/src/main/org/jboss/portal/test/theme/DynaMergeBehaviorTestCase.java 2007-04-26
17:06:10 UTC (rev 7083)
@@ -0,0 +1,60 @@
+/******************************************************************************
+ * 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.test.theme;
+
+import junit.framework.TestCase;
+import org.jboss.portal.theme.impl.render.dynamic.DynaMergeBehavior;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class DynaMergeBehaviorTestCase extends TestCase
+{
+
+ public void testForRegion()
+ {
+ assertEquals(true, DynaMergeBehavior.mergeForRegion(Boolean.TRUE, Boolean.TRUE));
+ assertEquals(false, DynaMergeBehavior.mergeForRegion(Boolean.TRUE,
Boolean.FALSE));
+ assertEquals(true, DynaMergeBehavior.mergeForRegion(Boolean.TRUE, null));
+ assertEquals(false, DynaMergeBehavior.mergeForRegion(Boolean.FALSE,
Boolean.TRUE));
+ assertEquals(false, DynaMergeBehavior.mergeForRegion(Boolean.FALSE,
Boolean.FALSE));
+ assertEquals(false, DynaMergeBehavior.mergeForRegion(Boolean.FALSE, null));
+ assertEquals(false, DynaMergeBehavior.mergeForRegion(null, Boolean.TRUE));
+ assertEquals(false, DynaMergeBehavior.mergeForRegion(null, Boolean.FALSE));
+ assertEquals(false, DynaMergeBehavior.mergeForRegion((Boolean)null, null));
+ }
+
+ public void testForWindow()
+ {
+ assertEquals(true, DynaMergeBehavior.mergeForWindow(Boolean.TRUE, Boolean.TRUE));
+ assertEquals(false, DynaMergeBehavior.mergeForWindow(Boolean.TRUE,
Boolean.FALSE));
+ assertEquals(true, DynaMergeBehavior.mergeForWindow(Boolean.TRUE, null));
+ assertEquals(false, DynaMergeBehavior.mergeForWindow(Boolean.FALSE,
Boolean.TRUE));
+ assertEquals(false, DynaMergeBehavior.mergeForWindow(Boolean.FALSE,
Boolean.FALSE));
+ assertEquals(false, DynaMergeBehavior.mergeForWindow(Boolean.FALSE, null));
+ assertEquals(false, DynaMergeBehavior.mergeForWindow(null, Boolean.TRUE));
+ assertEquals(false, DynaMergeBehavior.mergeForWindow(null, Boolean.FALSE));
+ assertEquals(false, DynaMergeBehavior.mergeForWindow((Boolean)null, null));
+ }
+}
Modified: trunk/theme/src/main/org/jboss/portal/test/theme/DynaTestContext.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/test/theme/DynaTestContext.java 2007-04-26
17:00:29 UTC (rev 7082)
+++ trunk/theme/src/main/org/jboss/portal/test/theme/DynaTestContext.java 2007-04-26
17:06:10 UTC (rev 7083)
@@ -299,8 +299,8 @@
PageResult pageRenderCtx = createResult(page.getRendererContext());
//
- pageRenderCtx.getPageProperties().put(DynaConstants.RESOURCE_BASE_URL,
requestContext.request.getContextPath() + "/dyna");
- pageRenderCtx.getPageProperties().put(DynaConstants.SERVER_BASE_URL,
requestContext.request.getContextPath() + requestContext.request.getServletPath());
+ pageRenderCtx.getProperties().put(DynaConstants.RESOURCE_BASE_URL,
requestContext.request.getContextPath() + "/dyna");
+ pageRenderCtx.getProperties().put(DynaConstants.SERVER_BASE_URL,
requestContext.request.getContextPath() + requestContext.request.getServletPath());
//
RendererContext rendererCtx = layout.getRenderContext(themeContext, markupInfo,
dispatcher);
@@ -315,7 +315,7 @@
PageResult result = new PageResult("page");
//
- result.getPageProperties().putAll(prc.getProperties());
+ result.getProperties().putAll(prc.getProperties());
//
for (Iterator i = prc.getRegions().iterator();i.hasNext();)
Modified: trunk/theme/src/main/org/jboss/portal/test/theme/tmp/TestHelper.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/test/theme/tmp/TestHelper.java 2007-04-26
17:00:29 UTC (rev 7082)
+++ trunk/theme/src/main/org/jboss/portal/test/theme/tmp/TestHelper.java 2007-04-26
17:06:10 UTC (rev 7083)
@@ -188,7 +188,7 @@
public static PageResult createPageResult(AttributeResolver navCtx, String pageName,
Map pageProperties, Map portalProperties,
WindowContext[] windows)
{
- PageResult pageResult = new PageResult(pageName, pageProperties,
portalProperties);
+ PageResult pageResult = new PageResult(pageName, pageProperties);
for (int i = 0; i < windows.length; i++)
{
pageResult.addWindowContext(windows[i]);
Modified:
trunk/theme/src/main/org/jboss/portal/test/theme/tmp/render/TestRenderedMarkup.java
===================================================================
---
trunk/theme/src/main/org/jboss/portal/test/theme/tmp/render/TestRenderedMarkup.java 2007-04-26
17:00:29 UTC (rev 7082)
+++
trunk/theme/src/main/org/jboss/portal/test/theme/tmp/render/TestRenderedMarkup.java 2007-04-26
17:06:10 UTC (rev 7083)
@@ -140,7 +140,7 @@
ServerRequest serverRequest = TestHelper.createServerRequest();
// pageresult obj
- PageResult pageResult = new PageResult(TEST_PAGE_NAME, pageProps, portalProps);
+ PageResult pageResult = new PageResult(TEST_PAGE_NAME, pageProps);
// create window ctx/results and add to page result
for (int i = 0; i < LEFT_WINDOWS; i++)
Modified:
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaDecorationRenderer.java
===================================================================
---
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaDecorationRenderer.java 2007-04-26
17:00:29 UTC (rev 7082)
+++
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaDecorationRenderer.java 2007-04-26
17:06:10 UTC (rev 7083)
@@ -52,28 +52,35 @@
public void render(RendererContext rendererContext, DecorationRendererContext drc)
throws RenderException
{
- DynaRenderOptions regionOptions =
(DynaRenderOptions)rendererContext.getAttribute(DynaConstants.RENDER_OPTIONS);
+ DynaRenderOptions options =
(DynaRenderOptions)rendererContext.getAttribute(DynaConstants.RENDER_OPTIONS);
//
PrintWriter markup = rendererContext.getWriter();
//
- if (regionOptions.isDnDEnabled())
+ if (!DynaRenderOptions.NO_AJAX.equals(options))
{
- DynaWindowRenderer.handleProvided.set(Boolean.TRUE);
+ if (options.isDnDEnabled())
+ {
+ DynaWindowRenderer.handleProvided.set(Boolean.TRUE);
- //
- markup.print("<div class=\"dnd-handle\">");
- markup.print("<div class=\"dyna-decoration\">\n");
- delegate.render(rendererContext, drc);
- markup.print("</div>\n");
- markup.print("</div>\n");
+ //
+ markup.print("<div class=\"dnd-handle\">");
+ markup.print("<div class=\"dyna-decoration\">\n");
+ delegate.render(rendererContext, drc);
+ markup.print("</div>\n");
+ markup.print("</div>\n");
+ }
+ else
+ {
+ markup.print("<div class=\"dyna-decoration\">\n");
+ delegate.render(rendererContext, drc);
+ markup.print("</div>\n");
+ }
}
else
{
- markup.print("<div class=\"dyna-decoration\">\n");
delegate.render(rendererContext, drc);
- markup.print("</div>\n");
}
}
}
\ No newline at end of file
Added:
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaMergeBehavior.java
===================================================================
---
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaMergeBehavior.java
(rev 0)
+++
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaMergeBehavior.java 2007-04-26
17:06:10 UTC (rev 7083)
@@ -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.impl.render.dynamic;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class DynaMergeBehavior
+{
+
+ public static boolean mergeForRegion(Boolean page, Boolean region)
+ {
+ return Boolean.TRUE.equals(page) & !Boolean.FALSE.equals(region);
+ }
+
+ public static DynaRenderOptions mergeForRegion(DynaRenderOptions page,
DynaRenderOptions region)
+ {
+ boolean dnd = mergeForRegion(page.getDnD(), region.getDnD());
+ boolean partialRefresh = mergeForRegion(page.getPartialRefresh(),
region.getPartialRefresh());
+ return DynaRenderOptions.getOptions(dnd, partialRefresh);
+ }
+
+ public static boolean mergeForWindow(Boolean region, Boolean window)
+ {
+ return Boolean.TRUE.equals(region) & !Boolean.FALSE.equals(window);
+ }
+
+ public static DynaRenderOptions mergeForWindow(DynaRenderOptions region,
DynaRenderOptions window)
+ {
+ boolean dnd = mergeForWindow(region.getDnD(), window.getDnD());
+ boolean partialRefresh = mergeForWindow(region.getPartialRefresh(),
window.getPartialRefresh());
+ return DynaRenderOptions.getOptions(dnd, partialRefresh);
+ }
+
+}
Modified:
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaPortletRenderer.java
===================================================================
---
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaPortletRenderer.java 2007-04-26
17:00:29 UTC (rev 7082)
+++
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaPortletRenderer.java 2007-04-26
17:06:10 UTC (rev 7083)
@@ -59,13 +59,12 @@
private void doDND(RendererContext rendererContext, PortletRendererContext prc) throws
RenderException
{
- DynaRenderOptions regionOptions =
(DynaRenderOptions)rendererContext.getAttribute(DynaConstants.RENDER_OPTIONS);
+ DynaRenderOptions options =
(DynaRenderOptions)rendererContext.getAttribute(DynaConstants.RENDER_OPTIONS);
//
- if (regionOptions.isDnDEnabled())
+ if (!DynaRenderOptions.NO_AJAX.equals(options))
{
- // Provide handle on content if needed
- if (Boolean.FALSE.equals(DynaWindowRenderer.handleProvided.get()))
+ if (options.isDnDEnabled() &&
Boolean.FALSE.equals(DynaWindowRenderer.handleProvided.get()))
{
//
DynaWindowRenderer.handleProvided.set(Boolean.TRUE);
@@ -85,7 +84,7 @@
}
else
{
- doCatchClicks(rendererContext, prc);
+ delegate.render(rendererContext, prc);
}
}
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-04-26
17:00:29 UTC (rev 7082)
+++
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaRegionRenderer.java 2007-04-26
17:06:10 UTC (rev 7083)
@@ -50,6 +50,7 @@
import org.jboss.portal.theme.render.RenderException;
import org.jboss.portal.theme.render.AbstractObjectRenderer;
import org.jboss.portal.theme.render.ObjectRendererContext;
+import org.jboss.portal.theme.render.PropertyFetch;
import org.jboss.portal.theme.render.renderer.RegionRendererContext;
import java.io.PrintWriter;
@@ -65,6 +66,9 @@
{
/** . */
+ private static final PropertyFetch RENDER_OPTIONS_FETCH = new
PropertyFetch(PropertyFetch.ANCESTORS_SCOPE);
+
+ /** . */
private RegionRenderer delegate;
public DynaRegionRenderer(RegionRenderer regionRenderer) throws
InstantiationException,
@@ -85,10 +89,19 @@
}
else
{
- String dndValue = rendererContext.getProperty(DynaRenderOptions.DND_ENABLED);
- String asyncWindowValue =
rendererContext.getProperty(DynaRenderOptions.PARTIAL_REFRESH_ENABLED);
- DynaRenderOptions options = DynaRenderOptions.getOptions(dndValue,
asyncWindowValue);
+ // Get ancestors options
+ String ancestorsDndValue =
rendererContext.getProperty(DynaRenderOptions.DND_ENABLED, RENDER_OPTIONS_FETCH);
+ String ancestorsPartialRefreshValue =
rendererContext.getProperty(DynaRenderOptions.PARTIAL_REFRESH_ENABLED,
RENDER_OPTIONS_FETCH);
+ DynaRenderOptions ancestorsOptions =
DynaRenderOptions.getOptions(ancestorsDndValue, ancestorsPartialRefreshValue);
+ // Get regions options
+ String regionDndValue =
rendererContext.getProperty(DynaRenderOptions.DND_ENABLED);
+ String regionPartialRefreshValue =
rendererContext.getProperty(DynaRenderOptions.PARTIAL_REFRESH_ENABLED);
+ DynaRenderOptions regionOptions = DynaRenderOptions.getOptions(regionDndValue,
regionPartialRefreshValue);
+
+ // Merge options
+ DynaRenderOptions options = DynaMergeBehavior.mergeForRegion(ancestorsOptions,
regionOptions);
+
//
rendererContext.setAttribute(DynaConstants.RENDER_OPTIONS, options);
DynaRenderStatus.set(rendererContext, true);
@@ -160,20 +173,28 @@
if (DynaRenderStatus.isActive(rendererContext))
{
//
- markup.print("<div class=\"dyna-region\">");
+ DynaRenderOptions options =
(DynaRenderOptions)rendererContext.getAttribute(DynaConstants.RENDER_OPTIONS);
//
- delegate.renderHeader(rendererContext, rrc);
+ if (!DynaRenderOptions.NO_AJAX.equals(options))
+ {
+ //
+ markup.print("<div class=\"dyna-region\">");
- //
- DynaRenderOptions options =
(DynaRenderOptions)rendererContext.getAttribute(DynaConstants.RENDER_OPTIONS);
+ //
+ delegate.renderHeader(rendererContext, rrc);
- //
- if (options.isDnDEnabled())
+ //
+ if (options.isDnDEnabled())
+ {
+ markup.print("<div class=\"dnd-region\"
id=\"");
+ markup.print(rrc.getId());
+ markup.print("\">");
+ }
+ }
+ else
{
- markup.print("<div class=\"dnd-region\" id=\"");
- markup.print(rrc.getId());
- markup.print("\">");
+ delegate.renderHeader(rendererContext, rrc);
}
}
}
@@ -196,17 +217,21 @@
DynaRenderOptions options =
(DynaRenderOptions)rendererContext.getAttribute(DynaConstants.RENDER_OPTIONS);
//
- PrintWriter markup = rendererContext.getWriter();
+ if (!DynaRenderOptions.NO_AJAX.equals(options))
+ {
+ //
+ PrintWriter markup = rendererContext.getWriter();
- // Close dnd-region
- if (options.isDnDEnabled())
- {
+ // Close dnd-region
+ if (options.isDnDEnabled())
+ {
+ markup.print("</div>");
+ }
+
+ // Close dyna-region
markup.print("</div>");
}
- // Close dyna-region
- markup.print("</div>");
-
//
delegate.renderFooter(rendererContext, rrc);
}
Modified:
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaRenderOptions.java
===================================================================
---
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaRenderOptions.java 2007-04-26
17:00:29 UTC (rev 7082)
+++
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaRenderOptions.java 2007-04-26
17:06:10 UTC (rev 7083)
@@ -60,6 +60,11 @@
new DynaRenderOptions(Boolean.FALSE, Boolean.FALSE),
};
+ public static DynaRenderOptions getOptions(boolean dnd, boolean partialRefresh)
+ {
+ return getOptions(Boolean.valueOf(dnd), Boolean.valueOf(partialRefresh));
+ }
+
public static DynaRenderOptions getOptions(Boolean dnd, Boolean partialRefresh)
{
int index = dnd == null ? 0 : dnd.booleanValue() ? 1 : 2;
Modified:
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaRenderStatus.java
===================================================================
---
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaRenderStatus.java 2007-04-26
17:00:29 UTC (rev 7082)
+++
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaRenderStatus.java 2007-04-26
17:06:10 UTC (rev 7083)
@@ -48,4 +48,5 @@
{
rendererContext.setAttribute(DynaConstants.RENDER_STATUS,
Boolean.valueOf(active));
}
+
}
Modified:
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaWindowRenderer.java
===================================================================
---
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaWindowRenderer.java 2007-04-26
17:00:29 UTC (rev 7082)
+++
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaWindowRenderer.java 2007-04-26
17:06:10 UTC (rev 7083)
@@ -57,51 +57,68 @@
/** @see org.jboss.portal.theme.render.renderer.WindowRenderer#render */
public void render(RendererContext rendererContext, WindowRendererContext wrc) throws
RenderException
{
- DynaRenderOptions regionOptions =
(DynaRenderOptions)rendererContext.getAttribute(DynaConstants.RENDER_OPTIONS);
-
- //
- String dndValue = rendererContext.getProperty(DynaRenderOptions.DND_ENABLED);
- String partialRefreshValue =
rendererContext.getProperty(DynaRenderOptions.PARTIAL_REFRESH_ENABLED);
- DynaRenderOptions windowOptions = DynaRenderOptions.getOptions(dndValue,
partialRefreshValue);
+ final DynaRenderOptions regionOptions =
(DynaRenderOptions)rendererContext.getAttribute(DynaConstants.RENDER_OPTIONS);
//
- boolean partialRefresh = !Boolean.FALSE.equals(regionOptions.getPartialRefresh())
& !Boolean.FALSE.equals(windowOptions.getPartialRefresh());
+ try
+ {
+ String dndValue = wrc.getProperty(DynaRenderOptions.DND_ENABLED);
+ String partialRefreshValue =
wrc.getProperty(DynaRenderOptions.PARTIAL_REFRESH_ENABLED);
+ DynaRenderOptions windowOptions = DynaRenderOptions.getOptions(dndValue,
partialRefreshValue);
- //
- PrintWriter out = rendererContext.getWriter();
- out.print("<div class=\"dyna-window\">");
- out.print("<div id=\"");
- out.print(wrc.getId());
- if (regionOptions.isDnDEnabled())
- {
- if (partialRefresh)
+ //
+ DynaRenderOptions options = DynaMergeBehavior.mergeForWindow(regionOptions,
windowOptions);
+ rendererContext.setAttribute(DynaConstants.RENDER_OPTIONS, options);
+
+ //
+ PrintWriter out = rendererContext.getWriter();
+
+ //
+ if (!DynaRenderOptions.NO_AJAX.equals(regionOptions))
{
- out.print("\" class=\"dnd-window
partial-refresh-window\">\n");
+ out.print("<div class=\"dyna-window\">");
+ out.print("<div id=\"");
+ out.print(wrc.getId());
+ if (options.isDnDEnabled())
+ {
+ if (options.isPartialRefreshEnabled())
+ {
+ out.print("\" class=\"dnd-window
partial-refresh-window\">\n");
+ }
+ else
+ {
+ out.print("\" class=\"dnd-window\">\n");
+ }
+ }
+ else
+ {
+ if (options.isPartialRefreshEnabled())
+ {
+ out.print("\"
class=\"partial-refresh-window\">\n");
+ }
+ else
+ {
+ out.print("\">\n");
+ }
+ }
+
+ //
+ delegate.render(rendererContext, wrc);
+
+ //
+ out.print("</div></div>\n");
}
else
{
- out.print("\" class=\"dnd-window\">\n");
+ delegate.render(rendererContext, wrc);
}
+
+ //
+ handleProvided.set(null);
}
- else
+ finally
{
- if (partialRefresh)
- {
- out.print("\"
class=\"partial-refresh-window\">\n");
- }
- else
- {
- out.print("\">\n");
- }
+ rendererContext.setAttribute(DynaConstants.RENDER_OPTIONS, regionOptions);
}
-
- //
- delegate.render(rendererContext, wrc);
-
- //
- out.print("</div></div>\n");
-
- //
- handleProvided.set(null);
}
}
Modified: trunk/theme/src/main/org/jboss/portal/theme/page/PageResult.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/page/PageResult.java 2007-04-26 17:00:29
UTC (rev 7082)
+++ trunk/theme/src/main/org/jboss/portal/theme/page/PageResult.java 2007-04-26 17:06:10
UTC (rev 7083)
@@ -53,22 +53,18 @@
protected String pageName;
/** . */
- protected Map portalProperties;
+ protected Map properties;
/** . */
- protected Map pageProperties;
-
- /** . */
protected String layoutState;
/** . */
final Map regions;
- public PageResult(String pageName, Map pageProperties, Map portalProperties)
+ public PageResult(String pageName, Map properties)
{
this.pageName = pageName;
- this.pageProperties = pageProperties == null ? new HashMap() : pageProperties;
- this.portalProperties = portalProperties == null ? new HashMap() :
portalProperties;
+ this.properties = properties == null ? new HashMap() : properties;
this.results = new HashMap(5);
this.windowContexts = new HashMap(5);
@@ -77,7 +73,7 @@
public PageResult(String pageName)
{
- this(pageName, new HashMap(), new HashMap());
+ this(pageName, new HashMap());
}
/**
@@ -102,26 +98,6 @@
}
/**
- * Get the properties that were set for this page.
- *
- * @return a <code>java.util.Map</code> of the properties of this page
- */
- public Map getPageProperties()
- {
- return pageProperties;
- }
-
- /**
- * Get the properties that were set for this page.
- *
- * @return a <code>java.util.Map</code> of the properties of this page
- */
- public Map getPortalProperties()
- {
- return portalProperties;
- }
-
- /**
* Get the state string of the layout. <p>The state is used to further sub
select a layout uri. One layout can
* contain a separate layout uri per state. The state has to match to string version
of one of the allowed window
* states.<p>
@@ -213,23 +189,12 @@
public String getProperty(String name)
{
- String s = (String)getPageProperties().get(name);
-
- //
- if (s == null)
- {
- s = (String)getPortalProperties().get(name);
- }
-
- //
- return s;
+ return (String)properties.get(name);
}
public Map getProperties()
{
- Map tmp = new HashMap(portalProperties);
- tmp.putAll(pageProperties);
- return Collections.unmodifiableMap(tmp);
+ return properties;
}
public Collection getRegions()
Added: trunk/theme/src/main/org/jboss/portal/theme/render/PropertyFetch.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/render/PropertyFetch.java
(rev 0)
+++ trunk/theme/src/main/org/jboss/portal/theme/render/PropertyFetch.java 2007-04-26
17:06:10 UTC (rev 7083)
@@ -0,0 +1,54 @@
+/******************************************************************************
+ * 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 class PropertyFetch
+{
+
+ /** . */
+ public static final int ALL_SCOPE = 0;
+
+ /** . */
+ public static final int ANCESTORS_SCOPE = 1;
+
+ /** . */
+ private final int scope;
+
+ public PropertyFetch(int scope)
+ {
+ if (scope < ALL_SCOPE || scope > ANCESTORS_SCOPE)
+ {
+ throw new IllegalArgumentException();
+ }
+ this.scope = scope;
+ }
+
+ public int getScope()
+ {
+ return scope;
+ }
+}
Modified: trunk/theme/src/main/org/jboss/portal/theme/render/RendererContext.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/render/RendererContext.java 2007-04-26
17:00:29 UTC (rev 7082)
+++ trunk/theme/src/main/org/jboss/portal/theme/render/RendererContext.java 2007-04-26
17:06:10 UTC (rev 7083)
@@ -158,7 +158,17 @@
public String getProperty(String propertyName)
{
- for (int i = stack.size() - 1;i >= 0;i--)
+ return getProperty(propertyName, stack.size() - 1);
+ }
+
+ public String getProperty(String propertyName, PropertyFetch fetch)
+ {
+ return getProperty(propertyName, stack.size() - (fetch.getScope() ==
PropertyFetch.ALL_SCOPE ? 1 : 2));
+ }
+
+ private String getProperty(String propertyName, int from)
+ {
+ for (int i = from;i >= 0;i--)
{
ObjectRendererContext ctx = (ObjectRendererContext)stack.get(i);
String propertyValue = ctx.getProperty(propertyName);
@@ -170,6 +180,16 @@
return null;
}
+// public int getObjectRendererContextSize()
+// {
+// return stack.size();
+// }
+//
+// public ObjectRendererContext getObjectRendererContext(int index)
+// {
+// return (ObjectRendererContext)stack.get(index);
+// }
+
public void pushObjectRenderContext(ObjectRendererContext objectRendererContext)
{
stack.add(objectRendererContext);