Author: hlship
Date: Thu Oct 30 10:13:24 2008
New Revision: 709213

URL: http://svn.apache.org/viewvc?rev=709213&view=rev
Log:
TAP5-124: DateField does not work correctly inside AjaxFormLoop

Added:
    
tapestry/tapestry5/trunk/tapestry-core/src/test/app1/DateFieldAjaxFormLoop.tml
    
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/data/DateHolder.java
    
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/DateFieldAjaxFormLoop.java
Modified:
    
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/EventConstants.java
    
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/PrimaryKeyEncoder.java
    
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/base/AbstractComponentEventLink.java
    
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/ActionLink.java
    
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/AddRowLink.java
    
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/AjaxFormLoop.java
    
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/EventLink.java
    
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Form.java
    
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/FormInjector.java
    
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/PageLink.java
    
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/RemoveRowLink.java
    
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/InternalComponentResourcesImpl.java
    
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Start.java

Modified: 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/EventConstants.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/EventConstants.java?rev=709213&r1=709212&r2=709213&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/EventConstants.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/EventConstants.java
 Thu Oct 30 10:13:24 2008
@@ -1,3 +1,17 @@
+//  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.tapestry5;
 
 /**
@@ -96,4 +110,17 @@
      * Event triggered by form-related components to validate user input.
      */
     public static final String VALIDATE = "validate";
+
+    /**
+     * Event triggered by [EMAIL PROTECTED] 
org.apache.tapestry5.corelib.components.AjaxFormLoop} to inform the container 
about the
+     * row removed on the client side.  The event context is the object that 
was removed.
+     */
+    public static final String REMOVE_ROW = "removeRow";
+
+    /**
+     * Event triggered by [EMAIL PROTECTED] 
org.apache.tapestry5.corelib.components.AjaxFormLoop} to inform the container 
that a
+     * new row has been requested.  The return value from the event handler 
must be the newly created object, which must
+     * also be visible in the [EMAIL PROTECTED] 
org.apache.tapestry5.PrimaryKeyEncoder encoder parameter}.
+     */
+    public static final String ADD_ROW = "addRow";
 }

Modified: 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/PrimaryKeyEncoder.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/PrimaryKeyEncoder.java?rev=709213&r1=709212&r2=709213&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/PrimaryKeyEncoder.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/PrimaryKeyEncoder.java
 Thu Oct 30 10:13:24 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,18 +14,19 @@
 
 package org.apache.tapestry5;
 
-import org.apache.tapestry5.corelib.components.Loop;
-
 import java.io.Serializable;
 import java.util.List;
 
 /**
- * Used by [EMAIL PROTECTED] Loop} and similar components to extract out an 
identifier, here termed a "primary key", that can be
- * stored on the client and later used to recover the same, or equivalent, 
server side object.
+ * Used by [EMAIL PROTECTED] org.apache.tapestry5.corelib.components.Loop}, 
[EMAIL PROTECTED] org.apache.tapestry5.corelib.components.AjaxFormLoop}
+ * and similar components to extract out an identifier, here termed a "primary 
key", that can be stored on the client
+ * and later used to recover the same, or equivalent, server side object.
+ * <p/>
+ * The [EMAIL PROTECTED] org.apache.tapestry5.util.DefaultPrimaryKeyEncoder} 
implementation is used in most circumstances.
  *
  * @param <K> the type of the primary key, used to identify the value (which 
must be serializable)
  * @param <V> the type of value identified by the key
- * @see ValueEncoder
+ * @see org.apache.tapestry5.ValueEncoder
  */
 public interface PrimaryKeyEncoder<K extends Serializable, V>
 {

Modified: 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/base/AbstractComponentEventLink.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/base/AbstractComponentEventLink.java?rev=709213&r1=709212&r2=709213&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/base/AbstractComponentEventLink.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/base/AbstractComponentEventLink.java
 Thu Oct 30 10:13:24 2008
@@ -21,8 +21,6 @@
 import org.apache.tapestry5.annotations.Parameter;
 import org.apache.tapestry5.internal.services.ClientBehaviorSupport;
 
-import java.util.List;
-
 /**
  * Base class for link-generating components that are based on a component 
event request. Such events have an event
  * context and may also update a [EMAIL PROTECTED] 
org.apache.tapestry5.corelib.components.Zone}.
@@ -35,7 +33,7 @@
      * methods.
      */
     @Parameter
-    private List<?> context;
+    private Object[] context;
 
     /**
      * Binding the zone parameter turns the link into a an Ajax control that 
causes the related zone to be updated.
@@ -50,9 +48,7 @@
     {
         if (isDisabled()) return;
 
-        Object[] contextArray = context == null ? new Object[0] : 
context.toArray();
-
-        Link link = createLink(contextArray);
+        Link link = createLink(context);
 
         writeLink(writer, link);
 
@@ -61,6 +57,8 @@
 
     /**
      * Invoked to create the Link that will become the href attribute of the 
output.
+     *
+     * @param eventContext the context as an object array, possibly null
      */
     protected abstract Link createLink(Object[] eventContext);
 
@@ -70,5 +68,4 @@
 
         writer.end(); // <a>
     }
