You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by hl...@apache.org on 2008/02/16 01:39:04 UTC

svn commit: r628219 - in /tapestry/tapestry5/trunk/tapestry-core/src: main/java/org/apache/tapestry/ main/java/org/apache/tapestry/beaneditor/ main/java/org/apache/tapestry/corelib/components/ main/java/org/apache/tapestry/internal/ main/java/org/apach...

Author: hlship
Date: Fri Feb 15 16:39:02 2008
New Revision: 628219

URL: http://svn.apache.org/viewvc?rev=628219&view=rev
Log:
TAPESTRY-1650: Add support for Form submissions that update Zones

Added:
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/AbstractOptionModel.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/AjaxUIDManager.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/AjaxUIDManagerImpl.java
    tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/AjaxUIDManagerImplTest.java
Modified:
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/beaneditor/PropertyModel.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/Form.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/OptionModelImpl.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/TapestryInternalUtils.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/AjaxComponentEventRequestHandler.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/AjaxComponentInstanceEventResultProcessor.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/AjaxPartialResponseRenderer.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/AjaxPartialResponseRendererImpl.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/ComponentEventRequestHandlerImpl.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/PageRenderQueue.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/PageRenderQueueImpl.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/PartialRenderPageRenderSupport.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/RenderCommandComponentEventResultProcessor.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/TapestryModule.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/util/EnumSelectModel.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/corelib/components/BeanDisplay.tml
    tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/corelib/components/BeanEditor.tml
    tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/corelib/components/GridColumns.tml
    tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/corelib/components/GridRows.tml
    tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/corelib/components/Palette.tml
    tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/corelib/pages/ExceptionReport.tml
    tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/corelib/pages/PropertyDisplayBlocks.tml
    tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/corelib/pages/PropertyEditBlocks.tml
    tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/corelib/pages/ServiceStatus.tml
    tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/tapestry.js
    tapestry/tapestry5/trunk/tapestry-core/src/test/app1/ZoneDemo.tml
    tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/corelib/components/SelectTest.java
    tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/ZoneDemo.java
    tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/OptionModelImplTest.java
    tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/AjaxComponentInstanceEventResultProcessorTest.java
    tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/PartialRenderPageRenderSupportTest.java

