Author: julien(a)jboss.com
Date: 2007-04-06 12:50:47 -0400 (Fri, 06 Apr 2007)
New Revision: 6935
Added:
trunk/theme/src/main/org/jboss/portal/test/theme/render/
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/render/dynamic/DynaStatus.java
Modified:
trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxResponseHandler.java
trunk/theme/src/bin/test/theme-test-war/WEB-INF/portal-renderSet.xml
trunk/theme/src/bin/test/theme-test-war/WEB-INF/portal-themes.xml
trunk/theme/src/bin/test/theme-test-war/layouts/generic/index.jsp
trunk/theme/src/bin/test/theme-test-war/themes/style.css
trunk/theme/src/main/org/jboss/portal/test/theme/TestServlet.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
Log:
improve dyna stuff
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-06
14:30:52 UTC (rev 6934)
+++
trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxResponseHandler.java 2007-04-06
16:50:47 UTC (rev 6935)
@@ -57,6 +57,7 @@
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.DynaConstants;
+import org.jboss.portal.theme.impl.render.dynamic.DynaStatus;
import org.jboss.portal.theme.LayoutService;
import org.jboss.portal.theme.PortalLayout;
import org.jboss.portal.theme.PageService;
@@ -309,7 +310,7 @@
RenderContext renderContext = layout.getRenderContext(markupInfo,
dispatcher, buffer);
// Should push region context as well
- renderContext.setAttribute(DynaConstants.AJAX_WINDOW_ENABLED,
Boolean.TRUE);
+ DynaStatus.set(renderContext, DynaStatus.DYNA_RENDERED_VALUE);
renderContext.pushObjectRenderContext(res);
// Render
Modified: trunk/theme/src/bin/test/theme-test-war/WEB-INF/portal-renderSet.xml
===================================================================
--- trunk/theme/src/bin/test/theme-test-war/WEB-INF/portal-renderSet.xml 2007-04-06
14:30:52 UTC (rev 6934)
+++ trunk/theme/src/bin/test/theme-test-war/WEB-INF/portal-renderSet.xml 2007-04-06
16:50:47 UTC (rev 6935)
@@ -41,22 +41,13 @@
<decoration-renderer>org.jboss.portal.theme.impl.render.empty.EmptyDecorationRenderer</decoration-renderer>
</set>
</renderSet>
- <renderSet name="ajaxDivRenderer">
+ <renderSet name="testRenderer">
<set content-type="text/html">
<ajax-enabled>true</ajax-enabled>
-
<region-renderer>org.jboss.portal.theme.impl.render.div.DivRegionRenderer</region-renderer>
-
<window-renderer>org.jboss.portal.theme.impl.render.div.DivWindowRenderer</window-renderer>
-
<portlet-renderer>org.jboss.portal.theme.impl.render.div.DivPortletRenderer</portlet-renderer>
-
<decoration-renderer>org.jboss.portal.theme.impl.render.div.DivDecorationRenderer</decoration-renderer>
+
<region-renderer>org.jboss.portal.test.theme.render.TestRegionRenderer</region-renderer>
+
<window-renderer>org.jboss.portal.test.theme.render.TestWindowRenderer</window-renderer>
+
<portlet-renderer>org.jboss.portal.test.theme.render.TestPortletRenderer</portlet-renderer>
+
<decoration-renderer>org.jboss.portal.test.theme.render.TestDecorationRenderer</decoration-renderer>
</set>
</renderSet>
- <renderSet name="ajaxEmptyRenderer">
- <set content-type="text/html">
- <ajax-enabled>true</ajax-enabled>
-
<region-renderer>org.jboss.portal.theme.impl.render.empty.EmptyRegionRenderer</region-renderer>
-
<window-renderer>org.jboss.portal.theme.impl.render.empty.EmptyWindowRenderer</window-renderer>
-
<portlet-renderer>org.jboss.portal.theme.impl.render.empty.EmptyPortletRenderer</portlet-renderer>
-
<decoration-renderer>org.jboss.portal.theme.impl.render.empty.EmptyDecorationRenderer</decoration-renderer>
- </set>
- </renderSet>
</portal-renderSet>
Modified: trunk/theme/src/bin/test/theme-test-war/WEB-INF/portal-themes.xml
===================================================================
--- trunk/theme/src/bin/test/theme-test-war/WEB-INF/portal-themes.xml 2007-04-06 14:30:52
UTC (rev 6934)
+++ trunk/theme/src/bin/test/theme-test-war/WEB-INF/portal-themes.xml 2007-04-06 16:50:47
UTC (rev 6935)
@@ -24,7 +24,7 @@
<themes>
<theme>
- <name>simple</name>
+ <name>testTheme</name>
<link rel="stylesheet" id="main_css"
href="/themes/style.css" type="text/css"/>
</theme>
</themes>
\ No newline at end of file
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-06 14:30:52
UTC (rev 6934)
+++ trunk/theme/src/bin/test/theme-test-war/layouts/generic/index.jsp 2007-04-06 16:50:47
UTC (rev 6935)
@@ -3,22 +3,14 @@
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
xmlns="http://www.w3.org/1999/xhtml">
<head>
- <meta http-equiv="Content-Type" content="text/html;"/>
+ <meta http-equiv="Content-Type" content="text/html"/>
<p:theme themeName="renaissance"/>
<p:headerContent/>
</head>
-<body id="body">
+<body>
<p:region regionName='AJAXScripts' regionID='AJAXScripts'/>
-<div id="portal-container">
- <div id="sizer">
- <div id="expander">
- <div id="content-container">
- <p:region regionName='left' regionID='regionA'/>
- <p:region regionName='center' regionID='regionB'/>
- </div>
- </div>
- </div>
-</div>
+<p:region regionName='left' regionID='regionA'/>
+<p:region regionName='center' regionID='regionB'/>
<p:region regionName='AJAXFooter' regionID='AJAXFooter'/>
</body>
</html>
Modified: trunk/theme/src/bin/test/theme-test-war/themes/style.css
===================================================================
--- trunk/theme/src/bin/test/theme-test-war/themes/style.css 2007-04-06 14:30:52 UTC (rev
6934)
+++ trunk/theme/src/bin/test/theme-test-war/themes/style.css 2007-04-06 16:50:47 UTC (rev
6935)
@@ -1,5 +1,20 @@
-div {
- border: 1px solid black;
- padding: 0px;
- margin: 1px;
+div.test-region {
+ width:512px;
+ padding:16px;
+ background-color:red;
+}
+
+div.test-window {
+ padding:16px;
+ background-color:blue;
+}
+
+div.test-decoration {
+ height:32px;
+ background-color:green;
+}
+
+div.test-portlet {
+ height:128px;
+ background-color:yellow;
}
\ No newline at end of file
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-06 14:30:52
UTC (rev 6934)
+++ trunk/theme/src/main/org/jboss/portal/test/theme/TestServlet.java 2007-04-06 16:50:47
UTC (rev 6935)
@@ -26,7 +26,6 @@
import org.jboss.mx.util.MBeanProxy;
import org.jboss.portal.theme.LayoutService;
import org.jboss.portal.theme.ThemeService;
-import org.jboss.portal.theme.PageService;
import org.jboss.portal.theme.PortalLayout;
import org.jboss.portal.theme.PortalTheme;
import org.jboss.portal.theme.ThemeConstants;
@@ -38,8 +37,6 @@
import org.jboss.portal.theme.render.RenderContext;
import org.jboss.portal.common.util.MediaType;
import org.jboss.portal.common.util.MarkupInfo;
-import org.jboss.portal.server.ServerRequest;
-import org.jboss.portal.test.theme.tmp.servlet.TestThemeServlet;
import org.jboss.portal.web.ServletContextDispatcher;
import org.jboss.portal.web.spi.ServletContainerContext;
@@ -50,7 +47,6 @@
import javax.management.MBeanServer;
import javax.management.ObjectName;
import java.io.IOException;
-import java.util.Map;
import java.util.HashMap;
import java.util.Collections;
@@ -83,14 +79,10 @@
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("divRenderer",
MediaType.HTML);
+ PortalRenderSet renderSet = layoutService.getRenderSet("testRenderer",
MediaType.HTML);
PortalLayout layout = layoutService.getLayout("generic", true);
- PortalTheme theme = themeService.getTheme("simple", true);
+ PortalTheme theme = themeService.getTheme("testTheme", true);
- System.out.println("renderSet = " + renderSet);
- System.out.println("layout = " + layout);
- System.out.println("theme = " + theme);
-
// Build a page structure
PageResult pageRenderCtx = new PageResult("test_page");
@@ -110,12 +102,12 @@
//
for (int i = 0; i < 2; i++)
{
- WindowContext wCtx = new WindowContext("WindowA_" + i,
"WindowA_" + i, "left", i, createWindowMarkup("WindowA_" + i
+ " Title", "<p>WindowA_" + i + "
Content</p>"));
+ WindowContext wCtx = new WindowContext("WindowA_" + i,
"WindowA_" + i, "left", i, createWindowMarkup("WindowA_" + i
+ " Title", "WindowA_" + i + " Content"));
pageRenderCtx.addWindowContext(wCtx);
}
for (int i = 0; i < 2; i++)
{
- WindowContext wCtx = new WindowContext("WindowB_" + i,
"WindowB_" + i, "center", i, createWindowMarkup("WindowB_" +
i + " Title", "<p>WindowB_" + i + "
Content</p>"));
+ WindowContext wCtx = new WindowContext("WindowB_" + i,
"WindowB_" + i, "center", i, createWindowMarkup("WindowB_" +
i + " Title", "WindowB_" + i + " Content"));
pageRenderCtx.addWindowContext(wCtx);
}
Added:
trunk/theme/src/main/org/jboss/portal/test/theme/render/TestDecorationRenderer.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/test/theme/render/TestDecorationRenderer.java
(rev 0)
+++
trunk/theme/src/main/org/jboss/portal/test/theme/render/TestDecorationRenderer.java 2007-04-06
16:50:47 UTC (rev 6935)
@@ -0,0 +1,43 @@
+/******************************************************************************
+ * 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.render;
+
+import org.jboss.portal.theme.render.DecorationRenderer;
+import org.jboss.portal.theme.render.RenderContext;
+import org.jboss.portal.theme.render.DecorationRenderContext;
+import org.jboss.portal.theme.render.RenderException;
+
+import java.io.PrintWriter;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ */
+public class TestDecorationRenderer
+ implements DecorationRenderer
+{
+ public void render(RenderContext renderContext, DecorationRenderContext drc) throws
RenderException
+ {
+ PrintWriter writer = renderContext.getWriter();
+ writer.print("<div
class=\"test-decoration\">Decoration</div>");
+ }
+}
Added: trunk/theme/src/main/org/jboss/portal/test/theme/render/TestPortletRenderer.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/test/theme/render/TestPortletRenderer.java
(rev 0)
+++
trunk/theme/src/main/org/jboss/portal/test/theme/render/TestPortletRenderer.java 2007-04-06
16:50:47 UTC (rev 6935)
@@ -0,0 +1,45 @@
+/******************************************************************************
+ * 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.render;
+
+import org.jboss.portal.theme.render.PortletRenderer;
+import org.jboss.portal.theme.render.RenderContext;
+import org.jboss.portal.theme.render.PortletRenderContext;
+import org.jboss.portal.theme.render.RenderException;
+
+import java.io.PrintWriter;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ */
+public class TestPortletRenderer
+ implements PortletRenderer
+{
+ public void render(RenderContext renderContext, PortletRenderContext prc) throws
RenderException
+ {
+ PrintWriter writer = renderContext.getWriter();
+ writer.print("<div class=\"test-portlet\">");
+ writer.print(prc.getMarkup());
+ writer.print("</div>");
+ }
+}
Added: trunk/theme/src/main/org/jboss/portal/test/theme/render/TestRegionRenderer.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/test/theme/render/TestRegionRenderer.java
(rev 0)
+++
trunk/theme/src/main/org/jboss/portal/test/theme/render/TestRegionRenderer.java 2007-04-06
16:50:47 UTC (rev 6935)
@@ -0,0 +1,61 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.theme.render;
+
+import org.jboss.portal.theme.render.RegionRenderer;
+import org.jboss.portal.theme.render.RenderContext;
+import org.jboss.portal.theme.render.RegionRenderContext;
+import org.jboss.portal.theme.render.RenderException;
+import org.jboss.portal.theme.render.WindowRenderContext;
+
+import java.util.Iterator;
+import java.io.PrintWriter;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ */
+public class TestRegionRenderer
+ implements RegionRenderer
+{
+
+ public void renderHeader(RenderContext renderContext, RegionRenderContext rrc) throws
RenderException
+ {
+ PrintWriter writer = renderContext.getWriter();
+ writer.print("<div class=\"test-region\">");
+ }
+
+ public void renderFooter(RenderContext renderContext, RegionRenderContext rrc) throws
RenderException
+ {
+ PrintWriter writer = renderContext.getWriter();
+ writer.print("</div>");
+ }
+
+ public void renderBody(RenderContext renderContext, RegionRenderContext rrc) throws
RenderException
+ {
+ for (Iterator i = rrc.getWindows().iterator(); i.hasNext();)
+ {
+ WindowRenderContext wrc = (WindowRenderContext)i.next();
+ renderContext.render(wrc);
+ }
+ }
+}
Added: trunk/theme/src/main/org/jboss/portal/test/theme/render/TestWindowRenderer.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/test/theme/render/TestWindowRenderer.java
(rev 0)
+++
trunk/theme/src/main/org/jboss/portal/test/theme/render/TestWindowRenderer.java 2007-04-06
16:50:47 UTC (rev 6935)
@@ -0,0 +1,45 @@
+/******************************************************************************
+ * 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.render;
+
+import org.jboss.portal.theme.render.WindowRenderer;
+import org.jboss.portal.theme.render.RenderContext;
+import org.jboss.portal.theme.render.WindowRenderContext;
+import org.jboss.portal.theme.render.RenderException;
+
+import java.io.PrintWriter;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ */
+public class TestWindowRenderer implements WindowRenderer
+{
+ public void render(RenderContext renderContext, WindowRenderContext wrc) throws
RenderException
+ {
+ PrintWriter writer = renderContext.getWriter();
+ writer.print("<div class=\"test-window\">");
+ renderContext.render(wrc.getDecoration());
+ renderContext.render(wrc.getPortlet());
+ writer.print("</div>");
+ }
+}
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-06
14:30:52 UTC (rev 6934)
+++
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaConstants.java 2007-04-06
16:50:47 UTC (rev 6935)
@@ -42,6 +42,9 @@
public static final String VIEW_STATE = "theme.ajax.view_state";
/** . */
- public static final String AJAX_WINDOW_ENABLED = "ajax_window_enabled";
+// public static final String AJAX_WINDOW_ENABLED = "ajax_window_enabled";
+
+ 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-06
14:30:52 UTC (rev 6934)
+++
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaDecorationRenderer.java 2007-04-06
16:50:47 UTC (rev 6935)
@@ -51,22 +51,22 @@
public void render(RenderContext renderContext, DecorationRenderContext drc) throws
RenderException
{
- if (Boolean.TRUE == renderContext.getAttribute(DynaConstants.AJAX_WINDOW_ENABLED))
+ switch(DynaStatus.get(renderContext))
{
- //
- DynaWindowRenderer.handleProvided.set(Boolean.TRUE);
+ case DynaStatus.DYNA_RENDERED_VALUE:
+ DynaWindowRenderer.handleProvided.set(Boolean.TRUE);
- //
- PrintWriter markup = renderContext.getWriter();
- markup.print("<div class=\"dyna-decoration\">\n");
- markup.print("<div class=\"handle\">");
- delegate.render(renderContext, drc);
- markup.print("</div>\n");
- markup.print("</div>\n");
+ //
+ PrintWriter markup = renderContext.getWriter();
+ markup.print("<div class=\"dyna-decoration\">\n");
+ markup.print("<div class=\"handle\">");
+ delegate.render(renderContext, drc);
+ markup.print("</div>\n");
+ markup.print("</div>\n");
+ break;
+ case DynaStatus.CLASSIC_RENDERED_VALUE:
+ delegate.render(renderContext, drc);
+ break;
}
- else
- {
- delegate.render(renderContext, 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-06
14:30:52 UTC (rev 6934)
+++
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaPortletRenderer.java 2007-04-06
16:50:47 UTC (rev 6935)
@@ -58,43 +58,45 @@
private void doDND(RenderContext renderContext, PortletRenderContext prc) throws
RenderException
{
- if (Boolean.TRUE == renderContext.getAttribute(DynaConstants.AJAX_WINDOW_ENABLED))
+ switch(DynaStatus.get(renderContext))
{
- // Provide handle on content if needed
- if (Boolean.FALSE.equals(DynaWindowRenderer.handleProvided.get()))
- {
- //
- DynaWindowRenderer.handleProvided.set(Boolean.TRUE);
+ case DynaStatus.DYNA_RENDERED_VALUE:
+ // 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(renderContext, prc);
+ doCatchClicks(renderContext, prc);
// out.append("</span>");
- }
- else
- {
+ }
+ else
+ {
+ doCatchClicks(renderContext, prc);
+ }
+ break;
+ case DynaStatus.CLASSIC_RENDERED_VALUE:
doCatchClicks(renderContext, prc);
- }
+ break;
}
- else
- {
- doCatchClicks(renderContext, prc);
- }
}
private void doCatchClicks(RenderContext renderContext, PortletRenderContext prc)
throws RenderException
{
- if (Boolean.TRUE == renderContext.getAttribute(DynaConstants.AJAX_WINDOW_ENABLED))
+ switch(DynaStatus.get(renderContext))
{
- PrintWriter out = renderContext.getWriter();
- out.print("<div class=\"dyna-portlet\">");
- delegate.render(renderContext, prc);
- out.print("</div>");
+ case DynaStatus.DYNA_RENDERED_VALUE:
+ PrintWriter out = renderContext.getWriter();
+ out.print("<div class=\"dyna-portlet\">");
+ delegate.render(renderContext, prc);
+ out.print("</div>");
+ break;
+ case DynaStatus.CLASSIC_RENDERED_VALUE:
+ delegate.render(renderContext, prc);
+ break;
}
- else
- {
- delegate.render(renderContext, 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-06
14:30:52 UTC (rev 6934)
+++
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaRegionRenderer.java 2007-04-06
16:50:47 UTC (rev 6935)
@@ -72,7 +72,6 @@
delegate = regionRenderer;
}
-
public void renderHeader(RenderContext renderContext, RegionRenderContext rrc) throws
RenderException
{
PrintWriter markup = renderContext.getWriter();
@@ -85,11 +84,15 @@
boolean pageEnabled = onPage != null && "true".equals(onPage);
//
- boolean regionEnabled = false;
- if (pageEnabled)
+ int status = DynaStatus.CLASSIC_RENDERED_VALUE;
+
+ // Handle special ajax region here
+ if ("AJAXScripts".equals(rrc.getId()))
{
- // Handle special ajax region here
- if ("AJAXScripts".equals(rrc.getId()))
+ status = DynaStatus.NOT_RENDERED_VALUE;
+
+ //
+ if (pageEnabled)
{
markup.print("<script type='text/javascript'
src='");
markup.print(jsBase);
@@ -124,53 +127,73 @@
//
markup.print("</script>\n");
}
- else if ("AJAXFooter".equals(rrc.getId()))
+ }
+ else if ("AJAXFooter".equals(rrc.getId()))
+ {
+ status = DynaStatus.NOT_RENDERED_VALUE;
+
+ //
+ if (pageEnabled)
{
markup.print("<script
type='text/javascript'>footer()</script>\n");
}
- else
+ }
+ else
+ {
+ if (pageEnabled)
{
String onRegion = rrc.getProperty(DynaConstants.OBJECT_ENABLED);
- regionEnabled = onRegion == null || "true".equals(onRegion);
+ boolean regionEnabled = onRegion == null ||
"true".equals(onRegion);
+ if (regionEnabled)
+ {
+ status = DynaStatus.DYNA_RENDERED_VALUE;
+ }
}
}
//
- renderContext.setAttribute(DynaConstants.AJAX_WINDOW_ENABLED,
Boolean.valueOf(regionEnabled));
+ renderContext.setAttribute(DynaConstants.DYNA_RENDER_STATUS, new Integer(status));
//
- if (regionEnabled)
+ switch(status)
{
- //
- delegate.renderHeader(renderContext, rrc);
+ case DynaStatus.DYNA_RENDERED_VALUE:
+ delegate.renderHeader(renderContext, rrc);
- // We need height and width otherwise the region will not be usable when empty
- markup.print("<div class=\"dyna-region\"
style=\"height:200px;width=200px\" id=\"");
- markup.print(rrc.getId());
- markup.print("\">");
+ // We need height and width otherwise the region will not be usable when
empty
+ markup.print("<div class=\"dyna-region\"
style=\"height:200px;width=200px\" id=\"");
+ markup.print(rrc.getId());
+ markup.print("\">");
+ break;
+ case DynaStatus.CLASSIC_RENDERED_VALUE:
+ delegate.renderHeader(renderContext, rrc);
+ break;
+ case DynaStatus.NOT_RENDERED_VALUE:
+ break;
}
- else
- {
- delegate.renderHeader(renderContext, rrc);
- }
}
public void renderFooter(RenderContext renderContext, RegionRenderContext rrc) throws
RenderException
{
- //
- if (Boolean.TRUE == renderContext.getAttribute(DynaConstants.AJAX_WINDOW_ENABLED))
- {
- PrintWriter markup = renderContext.getWriter();
+ int status = DynaStatus.get(renderContext);
- //
- markup.print("</div>");
- }
-
//
- delegate.renderFooter(renderContext, rrc);
+ renderContext.setAttribute(DynaConstants.DYNA_RENDER_STATUS, null);
//
- renderContext.setAttribute(DynaConstants.AJAX_WINDOW_ENABLED, null);
+ switch(status)
+ {
+ case DynaStatus.DYNA_RENDERED_VALUE:
+ PrintWriter markup = renderContext.getWriter();
+ markup.print("</div>");
+ delegate.renderFooter(renderContext, rrc);
+ break;
+ case DynaStatus.CLASSIC_RENDERED_VALUE:
+ delegate.renderFooter(renderContext, rrc);
+ break;
+ case DynaStatus.NOT_RENDERED_VALUE:
+ break;
+ }
}
/**
@@ -178,6 +201,16 @@
*/
public void renderBody(RenderContext renderContext, final RegionRenderContext rrc)
throws RenderException
{
- delegate.renderBody(renderContext, rrc);
+ switch(DynaStatus.get(renderContext))
+ {
+ case DynaStatus.DYNA_RENDERED_VALUE:
+ delegate.renderBody(renderContext, rrc);
+ break;
+ case DynaStatus.CLASSIC_RENDERED_VALUE:
+ delegate.renderBody(renderContext, rrc);
+ break;
+ case DynaStatus.NOT_RENDERED_VALUE:
+ break;
+ }
}
}
Added: 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
(rev 0)
+++
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaStatus.java 2007-04-06
16:50:47 UTC (rev 6935)
@@ -0,0 +1,59 @@
+/******************************************************************************
+ * 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.RenderContext;
+
+/**
+ * @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(RenderContext renderContext)
+ {
+ Integer status =
(Integer)renderContext.getAttribute(DynaConstants.DYNA_RENDER_STATUS);
+ return status != null ? status.intValue() : UNKNOWN_VALUE;
+ }
+
+ public static void set(RenderContext renderContext, int status)
+ {
+ renderContext.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-06
14:30:52 UTC (rev 6934)
+++
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaWindowRenderer.java 2007-04-06
16:50:47 UTC (rev 6935)
@@ -56,29 +56,29 @@
/** @see WindowRenderer#render */
public void render(RenderContext renderContext, WindowRenderContext wrc) throws
RenderException
{
- if (Boolean.TRUE == renderContext.getAttribute(DynaConstants.AJAX_WINDOW_ENABLED))
+ switch(DynaStatus.get(renderContext))
{
- // For now we say we have no provided any handle so far for the window
- handleProvided.set(Boolean.FALSE);
+ case DynaStatus.DYNA_RENDERED_VALUE:
+ // For now we say we have no provided any handle so far for the window
+ handleProvided.set(Boolean.FALSE);
- //
- PrintWriter out = renderContext.getWriter();
- out.print("<div class=\"dyna-window\"><div
id=\"");
- out.print(wrc.getId());
- out.print("\"/>\n");
- delegate.render(renderContext, wrc);
- out.print("</div></div>\n");
+ //
+ PrintWriter out = renderContext.getWriter();
+ out.print("<div class=\"dyna-window\"><div
id=\"");
+ out.print(wrc.getId());
+ out.print("\"/>\n");
+ delegate.render(renderContext, wrc);
+ out.print("</div></div>\n");
- //
- handleProvided.set(null);
- }
- else
- {
- //
- handleProvided.set(null);
+ //
+ handleProvided.set(null);
+ break;
+ case DynaStatus.CLASSIC_RENDERED_VALUE:
+ handleProvided.set(null);
- //
- delegate.render(renderContext, wrc);
+ //
+ delegate.render(renderContext, wrc);
+ break;
}
}
}