[jboss-svn-commits] JBoss Portal SVN: r5159 - in branches/tomek/portal-dnd: . dndRenderer.war/js/portal src/main/org/jboss/portal/core/theme/render/impl src/main/org/jboss/portal/dnd

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Wed Sep 6 10:10:10 EDT 2006


Author: roy.russo at jboss.com
Date: 2006-09-06 10:10:06 -0400 (Wed, 06 Sep 2006)
New Revision: 5159

Modified:
   branches/tomek/portal-dnd/build.xml
   branches/tomek/portal-dnd/dndRenderer.war/js/portal/PortalDD.js
   branches/tomek/portal-dnd/src/main/org/jboss/portal/core/theme/render/impl/DnDDecorationRenderer.java
   branches/tomek/portal-dnd/src/main/org/jboss/portal/core/theme/render/impl/DnDPortletRenderer.java
   branches/tomek/portal-dnd/src/main/org/jboss/portal/core/theme/render/impl/DnDRegionRenderer.java
   branches/tomek/portal-dnd/src/main/org/jboss/portal/core/theme/render/impl/DnDTools.java
   branches/tomek/portal-dnd/src/main/org/jboss/portal/core/theme/render/impl/DnDWindowRenderer.java
   branches/tomek/portal-dnd/src/main/org/jboss/portal/dnd/DnDAjaxServlet.java
   branches/tomek/portal-dnd/src/main/org/jboss/portal/dnd/DnDPersistance.java
   branches/tomek/portal-dnd/src/main/org/jboss/portal/dnd/DnDPersistanceImpl.java
Log:
JBPORTAL-1021 - Fix DnD code to work in JDK1.4+

Modified: branches/tomek/portal-dnd/build.xml
===================================================================
--- branches/tomek/portal-dnd/build.xml	2006-09-06 12:31:15 UTC (rev 5158)
+++ branches/tomek/portal-dnd/build.xml	2006-09-06 14:10:06 UTC (rev 5159)
@@ -4,7 +4,8 @@
 	<target name="_packaging_generation_" depends="build, N65540, deploy" />
 
 	<target name="build">
-		<mkdir dir="target" />
+      <delete dir="target/classes"/>
+      <mkdir dir="target" />
 		<mkdir dir="target/classes" />
 		<javac srcdir="src/main" destdir="target/classes">
 			<classpath path=".:lib/portal-api-lib.jar:lib/portal-common-lib.jar:lib/portal-core-lib.jar:lib/portal-theme-lib.jar:lib/jboss-common.jar:lib/javax.servlet.jar" />

Modified: branches/tomek/portal-dnd/dndRenderer.war/js/portal/PortalDD.js
===================================================================
--- branches/tomek/portal-dnd/dndRenderer.war/js/portal/PortalDD.js	2006-09-06 12:31:15 UTC (rev 5158)
+++ branches/tomek/portal-dnd/dndRenderer.war/js/portal/PortalDD.js	2006-09-06 14:10:06 UTC (rev 5159)
@@ -188,20 +188,20 @@
 function cleanUpDocument(id) {
 	var region = document.getElementById(id);
 	var nodeList = region.childNodes;
-/*	
+
 	// move down all the nodes under the portlet (including dropto portlet)
-	var i = 0;
-	while (i < nodeList.length) {
-		var nextNode = nodeList.item(i);
-		
-		log.log(nextNode, "warn");
-		if (nextNode instanceof Text) {
-			log.log("next one: "+id+" "+ i);
-			region.removeChild(nextNode);
-		}
-		else {
-			i++;
-		}
-	}
-*/
+//	var i = 0;
+//	while (i < nodeList.length) {
+//		var nextNode = nodeList.item(i);
+//
+//		log.log(nextNode, "warn");
+//		if (nextNode instanceof Text) {
+//			log.log("next one: "+id+" "+ i);
+//			region.removeChild(nextNode);
+//		}
+//		else {
+//			i++;
+//		}
+//	}
+
 }

Modified: branches/tomek/portal-dnd/src/main/org/jboss/portal/core/theme/render/impl/DnDDecorationRenderer.java
===================================================================
--- branches/tomek/portal-dnd/src/main/org/jboss/portal/core/theme/render/impl/DnDDecorationRenderer.java	2006-09-06 12:31:15 UTC (rev 5158)
+++ branches/tomek/portal-dnd/src/main/org/jboss/portal/core/theme/render/impl/DnDDecorationRenderer.java	2006-09-06 14:10:06 UTC (rev 5159)
@@ -1,24 +1,25 @@
 /*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., 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.
- */
+* 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.core.theme.render.impl;
 
 import org.jboss.logging.Logger;
@@ -30,46 +31,52 @@
 
 /**
  * Implementation of a drag and drop decoration renderer.
- * 
+ *
  * @author <a href="mailto:tomasz.szymanski at jboss.com">Tomasz Szymanski</a>
+ * @author <a href="mailto:roy at jboss.org">Roy Russo</a>
  * @version $LastChangedRevision$, $LastChangedDate$
  * @see org.jboss.portal.theme.render.DecorationRenderer
  */