Added: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/AbstractOptionModel.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/AbstractOptionModel.java?rev=628219&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/AbstractOptionModel.java (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/AbstractOptionModel.java Fri Feb 15 16:39:02 2008
@@ -0,0 +1,41 @@
+// Copyright 2008 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package org.apache.tapestry;
+
+import java.util.Map;
+
+/**
+ * Base class for implementing {@link OptionModel}.  Subclasses must implement
+ * {@link org.apache.tapestry.OptionModel#getLabel()} and
+ * {@link org.apache.tapestry.OptionModel#getValue()} }.
+ */
+public abstract class AbstractOptionModel implements OptionModel
+{
+    /**
+     * Returns false.
+     */
+    public boolean isDisabled()
+    {
+        return false;
+    }
+
+    /**
+     * Returns null.
+     */
+    public Map<String, String> getAttributes()
+    {
+        return null;
+    }
+}

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/beaneditor/PropertyModel.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/beaneditor/PropertyModel.java?rev=628219&r1=628218&r2=628219&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/beaneditor/PropertyModel.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/beaneditor/PropertyModel.java Fri Feb 15 16:39:02 2008
@@ -1,4 +1,4 @@
-// Copyright 2007 The Apache Software Foundation
+// Copyright 2007, 2008 The Apache Software Foundation
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
@@ -17,7 +17,7 @@
 import org.apache.tapestry.PropertyConduit;
 
 /**
- * Part of a {@link BeanModel} that defines the attributes of a single property of a bean.
+ * Part of a {@link org.apache.tapestry.beaneditor.BeanModel} that defines the attributes of a single property of a bean.
  */
 public interface PropertyModel
 {

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/Form.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/Form.java?rev=628219&r1=628218&r2=628219&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/Form.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/Form.java Fri Feb 15 16:39:02 2008
@@ -26,6 +26,7 @@
 import org.apache.tapestry.internal.services.ComponentInvocationMap;
 import org.apache.tapestry.internal.services.ComponentResultProcessorWrapper;
 import org.apache.tapestry.internal.services.HeartbeatImpl;
+import org.apache.tapestry.internal.services.ZoneSetup;
 import org.apache.tapestry.internal.util.Base64ObjectInputStream;
 import org.apache.tapestry.internal.util.Base64ObjectOutputStream;
 import org.apache.tapestry.ioc.Location;
@@ -59,8 +60,6 @@
  */
 public class Form implements ClientElement, FormValidationControl
 {
-
-
     /**
      * Invoked before {@link #PREPARE} when rendering out the form.
      */
@@ -131,6 +130,13 @@
     @Parameter("true")
     private boolean _clientValidation;
 
+    /**
+     * Binding the zone parameter will cause the form submission to be handled as an Ajax request that updates
+     * the indicated zone.  Often a Form will update the same zone that contains it.
+     */
+    @Parameter(defaultPrefix = TapestryConstants.LITERAL_BINDING_PREFIX)
+    private String _zone;
+
     @Inject
     private Environment _environment;
 
@@ -167,9 +173,14 @@
     @Mixin
     private RenderInformals _renderInformals;
 
-    @Inject
-    @Traditional
-    private ComponentEventResultProcessor _eventResultProcessor;
+    /**
+     * Set up via the traditional or Ajax component event request handler
+     */
+    @Environmental
+    private ComponentEventResultProcessor _componentEventResultProcessor;
+
+    @Environmental
+    private ZoneSetup _zoneSetup;
 
     private String _name;
 
@@ -201,6 +212,8 @@
 
         _formSupport = new FormSupportImpl(_name, _actions);
 
+        if (_zone != null) _zoneSetup.linkZone(_name, _zone);
+
         // TODO: Forms should not allow to nest. Perhaps a set() method instead of a push() method
         // for this kind of check?  
 
@@ -305,7 +318,8 @@
 
         try
         {
-            ComponentResultProcessorWrapper callback = new ComponentResultProcessorWrapper(_eventResultProcessor);
+            ComponentResultProcessorWrapper callback = new ComponentResultProcessorWrapper(
+                    _componentEventResultProcessor);
 
             _resources.triggerEvent(PREPARE_FOR_SUBMIT, context, callback);
 

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/OptionModelImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/OptionModelImpl.java?rev=628219&r1=628218&r2=628219&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/OptionModelImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/OptionModelImpl.java Fri Feb 15 16:39:02 2008
@@ -1,4 +1,4 @@
-// Copyright 2007 The Apache Software Foundation
+// Copyright 2007, 2008 The Apache Software Foundation
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
@@ -14,38 +14,26 @@
 
 package org.apache.tapestry.internal;
 
-import org.apache.tapestry.OptionModel;
+import org.apache.tapestry.AbstractOptionModel;
 
-import java.util.Map;
-
-public final class OptionModelImpl implements OptionModel
+public class OptionModelImpl extends AbstractOptionModel
 {
     private final String _label;
 
-    private final boolean _disabled;
-
     private final Object _value;
 
-    private final Map<String, String> _attributes;
-
-    public OptionModelImpl(String label, boolean disabled, Object value, String... keysAndValues)
+    /**
+     * Constructor for when the value and the label are the same.
+     */
+    public OptionModelImpl(String value)
     {
-        this(label, disabled, value, keysAndValues.length > 0 ? TapestryInternalUtils
-                .mapFromKeysAndValues(keysAndValues) : null);
+        this(value, value);
     }
 
-    public OptionModelImpl(String label, boolean disabled, Object value,
-                           Map<String, String> attributes)
+    public OptionModelImpl(String label, Object value)
     {
         _label = label;
-        _disabled = disabled;
         _value = value;
-        _attributes = attributes;
-    }
-
-    public Map<String, String> getAttributes()
-    {
-        return _attributes;
     }
 
     public String getLabel()
@@ -56,11 +44,6 @@
     public Object getValue()
     {
         return _value;
-    }
-
-    public boolean isDisabled()
-    {
-        return _disabled;
     }
 
     @Override

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/TapestryInternalUtils.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/TapestryInternalUtils.java?rev=628219&r1=628218&r2=628219&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/TapestryInternalUtils.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/TapestryInternalUtils.java Fri Feb 15 16:39:02 2008
@@ -155,12 +155,12 @@
 
         int equalsx = input.indexOf('=');
 
-        if (equalsx < 0) return new OptionModelImpl(input, false, input);
+        if (equalsx < 0) return new OptionModelImpl(input);
 
         String value = input.substring(0, equalsx);
         String label = input.substring(equalsx + 1);
 
-        return new OptionModelImpl(label, false, value);
+        return new OptionModelImpl(label, value);
     }
 
     /**
@@ -207,7 +207,7 @@
 
         String label = input.getValue() != null ? String.valueOf(input.getValue()) : "";
 
-        return new OptionModelImpl(label, false, input.getKey());
+        return new OptionModelImpl(label, input.getKey());
     }
 
     /**
@@ -251,7 +251,7 @@
     {
         String label = (input != null ? String.valueOf(input) : "");
 
-        return new OptionModelImpl(label, false, input);
+        return new OptionModelImpl(label, input);
     }
 
     /**

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/AjaxComponentEventRequestHandler.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/AjaxComponentEventRequestHandler.java?rev=628219&r1=628218&r2=628219&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/AjaxComponentEventRequestHandler.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/AjaxComponentEventRequestHandler.java Fri Feb 15 16:39:02 2008
@@ -40,15 +40,22 @@
 
     private final PageContentTypeAnalyzer _pageContentTypeAnalyzer;
 
+    private final Environment _environment;
+
+    private final AjaxPartialResponseRenderer _partialRenderer;
+
     public AjaxComponentEventRequestHandler(RequestPageCache cache, Request request, PageRenderQueue queue,
                                             @Ajax ComponentEventResultProcessor resultProcessor,
-                                            PageContentTypeAnalyzer pageContentTypeAnalyzer)
+                                            PageContentTypeAnalyzer pageContentTypeAnalyzer, Environment environment,
+                                            AjaxPartialResponseRenderer partialRenderer)
     {
         _cache = cache;
         _queue = queue;
         _resultProcessor = resultProcessor;
         _pageContentTypeAnalyzer = pageContentTypeAnalyzer;
         _request = request;
+        _environment = environment;
+        _partialRenderer = partialRenderer;
     }
 
     public void handle(ComponentEventRequestParameters parameters) throws IOException
@@ -57,15 +64,17 @@
 
         ComponentResultProcessorWrapper callback = new ComponentResultProcessorWrapper(_resultProcessor);
 
+
         activePage.getRootElement().triggerContextEvent(TapestryConstants.ACTIVATE_EVENT,
                                                         parameters.getPageActivationContext(), callback);
 
+
         if (callback.isAborted()) return;
 
         // If we end up doing a partial render, the page render queue service needs to know the
         // page that will be rendered (for logging purposes, if nothing else).
 
-        _queue.initializeForCompletePage(activePage);
+        _queue.setRenderingPage(activePage);
 
         ContentType contentType = _pageContentTypeAnalyzer.findContentType(activePage);
 
@@ -75,9 +84,20 @@
 
         ComponentPageElement element = containerPage.getComponentElementByNestedId(parameters.getNestedComponentId());
 
+        // In many cases, the triggered element is a Form that needs to be able to
+        // pass it's event handler return values to the correct result processor.
+
+        _environment.push(ComponentEventResultProcessor.class, _resultProcessor);
+
         element.triggerContextEvent(parameters.getEventType(), parameters.getEventContext(), callback);
 
-        if (callback.isAborted()) return;
+        _environment.pop(ComponentEventResultProcessor.class);
+
+        if (_queue.isPartialRenderInitialized())
+        {
+            _partialRenderer.renderPartialPageMarkup();
+            return;
+        }
 
         JSONObject reply = new JSONObject();
 

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/AjaxComponentInstanceEventResultProcessor.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/AjaxComponentInstanceEventResultProcessor.java?rev=628219&r1=628218&r2=628219&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/AjaxComponentInstanceEventResultProcessor.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/AjaxComponentInstanceEventResultProcessor.java Fri Feb 15 16:39:02 2008
@@ -28,12 +28,13 @@
 public class AjaxComponentInstanceEventResultProcessor implements ComponentEventResultProcessor<Component>
 {
     private final RequestPageCache _cache;
-    private final AjaxPartialResponseRenderer _renderer;
 
-    public AjaxComponentInstanceEventResultProcessor(AjaxPartialResponseRenderer renderer, RequestPageCache cache)
+    private final PageRenderQueue _pageRenderQueue;
+
+    public AjaxComponentInstanceEventResultProcessor(RequestPageCache cache, PageRenderQueue pageRenderQueue)
     {
-        _renderer = renderer;
         _cache = cache;
+        _pageRenderQueue = pageRenderQueue;
     }
 
     public void processResultValue(Component value) throws IOException
@@ -51,6 +52,6 @@
 
         RenderCommand command = nestedId == null ? page.getRootElement() : page.getComponentElementByNestedId(nestedId);
 
-        _renderer.renderPartialPageMarkup(command);
+        _pageRenderQueue.initializeForPartialPageRender(command);
     }
 }

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/AjaxPartialResponseRenderer.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/AjaxPartialResponseRenderer.java?rev=628219&r1=628218&r2=628219&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/AjaxPartialResponseRenderer.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/AjaxPartialResponseRenderer.java Fri Feb 15 16:39:02 2008
@@ -14,8 +14,6 @@
 
 package org.apache.tapestry.internal.services;
 
-import org.apache.tapestry.runtime.RenderCommand;
-
 import java.io.IOException;
 
 /**
@@ -29,9 +27,9 @@
 public interface AjaxPartialResponseRenderer
 {
     /**
-     * Used to render a partial response as part of an Ajax action request.
-     *
-     * @param renderCommand command that will be executed to render the content
+     * Used to render a partial response as part of an Ajax action request. A call
+     * to {@link org.apache.tapestry.internal.services.PageRenderQueue#initializeForPartialPageRender(org.apache.tapestry.runtime.RenderCommand)}
+     * should precede this call.
      */
-    void renderPartialPageMarkup(RenderCommand renderCommand) throws IOException;
+    void renderPartialPageMarkup() throws IOException;
 }

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/AjaxPartialResponseRendererImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/AjaxPartialResponseRendererImpl.java?rev=628219&r1=628218&r2=628219&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/AjaxPartialResponseRendererImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/AjaxPartialResponseRendererImpl.java Fri Feb 15 16:39:02 2008
@@ -1,4 +1,4 @@
-// Copyright 2007 The Apache Software Foundation
+// Copyright 2007, 2008 The Apache Software Foundation
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
@@ -18,46 +18,38 @@
 import org.apache.tapestry.MarkupWriter;
 import org.apache.tapestry.internal.InternalConstants;
 import org.apache.tapestry.json.JSONObject;
-import org.apache.tapestry.runtime.RenderCommand;
-import org.apache.tapestry.services.*;
+import org.apache.tapestry.services.MarkupWriterFactory;
+import org.apache.tapestry.services.PartialMarkupRenderer;
+import org.apache.tapestry.services.Request;
+import org.apache.tapestry.services.Response;
 
 import java.io.IOException;
 import java.io.PrintWriter;
 
 public class AjaxPartialResponseRendererImpl implements AjaxPartialResponseRenderer
 {
-    private final Environment _environment;
-
     private final MarkupWriterFactory _factory;
 
     private final Request _request;
+
     private final Response _response;
 
     private final PartialMarkupRenderer _partialMarkupRenderer;
 
-    private final PageRenderQueue _pageRenderQueue;
-
-    public AjaxPartialResponseRendererImpl(Environment environment, MarkupWriterFactory factory, Request request,
-                                           Response response, PartialMarkupRenderer partialMarkupRenderer,
-                                           PageRenderQueue pageRenderQueue)
+    public AjaxPartialResponseRendererImpl(MarkupWriterFactory factory, Request request,
+                                           Response response, PartialMarkupRenderer partialMarkupRenderer)
     {
-        _environment = environment;
         _factory = factory;
         _request = request;
         _response = response;
         _partialMarkupRenderer = partialMarkupRenderer;
-        _pageRenderQueue = pageRenderQueue;
     }
 
-    public void renderPartialPageMarkup(RenderCommand rootRenderCommand) throws IOException
+    public void renderPartialPageMarkup() throws IOException
     {
-        _environment.clear();
-
         // This is a complex area as we are trying to keep public and private services properly
         // seperated, and trying to keep stateless and stateful (i.e., perthread scope) services
         // seperated. So we inform the stateful queue service what it needs to do here ...
-
-        _pageRenderQueue.initializeForPartialPageRender(rootRenderCommand);
 
         ContentType pageContentType = (ContentType) _request.getAttribute(
                 InternalConstants.CONTENT_TYPE_ATTRIBUTE_NAME);

Added: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/AjaxUIDManager.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/AjaxUIDManager.java?rev=628219&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/AjaxUIDManager.java (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/AjaxUIDManager.java Fri Feb 15 16:39:02 2008
@@ -0,0 +1,27 @@
+// Copyright 2008 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package org.apache.tapestry.internal.services;
+
+/**
+ * Manages a UID that is injected into each action request URL.
+ */
+public interface AjaxUIDManager
+{
+    /**
+     * Extracts the UID from the request (parameter "t:uid").  If not present,
+     * returns "1" else returns the value of the requests uid plus 1.
+     */
+    String getAjaxUID();
+}

Added: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/AjaxUIDManagerImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/AjaxUIDManagerImpl.java?rev=628219&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/AjaxUIDManagerImpl.java (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/AjaxUIDManagerImpl.java Fri Feb 15 16:39:02 2008
@@ -0,0 +1,75 @@
+// Copyright 2008 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package org.apache.tapestry.internal.services;
+
+import org.apache.tapestry.Link;
+import org.apache.tapestry.ioc.services.PerthreadManager;
+import org.apache.tapestry.services.Request;
+
+/**
+ * Because this service implementation needs to be a LinkFactoryListener, it could not use
+ * the perthread scope.  Instead, we intract directly with the PerthreadManager service
+ * to store request-scoped data (the UID extracted from the Request).
+ */
+public class AjaxUIDManagerImpl implements LinkFactoryListener, AjaxUIDManager
+{
+    public static final String AJAX_UID_PARAMETER_NAME = "t:uid";
+
+    public static final String KEY = "AjaxUIDManager.UID";
+
+    private final Request _request;
+
+    private final PerthreadManager _perthreadManager;
+
+    public AjaxUIDManagerImpl(Request request, PerthreadManager perthreadManager)
+    {
+        _request = request;
+        _perthreadManager = perthreadManager;
+    }
+
+    public String getAjaxUID()
+    {
+        String result = (String) _perthreadManager.get(KEY);
+
+        if (result == null)
+        {
+            String requestUID = _request.getParameter(AJAX_UID_PARAMETER_NAME);
+
+            long asLong = requestUID == null ? 0 : Long.parseLong(requestUID);
+
+            result = Long.toString(asLong + 1);
+
+            _perthreadManager.put(KEY, result);
+        }
+
+        return result;
+    }
+
+    /**
+     * Does nothing.
+     */
+    public void createdPageLink(Link link)
+    {
+    }
+
+    /**
+     * Adds the Ajax UID to this request, if the request is an Ajax request.
+     */
+    public void createdActionLink(Link link)
+    {
+        if (_request.isXHR())
+            link.addParameter(AJAX_UID_PARAMETER_NAME, getAjaxUID());
+    }
+}

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/ComponentEventRequestHandlerImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/ComponentEventRequestHandlerImpl.java?rev=628219&r1=628218&r2=628219&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/ComponentEventRequestHandlerImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/ComponentEventRequestHandlerImpl.java Fri Feb 15 16:39:02 2008
@@ -31,14 +31,17 @@
 
     private final ActionRenderResponseGenerator _generator;
 
+    private final Environment _environment;
+
     public ComponentEventRequestHandlerImpl(@Traditional ComponentEventResultProcessor resultProcessor,
                                             RequestPageCache cache, Response response,
-                                            ActionRenderResponseGenerator generator)
+                                            ActionRenderResponseGenerator generator, Environment environment)
     {
         _resultProcessor = resultProcessor;
         _cache = cache;
         _response = response;
         _generator = generator;
+        _environment = environment;
     }
 
     public void handle(ComponentEventRequestParameters parameters) throws IOException
@@ -59,7 +62,11 @@
 
         ComponentPageElement element = containerPage.getComponentElementByNestedId(parameters.getNestedComponentId());
 
+        _environment.push(ComponentEventResultProcessor.class, _resultProcessor);
+
         element.triggerContextEvent(parameters.getEventType(), parameters.getEventContext(), callback);
+
+        _environment.pop(ComponentEventResultProcessor.class);
 
         if (callback.isAborted()) return;
 

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/PageRenderQueue.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/PageRenderQueue.java?rev=628219&r1=628218&r2=628219&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/PageRenderQueue.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/PageRenderQueue.java Fri Feb 15 16:39:02 2008
@@ -33,6 +33,11 @@
     void initializeForCompletePage(Page page);
 
     /**
+     * Sets the default page that will render the response.
+     */
+    void setRenderingPage(Page page);
+
+    /**
      * Returns the page that is rendering markup content.
      */
     Page getRenderingPage();
@@ -41,6 +46,11 @@
      * Initializes the queue for rendering of a portion of a page.
      */
     void initializeForPartialPageRender(RenderCommand rootCommand);
+
+    /**
+     * Returns true if {@link #initializeForPartialPageRender(org.apache.tapestry.runtime.RenderCommand)} has been invoked.
+     */
+    boolean isPartialRenderInitialized();
 
     /**
      * Render to the write, as setup by the initialize method.

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/PageRenderQueueImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/PageRenderQueueImpl.java?rev=628219&r1=628218&r2=628219&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/PageRenderQueueImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/PageRenderQueueImpl.java Fri Feb 15 16:39:02 2008
@@ -19,6 +19,7 @@
 import org.apache.tapestry.internal.structure.Page;
 import static org.apache.tapestry.ioc.IOCConstants.PERTHREAD_SCOPE;
 import org.apache.tapestry.ioc.annotations.Scope;
+import org.apache.tapestry.ioc.internal.util.Defense;
 import org.apache.tapestry.json.JSONObject;
 import org.apache.tapestry.runtime.RenderCommand;
 
@@ -40,8 +41,23 @@
         _rootCommand = page.getRootElement();
     }
 
+
+    public void setRenderingPage(Page page)
+    {
+        Defense.notNull(page, "page");
+
+        _page = page;
+    }
+
+    public boolean isPartialRenderInitialized()
+    {
+        return _rootCommand != null;
+    }
+
     public void initializeForPartialPageRender(RenderCommand rootCommand)
     {
+        Defense.notNull(rootCommand, "rootCommand");
+
         if (_page == null) throw new IllegalStateException("Page must be specified before root render command.");
 
         _rootCommand = rootCommand;

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/PartialRenderPageRenderSupport.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/PartialRenderPageRenderSupport.java?rev=628219&r1=628218&r2=628219&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/PartialRenderPageRenderSupport.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/PartialRenderPageRenderSupport.java Fri Feb 15 16:39:02 2008
@@ -1,4 +1,4 @@
-// Copyright 2007 The Apache Software Foundation
+// Copyright 2007, 2008 The Apache Software Foundation
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
@@ -27,12 +27,17 @@
 public class PartialRenderPageRenderSupport implements PageRenderSupport
 {
     private final StringBuilder _builder = new StringBuilder();
+
     private final Formatter _formatter = new Formatter(_builder);
+
     private boolean _dirty;
 
-    // TODO: A namespace for the id allocator to ensure uniquely allocated ids on the client.
+    private final IdAllocator _idAllocator;
 
-    private final IdAllocator _idAllocator = new IdAllocator();
+    public PartialRenderPageRenderSupport(String namespace)
+    {
+        _idAllocator = new IdAllocator(namespace);
+    }
 
     public String allocateClientId(String id)
     {

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/RenderCommandComponentEventResultProcessor.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/RenderCommandComponentEventResultProcessor.java?rev=628219&r1=628218&r2=628219&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/RenderCommandComponentEventResultProcessor.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/RenderCommandComponentEventResultProcessor.java Fri Feb 15 16:39:02 2008
@@ -22,19 +22,19 @@
 /**
  * Processor for objects that implement {@link RenderCommand} (such as {@link org.apache.tapestry.internal.structure.BlockImpl}).
  *
- * @see AjaxPartialResponseRenderer#renderPartialPageMarkup(org.apache.tapestry.runtime.RenderCommand)
+ * @see AjaxPartialResponseRenderer#renderPartialPageMarkup()
  */
 public class RenderCommandComponentEventResultProcessor implements ComponentEventResultProcessor<RenderCommand>
 {
-    private final AjaxPartialResponseRenderer _renderer;
+    private PageRenderQueue _pageRenderQueue;
 
-    public RenderCommandComponentEventResultProcessor(AjaxPartialResponseRenderer renderer)
+    public RenderCommandComponentEventResultProcessor(PageRenderQueue pageRenderQueue)
     {
-        _renderer = renderer;
+        _pageRenderQueue = pageRenderQueue;
     }
 
     public void processResultValue(RenderCommand value) throws IOException
     {
-        _renderer.renderPartialPageMarkup(value);
+        _pageRenderQueue.initializeForPartialPageRender(value);
     }
 }

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/TapestryModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/TapestryModule.java?rev=628219&r1=628218&r2=628219&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/TapestryModule.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/TapestryModule.java Fri Feb 15 16:39:02 2008
@@ -1450,20 +1450,21 @@
      */
     public void contributePartialMarkupRenderer(OrderedConfiguration<PartialMarkupRendererFilter> configuration,
 
+                                                final AjaxUIDManager ajaxUIDManager,
+
                                                 @Path("${tapestry.field-error-marker}")
                                                 final Asset fieldErrorIcon,
 
-                                                final ValidationMessagesSource validationMessagesSource,
-
-                                                final SymbolSource symbolSource,
-
-                                                final AssetSource assetSource)
+                                                final ValidationMessagesSource validationMessagesSource)
     {
         PartialMarkupRendererFilter pageRenderSupport = new PartialMarkupRendererFilter()
         {
             public void renderMarkup(MarkupWriter writer, JSONObject reply, PartialMarkupRenderer renderer)
             {
-                PartialRenderPageRenderSupport support = new PartialRenderPageRenderSupport();
+                String namespace = ":" + ajaxUIDManager.getAjaxUID();
+
+                PartialRenderPageRenderSupport support = new PartialRenderPageRenderSupport(
+                        namespace);
 
                 _environment.push(PageRenderSupport.class, support);
 
@@ -2117,5 +2118,14 @@
     {
         configuration.add("default", new DefaultNullFieldStrategy());
         configuration.add("zero", new ZeroNullFieldStrategy());
+    }
+
+    public static AjaxUIDManager buildAjaxUIDManager(LinkFactory linkFactory, ServiceResources resources)
+    {
+        AjaxUIDManagerImpl service = resources.autobuild(AjaxUIDManagerImpl.class);
+
+        linkFactory.addListener(service);
+
+        return service;
     }
 }

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/util/EnumSelectModel.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/util/EnumSelectModel.java?rev=628219&r1=628218&r2=628219&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/util/EnumSelectModel.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/util/EnumSelectModel.java Fri Feb 15 16:39:02 2008
@@ -53,7 +53,7 @@
         {
             String label = TapestryInternalUtils.getLabelForEnum(messages, prefix, value);
 
-            _options.add(new OptionModelImpl(label, false, value));
+            _options.add(new OptionModelImpl(label, value));
         }
     }
 

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/corelib/components/BeanDisplay.tml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/corelib/components/BeanDisplay.tml?rev=628219&r1=628218&r2=628219&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/corelib/components/BeanDisplay.tml (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/corelib/components/BeanDisplay.tml Fri Feb 15 16:39:02 2008
@@ -1,17 +1,16 @@
-<div class="t-beandisplay" 
-  xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
-  
+<div class="t-beandisplay" xml:space="default"
+     xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
 
-  <div 
-    class="t-beandisplay-row" t:type="loop" t:source="model.propertyNames"
-    t:volatile="true" t:value="propertyName">
-    
-    <div class="t-beandisplay-label">${propertyModel.label}:</div>
 
-    <div class="t-beandisplay-value">
-      <t:propertydisplay model="propertyModel" overrides="overrides" object="object"/>
-    </div>
-    
+    <div class="t-beandisplay-row" t:type="loop" t:source="model.propertyNames"
+         t:volatile="true" t:value="propertyName">
+
+        <div class="t-beandisplay-label">${propertyModel.label}:</div>
+
+        <div class="t-beandisplay-value">
+            <t:propertydisplay model="propertyModel" overrides="overrides" object="object"/>
+        </div>
+
     </div>
 
 </div>

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/corelib/components/BeanEditor.tml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/corelib/components/BeanEditor.tml?rev=628219&r1=628218&r2=628219&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/corelib/components/BeanEditor.tml (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/corelib/components/BeanEditor.tml Fri Feb 15 16:39:02 2008
@@ -1,6 +1,6 @@
-<div xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd"
-  class="t-beaneditor-row" t:type="loop" t:source="model.propertyNames"
-  t:volatile="true" t:value="propertyName">
-  <t:propertyEditor property="propertyName" object="object"
-    model="model" overrides="overrides" />
+<div xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd" xml:space="default"
+     class="t-beaneditor-row" t:type="loop" t:source="model.propertyNames"
+     t:volatile="true" t:value="propertyName">
+    <t:propertyEditor property="propertyName" object="object"
+                      model="model" overrides="overrides"/>
 </div>

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/corelib/components/GridColumns.tml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/corelib/components/GridColumns.tml?rev=628219&r1=628218&r2=628219&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/corelib/components/GridColumns.tml (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/corelib/components/GridColumns.tml Fri Feb 15 16:39:02 2008
@@ -1,4 +1,4 @@
-<thead xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
+<thead xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd" xml:space="default">
     <tr>
         <th t:type="Loop" source="columnNames" value="columnName" volatile="true" class="prop:headerClass"
             index="columnIndex">

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/corelib/components/GridRows.tml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/corelib/components/GridRows.tml?rev=628219&r1=628218&r2=628219&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/corelib/components/GridRows.tml (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/corelib/components/GridRows.tml Fri Feb 15 16:39:02 2008
@@ -1,7 +1,7 @@
-<tr class="${rowClass}" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
+<tr class="${rowClass}" xml:space="default" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
     <t:loop source="propertyNames" value="propertyName" volatile="inherit:volatile">
         <td class="${cellClass}">
-             <t:gridcell model="columnModel" object="row" overrides="componentResources.containerResources"/>
-        </td>        
+            <t:gridcell model="columnModel" object="row" overrides="componentResources.containerResources"/>
+        </td>
     </t:loop>
 </tr>

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/corelib/components/Palette.tml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/corelib/components/Palette.tml?rev=628219&r1=628218&r2=628219&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/corelib/components/Palette.tml (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/corelib/components/Palette.tml Fri Feb 15 16:39:02 2008
@@ -1,27 +1,27 @@
-<div class="t-palette" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
-  <div class="t-palette-available">
-    <div class="t-palette-title">${message:available-label}</div>
-    <t:delegate to="availableRenderer"/>
-  </div>
-  <div class="t-palette-controls">
-    <button id="${clientId}:select" disabled="disabled">
-      <img src="${select}" alt="${message:select-label}"/>
-    </button>
-    <button id="${clientId}:deselect" disabled="disabled">
-      <img src="${deselect}" alt="${message:deselect-label}"/>
-    </button>
-    <t:if test="reorder">
-      <button id="${clientId}:up" disabled="disabled">
-        <img src="${moveUp}" alt="${message:up-label}"/>
-      </button>
-      <button id="${clientId}:down" disabled="disabled">
-        <img src="${moveDown}" alt="${message:down-label}"/>
-      </button>
-    </t:if>
-  </div>
-  <div class="t-palette-selected">
-    <div class="t-palette-title">${message:selected-label}</div>
-    <t:delegate to="selectedRenderer"/>
-  </div>
-  <div class="t-palette-spacer"/>
+<div class="t-palette" xml:space="default" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
+    <div class="t-palette-available">
+        <div class="t-palette-title">${message:available-label}</div>
+        <t:delegate to="availableRenderer"/>
+    </div>
+    <div class="t-palette-controls">
+        <button id="${clientId}:select" disabled="disabled">
+            <img src="${select}" alt="${message:select-label}"/>
+        </button>
+        <button id="${clientId}:deselect" disabled="disabled">
+            <img src="${deselect}" alt="${message:deselect-label}"/>
+        </button>
+        <t:if test="reorder">
+            <button id="${clientId}:up" disabled="disabled">
+                <img src="${moveUp}" alt="${message:up-label}"/>
+            </button>
+            <button id="${clientId}:down" disabled="disabled">
+                <img src="${moveDown}" alt="${message:down-label}"/>
+            </button>
+        </t:if>
+    </div>
+    <div class="t-palette-selected">
+        <div class="t-palette-title">${message:selected-label}</div>
+        <t:delegate to="selectedRenderer"/>
+    </div>
+    <div class="t-palette-spacer"/>
 </div>

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/corelib/pages/ExceptionReport.tml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/corelib/pages/ExceptionReport.tml?rev=628219&r1=628218&r2=628219&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/corelib/pages/ExceptionReport.tml (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/corelib/pages/ExceptionReport.tml Fri Feb 15 16:39:02 2008
@@ -1,4 +1,4 @@
-<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
+<html xml:space="default" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
     <head>
         <title>Application Exception</title>
     </head>

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/corelib/pages/PropertyDisplayBlocks.tml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/corelib/pages/PropertyDisplayBlocks.tml?rev=628219&r1=628218&r2=628219&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/corelib/pages/PropertyDisplayBlocks.tml (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/corelib/pages/PropertyDisplayBlocks.tml Fri Feb 15 16:39:02 2008
@@ -1,4 +1,4 @@
-<t:container xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
+<t:container xml:space="default" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
 
     <t:block id="enum">
         ${convertedEnumValue}

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/corelib/pages/PropertyEditBlocks.tml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/corelib/pages/PropertyEditBlocks.tml?rev=628219&r1=628218&r2=628219&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/corelib/pages/PropertyEditBlocks.tml (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/corelib/pages/PropertyEditBlocks.tml Fri Feb 15 16:39:02 2008
@@ -1,4 +1,4 @@
-<div xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
+<div xml:space="default" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
 
     <t:block id="text">
         <t:label for="textField"/>

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/corelib/pages/ServiceStatus.tml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/corelib/pages/ServiceStatus.tml?rev=628219&r1=628218&r2=628219&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/corelib/pages/ServiceStatus.tml (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/corelib/pages/ServiceStatus.tml Fri Feb 15 16:39:02 2008
@@ -1,72 +1,72 @@
-<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
-  <head>
-    <title>Tapestry IoC Services Status</title>
-    <style>
-TR.defined {
-  color: #666666;
-  font-style: italic;
-}
-
-TR.virtual
-{
- color: blue;
-}
-
-TR.real
-{
-  color: green;
-}
-
-    
-    </style>
-  </head>
-  <body>
-
-    <h1>Tapestry IoC Services Status</h1>
-
-    <p>${activity.size()} services defined in the IoC Registry.</p>
-
-    <t:grid rowsperpage="100" model="model" pagerposition="top" rowClass="row.status"
-      source="activity" row="row">
-
-      <t:parameter name="serviceInterfaceCell">
-        ${row.serviceInterface}
-      </t:parameter>
-
-    </t:grid>
-
-    <p>
-      Explanation of status:
-      <dl>
-        <dt>Builtin</dt>
-        <dd>
-          A fundamental service that exists even before the Registry is
-          created.
-        </dd>
-
-        <dt>Defined</dt>
-        <dd>
-          The service is defined, but has not yet been referenced.
-        </dd>
-
-        <dt>Virtual</dt>
-        <dd>
-          The service has been referenced (usually for injection into
-          another service) but has not yet been
-          <em>realized</em>
-          into an instantiated service. Realization occurs with the
-          first method invocation on the proxy.
-        </dd>
-
-        <dt>Real</dt>
-        <dd>
-          The service has been realized: instantiated, dependencies
-          injected, decorated with interceptors and is fully in
-          operation.
-        </dd>
+<html xml:space="default" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
+    <head>
+        <title>Tapestry IoC Services Status</title>
+        <style>
+            TR.defined {
+            color: #666666;
+            font-style: italic;
+            }
+
+            TR.virtual
+            {
+            color: blue;
+            }
+
+            TR.real
+            {
+            color: green;
+            }
+
+
+        </style>
+    </head>
+    <body>
+
+        <h1>Tapestry IoC Services Status</h1>
+
+        <p>${activity.size()} services defined in the IoC Registry.</p>
+
+        <t:grid rowsperpage="100" model="model" pagerposition="top" rowClass="row.status"
+                source="activity" row="row">
+
+            <t:parameter name="serviceInterfaceCell">
+                ${row.serviceInterface}
+            </t:parameter>
+
+        </t:grid>
+
+        <p>
+            Explanation of status:
+            <dl>
+                <dt>Builtin</dt>
+                <dd>
+                    A fundamental service that exists even before the Registry is
+                    created.
+                </dd>
+
+                <dt>Defined</dt>
+                <dd>
+                    The service is defined, but has not yet been referenced.
+                </dd>
+
+                <dt>Virtual</dt>
+                <dd>
+                    The service has been referenced (usually for injection into
+                    another service) but has not yet been
+                    <em>realized</em>
+                    into an instantiated service. Realization occurs with the
+                    first method invocation on the proxy.
+                </dd>
+
+                <dt>Real</dt>
+                <dd>
+                    The service has been realized: instantiated, dependencies
+                    injected, decorated with interceptors and is fully in
+                    operation.
+                </dd>
 
-      </dl>
-    </p>
+            </dl>
+        </p>
 
-  </body>
+    </body>
 </html>

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/tapestry.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/tapestry.js?rev=628219&r1=628218&r2=628219&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/tapestry.js (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/tapestry.js Fri Feb 15 16:39:02 2008
@@ -35,19 +35,57 @@
         document.observe("dom:loaded", callback);
     },
 
+    // Find all elements marked with the "t-invisible" CSS class and hide() them, so that
+    // Prototype's visible() method operates correctly. This is invoked when the
+    // DOM is first loaded, and AGAIN whenever dynamic content is loaded via the Zone
+    // mechanism.
+
+    onDomLoadedCallback : function()
+    {
+        $$(".t-invisible").each(function(element)
+        {
+            element.hide();
+            element.removeClassName("t-invisible");
+        });
+
+        // Adds a focus observer that fades all error popups except for the
+        // field in question.
+
+        $$("INPUT", "SELECT", "TEXTAREA").each(function(element)
+        {
+            if (element.isObservingFocusChange == undefined)
+            {
+
+
+                element.observe("focus", function()
+                {
+                    Tapestry.focusedElement = element;
+
+                    $(Tapestry.errorPopups).each(function(popup)
+                    {
+                        popup.handleFocusChange(element);
+                    });
+                });
+
+                element.isObservingFocusChange = true;
+            }
+        });
+    },
+
     registerForm : function(form, clientValidations)
     {
         form = $(form);
-    
-    // This can probably be cleaned up with bind() ...
 
-        form.onsubmit = function()
+        // Because order is important, we don't observe
+        // the event, we take it over.
+
+        form.onsubmit = function(domevent)
         {
             var event = new Tapestry.FormEvent(form);
 
             form.firstError = true;
 
-	  // Locate elements that have an event manager (and therefore, validations)
+	        // Locate elements that have an event manager (and therefore, validations)
             // and let those validations execute, which may result in calls to recordError().
 
             form.getElements().each(function(element)
@@ -61,12 +99,13 @@
                 }
             });
 
+            if (! event.result) domevent.stop();
+
             return event.result;
         };
 
         form.recordError = function(field, event, message)
         {
-
             if (form.firstError)
             {
                 $(field).activate();
@@ -74,8 +113,7 @@
                 form.firstError = false;
             }
 
-            field.decorateForValidationError(event, message);
-
+            field.decorateForValidationError(message);
         };
 
         // And handle the validations
@@ -113,30 +151,67 @@
         });
     },
 
-    // Convert a link into a trigger of an Ajax update that
+    // Convert a form or link into a trigger of an Ajax update that
     // updates the indicated Zone.
 
-    linkZone : function(link, zoneDiv)
+    linkZone : function(element, zoneDiv)
     {
-        link = $(link);
+        element = $(element);
         var zone = $(zoneDiv).zone;
 
-        var clickHandler = function(event)
+        var successHandler = function(transport)
+        {
+            var response = transport.responseText;
+            var reply = eval("(" + response + ")");
+
+            zone.show(reply.content);
+
+            var newScript = reply.script;
+
+            if (newScript != undefined)
+                eval(newScript);
+
+            Tapestry.onDomLoadedCallback();
+        };
+
+
+        if (element.tagName == "FORM")
         {
-            var successHandler = function(transport)
+            // The existing handler, if present, will be responsible for form validations, which must
+            // come before submitting the form via XHR.
+
+            var existingHandler = element.onsubmit;
+
+            var handler = function(event)
             {
-                var response = transport.responseText;
-                var reply = eval("(" + response + ")");
+                if (existingHandler != undefined)
+                {
+                    var existingResult = existingHandler.call(element, event);
+                    if (! existingResult) return false;
+                }
 
-                zone.show(reply.content);
+                element.request({ onSuccess : successHandler });
+
+                event.stop();
+
+                return false;
             };
 
-            var request = new Ajax.Request(link.href, { onSuccess : successHandler });
+            element.onsubmit = handler;
+
+            return;
+        }
+
+        // Otherwise, assume it's just an ordinary link.
+
+        var handler = function(event)
+        {
+            new Ajax.Request(element.href, { onSuccess : successHandler });
 
             return false;
         };
 
-        link.onclick = clickHandler;
+        element.onclick = handler;
     },
 
     initializeZones : function (zoneSpecs, linkSpecs)
@@ -181,7 +256,7 @@
     // This is added to all Elements, but really only applys to form control elements. This method is invoked
     // when a validation error is associated with a field. This gives the field a chance to decorate itself, its label
     // and its icon.
-    decorateForValidationError : function (element, event, message)
+    decorateForValidationError : function (element, message)
     {
         $(element).fieldEventManager.addDecorations(message);
     }
@@ -296,6 +371,8 @@
 
             this.outerDiv.hide();
 
+            this.field.focus();
+
             event.stop();
         }.bindAsEventListener(this));
 
@@ -572,31 +649,5 @@
     }
 };
 
-// Find all elements marked with the "t-invisible" CSS class and hide() them, so that
-// Prototype's visible() method operates correctly.
-
-Tapestry.onDOMLoaded(function()
-{
-    $$(".t-invisible").each(function(element)
-    {
-        element.hide();
-        element.removeClassName("t-invisible");
-    });
-
-    // Adds a focus observer that fades all error popups except for the
-    // field in question.
-
-    $$("INPUT", "SELECT", "TEXTAREA").each(function(element)
-    {
-        element.observe("focus", function()
-        {
-            Tapestry.focusedElement = element;
-
-            $(Tapestry.errorPopups).each(function(popup)
-            {
-                popup.handleFocusChange(element);
-            });
-        });
-    });
-});
+Tapestry.onDOMLoaded(Tapestry.onDomLoadedCallback);
 

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/app1/ZoneDemo.tml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/app1/ZoneDemo.tml?rev=628219&r1=628218&r2=628219&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/app1/ZoneDemo.tml (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/app1/ZoneDemo.tml Fri Feb 15 16:39:02 2008
@@ -1,8 +1,8 @@
-<html t:type="Border" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
+<html t:type="Border" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd" xml:space="default">
     <h1>Zone/Ajax Demo</h1>
 
 
-    <t:zone t:id="output" style="float:right;">
+    <t:zone t:id="output" style="float:right; width: 800px;">
         No name has been selected.
 
         <t:block id="showName">
@@ -10,6 +10,29 @@
         </t:block>
 
     </t:zone>
+
+    <t:block id="registrationForm">
+        <form t:id="form" zone="output">
+
+            <t:errors/>
+
+            <div class="t-beaneditor">
+
+                <t:beaneditor t:id="registration"/>
+
+                <div class="t-beaneditor-row">
+                    <input type="submit" class="t-beaneditor-submit" value="Update"/>
+                    <t:actionlink t:id="clear" zone="output">clear</t:actionlink>
+                </div>
+            </div>
+
+        </form>
+
+    </t:block>
+
+    <t:block id="registrationOutput">
+        <t:beandisplay object="registration"/>
+    </t:block>
 
 
     <ul>

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/corelib/components/SelectTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/corelib/components/SelectTest.java?rev=628219&r1=628218&r2=628219&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/corelib/components/SelectTest.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/corelib/components/SelectTest.java Fri Feb 15 16:39:02 2008
@@ -161,7 +161,14 @@
         // Extra cast needed for Sun compiler, not Eclipse compiler.
 
         List<OptionModel> options = Arrays.asList(
-                (OptionModel) new OptionModelImpl("Fred", false, "fred", "class", "pixie"));
+                (OptionModel) new OptionModelImpl("Fred", "fred")
+                {
+                    @Override
+                    public Map<String, String> getAttributes()
+                    {
+                        return Collections.singletonMap("class", "pixie");
+                    }
+                });
 
         Select select = new Select();
 
@@ -194,8 +201,21 @@
 
         // Extra cast needed for Sun compiler, not Eclipse compiler.
 
-        List<OptionModel> options = CollectionFactory.newList(
-                (OptionModel) new OptionModelImpl("Fred", true, "fred", "class", "pixie"));
+        List<OptionModel> options = Arrays.asList(
+                (OptionModel) new OptionModelImpl("Fred", "fred")
+                {
+                    @Override
+                    public boolean isDisabled()
+                    {
+                        return true;
+                    }
+
+                    @Override
+                    public Map<String, String> getAttributes()
+                    {
+                        return Collections.singletonMap("class", "pixie");
+                    }
+                });
 
         Select select = new Select();
 

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/ZoneDemo.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/ZoneDemo.java?rev=628219&r1=628218&r2=628219&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/ZoneDemo.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/ZoneDemo.java Fri Feb 15 16:39:02 2008
@@ -1,4 +1,4 @@
-// Copyright 2007 The Apache Software Foundation
+// Copyright 2007, 2008 The Apache Software Foundation
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
@@ -15,21 +15,37 @@
 package org.apache.tapestry.integration.app1.pages;
 
 import org.apache.tapestry.Block;
+import org.apache.tapestry.annotations.ApplicationState;
+import org.apache.tapestry.annotations.Component;
+import org.apache.tapestry.corelib.components.Form;
+import org.apache.tapestry.integration.app1.data.RegistrationData;
 import org.apache.tapestry.ioc.annotations.Inject;
 import org.slf4j.Logger;
 
 public class ZoneDemo
 {
+    @Component
+    private Form _form;
+
     @Inject
     private Logger _logger;
 
     private String _name;
 
-    private static final String[] NAMES = {"Fred & Wilma", "Mr. <Roboto>", "Grim Fandango"};
+    @ApplicationState
+    private RegistrationData _registration;
+
+    private static final String[] NAMES = {"Fred & Wilma", "Mr. <Roboto>", "Grim Fandango", "Registration"};
 
     @Inject
     private Block _showName;
 
+    @Inject
+    private Block _registrationForm;
+
+    @Inject
+    private Block _registrationOutput;
+
     public String[] getNames()
     {
         return NAMES;
@@ -52,6 +68,27 @@
 
         _logger.info("Selected: '" + _name + "'");
 
+
+        if (name.equals("Registration")) return _registrationForm;
+
         return _showName;
+    }
+
+    Object onSuccess()
+    {
+        return _registrationOutput;
+    }
+
+    Object onActionFromClear()
+    {
+        _form.clearErrors();
+        _registration = null;
+
+        return _registrationForm;
+    }
+
+    public RegistrationData getRegistration()
+    {
+        return _registration;
     }
 }

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/OptionModelImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/OptionModelImplTest.java?rev=628219&r1=628218&r2=628219&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/OptionModelImplTest.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/OptionModelImplTest.java Fri Feb 15 16:39:02 2008
@@ -1,4 +1,4 @@
-// Copyright 2007 The Apache Software Foundation
+// Copyright 2007, 2008 The Apache Software Foundation
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
@@ -18,49 +18,21 @@
 import org.testng.Assert;
 import org.testng.annotations.Test;
 
-import java.util.Collections;
-import java.util.Map;
-
 public class OptionModelImplTest extends Assert
 {
     @Test
     public void basics()
     {
-        OptionModel model = new OptionModelImpl("Label", false, this);
+        OptionModel model = new OptionModelImpl("Label", this);
 
         assertEquals(model.getLabel(), "Label");
         assertFalse(model.isDisabled());
         assertSame(model.getValue(), this);
         assertNull(model.getAttributes());
 
-        model = new OptionModelImpl("Fred", true, "fred");
+        model = new OptionModelImpl("Fred", "fred");
 
-        assertEquals(model.getLabel(), "Fred");
-        assertTrue(model.isDisabled());
 
         assertEquals(model.toString(), "OptionModel[Fred fred]");
-    }
-
-    @Test
-    public void attributes_as_extra_parameters()
-    {
-        OptionModel model = new OptionModelImpl("Label", false, this, "fred", "flintstone",
-                                                "barney", "rubble");
-
-        Map<String, String> attributes = model.getAttributes();
-
-        assertEquals(attributes.size(), 2);
-        assertEquals(attributes.get("fred"), "flintstone");
-        assertEquals(attributes.get("barney"), "rubble");
-    }
-
-    @Test
-    public void attributes_as_map_are_retained()
-    {
-        Map<String, String> attributes = Collections.emptyMap();
-
-        OptionModel model = new OptionModelImpl("Label", false, this, attributes);
-
-        assertSame(model.getAttributes(), attributes);
     }
 }

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/AjaxComponentInstanceEventResultProcessorTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/AjaxComponentInstanceEventResultProcessorTest.java?rev=628219&r1=628218&r2=628219&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/AjaxComponentInstanceEventResultProcessorTest.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/AjaxComponentInstanceEventResultProcessorTest.java Fri Feb 15 16:39:02 2008
@@ -33,12 +33,11 @@
         String pageName = "Biff";
 
         RequestPageCache cache = mockRequestPageCache();
-        AjaxPartialResponseRenderer renderer = newMock(AjaxPartialResponseRenderer.class);
         Page page = mockPage();
         ComponentResources resources = mockComponentResources();
         Component component = mockComponent();
         ComponentPageElement element = mockComponentPageElement();
-
+        PageRenderQueue queue = mockPageRenderQueue();
 
         train_getComponentResources(component, resources);
         train_getPageName(resources, pageName);
@@ -46,12 +45,12 @@
         train_getNestedId(resources, nestedId);
         train_getComponentElementByNestedId(page, nestedId, element);
 
-        renderer.renderPartialPageMarkup(element);
+        queue.initializeForPartialPageRender(element);
 
         replay();
 
-        ComponentEventResultProcessor<Component> processor = new AjaxComponentInstanceEventResultProcessor(renderer,
-                                                                                                           cache);
+        ComponentEventResultProcessor<Component> processor = new AjaxComponentInstanceEventResultProcessor(
+                cache, queue);
 
         processor.processResultValue(component);
 
@@ -64,12 +63,11 @@
         String pageName = "Biff";
 
         RequestPageCache cache = mockRequestPageCache();
-        AjaxPartialResponseRenderer renderer = newMock(AjaxPartialResponseRenderer.class);
         Page page = mockPage();
         ComponentResources resources = mockComponentResources();
         Component component = mockComponent();
         ComponentPageElement element = mockComponentPageElement();
-
+        PageRenderQueue queue = mockPageRenderQueue();
 
         train_getComponentResources(component, resources);
         train_getPageName(resources, pageName);
@@ -77,12 +75,13 @@
         train_getNestedId(resources, null);
         train_getRootElement(page, element);
 
-        renderer.renderPartialPageMarkup(element);
+        queue.initializeForPartialPageRender(element);
 
         replay();
 
-        ComponentEventResultProcessor<Component> processor = new AjaxComponentInstanceEventResultProcessor(renderer,
-                                                                                                           cache);
+        ComponentEventResultProcessor<Component> processor = new AjaxComponentInstanceEventResultProcessor(
+                cache,
+                queue);
 
         processor.processResultValue(component);
 

Added: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/AjaxUIDManagerImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/AjaxUIDManagerImplTest.java?rev=628219&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/AjaxUIDManagerImplTest.java (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/AjaxUIDManagerImplTest.java Fri Feb 15 16:39:02 2008
@@ -0,0 +1,120 @@
+// Copyright 2008 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package org.apache.tapestry.internal.services;
+
+import org.apache.tapestry.Link;
+import org.apache.tapestry.internal.test.InternalBaseTestCase;
+import org.apache.tapestry.ioc.services.PerthreadManager;
+import org.apache.tapestry.services.Request;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+public class AjaxUIDManagerImplTest extends InternalBaseTestCase
+{
+    private PerthreadManager _perthreadManager;
+
+    @BeforeClass
+    public void setup()
+    {
+        _perthreadManager = getService(PerthreadManager.class);
+    }
+
+    @BeforeMethod
+    public void setup_method()
+    {
+        _perthreadManager.cleanup();
+    }
+
+    @Test
+    public void get_uid_when_no_parameter_in_request()
+    {
+        Request request = mockRequest();
+
+        train_getParameter(request, AjaxUIDManagerImpl.AJAX_UID_PARAMETER_NAME, null);
+
+        replay();
+
+        AjaxUIDManager manager = new AjaxUIDManagerImpl(request, _perthreadManager);
+
+        // Use a loop to check caching
+
+        for (int i = 0; i < 2; i++)
+        {
+            assertEquals(manager.getAjaxUID(), "1");
+        }
+
+        verify();
+    }
+
+    @Test
+    public void current_uid_increments_value_from_request()
+    {
+        Request request = mockRequest();
+
+        train_getParameter(request, AjaxUIDManagerImpl.AJAX_UID_PARAMETER_NAME, "123");
+
+        replay();
+
+        AjaxUIDManager manager = new AjaxUIDManagerImpl(request, _perthreadManager);
+
+        // Use a loop to check caching
+
+        for (int i = 0; i < 2; i++)
+        {
+            assertEquals(manager.getAjaxUID(), "124");
+        }
+
+        verify();
+    }
+
+    @Test
+    public void action_link_in_traditional_request()
+    {
+        Request request = mockRequest();
+        Link link = mockLink();
+
+        train_isXHR(request, false);
+
+        replay();
+
+        AjaxUIDManagerImpl manager = new AjaxUIDManagerImpl(request, _perthreadManager);
+
+
+        manager.createdActionLink(link);
+
+        verify();
+    }
+
+    @Test
+    public void action_link_in_ajax_request()
+    {
+        Request request = mockRequest();
+        Link link = mockLink();
+
+        train_isXHR(request, true);
+        train_getParameter(request, AjaxUIDManagerImpl.AJAX_UID_PARAMETER_NAME, "777");
+
+        link.addParameter(AjaxUIDManagerImpl.AJAX_UID_PARAMETER_NAME, "778");
+
+        replay();
+
+        AjaxUIDManagerImpl manager = new AjaxUIDManagerImpl(request, _perthreadManager);
+
+        manager.createdActionLink(link);
+
+        verify();
+    }
+}

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/PartialRenderPageRenderSupportTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/PartialRenderPageRenderSupportTest.java?rev=628219&r1=628218&r2=628219&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/PartialRenderPageRenderSupportTest.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/PartialRenderPageRenderSupportTest.java Fri Feb 15 16:39:02 2008
@@ -1,4 +1,4 @@
-// Copyright 2007 The Apache Software Foundation
+// Copyright 2007, 2008 The Apache Software Foundation
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
@@ -25,16 +25,26 @@
     @Test
     public void allocate_ids()
     {
-        PageRenderSupport prs = new PartialRenderPageRenderSupport();
+        PageRenderSupport prs = new PartialRenderPageRenderSupport("");
 
         assertEquals(prs.allocateClientId("foo"), "foo");
         assertEquals(prs.allocateClientId("foo"), "foo_0");
     }
 
     @Test
+    public void allocate_ids_with_uid()
+    {
+        PageRenderSupport prs = new PartialRenderPageRenderSupport(":uid");
+
+        assertEquals(prs.allocateClientId("foo"), "foo:uid");
+        assertEquals(prs.allocateClientId("foo"), "foo:uid_0");
+
+    }
+
+    @Test
     public void add_links_do_nothing()
     {
-        PageRenderSupport prs = new PartialRenderPageRenderSupport();
+        PageRenderSupport prs = new PartialRenderPageRenderSupport("");
 
         Asset asset = mockAsset();
 
@@ -50,7 +60,7 @@
     @Test
     public void add_script_and_update()
     {
-        PartialRenderPageRenderSupport prs = new PartialRenderPageRenderSupport();
+        PartialRenderPageRenderSupport prs = new PartialRenderPageRenderSupport("");
 
         JSONObject reply = new JSONObject();