Author: julien(a)jboss.com
Date: 2007-03-30 09:04:19 -0400 (Fri, 30 Mar 2007)
New Revision: 6878
Modified:
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaRegionRenderer.java
Log:
make the DnD ajax do not depend on the renderer implemnetation, still need some fixes, but
now basically fixed for empty region.
Modified:
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaRegionRenderer.java
===================================================================
---
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaRegionRenderer.java 2007-03-30
12:36:17 UTC (rev 6877)
+++
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaRegionRenderer.java 2007-03-30
13:04:19 UTC (rev 6878)
@@ -60,17 +60,6 @@
public void preRender(RenderContext renderContext, RegionRenderContext rrc) throws
RenderException
{
- delegate.preRender(renderContext, rrc);
- }
-
- public void postRender(RenderContext renderContext, RegionRenderContext rrc) throws
RenderException
- {
- delegate.postRender(renderContext, rrc);
- }
-
- /** @see RegionRenderer#render */
- public void render(RenderContext renderContext, final RegionRenderContext rrc) throws
RenderException
- {
StringBuffer markup = renderContext.getMarkupFragment();
String jsBase =
renderContext.getProperty(ThemeConstants.PORTAL_AJAX_JAVASCRIPT_BASE);
String remoteURL =
renderContext.getProperty(ThemeConstants.PORTAL_AJAX_REMOTE_URL);
@@ -84,37 +73,8 @@
if (pageEnabled)
{
// Handle special ajax region here
- if ("AJAXFooter".equals(rrc.getId()))
+ if ("AJAXScripts".equals(rrc.getId()))
{
- markup.append("<script>\n");
- markup.append(
- "\n" +
- "var toto = new Array();\n" +
- "for(region in regions_on_page) {\n" +
- " toto.push(region);\n" +
- "}\n" +
- "for(region in regions_on_page) {\n" +
- "Sortable.create(region,
{dropOnEmpty:true,handle:'handle',tag:'div',containment:toto,constraint:false,
ghosting: false,\n" +
- " onChange: function(el)\n" +
- " {\n" +
- " },\n" +
- " onUpdate: function (el)\n" +
- " {\n" +
- " }\n" +
- "});\n" +
- "}\n");
-
- //
- markup.append("Draggables.addObserver(new
WindowMoveObserver());\n");
-
- //
- markup.append("snapshot();\n");
-
- //
- markup.append("</script>\n");
- }
- else if ("AJAXScripts".equals(rrc.getId()))
- {
markup.append("\n\n\n");
markup.append("<script type='text/javascript'
src='").append(jsBase).append("/js/portal/prototype.js'></script>\n");
markup.append("<script type='text/javascript'
src='").append(jsBase).append("/js/portal/scriptaculous.js'></script>\n");
@@ -207,6 +167,35 @@
markup.append("</script>\n");
markup.append("\n\n\n");
}
+ else if ("AJAXFooter".equals(rrc.getId()))
+ {
+ markup.append("<script>\n");
+ markup.append(
+ "\n" +
+ "var toto = new Array();\n" +
+ "for(region in regions_on_page) {\n" +
+ " toto.push(region);\n" +
+ "}\n" +
+ "for(region in regions_on_page) {\n" +
+ "Sortable.create(region,
{dropOnEmpty:true,handle:'handle',tag:'div',containment:toto,constraint:false,
ghosting: false,\n" +
+ " onChange: function(el)\n" +
+ " {\n" +
+ " },\n" +
+ " onUpdate: function (el)\n" +
+ " {\n" +
+ " }\n" +
+ "});\n" +
+ "}\n");
+
+ //
+ markup.append("Draggables.addObserver(new
WindowMoveObserver());\n");
+
+ //
+ markup.append("snapshot();\n");
+
+ //
+ markup.append("</script>\n");
+ }
else
{
String onRegion =
rrc.getProperty(ThemeConstants.PORTAL_AJAX_OBJECT_ENABLED);
@@ -214,30 +203,55 @@
}
}
+ // Set up thread local
+ enabledLocal.set(Boolean.valueOf(regionEnabled));
+
//
if (regionEnabled)
{
// Keep a map of logical regions to div containers
markup.append("<script>").
- append("regions_on_page[\"").
- append(rrc.getCSSId()).
+ append("regions_on_page[\"bilto-").
+ append(rrc.getId()).
append("\"]=\"").
append(rrc.getId()).
append("\";").
append("</script>");
+
+ //
+ delegate.preRender(renderContext, rrc);
+
+ //
+ markup.append("<div
id=\"bilto-").append(rrc.getId()).append("\">");
}
+ else
+ {
+ delegate.preRender(renderContext, rrc);
+ }
+ }
+ public void postRender(RenderContext renderContext, RegionRenderContext rrc) throws
RenderException
+ {
//
- try
+ if (isEnabled())
{
- enabledLocal.set(Boolean.valueOf(regionEnabled));
+ StringBuffer markup = renderContext.getMarkupFragment();
- //
- delegate.render(renderContext, rrc);
+ // Always content so it can be used as a droppable element
+ markup.append("<div> </div>");
+ markup.append("</div>");
}
- finally
- {
- enabledLocal.set(null);
- }
+
+ //
+ delegate.postRender(renderContext, rrc);
+
+ //
+ enabledLocal.set(null);
}
+
+ /** @see RegionRenderer#render */
+ public void render(RenderContext renderContext, final RegionRenderContext rrc) throws
RenderException
+ {
+ delegate.render(renderContext, rrc);
+ }
}
Show replies by date