-public class DnDDecorationRenderer implements DecorationRenderer {
-	private static Logger log = Logger.getLogger(DnDDecorationRenderer.class);
+public class DnDDecorationRenderer implements DecorationRenderer
+{
+   private static Logger log = Logger.getLogger(DnDDecorationRenderer.class);
 
-	private DecorationRenderer delegate;
+   private DecorationRenderer delegate;
 
-	public DnDDecorationRenderer() throws InstantiationException,
-			IllegalAccessException, ClassNotFoundException {
-		super();
-		delegate = (DecorationRenderer) DnDTools.getRendererClass(
-				DnDTools.DECOR_CLASS).newInstance();
-	}
+   public DnDDecorationRenderer() throws InstantiationException,
+                                         IllegalAccessException, ClassNotFoundException
+   {
+      super();
+      delegate = (DecorationRenderer) DnDTools.getRendererClass(
+            DnDTools.DECOR_CLASS).newInstance();
+   }
 
-	/**
-	 * @see org.jboss.portal.theme.render.Renderer#renderStart
-	 */
-	public void renderStart(RenderContext ctx) {
-		delegate.renderStart(ctx);
-	}
+   /**
+    * @see org.jboss.portal.theme.render.Renderer#renderStart
+    */
+   public void renderStart(RenderContext ctx)
+   {
+      delegate.renderStart(ctx);
+   }
 
-	/**
-	 * @see org.jboss.portal.theme.render.Renderer#renderEnd
-	 */
-	public void renderEnd(RenderContext ctx) {
-		delegate.renderEnd(ctx);
-	}
+   /**
+    * @see org.jboss.portal.theme.render.Renderer#renderEnd
+    */
+   public void renderEnd(RenderContext ctx)
+   {
+      delegate.renderEnd(ctx);
+   }
 
-	/**
-	 * @see DecorationRenderer#render
-	 */
-	public void render(RenderContext renderContext,
-			WindowContext portletContext, WindowResult result)
-			throws RenderException {
+   /**
+    * @see DecorationRenderer#render
+    */
+   public void render(RenderContext renderContext,
+                      WindowContext portletContext, WindowResult result)
+         throws RenderException
+   {
 
-		delegate.render(renderContext, portletContext, result);
+      delegate.render(renderContext, portletContext, result);
 
-	}
+   }
 
 }
\ No newline at end of file

Modified: branches/tomek/portal-dnd/src/main/org/jboss/portal/core/theme/render/impl/DnDPortletRenderer.java
===================================================================
--- branches/tomek/portal-dnd/src/main/org/jboss/portal/core/theme/render/impl/DnDPortletRenderer.java	2006-09-06 12:31:15 UTC (rev 5158)
+++ branches/tomek/portal-dnd/src/main/org/jboss/portal/core/theme/render/impl/DnDPortletRenderer.java	2006-09-06 14:10:06 UTC (rev 5159)
@@ -1,24 +1,25 @@
 /*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., 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.
- */
+* 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.core.theme.render.impl;
 
 import org.jboss.portal.theme.page.WindowContext;
@@ -29,42 +30,49 @@
 
 /**
  * Implementation of a drag and drop Portlet renderer.
- * 
+ *
  * @author <a href="mailto:tomasz.szymanski at jboss.com">Tomasz Szymanski</a>
+ * @author <a href="mailto:roy at jboss.org">Roy Russo</a>
  * @version $LastChangedRevision$, $LastChangedDate$
  * @see org.jboss.portal.theme.render.PortletRenderer
  */
-public class DnDPortletRenderer implements PortletRenderer {
+public class DnDPortletRenderer implements PortletRenderer
+{
 
-	private PortletRenderer delegate;
+   private PortletRenderer delegate;
 
-	public DnDPortletRenderer() throws InstantiationException,
-			IllegalAccessException, ClassNotFoundException {
-		super();
-		delegate = (PortletRenderer) DnDTools.getRendererClass(
-				DnDTools.PORLTET_CLASS).newInstance();
-	}
-	/**
-	 * @see PortletRenderer#render
-	 */
-	public void render(RenderContext renderContext, WindowContext state,
-			WindowResult result) throws RenderException {
+   public DnDPortletRenderer() throws InstantiationException,
+                                      IllegalAccessException, ClassNotFoundException
+   {
+      super();
+      delegate = (PortletRenderer) DnDTools.getRendererClass(
+            DnDTools.PORLTET_CLASS).newInstance();
+   }
 
-		delegate.render(renderContext, state, result);
+   /**
+    * @see PortletRenderer#render
+    */
+   public void render(RenderContext renderContext, WindowContext state,
+                      WindowResult result) throws RenderException
+   {
 
-	}
+      delegate.render(renderContext, state, result);
 
-	/**
-	 * @see org.jboss.portal.theme.render.Renderer#renderStart
-	 */
-	public void renderStart(RenderContext ctx) {
-		delegate.renderStart(ctx);
-	}
+   }
 
-	/**
-	 * @see org.jboss.portal.theme.render.Renderer#renderEnd
-	 */
-	public void renderEnd(RenderContext ctx) {
-		delegate.renderEnd(ctx);
-	}
+   /**
+    * @see org.jboss.portal.theme.render.Renderer#renderStart
+    */
+   public void renderStart(RenderContext ctx)
+   {
+      delegate.renderStart(ctx);
+   }
+
+   /**
+    * @see org.jboss.portal.theme.render.Renderer#renderEnd
+    */
+   public void renderEnd(RenderContext ctx)
+   {
+      delegate.renderEnd(ctx);
+   }
 }

Modified: branches/tomek/portal-dnd/src/main/org/jboss/portal/core/theme/render/impl/DnDRegionRenderer.java
===================================================================
--- branches/tomek/portal-dnd/src/main/org/jboss/portal/core/theme/render/impl/DnDRegionRenderer.java	2006-09-06 12:31:15 UTC (rev 5158)
+++ branches/tomek/portal-dnd/src/main/org/jboss/portal/core/theme/render/impl/DnDRegionRenderer.java	2006-09-06 14:10:06 UTC (rev 5159)
@@ -1,204 +1,213 @@
 /*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., 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.
- */
+* 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.core.theme.render.impl;
 
-import java.util.HashMap;
-import java.util.Map;
-
 import org.jboss.logging.Logger;
 import org.jboss.portal.theme.page.Region;
 import org.jboss.portal.theme.render.RegionRenderer;
 import org.jboss.portal.theme.render.RenderContext;
 import org.jboss.portal.theme.render.RenderException;
 
+import java.util.HashMap;
+import java.util.Map;
+
 /**
  * Implementation of a drag and drop Region renderer.
- * 
+ *
  * @author <a href="mailto:tomasz.szymanski at jboss.com">Tomasz Szymanski</a>
- * @version $LastChangedRevision$, $LastChangedDate$
+ * @author <a href="mailto:roy at jboss.org">Roy Russo</a>
  * @see org.jboss.portal.theme.render.RegionRenderer
  */
-public class DnDRegionRenderer implements RegionRenderer {
+public class DnDRegionRenderer implements RegionRenderer
+{
+   private Map portletPos = new HashMap(); //<String, Integer>
 
-	private Map<String, Integer> portletNumbers = new HashMap<String, Integer>();
+   private Map windowIds = new HashMap();
 
-	private Map<String, String> windowIds = new HashMap<String, String>();
+   private final static Logger log = Logger.getLogger(DnDRegionRenderer.class);
 
-	private final static Logger log = Logger.getLogger(DnDRegionRenderer.class);
+   private RegionRenderer delegate;
 
-	private RegionRenderer delegate;
+   public DnDRegionRenderer() throws InstantiationException,
+                                     IllegalAccessException, ClassNotFoundException
+   {
+      super();
+      delegate = (RegionRenderer) DnDTools.getRendererClass(
+            DnDTools.REGION_CLASS).newInstance();
+   }
 
-	public DnDRegionRenderer() throws InstantiationException,
-			IllegalAccessException, ClassNotFoundException {
-		super();
-		delegate = (RegionRenderer) DnDTools.getRendererClass(
-				DnDTools.REGION_CLASS).newInstance();
-	}
-	
-	/**
-	 * @see RegionRenderer#render
-	 */
-	public void render(RenderContext renderContext, Region region,
-			Map portletContexts, Map windowResults) throws RenderException {
+   /**
+    * @see RegionRenderer#render
+    */
+   public void render(RenderContext renderContext, Region region,
+                      Map portletContexts, Map windowResults) throws RenderException
+   {
+      if(renderContext.getLayoutRegionNames().get(0).equals(region.getId()))
+      {
+         // add DND headers
+         renderContext.getMarkupFragment().append(DnDTools.DND_HEADERS);
+      }
 
-		if (renderContext.getLayoutRegionNames().get(0).equals(region.getId())) {
-			// add DND headers
-			renderContext.getMarkupFragment().append(DnDTools.DND_HEADERS);
-		}
+      renderContext.getMarkupFragment().append(
+            "<div id=\"regionDD" + renderContext.getRegionID() + "\">\n");
 
-		renderContext.getMarkupFragment().append(
-				"<div id=\"regionDD" + renderContext.getRegionID() + "\">\n");
+      delegate.render(renderContext, region, portletContexts, windowResults);
 
-		delegate.render(renderContext, region, portletContexts, windowResults);
+      renderContext.getMarkupFragment().append("</div>\n");
 
-		renderContext.getMarkupFragment().append("</div>\n");
+      if(portletPos.get(renderContext.getRegionID()) != null
+         && ((Integer) portletPos.get(renderContext.getRegionID())).intValue() > 0)
+      {
+         renderContext.getMarkupFragment().append(
+               "\n<script type='text/javascript'>\n");
+         renderContext.getMarkupFragment().append(
+               "YAHOO.example.DDApp" + renderContext.getRegionID()
+               + " = function() {\n");
+         renderContext.getMarkupFragment().append("    var ");
+         for(int i = 0; i < ((Integer) portletPos.get(renderContext.getRegionID())).intValue(); i++)
+         {
+            // add portlet vars
+            renderContext.getMarkupFragment().append(
+                  "ddPortlet" + renderContext.getRegionID() + i + ", ");
+         }
 
-		if (portletNumbers.get(renderContext.getRegionID()) != null
-				&& portletNumbers.get(renderContext.getRegionID()) > 0) {
-			renderContext.getMarkupFragment().append(
-					"\n<script type='text/javascript'>\n");
-			renderContext.getMarkupFragment().append(
-					"YAHOO.example.DDApp" + renderContext.getRegionID()
-							+ " = function() {\n");
-			renderContext.getMarkupFragment().append("    var ");
-			for (int i = 0; i < (portletNumbers
-					.get(renderContext.getRegionID())); i++) {
-				// add portlet vars
-				renderContext.getMarkupFragment().append(
-						"ddPortlet" + renderContext.getRegionID() + i + ", ");
-			}
+         // regionDD var
+         renderContext.getMarkupFragment().append(
+               "regionDrop" + renderContext.getRegionID() + ";\n");
 
-			// regionDD var
-			renderContext.getMarkupFragment().append(
-					"regionDrop" + renderContext.getRegionID() + ";\n");
+         renderContext.getMarkupFragment().append(
+               "    var DDM = YAHOO.util.DDM;\n");
+         renderContext.getMarkupFragment().append(
+               "    DDM.mode = DDM.POINT;\n");
 
-			renderContext.getMarkupFragment().append(
-					"    var DDM = YAHOO.util.DDM;\n");
-			renderContext.getMarkupFragment().append(
-					"    DDM.mode = DDM.POINT;\n");
+         renderContext.getMarkupFragment().append("    return {\n");
+         renderContext.getMarkupFragment().append(
+               "        init: function() {\n");
 
-			renderContext.getMarkupFragment().append("    return {\n");
-			renderContext.getMarkupFragment().append(
-					"        init: function() {\n");
+         // write regionDD var declaration
+         renderContext.getMarkupFragment().append(
+               "            regionDrop" + renderContext.getRegionID()
+               + " = new YAHOO.util.PortalDD('regionDrop"
+               + renderContext.getRegionID() + "');\n");
+         renderContext.getMarkupFragment().append(
+               "            regionDrop" + renderContext.getRegionID()
+               + ".setXConstraint(0, 0, 1);\n");
+         renderContext.getMarkupFragment().append(
+               "            regionDrop" + renderContext.getRegionID()
+               + ".setYConstraint(0, 0, 1);\n");
 
-			// write regionDD var declaration
-			renderContext.getMarkupFragment().append(
-					"            regionDrop" + renderContext.getRegionID()
-							+ " = new YAHOO.util.PortalDD('regionDrop"
-							+ renderContext.getRegionID() + "');\n");
-			renderContext.getMarkupFragment().append(
-					"            regionDrop" + renderContext.getRegionID()
-							+ ".setXConstraint(0, 0, 1);\n");
-			renderContext.getMarkupFragment().append(
-					"            regionDrop" + renderContext.getRegionID()
-							+ ".setYConstraint(0, 0, 1);\n");
+         for(int i = 0; i < ((Integer) portletPos.get(renderContext.getRegionID())).intValue(); i++)
+         {
+            // add new DnD objects
 
-			for (int i = 0; i < portletNumbers.get(renderContext.getRegionID()); i++) {
-				// add new DnD objects
+            renderContext.getMarkupFragment().append(
+                  "            ddPortlet" + renderContext.getRegionID()
+                  + i
+                  + " = new YAHOO.util.PortalDD('portlet-dnd-"
+                  + renderContext.getRegionID() + "-" + i
+                  + "');\n");
+            renderContext.getMarkupFragment()
+                  .append(
+                        "            ddPortlet"
+                        + renderContext.getRegionID() + i
+                        + ".windowId = \"" + (String) windowIds.get("portlet-dnd-" + renderContext.getRegionID() + "-" + i)
+                        + "\";\n");
+            /*
+                 * renderContext.getMarkupFragment().append( " ddPortlet" +
+                 * renderContext.getRegionID() + i + ".setXConstraint(1000,
+                 * 1000, 1);\n"); renderContext.getMarkupFragment().append( "
+                 * ddPortlet" + renderContext.getRegionID() + i +
+                 * ".setYConstraint(1000, 1000, 1);\n");
+                 */
 
-				renderContext.getMarkupFragment().append(
-						"            ddPortlet" + renderContext.getRegionID()
-								+ i
-								+ " = new YAHOO.util.PortalDD('portlet-dnd-"
-								+ renderContext.getRegionID() + "-" + i
-								+ "');\n");
-				renderContext.getMarkupFragment()
-						.append(
-								"            ddPortlet"
-										+ renderContext.getRegionID() + i
-										+ ".windowId = \""+windowIds.get("portlet-dnd-"
-										+ renderContext.getRegionID() + "-" + i)
-										+ "\";\n");
-				/*
-				 * renderContext.getMarkupFragment().append( " ddPortlet" +
-				 * renderContext.getRegionID() + i + ".setXConstraint(1000,
-				 * 1000, 1);\n"); renderContext.getMarkupFragment().append( "
-				 * ddPortlet" + renderContext.getRegionID() + i +
-				 * ".setYConstraint(1000, 1000, 1);\n");
-				 */
+            /*
+                 * renderContext.getMarkupFragment().append( " regionDD" +
+                 * renderContext.getRegionID() + ".getDragEl().appendChild("+
+                 * "ddPortlet" + renderContext.getRegionID() + i +
+                 * ".getDragEl());\n");
+                 */
+         }
 
-				/*
-				 * renderContext.getMarkupFragment().append( " regionDD" +
-				 * renderContext.getRegionID() + ".getDragEl().appendChild("+
-				 * "ddPortlet" + renderContext.getRegionID() + i +
-				 * ".getDragEl());\n");
-				 */
-			}
+         // add this regiondrop id
+         renderContext.getMarkupFragment().append(
+               "            ddPortlet" + renderContext.getRegionID() + "0"
+               + ".getEl().parentNode.dropToRegion = 'regionDrop"
+               + renderContext.getRegionID() + "';\n");
 
-			// add this regiondrop id
-			renderContext.getMarkupFragment().append(
-					"            ddPortlet" + renderContext.getRegionID() + "0"
-							+ ".getEl().parentNode.dropToRegion = 'regionDrop"
-							+ renderContext.getRegionID() + "';\n");
-			
-			// add this region id
-			renderContext.getMarkupFragment().append(
-					"            ddPortlet" + renderContext.getRegionID() + "0"
-							+ ".getEl().parentNode.regionId = '"
-							+ region.getId() + "';\n");
+         // add this region id
+         renderContext.getMarkupFragment().append(
+               "            ddPortlet" + renderContext.getRegionID() + "0"
+               + ".getEl().parentNode.regionId = '"
+               + region.getId() + "';\n");
 
-			renderContext.getMarkupFragment().append("        }\n");
-			renderContext.getMarkupFragment().append("    };\n");
-			renderContext.getMarkupFragment().append("} ();\n");
-			renderContext.getMarkupFragment().append(
-					"YAHOO.util.Event.addListener(window, 'load', YAHOO.example.DDApp"
-							+ renderContext.getRegionID() + ".init);\n");
-			renderContext.getMarkupFragment().append(
-					"YAHOO.util.Event.addListener(window, 'load', cleanUpDocument(\"regionDD" + renderContext.getRegionID()  +"\"));\n");
-					
-			
-			renderContext.getMarkupFragment().append("</script>\n\n");
+         renderContext.getMarkupFragment().append("        }\n");
+         renderContext.getMarkupFragment().append("    };\n");
+         renderContext.getMarkupFragment().append("} ();\n");
+         renderContext.getMarkupFragment().append(
+               "YAHOO.util.Event.addListener(window, 'load', YAHOO.example.DDApp"
+               + renderContext.getRegionID() + ".init);\n");
+         renderContext.getMarkupFragment().append(
+               "YAHOO.util.Event.addListener(window, 'load', cleanUpDocument(\"regionDD" + renderContext.getRegionID() + "\"));\n");
 
-			portletNumbers.put(renderContext.getRegionID(), 0);
-		}
-	}
 
-	/**
-	 * @see org.jboss.portal.theme.render.Renderer#renderStart(org.jboss.portal.theme.render.RenderContext)
-	 */
-	public void renderStart(RenderContext ctx) {
-		delegate.renderStart(ctx);
-	}
+         renderContext.getMarkupFragment().append("</script>\n\n");
 
-	/**
-	 * @see org.jboss.portal.theme.render.Renderer#renderEnd(org.jboss.portal.theme.render.RenderContext)
-	 */
-	public void renderEnd(RenderContext ctx) {
-		delegate.renderEnd(ctx);
-	}
+         portletPos.put(renderContext.getRegionID(), new Integer(0));
+      }
+   }
 
-	public int getPortletNumber(String regionId) {
+   /**
+    * @see org.jboss.portal.theme.render.Renderer#renderStart(org.jboss.portal.theme.render.RenderContext)
+    */
+   public void renderStart(RenderContext ctx)
+   {
+      delegate.renderStart(ctx);
+   }
 
-		int number = 0;
-		if (portletNumbers.get(regionId) != null) {
-			number = portletNumbers.get(regionId);
-		}
+   /**
+    * @see org.jboss.portal.theme.render.Renderer#renderEnd(org.jboss.portal.theme.render.RenderContext)
+    */
+   public void renderEnd(RenderContext ctx)
+   {
+      delegate.renderEnd(ctx);
+   }
 
-		portletNumbers.put(regionId, ++number);
+   public int getPortletNumber(String regionId)
+   {
 
-		return number - 1;
-	}
+      int number = 0;
+      if(portletPos.get(regionId) != null)
+      {
+         number = ((Integer) portletPos.get(regionId)).intValue();
+      }
 
-	public void setWindowId(String portletId, String windowId) {
-		windowIds.put(portletId, windowId);
-	}
+      portletPos.put(regionId, new Integer(++number));
+
+      return number - 1;
+   }
+
+   public void setWindowId(String portletId, String windowId)
+   {
+      windowIds.put(portletId, windowId);
+   }
 }

Modified: branches/tomek/portal-dnd/src/main/org/jboss/portal/core/theme/render/impl/DnDTools.java
===================================================================
--- branches/tomek/portal-dnd/src/main/org/jboss/portal/core/theme/render/impl/DnDTools.java	2006-09-06 12:31:15 UTC (rev 5158)
+++ branches/tomek/portal-dnd/src/main/org/jboss/portal/core/theme/render/impl/DnDTools.java	2006-09-06 14:10:06 UTC (rev 5159)
@@ -1,68 +1,102 @@
+/*
+* 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.core.theme.render.impl;
 
-import java.io.FileInputStream;
+/**
+ * Debugging tools for client-side javascript
+ *
+ * @author <a href="mailto:tomasz.szymanski at jboss.com">Tomasz Szymanski</a>
+ * @author <a href="mailto:roy at jboss.org">Roy Russo</a>
+ */
+
+import org.jboss.logging.Logger;
+
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.Properties;
 
-import org.jboss.logging.Logger;
+public class DnDTools
+{
 
-public class DnDTools {
+   public static final String DECOR_CLASS = "decorationRenderer.class";
+   public static final String PORLTET_CLASS = "portletRenderer.class";
+   public static final String REGION_CLASS = "regionRenderer.class";
+   public static final String WINDOW_CLASS = "windowRenderer.class";
 
-	public static final String DECOR_CLASS = "decorationRenderer.class";
-	public static final String PORLTET_CLASS = "portletRenderer.class";
-	public static final String REGION_CLASS = "regionRenderer.class";
-	public static final String WINDOW_CLASS = "windowRenderer.class";
-	
-	public static final String DND_PROP_FILENAME = "/dnd.properties";
-	
-	private static final Logger log = Logger.getLogger(DnDTools.class);
-	
-	public static final String DND_HEADERS = "\n\n\n<script type='text/javascript' src='/dndRenderer/js/yahoo/yahoo.js' ></script>\n"
-			+ "<script type='text/javascript' src='/dndRenderer/js/event/event.js' ></script>\n"
-			+ "<script type='text/javascript' src='/dndRenderer/js/dom/dom.js'></script>\n"
-			+ "<script type='text/javascript' src='/dndRenderer/js/logger/logger.js' ></script>\n"
-			+ "<script type='text/javascript' src='/dndRenderer/js/dragdrop/dragdrop-debug.js' ></script>\n"
-			+ "<script type='text/javascript' src='/dndRenderer/js/connection/connection.js' ></script>\n"
-			+ "<script type='text/javascript' src='/dndRenderer/js/portal/PortalDD.js' ></script>\n\n\n"
-			// comment out everything under this if you don't wanna have the logger
-			
-			+ "<script type='text/javascript'>"
-			+ "var myLogReader1 = new YAHOO.widget.LogReader(null, { newestOnTop: true, height: \"400px\" });"
-			+ "</script>\n\n"
-			
-			+ "<style type=\"text/css\">\n"
-			+ "#yui-log {position:absolute;top:1em;right:1em;font-size:77%;text-align:left; width: 300px}\n"
-			+ ".yui-log {background-color:#AAA;border:1px solid black;font-family:monospace;z-index:9000;}\n"
-			+ ".yui-log p {margin:1px;padding:.1em;}\n"
-			+ ".yui-log button {font-family:monospace;}\n"
-			+ ".yui-log .yui-log-hd {padding:.5em;background-color:#575757;color:#FFF;}\n"
-			+ ".yui-log .yui-log-bd {width:100%;height:20em;background-color:#FFF;border:1px solid gray;overflow:auto;}\n"
-			+ ".yui-log .yui-log-ft {margin-top:.5em;margin-bottom:1em;}\n"
-			+ ".yui-log .yui-log-ft .yui-log-categoryfilters {}\n"
-			+ ".yui-log .yui-log-ft .yui-log-sourcefilters {width:100%;border-top:1px solid #575757;margin-top:.75em;padding-top:.75em;}\n"
-			+ ".yui-log .yui-log-btns {position:relative;float:right;bottom:.25em;}\n"
-			+ ".yui-log .yui-log-filtergrp {margin-right:.5em;}\n"
-			+ ".yui-log .info {background-color:#A7CC25;} \n"
-			+ ".yui-log .warn {background-color:#F58516;}\n"
-			+ ".yui-log .error {background-color:#E32F0B;} \n"
-			+ ".yui-log .time {background-color:#A6C9D7;} \n"
-			+ ".yui-log .window {background-color:#F2E886;} \n"
-			+ "</style>\n\n";
+   public static final String DND_PROP_FILENAME = "/dnd.properties";
 
-	public static Class getRendererClass(String className) throws ClassNotFoundException{
-		Properties props = new Properties();
-		
-		InputStream is = DnDTools.class.getResourceAsStream(DND_PROP_FILENAME);
-		try {
-			props.load(is);
-			
-			Class clas = Class.forName(props.getProperty(className));
-			
-			return clas;
-		} catch (IOException e) {
-			log.error(e);
-			throw new ClassNotFoundException(e.getMessage());
-		}
-	}
+   private static final Logger log = Logger.getLogger(DnDTools.class);
+
+   public static final String DND_HEADERS = "\n\n\n<script type='text/javascript' src='/dndRenderer/js/yahoo/yahoo.js'></script>\n"
+                                            + "<script type='text/javascript' src='/dndRenderer/js/event/event.js'></script>\n"
+                                            + "<script type='text/javascript' src='/dndRenderer/js/dom/dom.js'></script>\n"
+                                            + "<script type='text/javascript' src='/dndRenderer/js/logger/logger.js'></script>\n"
+                                            + "<script type='text/javascript' src='/dndRenderer/js/dragdrop/dragdrop-debug.js'></script>\n"
+                                            + "<script type='text/javascript' src='/dndRenderer/js/connection/connection.js'></script>\n"
+                                            + "<script type='text/javascript' src='/dndRenderer/js/portal/PortalDD.js'></script>\n\n\n";
+
+   /**
+    * Javascript logger embedded in Footer. Do not move from footer, or IE will crash!
+    * TODO: Needs to be a flag in the renderer.
+    */
+   public static final String DND_FOOTERS = "\n\n\n<script type='text/javascript'>"
+                                            + "var myLogReader1 = new YAHOO.widget.LogReader(null, { newestOnTop: true, height: \"400px\" });"
+                                            + "</script>\n\n"
+                                            + "\n\n\n<style type=\"text/css\">\n"
+                                            + "#yui-log {position:absolute;top:1em;right:1em;font-size:77%;text-align:left; width: 300px}\n"
+                                            + ".yui-log {background-color:#AAA;border:1px solid black;font-family:monospace;z-index:9000;}\n"
+                                            + ".yui-log p {margin:1px;padding:.1em;}\n"
+                                            + ".yui-log button {font-family:monospace;}\n"
+                                            + ".yui-log .yui-log-hd {padding:.5em;background-color:#575757;color:#FFF;}\n"
+                                            + ".yui-log .yui-log-bd {width:100%;height:20em;background-color:#FFF;border:1px solid gray;overflow:auto;}\n"
+                                            + ".yui-log .yui-log-ft {margin-top:.5em;margin-bottom:1em;}\n"
+                                            + ".yui-log .yui-log-ft .yui-log-categoryfilters {}\n"
+                                            + ".yui-log .yui-log-ft .yui-log-sourcefilters {width:100%;border-top:1px solid #575757;margin-top:.75em;padding-top:.75em;}\n"
+                                            + ".yui-log .yui-log-btns {position:relative;float:right;bottom:.25em;}\n"
+                                            + ".yui-log .yui-log-filtergrp {margin-right:.5em;}\n"
+                                            + ".yui-log .info {background-color:#A7CC25;} \n"
+                                            + ".yui-log .warn {background-color:#F58516;}\n"
+                                            + ".yui-log .error {background-color:#E32F0B;} \n"
+                                            + ".yui-log .time {background-color:#A6C9D7;} \n"
+                                            + ".yui-log .window {background-color:#F2E886;} \n"
+                                            + "</style>\n\n";
+
+   public static Class getRendererClass(String className) throws ClassNotFoundException
+   {
+      Properties props = new Properties();
+
+      InputStream is = DnDTools.class.getResourceAsStream(DND_PROP_FILENAME);
+      try
+      {
+         props.load(is);
+
+         Class clas = Class.forName(props.getProperty(className));
+
+         return clas;
+      }
+      catch(IOException e)
+      {
+         log.error(e);
+         throw new ClassNotFoundException(e.getMessage());
+      }
+   }
 }

Modified: branches/tomek/portal-dnd/src/main/org/jboss/portal/core/theme/render/impl/DnDWindowRenderer.java
===================================================================
--- branches/tomek/portal-dnd/src/main/org/jboss/portal/core/theme/render/impl/DnDWindowRenderer.java	2006-09-06 12:31:15 UTC (rev 5158)
+++ branches/tomek/portal-dnd/src/main/org/jboss/portal/core/theme/render/impl/DnDWindowRenderer.java	2006-09-06 14:10:06 UTC (rev 5159)
@@ -1,97 +1,103 @@
 /*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., 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.
- */
+* 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.core.theme.render.impl;
 
 import org.jboss.logging.Logger;
-import org.jboss.portal.theme.impl.render.DivWindowRenderer;
 import org.jboss.portal.theme.page.WindowContext;
 import org.jboss.portal.theme.page.WindowResult;
-import org.jboss.portal.theme.render.RegionRenderer;
 import org.jboss.portal.theme.render.RenderContext;
 import org.jboss.portal.theme.render.RenderException;
 import org.jboss.portal.theme.render.WindowRenderer;
 
 /**
  * Implementation of a drag and drop WindowRenderer.
- * 
+ *
  * @author <a href="mailto:tomasz.szymanski at jboss.com">Tomasz Szymanski</a>
+ * @author <a href="mailto:roy at jboss.org">Roy Russo</a>
  * @version $LastChangedRevision$, $LastChangedDate$
  * @see org.jboss.portal.theme.render.WindowRenderer
  */
-public class DnDWindowRenderer implements WindowRenderer {
-	private static Logger log = Logger.getLogger(DnDWindowRenderer.class);
+public class DnDWindowRenderer implements WindowRenderer
+{
+   private static Logger log = Logger.getLogger(DnDWindowRenderer.class);
 
-	private WindowRenderer delegate;
+   private WindowRenderer delegate;
 
-	public DnDWindowRenderer() throws InstantiationException,
-			IllegalAccessException, ClassNotFoundException {
-		super();
-		delegate = (WindowRenderer) DnDTools.getRendererClass(
-				DnDTools.WINDOW_CLASS).newInstance();
-	}
+   public DnDWindowRenderer() throws InstantiationException,
+                                     IllegalAccessException, ClassNotFoundException
+   {
+      super();
+      delegate = (WindowRenderer) DnDTools.getRendererClass(
+            DnDTools.WINDOW_CLASS).newInstance();
+   }
 
-	/**
-	 * @see WindowRenderer#render
-	 */
-	public void render(RenderContext renderContext,
-			WindowContext portletContext, WindowResult result)
-			throws RenderException {
-		int portletNumber = ((DnDRegionRenderer) renderContext
-				.getRegionRenderer()).getPortletNumber(renderContext
-				.getRegionID());
+   /**
+    * @see WindowRenderer#render
+    */
+   public void render(RenderContext renderContext,
+                      WindowContext portletContext, WindowResult result)
+         throws RenderException
+   {
+      int portletNumber = ((DnDRegionRenderer) renderContext
+            .getRegionRenderer()).getPortletNumber(renderContext
+            .getRegionID());
 
-		((DnDRegionRenderer) renderContext.getRegionRenderer()).setWindowId(
-				"portlet-dnd-" + renderContext.getRegionID() + "-"
-						+ portletNumber, portletContext.getWindowName());
+      ((DnDRegionRenderer) renderContext.getRegionRenderer()).setWindowId(
+            "portlet-dnd-" + renderContext.getRegionID() + "-"
+            + portletNumber, portletContext.getWindowName());
 
-		if (portletNumber == 0) {
-			renderContext
-					.getMarkupFragment()
-					.append(
-							"<div style='display: none; visibility: hidden; padding: 50px; margin: 10px; border: 1px dashed black;' id='regionDrop"
-									+ renderContext.getRegionID()
-									+ "'>Drop your portlets here</div>");
-		}
+      if(portletNumber == 0)
+      {
+         renderContext
+               .getMarkupFragment()
+               .append(
+                     "<div style='display: none; visibility: hidden; padding: 50px; margin: 10px; border: 1px dashed black;' id='regionDrop"
+                     + renderContext.getRegionID()
+                     + "'>Drop your portlets here</div>");
+      }
 
-		renderContext.getMarkupFragment().append(
-				"<div id=\"portlet-dnd-" + renderContext.getRegionID() + "-"
-						+ portletNumber + "\">\n");
+      renderContext.getMarkupFragment().append(
+            "<div id=\"portlet-dnd-" + renderContext.getRegionID() + "-"
+            + portletNumber + "\">\n");
 
-		delegate.render(renderContext, portletContext, result);
+      delegate.render(renderContext, portletContext, result);
 
-		renderContext.getMarkupFragment().append("</div>");
-	}
+      renderContext.getMarkupFragment().append("</div>");
+   }
 
-	/**
-	 * @see org.jboss.portal.theme.render.Renderer#renderStart(org.jboss.portal.theme.render.RenderContext)
-	 */
-	public void renderStart(RenderContext ctx) {
-		delegate.renderStart(ctx);
-	}
+   /**
+    * @see org.jboss.portal.theme.render.Renderer#renderStart(org.jboss.portal.theme.render.RenderContext)
+    */
+   public void renderStart(RenderContext ctx)
+   {
+      delegate.renderStart(ctx);
+   }
 
-	/**
-	 * @see org.jboss.portal.theme.render.Renderer#renderEnd(org.jboss.portal.theme.render.RenderContext)
-	 */
-	public void renderEnd(RenderContext ctx) {
-		delegate.renderEnd(ctx);
-	}
+   /**
+    * @see org.jboss.portal.theme.render.Renderer#renderEnd(org.jboss.portal.theme.render.RenderContext)
+    */
+   public void renderEnd(RenderContext ctx)
+   {
+      delegate.renderEnd(ctx);
+   }
 }

Modified: branches/tomek/portal-dnd/src/main/org/jboss/portal/dnd/DnDAjaxServlet.java
===================================================================
--- branches/tomek/portal-dnd/src/main/org/jboss/portal/dnd/DnDAjaxServlet.java	2006-09-06 12:31:15 UTC (rev 5158)
+++ branches/tomek/portal-dnd/src/main/org/jboss/portal/dnd/DnDAjaxServlet.java	2006-09-06 14:10:06 UTC (rev 5159)
@@ -1,102 +1,150 @@
+/*
+* 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.dnd;
 
-import java.io.IOException;
-import java.util.Date;
-import java.util.Enumeration;
+/**
+ * Gateway for AJAX DnD req/res
+ *
+ * @author <a href="mailto:tomasz.szymanski at jboss.com">Tomasz Szymanski</a>
+ * @author <a href="mailto:roy at jboss.org">Roy Russo</a>
+ */
 
+import org.jboss.logging.Logger;
+
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServlet;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.Date;
+import java.util.Enumeration;
 
-import org.jboss.logging.Logger;
+public class DnDAjaxServlet extends HttpServlet
+{
 
-public class DnDAjaxServlet extends HttpServlet {
+   /**
+    *
+    */
+   private static final long serialVersionUID = 1L;
 
-	/**
-	 * 
-	 */
-	private static final long serialVersionUID = 1L;
+   private static final String PERSIST = "PERSIST";
 
-	private static final String PERSIST = "PERSIST";
+   private static final String TEST_MODE = "TEST_MODE";
 
-	private static final String TEST_MODE = "TEST_MODE";
+   private final static Logger log = Logger.getLogger(DnDAjaxServlet.class);
 
-	private final static Logger log = Logger.getLogger(DnDAjaxServlet.class);
+   private DnDPersistance persistance = new DnDPersistanceImpl();
 
-	private DnDPersistance persistance = new DnDPersistanceImpl();
+   private boolean testMode = false;
 
-	private boolean testMode = false;
+   protected void doGet(HttpServletRequest req, HttpServletResponse resp)
+         throws ServletException, IOException
+   {
+      doPost(req, resp);
+   }
 
-	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
-			throws ServletException, IOException {
-		doPost(req, resp);
-	}
+   protected void doPost(HttpServletRequest req, HttpServletResponse resp)
+         throws ServletException, IOException
+   {
+      Enumeration attNames = req.getAttributeNames();
+      while(attNames.hasMoreElements())
+      {
+         String name = (String) attNames.nextElement();
+         log.info("Attribute: " + name + " = " + req.getAttribute(name));
+      }
 
-	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
-			throws ServletException, IOException {
-		Enumeration<String> attNames = req.getAttributeNames();
-		while (attNames.hasMoreElements()) {
-			String name = attNames.nextElement();
-			log.info("Attribute: " + name + " = " + req.getAttribute(name));
-		}
+      Enumeration paramNames = req.getParameterNames();
+      while(paramNames.hasMoreElements())
+      {
+         String name = (String) paramNames.nextElement();
+         log.info("Parameter: " + name + " = " + req.getParameter(name));
+      }
 
-		Enumeration<String> paramNames = req.getParameterNames();
-		while (paramNames.hasMoreElements()) {
-			String name = paramNames.nextElement();
-			log.info("Parameter: " + name + " = " + req.getParameter(name));
-		}
+      if(req.getParameter("action") != null)
+      {
+         if(req.getParameter("action").equals(PERSIST))
+         {
+            if(req.getParameter("positionNo") == null
+               || req.getParameter("windowId") == null
+               || req.getParameter("oldRegionId") == null
+               || req.getParameter("newRegionId") == null)
+            {
+               resp.sendError(400, "Not enought parameters");
+               return;
+            }
 
-		if (req.getParameter("action") != null) {
-			if (req.getParameter("action").equals(PERSIST)) {
-				if (req.getParameter("positionNo") == null
-						|| req.getParameter("windowId") == null
-						|| req.getParameter("oldRegionId") == null
-						|| req.getParameter("newRegionId") == null) {
-					resp.sendError(400, "Not enought parameters");
-					return;
-				}
+            if(!testMode)
+            {
+               persistance.persistPosition(req.getParameter("positionNo"),
+                                           req.getParameter("windowId"), req
+                     .getParameter("oldRegionId"), req
+                     .getParameter("newRegionId"));
+            }
 
-				if (!testMode) {
-					persistance.persistPosition(req.getParameter("positionNo"),
-							req.getParameter("windowId"), req
-									.getParameter("oldRegionId"), req
-									.getParameter("newRegionId"));
-				}
+            sendResp(resp, "Position persisted");
+         }
+         else if(req.getParameter("action").equals(TEST_MODE))
+         {
+            if(req.getParameter("mode") != null)
+            {
+               try
+               {
+                  testMode = Boolean.valueOf(req.getParameter("mode"))
+                        .booleanValue();
+               }
+               catch(RuntimeException e)
+               {
+                  resp.sendError(400, "Bad arguments");
+                  return;
+               }
 
-				sendResp(resp, "Position persisted");
-			} else if (req.getParameter("action").equals(TEST_MODE)) {
-				if (req.getParameter("mode") != null) {
-					try {
-						testMode = Boolean.valueOf(req.getParameter("mode"))
-								.booleanValue();
-					} catch (RuntimeException e) {
-						resp.sendError(400, "Bad arguments");
-						return;
-					}
-					
-					sendResp(resp, ((testMode) ? "Test mode ON" : "Test mode OFF"));
+               sendResp(resp, ((testMode) ? "Test mode ON" : "Test mode OFF"));
 
-				} else {
-					resp.sendError(400, "Not enought parameters");
-					return;
-				}
-			} else {
-				resp.sendError(400, "Unknown ajax call");
-				return;
-			}
-		}
-	}
+            }
+            else
+            {
+               resp.sendError(400, "Not enought parameters");
+               return;
+            }
+         }
+         else
+         {
+            resp.sendError(400, "Unknown ajax call");
+            return;
+         }
+      }
+   }
 
-	private void sendResp(HttpServletResponse resp, String respData)
-			throws IOException {
-		resp.setHeader("Expires", "Mon, 26 Jul 1997 05:00:00 GMT");
-		resp.setDateHeader("Last-Modified", new Date().getTime());
-		resp.setHeader("Cache-Control", "no-store, no-cache, must-revalidate");
-		resp.addHeader("Cache-Control", "post-check=0, pre-check=0");
-		resp.setContentType("text/html");
+   private void sendResp(HttpServletResponse resp, String respData)
+         throws IOException
+   {
+      resp.setHeader("Expires", "Mon, 26 Jul 1997 05:00:00 GMT");
+      resp.setDateHeader("Last-Modified", new Date().getTime());
+      resp.setHeader("Cache-Control", "no-store, no-cache, must-revalidate");
+      resp.addHeader("Cache-Control", "post-check=0, pre-check=0");
+      resp.setContentType("text/html");
 
-		resp.getWriter().write(respData);
-	}
+      resp.getWriter().write(respData);
+   }
 
 }

Modified: branches/tomek/portal-dnd/src/main/org/jboss/portal/dnd/DnDPersistance.java
===================================================================
--- branches/tomek/portal-dnd/src/main/org/jboss/portal/dnd/DnDPersistance.java	2006-09-06 12:31:15 UTC (rev 5158)
+++ branches/tomek/portal-dnd/src/main/org/jboss/portal/dnd/DnDPersistance.java	2006-09-06 14:10:06 UTC (rev 5159)
@@ -1,7 +1,35 @@
+/*
+* 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.dnd;
 
-public interface DnDPersistance {
-	
-	public void persistPosition(String positionNo, String windowId,
-			String oldRegionId, String newRegionId);
+/**
+ * @author <a href="mailto:tomasz.szymanski at jboss.com">Tomasz Szymanski</a>
+ * @author <a href="mailto:roy at jboss.org">Roy Russo</a>
+ */
+
+public interface DnDPersistance
+{
+
+   public void persistPosition(String positionNo, String windowId,
+                               String oldRegionId, String newRegionId);
 }

Modified: branches/tomek/portal-dnd/src/main/org/jboss/portal/dnd/DnDPersistanceImpl.java
===================================================================
--- branches/tomek/portal-dnd/src/main/org/jboss/portal/dnd/DnDPersistanceImpl.java	2006-09-06 12:31:15 UTC (rev 5158)
+++ branches/tomek/portal-dnd/src/main/org/jboss/portal/dnd/DnDPersistanceImpl.java	2006-09-06 14:10:06 UTC (rev 5159)
@@ -1,14 +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.dnd;
 
+/**
+ * @author <a href="mailto:tomasz.szymanski at jboss.com">Tomasz Szymanski</a>
+ * @author <a href="mailto:roy at jboss.org">Roy Russo</a>
+ */
+
 import org.jboss.logging.Logger;
 
-public class DnDPersistanceImpl implements DnDPersistance {
+public class DnDPersistanceImpl implements DnDPersistance
+{
 
-	private final static Logger log = Logger.getLogger(DnDPersistanceImpl.class);
-	
-	public void persistPosition(String positionNo, String windowId,
-			String oldRegionId, String newRegionId) {
-		log.info("New position persistance call: " + positionNo + " "
-				+ windowId + " " + oldRegionId + " " + newRegionId);
-	}
+   private final static Logger log = Logger.getLogger(DnDPersistanceImpl.class);
+
+   public void persistPosition(String positionNo, String windowId,
+                               String oldRegionId, String newRegionId)
+   {
+      log.info("New position persistance call: " + positionNo + " "
+               + windowId + " " + oldRegionId + " " + newRegionId);
+   }
 }




More information about the jboss-svn-commits mailing list