Author: julien(a)jboss.com
Date: 2007-04-07 16:11:25 -0400 (Sat, 07 Apr 2007)
New Revision: 6944
Added:
trunk/theme/src/main/org/jboss/portal/test/theme/Counter.java
trunk/theme/src/main/org/jboss/portal/test/theme/RegionDef.java
trunk/theme/src/main/org/jboss/portal/test/theme/TestContext.java
trunk/theme/src/main/org/jboss/portal/test/theme/WindowId.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/render/AbstractObjectRenderer.java
Removed:
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaStatus.java
Modified:
trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java
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/theme/src/bin/portal-ajax-war/dyna/dyna.js
trunk/theme/src/bin/test/theme-test-war/layouts/generic/index.jsp
trunk/theme/src/main/org/jboss/portal/test/theme/TestServlet.java
trunk/theme/src/main/org/jboss/portal/test/theme/render/TestDecorationRenderer.java
trunk/theme/src/main/org/jboss/portal/test/theme/render/TestPortletRenderer.java
trunk/theme/src/main/org/jboss/portal/test/theme/render/TestRegionRenderer.java
trunk/theme/src/main/org/jboss/portal/test/theme/render/TestWindowRenderer.java
trunk/theme/src/main/org/jboss/portal/theme/impl/JSPLayout.java
trunk/theme/src/main/org/jboss/portal/theme/impl/render/div/DivDecorationRenderer.java
trunk/theme/src/main/org/jboss/portal/theme/impl/render/div/DivPortletRenderer.java
trunk/theme/src/main/org/jboss/portal/theme/impl/render/div/DivRegionRenderer.java
trunk/theme/src/main/org/jboss/portal/theme/impl/render/div/DivWindowRenderer.java
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaConstants.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/DynaWindowRenderer.java
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/JSONMarshaller.java
trunk/theme/src/main/org/jboss/portal/theme/impl/render/empty/EmptyDecorationRenderer.java
trunk/theme/src/main/org/jboss/portal/theme/impl/render/empty/EmptyPortletRenderer.java
trunk/theme/src/main/org/jboss/portal/theme/impl/render/empty/EmptyRegionRenderer.java
trunk/theme/src/main/org/jboss/portal/theme/impl/render/empty/EmptyWindowRenderer.java
trunk/theme/src/main/org/jboss/portal/theme/page/PageResult.java
trunk/theme/src/main/org/jboss/portal/theme/page/Region.java
trunk/theme/src/main/org/jboss/portal/theme/render/ObjectRenderer.java
trunk/theme/src/main/org/jboss/portal/theme/render/RendererContext.java
trunk/theme/src/main/org/jboss/portal/theme/tag/basic/IfRegionIsEmptyTag.java
Log:
- added in renderer a contextualization phase which helps to separate
contextualization/uncontextualization of the RenderContext when a RendererContext is
pushed on the stack instead of rendering it, improving fragment rendering
- added a simple test application for the dyna renderers
Modified:
trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java 2007-04-07
10:37:43 UTC (rev 6943)
+++
trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java 2007-04-07
20:11:25 UTC (rev 6944)
@@ -51,6 +51,7 @@
import org.jboss.portal.theme.page.PageRendition;
import org.jboss.portal.theme.ThemeConstants;
import org.jboss.portal.theme.impl.render.dynamic.DynaConstants;
+import org.jboss.portal.theme.impl.render.dynamic.DynaRenderOptions;
import org.jboss.portal.theme.page.Region;
import org.jboss.portal.theme.page.WindowContext;
import org.jboss.portal.theme.page.WindowResult;
@@ -79,6 +80,9 @@
private static Logger log = Logger.getLogger(PageCustomizerInterceptor.class);
/** . */
+ private static final DynaRenderOptions NO_AJAX_OPTIONS =
DynaRenderOptions.getOptions(Boolean.FALSE, Boolean.FALSE);
+
+ /** . */
private static final String RESOURCE_PREFIX = "PAGENAME_";
/** . */
@@ -124,7 +128,7 @@
//
Region region =
rendition.getPageResult().getRegion2("navigation");
- region.setProperty(DynaConstants.OBJECT_ENABLED, "false");
+ NO_AJAX_OPTIONS.setOptions(region.getProperties());
}
}
@@ -142,7 +146,7 @@
//
Region region =
rendition.getPageResult().getRegion2("dashboardnav");
- region.setProperty(DynaConstants.OBJECT_ENABLED, "false");
+ NO_AJAX_OPTIONS.setOptions(region.getProperties());
}
}
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-07
10:37:43 UTC (rev 6943)
+++
trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxInterceptor.java 2007-04-07
20:11:25 UTC (rev 6944)
@@ -30,6 +30,7 @@
import org.jboss.portal.core.model.portal.ns.PortalObjectNavigationalStateContext;
import org.jboss.portal.theme.page.PageRendition;
import org.jboss.portal.theme.impl.render.dynamic.DynaConstants;
+import org.jboss.portal.theme.impl.render.dynamic.DynaRenderOptions;
import org.jboss.portal.server.ServerURL;
import org.jboss.portal.server.AbstractServerURL;
import org.jboss.portal.server.ServerInvocationContext;
@@ -44,6 +45,9 @@
public class AjaxInterceptor extends ControllerInterceptor
{
+ /** . */
+ private static final DynaRenderOptions AJAX_OPTIONS =
DynaRenderOptions.getOptions(Boolean.TRUE, Boolean.TRUE);
+
public Object invoke(ControllerCommand cmd) throws Exception, InvocationException
{
Object response = cmd.invokeNext();
@@ -59,27 +63,29 @@
//
ControllerContext controllerContext = rpc.getControllerContext();
+ //
+ PageRendition rendition = (PageRendition)response;
+ Map pageProps = rendition.getPageResult().getPageProperties();
+
+ //
+ PortalObjectNavigationalStateContext ctx =
(PortalObjectNavigationalStateContext)controllerContext.getAttributeResolver(ControllerCommand.NAVIGATIONAL_STATE_SCOPE);
+ String viewId = ctx.getViewId();
+
+ //
+ ServerURL surl = new AbstractServerURL();
+ surl.setPortalRequestPath("/ajax");
+ String url = serverContext.renderURL(surl, serverContext.getURLContext(),
URLFormat.newInstance(true, true));
+
+ //
+ pageProps.put(DynaConstants.DYNA_RESOURCE_BASE_URL,
"/portal-ajax/dyna");
+ pageProps.put(DynaConstants.ASYNC_SERVER_URL, url);
+ pageProps.put(DynaConstants.VIEW_STATE, viewId);
+
// If user is logged in and is on dashboard we enable ajax
if (serverContext.getClientRequest().getRemoteUser() != null &&
rpc.isDashboard())
{
- ServerURL surl = new AbstractServerURL();
- surl.setPortalRequestPath("/ajax");
- String url = serverContext.renderURL(surl, serverContext.getURLContext(),
URLFormat.newInstance(true, true));
-
- //
- PortalObjectNavigationalStateContext ctx =
(PortalObjectNavigationalStateContext)controllerContext.getAttributeResolver(ControllerCommand.NAVIGATIONAL_STATE_SCOPE);
- String viewId = ctx.getViewId();
-
- //
- PageRendition rendition = (PageRendition)response;
- Map pageProps = rendition.getPageResult().getPageProperties();
-
- //
- pageProps.put(DynaConstants.DYNA_RESOURCE_BASE_URL,
"/portal-ajax/dyna");
- pageProps.put(DynaConstants.OBJECT_ENABLED, "true");
- pageProps.put(DynaConstants.ASYNC_SERVER_URL, url);
- pageProps.put(DynaConstants.VIEW_STATE, viewId);
+ AJAX_OPTIONS.setOptions(pageProps);
}
}
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-07
10:37:43 UTC (rev 6943)
+++
trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxResponseHandler.java 2007-04-07
20:11:25 UTC (rev 6944)
@@ -56,15 +56,17 @@
import org.jboss.portal.common.util.MarkupInfo;
import org.jboss.portal.theme.impl.render.dynamic.response.UpdatePageLocationResponse;
import org.jboss.portal.theme.impl.render.dynamic.response.UpdatePageStateResponse;
-import org.jboss.portal.theme.impl.render.dynamic.DynaStatus;
+import org.jboss.portal.theme.impl.render.dynamic.DynaRenderStatus;
import org.jboss.portal.theme.LayoutService;
import org.jboss.portal.theme.PortalLayout;
import org.jboss.portal.theme.PageService;
+import org.jboss.portal.theme.ThemeConstants;
import org.jboss.portal.theme.render.RendererContext;
import org.jboss.portal.theme.render.ThemeContext;
import org.jboss.portal.theme.page.PageResult;
import org.jboss.portal.theme.page.WindowResult;
import org.jboss.portal.theme.page.WindowContext;
+import org.jboss.portal.theme.page.Region;
import javax.servlet.ServletException;
import java.io.IOException;
@@ -292,11 +294,14 @@
WindowContext wc = new WindowContext(
_window.getName(),
_window.getId().toString(PortalObjectId.LEGACY_BASE64_FORMAT),
- "ABC",
+ _window.getProperty(ThemeConstants.PORTAL_PROP_REGION),
0,
windowResult);
//
+ res.addWindowContext(wc);
+
+ //
MarkupInfo markupInfo =
(MarkupInfo)invocation.getResponse().getContentInfo();
// The buffer
@@ -311,13 +316,22 @@
// get render context
RendererContext rendererContext =
layout.getRenderContext(themeContext, markupInfo, dispatcher, buffer);
- // Should push region context as well
- DynaStatus.set(rendererContext, DynaStatus.DYNA_RENDERED_VALUE);
+ // Push page
rendererContext.pushObjectRenderContext(res);
+ // Push regin
+ Region region = res.getRegion2(wc.getRegionName());
+ rendererContext.pushObjectRenderContext(region);
+
// Render
rendererContext.render(wc);
+ // Pop region
+ rendererContext.popObjectRenderContext();
+
+ // Pop page
+ rendererContext.popObjectRenderContext();
+
// Add render to the page
updatePage.addFragment(wc.getId(), buffer.toString());
}
Modified: trunk/theme/src/bin/portal-ajax-war/dyna/dyna.js
===================================================================
--- trunk/theme/src/bin/portal-ajax-war/dyna/dyna.js 2007-04-07 10:37:43 UTC (rev 6943)
+++ trunk/theme/src/bin/portal-ajax-war/dyna/dyna.js 2007-04-07 20:11:25 UTC (rev 6944)
@@ -105,7 +105,7 @@
var headers = ["ajax","true"];
// Add the view state value
- if (view_state !== undefined)
+ if (view_state != null)
{
headers.view_state = view_state;
}
@@ -139,7 +139,10 @@
}
// update view state
- view_state = resp.view_state;
+ if (resp.view_state != null)
+ {
+ view_state = resp.view_state;
+ }
}
else if (resp.type == "update_page")
{
@@ -203,11 +206,11 @@
snapshot();
// Find the dyna portlets
- var portlets_on_page = document.getElementsByClassName("dyna-window");
+ var portlets_on_page = document.getElementsByClassName("async-window");
// Add listener for the dyna windows
for(var i = 0;i < portlets_on_page.length;i++) {
- var portlet = portlets_on_page[i];
+ var portlet = Element.up(portlets_on_page[i]);
Event.observe(portlet, "click", bilto);
}
}
Modified: trunk/theme/src/bin/test/theme-test-war/layouts/generic/index.jsp
===================================================================
--- trunk/theme/src/bin/test/theme-test-war/layouts/generic/index.jsp 2007-04-07 10:37:43
UTC (rev 6943)
+++ trunk/theme/src/bin/test/theme-test-war/layouts/generic/index.jsp 2007-04-07 20:11:25
UTC (rev 6944)
@@ -9,8 +9,10 @@
</head>
<body>
<p:region regionName='AJAXScripts' regionID='AJAXScripts'/>
-<p:region regionName='left' regionID='regionA'/>
-<p:region regionName='center' regionID='regionB'/>
+<p:region regionName='RegionA' regionID='regionA'/>
+<p:region regionName='RegionB' regionID='regionB'/>
+<p:region regionName='RegionC' regionID='regionC'/>
+<p:region regionName='RegionD' regionID='regionD'/>
<p:region regionName='AJAXFooter' regionID='AJAXFooter'/>
</body>
</html>
Added: trunk/theme/src/main/org/jboss/portal/test/theme/Counter.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/test/theme/Counter.java
(rev 0)
+++ trunk/theme/src/main/org/jboss/portal/test/theme/Counter.java 2007-04-07 20:11:25 UTC
(rev 6944)
@@ -0,0 +1,51 @@
+/******************************************************************************
+ * 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 javax.servlet.http.HttpSession;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class Counter
+{
+
+ /** . */
+ private int value;
+
+ public Counter(int value)
+ {
+ this.value = value;
+ }
+
+ public void increment()
+ {
+ value++;
+ }
+
+ public int getValue()
+ {
+ return value;
+ }
+}
Added: trunk/theme/src/main/org/jboss/portal/test/theme/RegionDef.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/test/theme/RegionDef.java
(rev 0)
+++ trunk/theme/src/main/org/jboss/portal/test/theme/RegionDef.java 2007-04-07 20:11:25
UTC (rev 6944)
@@ -0,0 +1,55 @@
+/******************************************************************************
+ * 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 org.jboss.portal.theme.impl.render.dynamic.DynaRenderOptions;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class RegionDef
+{
+
+ /** . */
+ private String name;
+
+ /** . */
+ private DynaRenderOptions renderOptions;
+
+ public RegionDef(String name, DynaRenderOptions renderOptions)
+ {
+ this.name = name;
+ this.renderOptions = renderOptions;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public DynaRenderOptions getRenderOptions()
+ {
+ return renderOptions;
+ }
+}
Added: trunk/theme/src/main/org/jboss/portal/test/theme/TestContext.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/test/theme/TestContext.java
(rev 0)
+++ trunk/theme/src/main/org/jboss/portal/test/theme/TestContext.java 2007-04-07 20:11:25
UTC (rev 6944)
@@ -0,0 +1,89 @@
+/******************************************************************************
+ * 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 org.jboss.portal.theme.page.WindowResult;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+import java.util.Collections;
+import java.util.HashMap;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestContext
+{
+
+ /** . */
+ private HttpServletRequest request;
+
+ private String asyncServerURL;
+
+
+ public TestContext(HttpServletRequest request)
+ {
+ this.request = request;
+ this.asyncServerURL = request.getContextPath() + "/test";
+ }
+
+ public String getAsyncServerURL()
+ {
+ return asyncServerURL;
+ }
+
+ public Counter getCounter(WindowId windowId)
+ {
+ HttpSession session = request.getSession();
+
+ //
+ Counter counter = (Counter)session.getAttribute(windowId.toString());
+ if (counter == null)
+ {
+ counter = new Counter(0);
+ session.setAttribute(windowId.toString(), counter);
+ }
+ return counter;
+ }
+
+ public WindowResult renderWindow(WindowId windowId)
+ {
+ Counter counter = getCounter(windowId);
+ String link = asyncServerURL + "?windowId=" + windowId +
"&action=increment";
+ return createWindowMarkup("Window Title", "Counter value is " +
counter.getValue() + ", <a href=\"" + link + "\">Increment
counter</a>");
+ }
+
+ private WindowResult createWindowMarkup(String title, String content)
+ {
+ return new WindowResult(
+ title,
+ content,
+ Collections.EMPTY_MAP,
+ new HashMap(),
+ null,
+ null,
+ null,
+ null);
+ }
+}
Modified: trunk/theme/src/main/org/jboss/portal/test/theme/TestServlet.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/test/theme/TestServlet.java 2007-04-07 10:37:43
UTC (rev 6943)
+++ trunk/theme/src/main/org/jboss/portal/test/theme/TestServlet.java 2007-04-07 20:11:25
UTC (rev 6944)
@@ -32,7 +32,11 @@
import org.jboss.portal.theme.page.PageResult;
import org.jboss.portal.theme.page.WindowContext;
import org.jboss.portal.theme.page.WindowResult;
+import org.jboss.portal.theme.page.Region;
import org.jboss.portal.theme.impl.render.dynamic.DynaConstants;
+import org.jboss.portal.theme.impl.render.dynamic.DynaRenderOptions;
+import org.jboss.portal.theme.impl.render.dynamic.JSONMarshaller;
+import org.jboss.portal.theme.impl.render.dynamic.response.UpdatePageStateResponse;
import org.jboss.portal.theme.PortalRenderSet;
import org.jboss.portal.theme.render.RendererContext;
import org.jboss.portal.theme.render.ThemeContext;
@@ -48,14 +52,42 @@
import javax.management.MBeanServer;
import javax.management.ObjectName;
import java.io.IOException;
-import java.util.HashMap;
-import java.util.Collections;
+import java.io.StringWriter;
+import java.util.Map;
+import java.util.Iterator;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
/** @author <a href="mailto:roy@jboss.org">Roy Russo</a> */
public class TestServlet extends HttpServlet
{
+ /** . */
+ private Map page;
+
+ public TestServlet()
+ {
+ this.page = new LinkedHashMap();
+
+ //
+ RegionDef regionA = new RegionDef("RegionA",
DynaRenderOptions.getOptions(Boolean.FALSE, Boolean.FALSE));
+ RegionDef regionB = new RegionDef("RegionB",
DynaRenderOptions.getOptions(Boolean.FALSE, Boolean.TRUE));
+ RegionDef regionC = new RegionDef("RegionC",
DynaRenderOptions.getOptions(Boolean.TRUE, Boolean.FALSE));
+ RegionDef regionD = new RegionDef("RegionD",
DynaRenderOptions.getOptions(Boolean.TRUE, Boolean.TRUE));
+
+ //
+ page.put(new WindowId(0), regionA);
+ page.put(new WindowId(1), regionA);
+ page.put(new WindowId(2), regionB);
+ page.put(new WindowId(3), regionB);
+ page.put(new WindowId(4), regionC);
+ page.put(new WindowId(5), regionC);
+ page.put(new WindowId(6), regionD);
+ page.put(new WindowId(7), regionD);
+ }
+
+
/**
* Generates a portal page with windows, using the theme api.
*/
@@ -79,20 +111,35 @@
ServletContainerContext servletContainerContext =
(ServletContainerContext)MBeanProxy.get(ServletContainerContext.class, new
ObjectName("portal:service=ServletContainerContext"), mbeanServer);
LayoutService layoutService = (LayoutService)MBeanProxy.get(LayoutService.class,
new ObjectName("portal:service=LayoutService"), mbeanServer);
ThemeService themeService = (ThemeService)MBeanProxy.get(ThemeService.class, new
ObjectName("portal:service=ThemeService"), mbeanServer);
-
PortalRenderSet renderSet = layoutService.getRenderSet("testRenderer",
MediaType.HTML);
PortalLayout layout = layoutService.getLayout("generic", true);
PortalTheme theme = themeService.getTheme("testTheme", true);
+ //
+ TestContext testContext = new TestContext(request);
+
+ // Handle action here
+ WindowId windowId = request.getParameter("windowId") != null ? new
WindowId(request.getParameter("windowId")) : null;
+ String action = request.getParameter("action");
+ if ("increment".equals(action))
+ {
+ Counter counter = testContext.getCounter(windowId);
+ counter.increment();
+ }
+
+ //
+ boolean ajax = "true".equals(request.getHeader("ajax"));
+ MarkupInfo markupInfo = new MarkupInfo(MediaType.HTML, "UTF-8");
+ ServletContextDispatcher dispatcher = new ServletContextDispatcher(request,
response, servletContainerContext);
+ ThemeContext themeContext = new ThemeContext(theme, themeService);
+
// Build a page structure
PageResult pageRenderCtx = new PageResult("test_page");
//
pageRenderCtx.setLayoutState(null);
-
- //
pageRenderCtx.getPageProperties().put(DynaConstants.DYNA_RESOURCE_BASE_URL,
request.getContextPath() + "/dyna");
- pageRenderCtx.getPageProperties().put(DynaConstants.ASYNC_SERVER_URL,
request.getContextPath());
+ pageRenderCtx.getPageProperties().put(DynaConstants.ASYNC_SERVER_URL,
testContext.getAsyncServerURL());
//
pageRenderCtx.getPortalProperties().put(ThemeConstants.PORTAL_PROP_THEME,
theme.getThemeInfo().getName());
@@ -100,61 +147,48 @@
pageRenderCtx.getPortalProperties().put(ThemeConstants.PORTAL_PROP_LAYOUT,
layout.getLayoutInfo().getName());
//
- for (int i = 0; i < 2; i++)
+ for (Iterator i = page.entrySet().iterator();i.hasNext();)
{
- WindowContext wCtx = new WindowContext("WindowA_" + i,
"WindowA_" + i, "left", i, createWindowMarkup("WindowA_" + i
+ " Title", "WindowA_" + i + " Content"));
- pageRenderCtx.addWindowContext(wCtx);
+ Map.Entry entry = (Map.Entry)i.next();
+ WindowId _windowId = (WindowId)entry.getKey();
+ RegionDef region = (RegionDef)entry.getValue();
+ WindowResult window = testContext.renderWindow(_windowId);
+ pageRenderCtx.addWindow(region.getName(), _windowId.toString(),
window.toString(), window);
}
- for (int i = 0; i < 2; i++)
+
+ //
+ for (Iterator i = new HashSet(page.values()).iterator();i.hasNext();)
{
- WindowContext wCtx = new WindowContext("WindowB_" + i,
"WindowB_" + i, "center", i, createWindowMarkup("WindowB_" +
i + " Title", "WindowB_" + i + " Content"));
- pageRenderCtx.addWindowContext(wCtx);
+ RegionDef region = (RegionDef)i.next();
+
region.getRenderOptions().setOptions(pageRenderCtx.getRegion2(region.getName()).getProperties());
}
//
- MarkupInfo markupInfo = new MarkupInfo(MediaType.HTML, "UTF-8");
+ if (ajax)
+ {
+ WindowContext windowCtx = pageRenderCtx.getWindowContext(windowId.toString());
+ Region region = pageRenderCtx.getRegion2(windowCtx.getRegionName());
- ServletContextDispatcher dispatcher = new ServletContextDispatcher(request,
response, servletContainerContext);
+ //
+ StringWriter buffer = new StringWriter();
+ RendererContext rendererCtx = layout.getRenderContext(themeContext, markupInfo,
dispatcher, buffer);
+ rendererCtx.pushObjectRenderContext(pageRenderCtx);
+ rendererCtx.pushObjectRenderContext(region);
+ rendererCtx.render(windowCtx);
- ThemeContext themeContext = new ThemeContext(theme, themeService);
+ //
+ UpdatePageStateResponse resp = new UpdatePageStateResponse(null);
+ resp.addFragment(windowId.toString(), buffer.toString());
+ JSONMarshaller marshaller = new JSONMarshaller();
- RendererContext rendererCtx = layout.getRenderContext(themeContext, markupInfo,
dispatcher);
-
- pageRenderCtx.getPageProperties().put(DynaConstants.OBJECT_ENABLED,
"true");
-
- rendererCtx.render(pageRenderCtx);
-
-
-// //
-// ServerRequest serverRequest = new ServerRequest(null);
-//
-// // pageresult obj
-// PageResult pageResult = new PageResult(TEST_PAGE_NAME, pageProps, portalProps);
-// pageResult.setLayoutURI(layout.getLayoutInfo().getURI());
-// pageResult.setTheme(theme);
-//
-// // set the renderctx and req/res attr
-//// RenderContext renderCtx = new RenderContext(layout, markupInfo, pageResult);
-//// response.setContentType(renderCtx.getContentType().toString());
-//// response.setCharacterEncoding(renderCtx.getCharset());
-//// request.setAttribute(LayoutConstants.ATTR_RENDERCONTEXT, renderCtx);
-//// request.setAttribute(LayoutConstants.ATTR_PAGE, pageResult);
-//// request.setAttribute(ThemeConstants.ATTR_THEME, theme);
-//
-// //
-//// LayoutDispatcher dispatcher1 = new LayoutDispatcher(renderCtx, request,
response, pageResult);
-//// dispatcher1.include();
+ //
+ response.setContentType("text/xml");
+ marshaller.write(resp, response.getWriter());
+ }
+ else
+ {
+ RendererContext rendererCtx = layout.getRenderContext(themeContext, markupInfo,
dispatcher);
+ rendererCtx.render(pageRenderCtx);
+ }
}
-
- /**
- * Generates the WindowResult for our windowcontext
- *
- * @param sTitle
- * @param sContent
- * @return window markup result
- */
- private WindowResult createWindowMarkup(String sTitle, String sContent)
- {
- return new WindowResult(sTitle, sContent, Collections.EMPTY_MAP, new HashMap(),
null, null, null, null);
- }
}
Added: trunk/theme/src/main/org/jboss/portal/test/theme/WindowId.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/test/theme/WindowId.java
(rev 0)
+++ trunk/theme/src/main/org/jboss/portal/test/theme/WindowId.java 2007-04-07 20:11:25 UTC
(rev 6944)
@@ -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.test.theme;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class WindowId
+{
+
+ /** . */
+ private final int value;
+
+ public WindowId(int value)
+ {
+ this.value = value;
+ }
+
+ public int getValue()
+ {
+ return value;
+ }
+
+ public WindowId(String value)
+ {
+ this.value = Integer.parseInt(value.substring("WindowId_".length()));
+ }
+
+ public String toString()
+ {
+ return "WindowId_" + value;
+ }
+}
Modified:
trunk/theme/src/main/org/jboss/portal/test/theme/render/TestDecorationRenderer.java
===================================================================
---
trunk/theme/src/main/org/jboss/portal/test/theme/render/TestDecorationRenderer.java 2007-04-07
10:37:43 UTC (rev 6943)
+++
trunk/theme/src/main/org/jboss/portal/test/theme/render/TestDecorationRenderer.java 2007-04-07
20:11:25 UTC (rev 6944)
@@ -26,13 +26,14 @@
import org.jboss.portal.theme.render.renderer.DecorationRendererContext;
import org.jboss.portal.theme.render.RendererContext;
import org.jboss.portal.theme.render.RenderException;
+import org.jboss.portal.theme.render.AbstractObjectRenderer;
import java.io.PrintWriter;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
*/
-public class TestDecorationRenderer
+public class TestDecorationRenderer extends AbstractObjectRenderer
implements DecorationRenderer
{
public void render(RendererContext rendererContext, DecorationRendererContext drc)
throws RenderException
Modified:
trunk/theme/src/main/org/jboss/portal/test/theme/render/TestPortletRenderer.java
===================================================================
---
trunk/theme/src/main/org/jboss/portal/test/theme/render/TestPortletRenderer.java 2007-04-07
10:37:43 UTC (rev 6943)
+++
trunk/theme/src/main/org/jboss/portal/test/theme/render/TestPortletRenderer.java 2007-04-07
20:11:25 UTC (rev 6944)
@@ -26,13 +26,14 @@
import org.jboss.portal.theme.render.RendererContext;
import org.jboss.portal.theme.render.renderer.PortletRendererContext;
import org.jboss.portal.theme.render.RenderException;
+import org.jboss.portal.theme.render.AbstractObjectRenderer;
import java.io.PrintWriter;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
*/
-public class TestPortletRenderer
+public class TestPortletRenderer extends AbstractObjectRenderer
implements PortletRenderer
{
public void render(RendererContext rendererContext, PortletRendererContext prc) throws
RenderException
Modified: trunk/theme/src/main/org/jboss/portal/test/theme/render/TestRegionRenderer.java
===================================================================
---
trunk/theme/src/main/org/jboss/portal/test/theme/render/TestRegionRenderer.java 2007-04-07
10:37:43 UTC (rev 6943)
+++
trunk/theme/src/main/org/jboss/portal/test/theme/render/TestRegionRenderer.java 2007-04-07
20:11:25 UTC (rev 6944)
@@ -26,6 +26,7 @@
import org.jboss.portal.theme.render.RendererContext;
import org.jboss.portal.theme.render.renderer.RegionRendererContext;
import org.jboss.portal.theme.render.RenderException;
+import org.jboss.portal.theme.render.AbstractObjectRenderer;
import org.jboss.portal.theme.render.renderer.WindowRendererContext;
import java.util.Iterator;
@@ -34,7 +35,7 @@
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
*/
-public class TestRegionRenderer
+public class TestRegionRenderer extends AbstractObjectRenderer
implements RegionRenderer
{
Modified: trunk/theme/src/main/org/jboss/portal/test/theme/render/TestWindowRenderer.java
===================================================================
---
trunk/theme/src/main/org/jboss/portal/test/theme/render/TestWindowRenderer.java 2007-04-07
10:37:43 UTC (rev 6943)
+++
trunk/theme/src/main/org/jboss/portal/test/theme/render/TestWindowRenderer.java 2007-04-07
20:11:25 UTC (rev 6944)
@@ -26,20 +26,21 @@
import org.jboss.portal.theme.render.RendererContext;
import org.jboss.portal.theme.render.renderer.WindowRendererContext;
import org.jboss.portal.theme.render.RenderException;
+import org.jboss.portal.theme.render.AbstractObjectRenderer;
import java.io.PrintWriter;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
*/
-public class TestWindowRenderer implements WindowRenderer
+public class TestWindowRenderer extends AbstractObjectRenderer implements WindowRenderer
{
public void render(RendererContext rendererContext, WindowRendererContext wrc) throws
RenderException
{
PrintWriter writer = rendererContext.getWriter();
- writer.print("<div class=\"test-window\">");
+ writer.print("<div class=\"test-window\">\n");
rendererContext.render(wrc.getDecoration());
rendererContext.render(wrc.getPortlet());
- writer.print("</div>");
+ writer.print("\n</div>\n");
}
}
Modified: trunk/theme/src/main/org/jboss/portal/theme/impl/JSPLayout.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/impl/JSPLayout.java 2007-04-07 10:37:43
UTC (rev 6943)
+++ trunk/theme/src/main/org/jboss/portal/theme/impl/JSPLayout.java 2007-04-07 20:11:25
UTC (rev 6944)
@@ -34,6 +34,7 @@
import org.jboss.portal.theme.render.RenderException;
import org.jboss.portal.theme.render.RendererFactory;
import org.jboss.portal.theme.render.ThemeContext;
+import org.jboss.portal.theme.render.ObjectRendererContext;
import org.jboss.portal.WindowState;
import org.jboss.portal.web.ServletContextDispatcher;
import org.jboss.portal.common.util.MarkupInfo;
@@ -62,7 +63,6 @@
return new JSPRendererContext(themeContext, factory, dispatcher, markupInfo);
}
-
public RendererContext getRenderContext(ThemeContext themeContext, MarkupInfo
markupInfo, ServletContextDispatcher dispatcher, Writer writer)
{
RendererFactory factory = new RendererFactoryImpl(this, serviceInfo, info);
@@ -71,6 +71,14 @@
return new WriterRendererContext(themeContext, factory, dispatcher, markupInfo, new
PrintWriter(writer));
}
+ public void startContext(RendererContext rendererContext, ObjectRendererContext
objectRenderContext)
+ {
+ }
+
+ public void endContext(RendererContext rendererContext, ObjectRendererContext
objectRenderContext)
+ {
+ }
+
public void render(RendererContext rendererContext, PageRendererContext prc) throws
RenderException
{
PageResult pageResult = (PageResult)prc;
Modified:
trunk/theme/src/main/org/jboss/portal/theme/impl/render/div/DivDecorationRenderer.java
===================================================================
---
trunk/theme/src/main/org/jboss/portal/theme/impl/render/div/DivDecorationRenderer.java 2007-04-07
10:37:43 UTC (rev 6943)
+++
trunk/theme/src/main/org/jboss/portal/theme/impl/render/div/DivDecorationRenderer.java 2007-04-07
20:11:25 UTC (rev 6944)
@@ -27,6 +27,7 @@
import org.jboss.portal.theme.render.renderer.DecorationRenderer;
import org.jboss.portal.theme.render.RendererContext;
import org.jboss.portal.theme.render.RenderException;
+import org.jboss.portal.theme.render.AbstractObjectRenderer;
import org.jboss.portal.theme.render.renderer.DecorationRendererContext;
import org.jboss.portal.theme.render.renderer.ActionRendererContext;
@@ -46,7 +47,7 @@
* @version $LastChangedRevision$, $LastChangedDate$
* @see org.jboss.portal.theme.render.renderer.DecorationRenderer
*/
-public class DivDecorationRenderer
+public class DivDecorationRenderer extends AbstractObjectRenderer
implements DecorationRenderer
{
Modified:
trunk/theme/src/main/org/jboss/portal/theme/impl/render/div/DivPortletRenderer.java
===================================================================
---
trunk/theme/src/main/org/jboss/portal/theme/impl/render/div/DivPortletRenderer.java 2007-04-07
10:37:43 UTC (rev 6943)
+++
trunk/theme/src/main/org/jboss/portal/theme/impl/render/div/DivPortletRenderer.java 2007-04-07
20:11:25 UTC (rev 6944)
@@ -25,6 +25,7 @@
import org.jboss.portal.theme.render.renderer.PortletRenderer;
import org.jboss.portal.theme.render.RendererContext;
import org.jboss.portal.theme.render.RenderException;
+import org.jboss.portal.theme.render.AbstractObjectRenderer;
import org.jboss.portal.theme.render.renderer.PortletRendererContext;
import java.io.PrintWriter;
@@ -36,7 +37,7 @@
* @version $LastChangedRevision$, $LastChangedDate$
* @see org.jboss.portal.theme.render.renderer.PortletRenderer
*/
-public class DivPortletRenderer implements PortletRenderer
+public class DivPortletRenderer extends AbstractObjectRenderer implements
PortletRenderer
{
public void render(RendererContext rendererContext, PortletRendererContext prc) throws
RenderException
{
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-04-07
10:37:43 UTC (rev 6943)
+++
trunk/theme/src/main/org/jboss/portal/theme/impl/render/div/DivRegionRenderer.java 2007-04-07
20:11:25 UTC (rev 6944)
@@ -25,6 +25,7 @@
import org.jboss.portal.theme.render.renderer.RegionRenderer;
import org.jboss.portal.theme.render.RendererContext;
import org.jboss.portal.theme.render.RenderException;
+import org.jboss.portal.theme.render.AbstractObjectRenderer;
import org.jboss.portal.theme.render.renderer.RegionRendererContext;
import org.jboss.portal.theme.render.renderer.WindowRendererContext;
@@ -39,7 +40,7 @@
* @version $LastChangedRevision$, $LastChangedDate$
* @see org.jboss.portal.theme.render.renderer.RegionRenderer
*/
-public class DivRegionRenderer
+public class DivRegionRenderer extends AbstractObjectRenderer
implements RegionRenderer
{
Modified:
trunk/theme/src/main/org/jboss/portal/theme/impl/render/div/DivWindowRenderer.java
===================================================================
---
trunk/theme/src/main/org/jboss/portal/theme/impl/render/div/DivWindowRenderer.java 2007-04-07
10:37:43 UTC (rev 6943)
+++
trunk/theme/src/main/org/jboss/portal/theme/impl/render/div/DivWindowRenderer.java 2007-04-07
20:11:25 UTC (rev 6944)
@@ -24,6 +24,7 @@
import org.jboss.portal.theme.render.RendererContext;
import org.jboss.portal.theme.render.RenderException;
+import org.jboss.portal.theme.render.AbstractObjectRenderer;
import org.jboss.portal.theme.render.renderer.WindowRenderer;
import org.jboss.portal.theme.render.renderer.WindowRendererContext;
@@ -36,7 +37,7 @@
* @version $LastChangedRevision$, $LastChangedDate$
* @see org.jboss.portal.theme.render.renderer.WindowRenderer
*/
-public class DivWindowRenderer
+public class DivWindowRenderer extends AbstractObjectRenderer
implements WindowRenderer
{
public void render(RendererContext rendererContext, WindowRendererContext wrc) throws
RenderException
Modified:
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaConstants.java
===================================================================
---
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaConstants.java 2007-04-07
10:37:43 UTC (rev 6943)
+++
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaConstants.java 2007-04-07
20:11:25 UTC (rev 6944)
@@ -29,25 +29,19 @@
public final class DynaConstants
{
- /** The mask for the DnDability. */
- public static final int DYNA_DND_MASK = 0x01;
-
- /** The mask for asynchronous windows. */
- public static final int DYNA_ASYNC_WINDOW_MASK = 0x02;
-
/** . */
public static final String DYNA_RESOURCE_BASE_URL =
"theme.dyna.resource_base_url";
/** . */
public static final String ASYNC_SERVER_URL =
"theme.dyna.async_server_url";
- /** . */
- public static final String OBJECT_ENABLED = "theme.dyna.object_enabled";
-
/** The id for view state. */
public static final String VIEW_STATE = "theme.dyna.view_state";
/** . */
+ public static final String DYNA_RENDER_OPTIONS = "dyna_render_options";
+
+ /** . */
public static final String DYNA_RENDER_STATUS = "dyna_render_status";
}
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-07
10:37:43 UTC (rev 6943)
+++
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaDecorationRenderer.java 2007-04-07
20:11:25 UTC (rev 6944)
@@ -25,6 +25,7 @@
import org.jboss.portal.theme.render.renderer.DecorationRenderer;
import org.jboss.portal.theme.render.RendererContext;
import org.jboss.portal.theme.render.RenderException;
+import org.jboss.portal.theme.render.AbstractObjectRenderer;
import org.jboss.portal.theme.render.renderer.DecorationRendererContext;
import java.io.PrintWriter;
@@ -37,7 +38,7 @@
* @version $LastChangedRevision$, $LastChangedDate$
* @see org.jboss.portal.theme.render.renderer.DecorationRenderer
*/
-public class DynaDecorationRenderer implements DecorationRenderer
+public class DynaDecorationRenderer extends AbstractObjectRenderer implements
DecorationRenderer
{
/** . */
@@ -51,22 +52,24 @@
public void render(RendererContext rendererContext, DecorationRendererContext drc)
throws RenderException
{
- switch(DynaStatus.get(rendererContext))
+ DynaRenderOptions regionOptions =
(DynaRenderOptions)rendererContext.getAttribute(DynaConstants.DYNA_RENDER_OPTIONS);
+
+ //
+ if (regionOptions.isDnDEnabled())
{
- case DynaStatus.DYNA_RENDERED_VALUE:
- DynaWindowRenderer.handleProvided.set(Boolean.TRUE);
+ DynaWindowRenderer.handleProvided.set(Boolean.TRUE);
- //
- PrintWriter markup = rendererContext.getWriter();
- markup.print("<div class=\"dyna-decoration\">\n");
- markup.print("<div class=\"handle\">");
- delegate.render(rendererContext, drc);
- markup.print("</div>\n");
- markup.print("</div>\n");
- break;
- case DynaStatus.CLASSIC_RENDERED_VALUE:
- delegate.render(rendererContext, drc);
- break;
+ //
+ PrintWriter markup = rendererContext.getWriter();
+ markup.print("<div class=\"dyna-decoration\">\n");
+ markup.print("<div class=\"handle\">");
+ delegate.render(rendererContext, drc);
+ markup.print("</div>\n");
+ markup.print("</div>\n");
}
+ else
+ {
+ delegate.render(rendererContext, drc);
+ }
}
}
\ No newline at end of file
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-07
10:37:43 UTC (rev 6943)
+++
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaPortletRenderer.java 2007-04-07
20:11:25 UTC (rev 6944)
@@ -26,6 +26,7 @@
import org.jboss.portal.theme.render.renderer.PortletRenderer;
import org.jboss.portal.theme.render.RendererContext;
import org.jboss.portal.theme.render.RenderException;
+import org.jboss.portal.theme.render.AbstractObjectRenderer;
import org.jboss.portal.theme.render.renderer.PortletRendererContext;
import java.io.PrintWriter;
@@ -38,7 +39,7 @@
* @version $LastChangedRevision$, $LastChangedDate$
* @see org.jboss.portal.theme.render.renderer.PortletRenderer
*/
-public class DynaPortletRenderer implements PortletRenderer
+public class DynaPortletRenderer extends AbstractObjectRenderer implements
PortletRenderer
{
private PortletRenderer delegate;
@@ -58,45 +59,39 @@
private void doDND(RendererContext rendererContext, PortletRendererContext prc) throws
RenderException
{
- switch(DynaStatus.get(rendererContext))
+ DynaRenderOptions regionOptions =
(DynaRenderOptions)rendererContext.getAttribute(DynaConstants.DYNA_RENDER_OPTIONS);
+
+ //
+ if (regionOptions.isDnDEnabled())
{
- case DynaStatus.DYNA_RENDERED_VALUE:
- // Provide handle on content if needed
- if (Boolean.FALSE.equals(DynaWindowRenderer.handleProvided.get()))
- {
- //
- DynaWindowRenderer.handleProvided.set(Boolean.TRUE);
+ // Provide handle on content if needed
+ if (Boolean.FALSE.equals(DynaWindowRenderer.handleProvided.get()))
+ {
+ //
+ DynaWindowRenderer.handleProvided.set(Boolean.TRUE);
- //
+ //
// StringBuffer out = renderContext.getMarkupFragment();
// out.append("<span class=\"handle\">");
- doCatchClicks(rendererContext, prc);
+ doCatchClicks(rendererContext, prc);
// out.append("</span>");
- }
- else
- {
- doCatchClicks(rendererContext, prc);
- }
- break;
- case DynaStatus.CLASSIC_RENDERED_VALUE:
+ }
+ else
+ {
doCatchClicks(rendererContext, prc);
- break;
+ }
}
+ else
+ {
+ doCatchClicks(rendererContext, prc);
+ }
}
private void doCatchClicks(RendererContext rendererContext, PortletRendererContext
prc) throws RenderException
{
- switch(DynaStatus.get(rendererContext))
- {
- case DynaStatus.DYNA_RENDERED_VALUE:
- PrintWriter out = rendererContext.getWriter();
- out.print("<div class=\"dyna-portlet\">");
- delegate.render(rendererContext, prc);
- out.print("</div>");
- break;
- case DynaStatus.CLASSIC_RENDERED_VALUE:
- delegate.render(rendererContext, prc);
- break;
- }
+ PrintWriter out = rendererContext.getWriter();
+ out.print("<div class=\"dyna-portlet\">");
+ delegate.render(rendererContext, prc);
+ out.print("</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-04-07
10:37:43 UTC (rev 6943)
+++
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaRegionRenderer.java 2007-04-07
20:11:25 UTC (rev 6944)
@@ -48,6 +48,8 @@
import org.jboss.portal.theme.render.renderer.RegionRenderer;
import org.jboss.portal.theme.render.RendererContext;
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.renderer.RegionRendererContext;
import java.io.PrintWriter;
@@ -59,7 +61,7 @@
* @author <a href="mailto:roy@jboss.org">Roy Russo</a>
* @see org.jboss.portal.theme.render.renderer.RegionRenderer
*/
-public class DynaRegionRenderer implements RegionRenderer
+public class DynaRegionRenderer extends AbstractObjectRenderer implements RegionRenderer
{
/** . */
@@ -72,6 +74,36 @@
delegate = regionRenderer;
}
+ public void startContext(RendererContext rendererContext, ObjectRendererContext
objectRenderContext)
+ {
+ RegionRendererContext rrc = (RegionRendererContext)objectRenderContext;
+
+ //
+ if ("AJAXScripts".equals(rrc.getId()) ||
"AJAXFooter".equals(rrc.getId()))
+ {
+ DynaRenderStatus.set(rendererContext, false);
+ }
+ else
+ {
+ String dndValue = rendererContext.getProperty(DynaRenderOptions.DND_ENABLED);
+ String asyncWindowValue =
rendererContext.getProperty(DynaRenderOptions.ASYNC_WINDOW_ENABLED);
+ DynaRenderOptions options = DynaRenderOptions.getOptions(dndValue,
asyncWindowValue);
+
+ //
+ rendererContext.setAttribute(DynaConstants.DYNA_RENDER_OPTIONS, options);
+ DynaRenderStatus.set(rendererContext, true);
+ }
+ }
+
+
+ public void endContext(RendererContext rendererContext, ObjectRendererContext
objectRenderContext)
+ {
+ if (DynaRenderStatus.get(rendererContext))
+ {
+ rendererContext.setAttribute(DynaConstants.DYNA_RENDER_OPTIONS, null);
+ }
+ }
+
public void renderHeader(RendererContext rendererContext, RegionRendererContext rrc)
throws RenderException
{
PrintWriter markup = rendererContext.getWriter();
@@ -79,138 +111,95 @@
String asyncServerURL =
rendererContext.getProperty(DynaConstants.ASYNC_SERVER_URL);
String viewState = rendererContext.getProperty(DynaConstants.VIEW_STATE);
- //
- Object onPage = rendererContext.getProperty(DynaConstants.OBJECT_ENABLED);
- boolean pageEnabled = onPage != null && "true".equals(onPage);
-
- //
- int status = DynaStatus.CLASSIC_RENDERED_VALUE;
-
// Handle special ajax region here
if ("AJAXScripts".equals(rrc.getId()))
{
- status = DynaStatus.NOT_RENDERED_VALUE;
+ markup.print("<script type='text/javascript' src='");
+ markup.print(jsBase);
+ markup.print("/prototype.js'></script>\n");
+ markup.print("<script type='text/javascript' src='");
+ markup.print(jsBase);
+ markup.print("/scriptaculous.js'></script>\n");
+ markup.print("<script type='text/javascript' src='");
+ markup.print(jsBase);
+ markup.print("/effects.js'></script>\n");
+ markup.print("<script type='text/javascript' src='");
+ markup.print(jsBase);
+ markup.print("/dragdrop.js'></script>\n");
+ markup.print("<script type='text/javascript' src='");
+ markup.print(jsBase);
+ markup.print("/dyna.js'></script>\n");
+ markup.print("<script type='text/javascript'>\n");
- //
- if (pageEnabled)
- {
- markup.print("<script type='text/javascript'
src='");
- markup.print(jsBase);
- markup.print("/prototype.js'></script>\n");
- markup.print("<script type='text/javascript'
src='");
- markup.print(jsBase);
- markup.print("/scriptaculous.js'></script>\n");
- markup.print("<script type='text/javascript'
src='");
- markup.print(jsBase);
- markup.print("/effects.js'></script>\n");
- markup.print("<script type='text/javascript'
src='");
- markup.print(jsBase);
- markup.print("/dragdrop.js'></script>\n");
- markup.print("<script type='text/javascript'
src='");
- markup.print(jsBase);
- markup.print("/dyna.js'></script>\n");
- markup.print("<script type='text/javascript'>\n");
+ // Async server URL needed for callbacks
+ markup.print("async_server_url=\"");
+ markup.print(asyncServerURL);
+ markup.print("\";\n");
- // Async server URL needed for callbacks
- markup.print("async_server_url=\"");
- markup.print(asyncServerURL);
+ // View state if not null
+ if (viewState != null)
+ {
+ markup.print("view_state = \"");
+ markup.print(viewState);
markup.print("\";\n");
-
- // View state if not null
- if (viewState != null)
- {
- markup.print("view_state=\"");
- markup.print(viewState);
- markup.print("\";\n");
- }
-
- //
- markup.print("</script>\n");
}
- }
- else if ("AJAXFooter".equals(rrc.getId()))
- {
- status = DynaStatus.NOT_RENDERED_VALUE;
-
- //
- if (pageEnabled)
+ else
{
- markup.print("<script
type='text/javascript'>footer()</script>\n");
+ markup.print("view_state = null;");
}
+
+ //
+ markup.print("</script>\n");
}
- else
+ else if ("AJAXFooter".equals(rrc.getId()))
{
- if (pageEnabled)
- {
- String onRegion = rrc.getProperty(DynaConstants.OBJECT_ENABLED);
- boolean regionEnabled = onRegion == null ||
"true".equals(onRegion);
- if (regionEnabled)
- {
- status = DynaStatus.DYNA_RENDERED_VALUE;
- }
- }
+ markup.print("<script
type='text/javascript'>footer()</script>\n");
}
//
- rendererContext.setAttribute(DynaConstants.DYNA_RENDER_STATUS, new
Integer(status));
-
- //
- switch(status)
+ if (DynaRenderStatus.get(rendererContext))
{
- case DynaStatus.DYNA_RENDERED_VALUE:
- delegate.renderHeader(rendererContext, rrc);
+ delegate.renderHeader(rendererContext, rrc);
- // We need height and width otherwise the region will not be usable when
empty
+ //
+ DynaRenderOptions options =
(DynaRenderOptions)rendererContext.getAttribute(DynaConstants.DYNA_RENDER_OPTIONS);
+
+ //
+ if (options.isDnDEnabled())
+ {
markup.print("<div class=\"dyna-region\"
id=\"");
markup.print(rrc.getId());
markup.print("\">");
- break;
- case DynaStatus.CLASSIC_RENDERED_VALUE:
- delegate.renderHeader(rendererContext, rrc);
- break;
- case DynaStatus.NOT_RENDERED_VALUE:
- break;
+ }
}
}
- public void renderFooter(RendererContext rendererContext, RegionRendererContext rrc)
throws RenderException
+ /**
+ * @see org.jboss.portal.theme.render.renderer.RegionRenderer#renderBody
+ */
+ public void renderBody(RendererContext rendererContext, final RegionRendererContext
rrc) throws RenderException
{
- int status = DynaStatus.get(rendererContext);
-
- //
- rendererContext.setAttribute(DynaConstants.DYNA_RENDER_STATUS, null);
-
- //
- switch(status)
+ if (DynaRenderStatus.get(rendererContext))
{
- case DynaStatus.DYNA_RENDERED_VALUE:
- PrintWriter markup = rendererContext.getWriter();
- markup.print("</div>");
- delegate.renderFooter(rendererContext, rrc);
- break;
- case DynaStatus.CLASSIC_RENDERED_VALUE:
- delegate.renderFooter(rendererContext, rrc);
- break;
- case DynaStatus.NOT_RENDERED_VALUE:
- break;
+ delegate.renderBody(rendererContext, rrc);
}
}
- /**
- * @see org.jboss.portal.theme.render.renderer.RegionRenderer#renderBody
- */
- public void renderBody(RendererContext rendererContext, final RegionRendererContext
rrc) throws RenderException
+ public void renderFooter(RendererContext rendererContext, RegionRendererContext rrc)
throws RenderException
{
- switch(DynaStatus.get(rendererContext))
+ if (DynaRenderStatus.get(rendererContext))
{
- case DynaStatus.DYNA_RENDERED_VALUE:
- delegate.renderBody(rendererContext, rrc);
- break;
- case DynaStatus.CLASSIC_RENDERED_VALUE:
- delegate.renderBody(rendererContext, rrc);
- break;
- case DynaStatus.NOT_RENDERED_VALUE:
- break;
+ DynaRenderOptions options =
(DynaRenderOptions)rendererContext.getAttribute(DynaConstants.DYNA_RENDER_OPTIONS);
+
+ //
+ if (options.isDnDEnabled())
+ {
+ PrintWriter markup = rendererContext.getWriter();
+ markup.print("</div>");
+ }
+
+ //
+ delegate.renderFooter(rendererContext, rrc);
}
}
}
Added:
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
(rev 0)
+++
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaRenderOptions.java 2007-04-07
20:11:25 UTC (rev 6944)
@@ -0,0 +1,137 @@
+/******************************************************************************
+ * 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;
+
+import java.util.Map;
+
+/**
+ * Encapsulate dyna render options.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class DynaRenderOptions
+{
+
+ /** . */
+ public static final String DND_ENABLED = "theme.dyna.dnd_enabled";
+
+ /** . */
+ public static final String ASYNC_WINDOW_ENABLED =
"theme.dyna.async_window_enabled";
+
+ /**
+ * Flyweight pattern.
+ */
+ private static final DynaRenderOptions[] FLYWEIGHTS =
+ {
+ new DynaRenderOptions(null, null),
+ new DynaRenderOptions(Boolean.TRUE, null),
+ new DynaRenderOptions(Boolean.FALSE, null),
+ null,
+ new DynaRenderOptions(null, Boolean.TRUE),
+ new DynaRenderOptions(Boolean.TRUE, Boolean.TRUE),
+ new DynaRenderOptions(Boolean.FALSE, Boolean.TRUE),
+ null,
+ new DynaRenderOptions(null, Boolean.FALSE),
+ new DynaRenderOptions(Boolean.TRUE, Boolean.FALSE),
+ new DynaRenderOptions(Boolean.FALSE, Boolean.FALSE),
+ };
+
+ public static DynaRenderOptions getOptions(Boolean dnd, Boolean asyncWindow)
+ {
+ int index = dnd == null ? 0 : dnd.booleanValue() ? 1 : 2;
+ index += asyncWindow == null ? 0 : asyncWindow.booleanValue() ? 4 : 8;
+ return FLYWEIGHTS[index];
+ }
+
+ public static DynaRenderOptions getOptions(String dndValue, String asyncWindowValue)
+ {
+ Boolean dnd = dndValue == null ? null : Boolean.valueOf(dndValue);
+ Boolean asyncValue = asyncWindowValue == null ? null :
Boolean.valueOf(asyncWindowValue);
+ return getOptions(dnd, asyncValue);
+ }
+
+ public static DynaRenderOptions getOptions(Map propertyMap)
+ {
+ String dndValue = (String)propertyMap.get(DND_ENABLED);
+ String asyncWindowValue = (String)propertyMap.get(ASYNC_WINDOW_ENABLED);
+ return getOptions(dndValue, asyncWindowValue);
+ }
+
+ /**
+ * Set the options on the specifed property map.
+ *
+ * @param propertyMap the map to alter
+ */
+ public void setOptions(Map propertyMap)
+ {
+ if (dnd != null)
+ {
+ propertyMap.put(DND_ENABLED, dnd.toString());
+ }
+ else
+ {
+ propertyMap.remove(DND_ENABLED);
+ }
+ if (dnd != null)
+ {
+ propertyMap.put(ASYNC_WINDOW_ENABLED, asyncWindow.toString());
+ }
+ else
+ {
+ propertyMap.remove(ASYNC_WINDOW_ENABLED);
+ }
+ }
+
+ /** . */
+ private final Boolean dnd;
+
+ /** . */
+ private final Boolean asyncWindow;
+
+ private DynaRenderOptions(Boolean dnd, Boolean asyncWindow)
+ {
+ this.dnd = dnd;
+ this.asyncWindow = asyncWindow;
+ }
+
+ public Boolean getDnD()
+ {
+ return dnd;
+ }
+
+ public boolean isDnDEnabled()
+ {
+ return dnd != null && dnd.booleanValue();
+ }
+
+ public Boolean getAsyncWindow()
+ {
+ return asyncWindow;
+ }
+
+ public boolean isAsyncWindowEnabled()
+ {
+ return asyncWindow != null && asyncWindow.booleanValue();
+ }
+}
Copied:
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaRenderStatus.java
(from rev 6942,
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaStatus.java)
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaRenderStatus.java
(rev 0)
+++
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaRenderStatus.java 2007-04-07
20:11:25 UTC (rev 6944)
@@ -0,0 +1,51 @@
+/******************************************************************************
+ * 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;
+
+import org.jboss.portal.theme.render.RendererContext;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class DynaRenderStatus
+{
+
+ public static boolean get(RendererContext rendererContext)
+ {
+ Boolean status =
(Boolean)rendererContext.getAttribute(DynaConstants.DYNA_RENDER_STATUS);
+ return status == null || status.booleanValue();
+ }
+
+ public static boolean remove(RendererContext rendererContext)
+ {
+ Boolean status =
(Boolean)rendererContext.getAttribute(DynaConstants.DYNA_RENDER_STATUS);
+ rendererContext.setAttribute(DynaConstants.DYNA_RENDER_STATUS, null);
+ return status == null || status.booleanValue();
+ }
+
+ public static void set(RendererContext rendererContext, boolean status)
+ {
+ rendererContext.setAttribute(DynaConstants.DYNA_RENDER_STATUS,
Boolean.valueOf(status));
+ }
+}
Deleted: trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaStatus.java
===================================================================
---
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaStatus.java 2007-04-07
10:37:43 UTC (rev 6943)
+++
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaStatus.java 2007-04-07
20:11:25 UTC (rev 6944)
@@ -1,59 +0,0 @@
-/******************************************************************************
- * 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;
-
-import org.jboss.portal.theme.render.RendererContext;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class DynaStatus
-{
-
- /** . */
- private static final Integer[] INTEGERS = {new Integer(0),new Integer(1),new
Integer(2),new Integer(3)};
-
- /** . */
- public static final int UNKNOWN_VALUE = 0;
-
- /** . */
- public static final int DYNA_RENDERED_VALUE = 2;
-
- /** . */
- public static final int CLASSIC_RENDERED_VALUE = 3;
-
- /** . */
- public static final int NOT_RENDERED_VALUE = 4;
-
- public static int get(RendererContext rendererContext)
- {
- Integer status =
(Integer)rendererContext.getAttribute(DynaConstants.DYNA_RENDER_STATUS);
- return status != null ? status.intValue() : UNKNOWN_VALUE;
- }
-
- public static void set(RendererContext rendererContext, int status)
- {
- rendererContext.setAttribute(DynaConstants.DYNA_RENDER_STATUS, INTEGERS[status]);
- }
-}
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-07
10:37:43 UTC (rev 6943)
+++
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaWindowRenderer.java 2007-04-07
20:11:25 UTC (rev 6944)
@@ -25,6 +25,7 @@
import org.jboss.portal.theme.render.RendererContext;
import org.jboss.portal.theme.render.RenderException;
+import org.jboss.portal.theme.render.AbstractObjectRenderer;
import org.jboss.portal.theme.render.renderer.WindowRenderer;
import org.jboss.portal.theme.render.renderer.WindowRendererContext;
@@ -38,7 +39,7 @@
* @version $LastChangedRevision$, $LastChangedDate$
* @see org.jboss.portal.theme.render.renderer.WindowRenderer
*/
-public class DynaWindowRenderer implements WindowRenderer
+public class DynaWindowRenderer extends AbstractObjectRenderer implements WindowRenderer
{
//
@@ -56,29 +57,48 @@
/** @see org.jboss.portal.theme.render.renderer.WindowRenderer#render */
public void render(RendererContext rendererContext, WindowRendererContext wrc) throws
RenderException
{
- switch(DynaStatus.get(rendererContext))
+ DynaRenderOptions regionOptions =
(DynaRenderOptions)rendererContext.getAttribute(DynaConstants.DYNA_RENDER_OPTIONS);
+
+ //
+ String dndValue = rendererContext.getProperty(DynaRenderOptions.DND_ENABLED);
+ String asyncWindowValue =
rendererContext.getProperty(DynaRenderOptions.ASYNC_WINDOW_ENABLED);
+ DynaRenderOptions windowOptions = DynaRenderOptions.getOptions(dndValue,
asyncWindowValue);
+
+ //
+ PrintWriter out = rendererContext.getWriter();
+ out.print("<div class=\"dyna-window\">");
+ out.print("<div id=\"");
+ out.print(wrc.getId());
+ if (regionOptions.isDnDEnabled())
{
- case DynaStatus.DYNA_RENDERED_VALUE:
- // For now we say we have no provided any handle so far for the window
- handleProvided.set(Boolean.FALSE);
+ if (windowOptions.isAsyncWindowEnabled())
+ {
+ out.print("\" class=\"dnd-window
async-window\">\n");
+ }
+ else
+ {
+ out.print("\" class=\"dnd-window\">\n");
+ }
+ }
+ else
+ {
+ if (windowOptions.isAsyncWindowEnabled())
+ {
+ out.print("\" class=\"async-window\">\n");
+ }
+ else
+ {
+ out.print("\">\n");
+ }
+ }
- //
- PrintWriter out = rendererContext.getWriter();
- out.print("<div class=\"dyna-window\"><div
id=\"");
- out.print(wrc.getId());
- out.print("\"/>\n");
- delegate.render(rendererContext, wrc);
- out.print("</div></div>\n");
+ //
+ delegate.render(rendererContext, wrc);
- //
- handleProvided.set(null);
- break;
- case DynaStatus.CLASSIC_RENDERED_VALUE:
- handleProvided.set(null);
+ //
+ out.print("</div></div>\n");
- //
- delegate.render(rendererContext, wrc);
- break;
- }
+ //
+ handleProvided.set(null);
}
}
Modified:
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/JSONMarshaller.java
===================================================================
---
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/JSONMarshaller.java 2007-04-07
10:37:43 UTC (rev 6943)
+++
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/JSONMarshaller.java 2007-04-07
20:11:25 UTC (rev 6944)
@@ -54,9 +54,14 @@
//
writer.key("type").value("update_markup");
- writer.key("view_state").value(umr.getViewState());
//
+ if (umr.getViewState() != null)
+ {
+ writer.key("view_state").value(umr.getViewState());
+ }
+
+ //
writer.key("fragments").object();
for (Iterator i = umr.getFragments().entrySet().iterator();i.hasNext();)
{
Modified:
trunk/theme/src/main/org/jboss/portal/theme/impl/render/empty/EmptyDecorationRenderer.java
===================================================================
---
trunk/theme/src/main/org/jboss/portal/theme/impl/render/empty/EmptyDecorationRenderer.java 2007-04-07
10:37:43 UTC (rev 6943)
+++
trunk/theme/src/main/org/jboss/portal/theme/impl/render/empty/EmptyDecorationRenderer.java 2007-04-07
20:11:25 UTC (rev 6944)
@@ -25,6 +25,7 @@
import org.jboss.portal.theme.render.renderer.DecorationRenderer;
import org.jboss.portal.theme.render.RendererContext;
import org.jboss.portal.theme.render.RenderException;
+import org.jboss.portal.theme.render.AbstractObjectRenderer;
import org.jboss.portal.theme.render.renderer.DecorationRendererContext;
/**
@@ -34,7 +35,7 @@
* @version $LastChangedRevision$, $LastChangedDate$
* @see org.jboss.portal.theme.render.renderer.DecorationRenderer
*/
-public class EmptyDecorationRenderer
+public class EmptyDecorationRenderer extends AbstractObjectRenderer
implements DecorationRenderer
{
public void render(RendererContext rendererContext, DecorationRendererContext drc)
throws RenderException
Modified:
trunk/theme/src/main/org/jboss/portal/theme/impl/render/empty/EmptyPortletRenderer.java
===================================================================
---
trunk/theme/src/main/org/jboss/portal/theme/impl/render/empty/EmptyPortletRenderer.java 2007-04-07
10:37:43 UTC (rev 6943)
+++
trunk/theme/src/main/org/jboss/portal/theme/impl/render/empty/EmptyPortletRenderer.java 2007-04-07
20:11:25 UTC (rev 6944)
@@ -25,6 +25,7 @@
import org.jboss.portal.theme.render.renderer.PortletRenderer;
import org.jboss.portal.theme.render.RendererContext;
import org.jboss.portal.theme.render.RenderException;
+import org.jboss.portal.theme.render.AbstractObjectRenderer;
import org.jboss.portal.theme.render.renderer.PortletRendererContext;
/**
@@ -34,7 +35,7 @@
* @version $LastChangedRevision$, $LastChangedDate$
* @see org.jboss.portal.theme.render.renderer.PortletRenderer
*/
-public class EmptyPortletRenderer
+public class EmptyPortletRenderer extends AbstractObjectRenderer
implements PortletRenderer
{
public void render(RendererContext rendererContext, PortletRendererContext prc) throws
RenderException
Modified:
trunk/theme/src/main/org/jboss/portal/theme/impl/render/empty/EmptyRegionRenderer.java
===================================================================
---
trunk/theme/src/main/org/jboss/portal/theme/impl/render/empty/EmptyRegionRenderer.java 2007-04-07
10:37:43 UTC (rev 6943)
+++
trunk/theme/src/main/org/jboss/portal/theme/impl/render/empty/EmptyRegionRenderer.java 2007-04-07
20:11:25 UTC (rev 6944)
@@ -26,6 +26,7 @@
import org.jboss.portal.theme.render.renderer.RegionRenderer;
import org.jboss.portal.theme.render.RendererContext;
import org.jboss.portal.theme.render.RenderException;
+import org.jboss.portal.theme.render.AbstractObjectRenderer;
import org.jboss.portal.theme.render.renderer.RegionRendererContext;
import org.jboss.portal.theme.render.renderer.WindowRendererContext;
@@ -41,7 +42,7 @@
* @version $LastChangedRevision$, $LastChangedDate$
* @see org.jboss.portal.theme.render.renderer.RegionRenderer
*/
-public class EmptyRegionRenderer
+public class EmptyRegionRenderer extends AbstractObjectRenderer
implements RegionRenderer
{
private static Logger log = Logger.getLogger(EmptyRegionRenderer.class);
Modified:
trunk/theme/src/main/org/jboss/portal/theme/impl/render/empty/EmptyWindowRenderer.java
===================================================================
---
trunk/theme/src/main/org/jboss/portal/theme/impl/render/empty/EmptyWindowRenderer.java 2007-04-07
10:37:43 UTC (rev 6943)
+++
trunk/theme/src/main/org/jboss/portal/theme/impl/render/empty/EmptyWindowRenderer.java 2007-04-07
20:11:25 UTC (rev 6944)
@@ -24,6 +24,7 @@
import org.jboss.portal.theme.render.RendererContext;
import org.jboss.portal.theme.render.RenderException;
+import org.jboss.portal.theme.render.AbstractObjectRenderer;
import org.jboss.portal.theme.render.renderer.WindowRenderer;
import org.jboss.portal.theme.render.renderer.WindowRendererContext;
@@ -34,7 +35,7 @@
* @version $LastChangedRevision$, $LastChangedDate$
* @see org.jboss.portal.theme.render.renderer.WindowRenderer
*/
-public class EmptyWindowRenderer implements WindowRenderer
+public class EmptyWindowRenderer extends AbstractObjectRenderer implements
WindowRenderer
{
public void render(RendererContext rendererContext, WindowRendererContext wrc) throws
RenderException
{
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-07 10:37:43
UTC (rev 6943)
+++ trunk/theme/src/main/org/jboss/portal/theme/page/PageResult.java 2007-04-07 20:11:25
UTC (rev 6944)
@@ -195,6 +195,23 @@
region.addWindowContext(windowContext);
}
+ public WindowContext addWindow(String regionName, String windowId, String windowName,
WindowResult window)
+ {
+ int order = 0;
+
+ //
+ Region region = getRegion2(regionName);
+ if (region != null)
+ {
+ order = region.getWindows().size();
+ }
+
+ //
+ WindowContext windowCtx = new WindowContext(windowName, windowId, regionName,
order, window);
+ addWindowContext(windowCtx);
+ return windowCtx;
+ }
+
// PageRenderContext implementation
*********************************************************************************
public String getProperty(String name)
Modified: trunk/theme/src/main/org/jboss/portal/theme/page/Region.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/page/Region.java 2007-04-07 10:37:43 UTC
(rev 6943)
+++ trunk/theme/src/main/org/jboss/portal/theme/page/Region.java 2007-04-07 20:11:25 UTC
(rev 6944)
@@ -69,35 +69,19 @@
this.name = name;
this.windows = new ArrayList();
this.sorted = false;
+ this.properties = new HashMap();
}
- public String getProperty(String name)
+ public Map getProperties()
{
- if (properties != null)
- {
- return (String)properties.get(name);
- }
- else
- {
- return null;
- }
+ return properties;
}
public void setProperty(String name, String value)
{
- if (properties == null)
- {
- properties = new HashMap();
- }
properties.put(name, value);
}
- /** @return the identifier of this region (i.e. the name of this region) */
- public String getId()
- {
- return name;
- }
-
/** @return if there are any portlet windows in this region */
public boolean isEmpty()
{
@@ -115,14 +99,25 @@
windows.add(windowContext);
}
- /**
- * Get a list of all window contexts in this region. The list is sorted by order
according to the order provided in
- * the window definition.
- *
- * @return a sorted list of
<code>org.jboss.portal.theme.page.WindowContext</code> items
- */
- public List getWindows2()
+ public String toString()
{
+ return "Region[name" + name + "]";
+ }
+
+ // RegionRenderContext implementation
*******************************************************************************
+
+ public String getId()
+ {
+ return name;
+ }
+
+ public String getProperty(String name)
+ {
+ return (String)properties.get(name);
+ }
+
+ public Collection getWindows()
+ {
if (windows == null)
{
return Collections.EMPTY_LIST;
@@ -135,18 +130,6 @@
return Collections.unmodifiableList(windows);
}
- public String toString()
- {
- return "Region[name" + name + "]";
- }
-
- // RegionRenderContext implementation
*******************************************************************************
-
- public Collection getWindows()
- {
- return windows;
- }
-
public Orientation getOrientation()
{
return null;
Added: trunk/theme/src/main/org/jboss/portal/theme/render/AbstractObjectRenderer.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/render/AbstractObjectRenderer.java
(rev 0)
+++
trunk/theme/src/main/org/jboss/portal/theme/render/AbstractObjectRenderer.java 2007-04-07
20:11:25 UTC (rev 6944)
@@ -0,0 +1,39 @@
+/******************************************************************************
+ * 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 abstract class AbstractObjectRenderer implements ObjectRenderer
+{
+
+ public void startContext(RendererContext rendererContext, ObjectRendererContext
objectRenderContext)
+ {
+ }
+
+ public void endContext(RendererContext rendererContext, ObjectRendererContext
objectRenderContext)
+ {
+ }
+}
Modified: trunk/theme/src/main/org/jboss/portal/theme/render/ObjectRenderer.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/render/ObjectRenderer.java 2007-04-07
10:37:43 UTC (rev 6943)
+++ trunk/theme/src/main/org/jboss/portal/theme/render/ObjectRenderer.java 2007-04-07
20:11:25 UTC (rev 6944)
@@ -31,4 +31,6 @@
*/
public interface ObjectRenderer
{
+ void startContext(RendererContext rendererContext, ObjectRendererContext
objectRenderContext);
+ void endContext(RendererContext rendererContext, ObjectRendererContext
objectRenderContext);
}
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-07
10:37:43 UTC (rev 6943)
+++ trunk/theme/src/main/org/jboss/portal/theme/render/RendererContext.java 2007-04-07
20:11:25 UTC (rev 6944)
@@ -28,7 +28,6 @@
import org.jboss.portal.theme.render.renderer.DecorationRendererContext;
import org.jboss.portal.theme.render.renderer.DecorationRenderer;
import org.jboss.portal.theme.render.renderer.WindowRendererContext;
-import org.jboss.portal.theme.render.ObjectRendererContext;
import org.jboss.portal.theme.render.renderer.RegionRenderer;
import org.jboss.portal.theme.render.renderer.RegionRendererContext;
import org.jboss.portal.theme.render.renderer.PortletRendererContext;
@@ -171,14 +170,19 @@
return null;
}
- public void pushObjectRenderContext(ObjectRendererContext ctx)
+ public void pushObjectRenderContext(ObjectRendererContext objectRendererContext)
{
- stack.add(ctx);
+ stack.add(objectRendererContext);
+ ObjectRenderer renderer = rendererFactory.getRenderer(this,
objectRendererContext);
+ renderer.startContext(this, objectRendererContext);
}
public ObjectRendererContext popObjectRenderContext()
{
- return (ObjectRendererContext)stack.remove(stack.size() - 1);
+ ObjectRendererContext objectRendererContext =
(ObjectRendererContext)stack.remove(stack.size() - 1);
+ ObjectRenderer renderer = rendererFactory.getRenderer(this,
objectRendererContext);
+ renderer.endContext(this, objectRendererContext);
+ return objectRendererContext;
}
public void render(ObjectRendererContext ctx) throws RenderException,
IllegalStateException
Modified: trunk/theme/src/main/org/jboss/portal/theme/tag/basic/IfRegionIsEmptyTag.java
===================================================================
---
trunk/theme/src/main/org/jboss/portal/theme/tag/basic/IfRegionIsEmptyTag.java 2007-04-07
10:37:43 UTC (rev 6943)
+++
trunk/theme/src/main/org/jboss/portal/theme/tag/basic/IfRegionIsEmptyTag.java 2007-04-07
20:11:25 UTC (rev 6944)
@@ -57,7 +57,7 @@
HttpServletRequest request = (HttpServletRequest)pageContext.getRequest();
PageResult page = (PageResult)request.getAttribute(LayoutConstants.ATTR_PAGE);
Region region = page.getRegion2(this.region);
- if (region != null && region.getWindows2().iterator().hasNext())
+ if (region != null && region.getWindows().iterator().hasNext())
{
return Tag.SKIP_BODY;
}