-
 }

Modified: 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/ActionLink.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/ActionLink.java?rev=709213&r1=709212&r2=709213&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/ActionLink.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/ActionLink.java
 Thu Oct 30 10:13:24 2008
@@ -28,9 +28,9 @@
     @Inject
     private ComponentResources resources;
 
+    @Override
     protected Link createLink(Object[] contextArray)
     {
         return resources.createEventLink(EventConstants.ACTION, contextArray);
     }
-
 }

Modified: 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/AddRowLink.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/AddRowLink.java?rev=709213&r1=709212&r2=709213&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/AddRowLink.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/AddRowLink.java
 Thu Oct 30 10:13:24 2008
@@ -24,7 +24,9 @@
 
 /**
  * Used inside an [EMAIL PROTECTED] 
org.apache.tapestry5.corelib.components.AjaxFormLoop} component to spur the 
addition of a new
- * row.  Triggers a server-side "addRow" event which must return a Block (or 
component) to render the new row.
+ * row.  Triggers a server-side [EMAIL PROTECTED] 
org.apache.tapestry5.EventConstants#ADD_ROW addRow} event on the
+ * AjaxFormLoop, which must return the newly added object, which will be 
rendered in the body of the AjaxFormLoop and
+ * sent to the client web browser.
  */
 @SupportsInformalParameters
 public class AddRowLink

Modified: 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/AjaxFormLoop.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/AjaxFormLoop.java?rev=709213&r1=709212&r2=709213&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/AjaxFormLoop.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/AjaxFormLoop.java
 Thu Oct 30 10:13:24 2008
@@ -29,12 +29,17 @@
 import java.io.Serializable;
 import java.util.Collections;
 import java.util.Iterator;
-import java.util.List;
 
 /**
  * A special form of the [EMAIL PROTECTED] 
org.apache.tapestry5.corelib.components.Loop} component that adds a lot of Ajax 
support
  * to handle adding new rows and removing existing rows dynamically.  Expects 
that the values being iterated over are
  * entities that can be identified via a [EMAIL PROTECTED] 
org.apache.tapestry5.PrimaryKeyEncoder}.
+ * <p/>
+ * Works with [EMAIL PROTECTED] 
org.apache.tapestry5.corelib.components.AddRowLink} and [EMAIL PROTECTED]
+ * org.apache.tapestry5.corelib.components.RemoveRowLink} components.
+ *
+ * @see org.apache.tapestry5.EventConstants#ADD_ROW
+ * @see org.apache.tapestry5.EventConstants#REMOVE_ROW
  */
 public class AjaxFormLoop
 {
@@ -65,7 +70,7 @@
      * handler methods.
      */
     @Parameter
-    private List<?> context;
+    private Object[] context;
 
 
     /**
@@ -379,7 +384,7 @@
             }
         };
 
-        resources.triggerContextEvent("addRow", context, callback);
+        resources.triggerContextEvent(EventConstants.ADD_ROW, context, 
callback);
 
         if (value == null)
             throw new IllegalArgumentException(
@@ -414,7 +419,7 @@
 
         Object value = encoder.toValue(coerced);
 
-        resources.triggerEvent("removeRow", new Object[] {value}, null);
+        resources.triggerEvent(EventConstants.REMOVE_ROW, new Object[] 
{value}, null);
 
         return new JSONObject();
     }

Modified: 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/EventLink.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/EventLink.java?rev=709213&r1=709212&r2=709213&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/EventLink.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/EventLink.java
 Thu Oct 30 10:13:24 2008
@@ -49,6 +49,7 @@
         return resources.getId();
     }
 
+    @Override
     protected Link createLink(Object[] eventContext)
     {
         ComponentResources containerResources = 
resources.getContainerResources();

Modified: 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Form.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Form.java?rev=709213&r1=709212&r2=709213&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Form.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Form.java
 Thu Oct 30 10:13:24 2008
@@ -42,7 +42,6 @@
 import java.io.EOFException;
 import java.io.IOException;
 import java.io.ObjectInputStream;
-import java.util.List;
 
 /**
  * An HTML form, which will enclose other components to render out the various 
types of fields.
@@ -111,7 +110,7 @@
      * methods.
      */
     @Parameter
-    private List<?> context;
+    private Object[] context;
 
     /**
      * The object which will record user input and validation errors. The 
object must be persistent between requests
@@ -250,13 +249,11 @@
         // Now that the environment is setup, inform the component or other 
listeners that the form
         // is about to render.  
 
-        Object[] contextArray = context == null ? new Object[0] : 
context.toArray();
+        resources.triggerEvent(EventConstants.PREPARE_FOR_RENDER, context, 
null);
 
-        resources.triggerEvent(EventConstants.PREPARE_FOR_RENDER, 
contextArray, null);
+        resources.triggerEvent(EventConstants.PREPARE, context, null);
 
-        resources.triggerEvent(EventConstants.PREPARE, contextArray, null);
-
-        Link link = resources.createFormEventLink(EventConstants.ACTION, 
contextArray);
+        Link link = resources.createFormEventLink(EventConstants.ACTION, 
context);
 
         // Save the form element for later, in case we want to write an 
encoding type attribute.
 

Modified: 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/FormInjector.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/FormInjector.java?rev=709213&r1=709212&r2=709213&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/FormInjector.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/FormInjector.java
 Thu Oct 30 10:13:24 2008
@@ -35,7 +35,6 @@
 import org.slf4j.Logger;
 
 import java.io.IOException;
-import java.util.List;
 
 /**
  * A way to add new content to an existing Form. The FormInjector emulates its 
tag from the template (or uses a
@@ -61,7 +60,7 @@
      * methods.
      */
     @Parameter
-    private List<?> context;
+    private Object[] context;
 
     @Parameter(defaultPrefix = BindingConstants.LITERAL, value = "above")
     private InsertPosition position;
@@ -129,16 +128,13 @@
     {
         clientId = renderSupport.allocateClientId(resources);
 
-        clientElement = writer.element(element,
-
-                                       "id", clientId);
+        clientElement = writer.element(element, "id", clientId);
 
         resources.renderInformalParameters(writer);
 
         // Now work on the JavaScript side of things.
 
-        Link link = resources.createEventLink(INJECT_EVENT,
-                                              context == null ? new Object[0] 
: context.toArray());
+        Link link = resources.createEventLink(INJECT_EVENT, context);
 
         link.addParameter(FORM_CLIENTID_PARAMETER, formSupport.getClientId());
         link.addParameter(FORM_COMPONENTID_PARAMETER, 
formSupport.getFormComponentId());

Modified: 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/PageLink.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/PageLink.java?rev=709213&r1=709212&r2=709213&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/PageLink.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/PageLink.java
 Thu Oct 30 10:13:24 2008
@@ -22,8 +22,6 @@
 import org.apache.tapestry5.corelib.base.AbstractLink;
 import org.apache.tapestry5.ioc.annotations.Inject;
 
-import java.util.List;
-
 /**
  * Generates a render request link to some other page in the application. If 
an activation context is supplied (as the
  * context parameter), then the context values will be encoded into the URL. 
If no context is supplied, then the target
@@ -48,17 +46,13 @@
      * If not provided, then the target page will provide its own activation 
context.
      */
     @Parameter
-    private List context;
-
-    private final Object[] emptyContext = new Object[0];
+    private Object[] context;
 
     void beginRender(MarkupWriter writer)
     {
         if (isDisabled()) return;
 
-        Object[] activationContext = context != null ? context.toArray() : 
emptyContext;
-
-        Link link = resources.createPageLink(page, 
resources.isBound("context"), activationContext);
+        Link link = resources.createPageLink(page, 
resources.isBound("context"), context);
 
         writeLink(writer, link);
     }

Modified: 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/RemoveRowLink.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/RemoveRowLink.java?rev=709213&r1=709212&r2=709213&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/RemoveRowLink.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/RemoveRowLink.java
 Thu Oct 30 10:13:24 2008
@@ -24,8 +24,8 @@
 
 /**
  * Used inside a [EMAIL PROTECTED] 
org.apache.tapestry5.corelib.components.AjaxFormLoop} to remove the current row 
from the loop.
- * This fires a server-side "removeRow" event (from the AjaxFormLoop 
component). On the client-side, the element for the
- * row is hidden, then removed altogether.
+ * This fires a server-side  event (from the AjaxFormLoop component); the 
event context is the object to be removed. On
+ * the client-side, the element for the row is hidden, then removed altogether.
  */
 @SupportsInformalParameters
 public class RemoveRowLink

Modified: 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/InternalComponentResourcesImpl.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/InternalComponentResourcesImpl.java?rev=709213&r1=709212&r2=709213&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/InternalComponentResourcesImpl.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/InternalComponentResourcesImpl.java
 Thu Oct 30 10:13:24 2008
@@ -67,6 +67,8 @@
     // Case insensitive
     private Map<String, Object> renderVariables;
 
+    private static final Object[] EMPTY = new Object[0];
+
     public InternalComponentResourcesImpl(Page page, ComponentPageElement 
element,
                                           ComponentResources 
containerResources, PageResources pageResources,
                                           String completeId, String nestedId, 
Instantiator componentInstantiator
@@ -127,27 +129,27 @@
      */
     public Link createActionLink(String eventType, boolean forForm, Object... 
context)
     {
-        return page.createComponentEventLink(element.getNestedId(), eventType, 
forForm, context);
+        return page.createComponentEventLink(element.getNestedId(), eventType, 
forForm, defaulted(context));
     }
 
     public Link createEventLink(String eventType, Object... context)
     {
-        return page.createComponentEventLink(element.getNestedId(), eventType, 
false, context);
+        return page.createComponentEventLink(element.getNestedId(), eventType, 
false, defaulted(context));
     }
 
     public Link createFormEventLink(String eventType, Object... context)
     {
-        return page.createComponentEventLink(element.getNestedId(), eventType, 
true, context);
+        return page.createComponentEventLink(element.getNestedId(), eventType, 
true, defaulted(context));
     }
 
     public Link createPageLink(String pageName, boolean override, Object... 
context)
     {
-        return page.createPageRenderLink(pageName, override, context);
+        return page.createPageRenderLink(pageName, override, 
defaulted(context));
     }
 
     public Link createPageLink(Class pageClass, boolean override, Object... 
context)
     {
-        return page.createPageRenderLink(pageClass, override, context);
+        return page.createPageRenderLink(pageClass, override, 
defaulted(context));
     }
 
     public void discardPersistentFieldChanges()
@@ -213,7 +215,12 @@
 
     public boolean triggerEvent(String eventType, Object[] context, 
ComponentEventCallback handler)
     {
-        return element.triggerEvent(eventType, context, handler);
+        return element.triggerEvent(eventType, defaulted(context), handler);
+    }
+
+    private Object[] defaulted(Object[] input)
+    {
+        return input == null ? EMPTY : input;
     }
 
     public boolean triggerContextEvent(String eventType, EventContext context, 
ComponentEventCallback callback)

Added: 
tapestry/tapestry5/trunk/tapestry-core/src/test/app1/DateFieldAjaxFormLoop.tml
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/app1/DateFieldAjaxFormLoop.tml?rev=709213&view=auto
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/test/app1/DateFieldAjaxFormLoop.tml 
(added)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/test/app1/DateFieldAjaxFormLoop.tml 
Thu Oct 30 10:13:24 2008
@@ -0,0 +1,20 @@
+<html t:type="border" 
xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd";>
+
+    <h1>DateField in AjaxFormLoop</h1>
+
+    <t:form>
+
+        <div t:type="ajaxformloop" t:id="loop" source="dateHolders" 
value="current" encoder="dateHolderConverter">
+
+            <t:datefield value="current.date"/>
+            <t:removerowlink>remove</t:removerowlink>
+
+        </div>
+
+        <p>
+            <input type="submit" value="Go"/>
+        </p>
+    </t:form>
+
+
+</html>
\ No newline at end of file

Added: 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/data/DateHolder.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/data/DateHolder.java?rev=709213&view=auto
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/data/DateHolder.java
 (added)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/data/DateHolder.java
 Thu Oct 30 10:13:24 2008
@@ -0,0 +1,47 @@
+//  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.tapestry5.integration.app1.data;
+
+import org.apache.tapestry5.beaneditor.NonVisual;
+
+import java.util.Date;
+
+public class DateHolder
+{
+    @NonVisual
+    private int id;
+
+    private Date date;
+
+    public int getId()
+    {
+        return id;
+    }
+
+    public void setId(int id)
+    {
+        this.id = id;
+    }
+
+    public Date getDate()
+    {
+        return date;
+    }
+
+    public void setDate(Date date)
+    {
+        this.date = date;
+    }
+}

Added: 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/DateFieldAjaxFormLoop.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/DateFieldAjaxFormLoop.java?rev=709213&view=auto
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/DateFieldAjaxFormLoop.java
 (added)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/DateFieldAjaxFormLoop.java
 Thu Oct 30 10:13:24 2008
@@ -0,0 +1,87 @@
+//  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.tapestry5.integration.app1.pages;
+
+import org.apache.tapestry5.PrimaryKeyEncoder;
+import org.apache.tapestry5.annotations.Persist;
+import org.apache.tapestry5.annotations.Property;
+import org.apache.tapestry5.integration.app1.data.DateHolder;
+import org.apache.tapestry5.ioc.internal.util.CollectionFactory;
+import org.apache.tapestry5.util.DefaultPrimaryKeyEncoder;
+
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Map;
+
+public class DateFieldAjaxFormLoop
+{
+    @Persist
+    private Map<Integer, DateHolder> database;
+
+    @Property
+    private DateHolder current;
+
+    void beginRender()
+    {
+        if (database == null)
+            database = CollectionFactory.newMap();
+    }
+
+
+    public List<DateHolder> getDateHolders()
+    {
+        List<DateHolder> result = CollectionFactory.newList(database.values());
+
+
+        Collections.sort(result, new Comparator<DateHolder>()
+        {
+            public int compare(DateHolder o1, DateHolder o2)
+            {
+                return o1.getId() - o2.getId();
+            }
+        });
+
+        return result;
+    }
+
+    public PrimaryKeyEncoder<Integer, DateHolder> getDateHolderConverter()
+    {
+        DefaultPrimaryKeyEncoder<Integer, DateHolder> result = new 
DefaultPrimaryKeyEncoder<Integer, DateHolder>();
+
+        for (DateHolder dh : getDateHolders())
+        {
+            result.add(dh.getId(), dh);
+        }
+
+        return result;
+    }
+
+    DateHolder onAddRowFromLoop()
+    {
+        DateHolder dh = new DateHolder();
+
+        dh.setId(database.size() + 1);
+
+        database.put(dh.getId(), dh);
+
+        return dh;
+    }
+
+    void onRemoveRowFromLoop(DateHolder holder)
+    {
+        database.remove(holder.getId());
+    }
+}

Modified: 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Start.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Start.java?rev=709213&r1=709212&r2=709213&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Start.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Start.java
 Thu Oct 30 10:13:24 2008
@@ -65,6 +65,9 @@
 
     private static final List<Item> ITEMS = CollectionFactory.newList(
 
+            new Item("DateFieldAjaxFormLoop", "DateField inside AjaxFormLoop",
+                     "Show that DateField component works correctly inside 
AjaxFormLoop"),
+
             new Item("NestedForm", "Nested Form Demo", "Error when a Form is 
nested inside another Form."),
 
             new Item("UnhandledEventDemo", "Unhandled Event Demo",


Reply via email to