You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by hl...@apache.org on 2008/08/23 23:13:30 UTC

svn commit: r688414 - in /tapestry/tapestry5/trunk: tapestry-core/src/main/java/org/apache/tapestry5/corelib/base/ tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/ tapestry-core/src/main/java/org/apache/tapestry5/services/ tapestry-...

Author: hlship
Date: Sat Aug 23 14:13:29 2008
New Revision: 688414

URL: http://svn.apache.org/viewvc?rev=688414&view=rev
Log:
TAPESTRY-1856: Add localization support to DateField

Modified:
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/base/AbstractTextField.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Checkbox.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/DateField.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/DateField.xdoc
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Palette.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Select.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/corelib/components/datefield.js
    tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry.js
    tapestry/tapestry5/trunk/tapestry-core/src/test/app1/DateFieldDemo.tml
    tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java
    tapestry/tapestry5/trunk/tapestry-core/src/test/resources/log4j.properties
    tapestry/tapestry5/trunk/tapestry-upload/src/main/java/org/apache/tapestry5/upload/components/Upload.java

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/base/AbstractTextField.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/base/AbstractTextField.java?rev=688414&r1=688413&r2=688414&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/base/AbstractTextField.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/base/AbstractTextField.java Sat Aug 23 14:13:29 2008
@@ -148,6 +148,9 @@
     /**
      * The default value is a property of the container whose name matches the component's id. May return null if the
      * container does not have a matching property.
+     *
+     * @deprecated Likely to be removed in the future, use {@link org.apache.tapestry5.annotations.Parameter#autoconnect()}
+     *             instead
      */
     final Binding defaultValue()
     {

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Checkbox.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Checkbox.java?rev=688414&r1=688413&r2=688414&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Checkbox.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Checkbox.java Sat Aug 23 14:13:29 2008
@@ -14,7 +14,6 @@
 
 package org.apache.tapestry5.corelib.components;
 
-import org.apache.tapestry5.Binding;
 import org.apache.tapestry5.ComponentResources;
 import org.apache.tapestry5.MarkupWriter;
 import org.apache.tapestry5.ValidationTracker;
@@ -33,7 +32,7 @@
      * The value to be read or updated. If not bound, the Checkbox will attempt to edit a property of its container
      * whose name matches the component's id.
      */
-    @Parameter(required = true)
+    @Parameter(required = true, autoconnect = true)
     private boolean value;
 
     @Inject
@@ -49,11 +48,6 @@
     @Environmental
     private ValidationTracker tracker;
 
-    Binding defaultValue()
-    {
-        return createDefaultParameterBinding("value");
-    }
-
     @BeginRender
     void begin(MarkupWriter writer)
     {
@@ -91,5 +85,4 @@
 
         value = postedValue != null;
     }
-
 }

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/DateField.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/DateField.java?rev=688414&r1=688413&r2=688414&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/DateField.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/DateField.java Sat Aug 23 14:13:29 2008
@@ -34,20 +34,34 @@
 
 /**
  * A component used to collect a provided date from the user using a client-side JavaScript calendar. Non-JavaScript
- * clients can simply type into a text field..
+ * clients can simply type into a text field.
+ * <p/>
+ * One wierd aspect here is that, because client-side JavaScript formatting and parsing is so limited, we (currently)
+ * use Ajax to send the user's input to the server for parsing (before raising the popup) and formatting (after closing
+ * the popup).  Wierd and inefficient, but easier than writing client-side JavaScript for that purpose.
  */
 // TODO: More testing; see https://issues.apache.org/jira/browse/TAPESTRY-1844
 @IncludeStylesheet("${tapestry.datepicker}/css/datepicker.css")
-@IncludeJavaScriptLibrary({"${tapestry.datepicker}/js/datepicker.js", "datefield.js"})
+@IncludeJavaScriptLibrary({"${tapestry.datepicker}/js/datepicker.js",
+        "datefield.js"
+        })
 public class DateField extends AbstractField
 {
     /**
      * The value parameter of a DateField must be a {@link Date}.
      */
-    @Parameter(required = true, principal = true)
+    @Parameter(required = true, principal = true, autoconnect = true)
     private Date value;
 
     /**
+     * The format used to format <em>and parse</em> dates. This is typically specified as a string which is coerced to a
+     * DateFormat. You should be aware that using a date format with a two digit year is problematic: Java (not
+     * Tapestry) may get confused about the century.
+     */
+    @Parameter(required = true, allowNull = false, defaultPrefix = BindingConstants.LITERAL)
+    private DateFormat format;
+
+    /**
      * The object that will perform input validation (which occurs after translation). The translate binding prefix is
      * generally used to provide this object in a declarative fashion.
      */
@@ -82,21 +96,29 @@
     /**
      * For output, format nicely and unambiguously as four digits.
      */
-    private final DateFormat outputFormat = new SimpleDateFormat("MM/dd/yyyy");
+    private final DateFormat popupFormat = new SimpleDateFormat("MM/dd/yyyy");
 
-    /**
-     * When the user types a value, they may only type two digits for the year; SimpleDateFormat will do something
-     * reasonable.  If they use the popup, it will be unambiguously 4 digits.
-     */
-    private final DateFormat inputFormat = new SimpleDateFormat("MM/dd/yy");
+    private static final String RESULT = "result";
 
-    /**
-     * The default value is a property of the container whose name matches the component's id. May return null if the
-     * container does not have a matching property.
-     */
-    final Binding defaultValue()
+    private static final String ERROR = "error";
+    private static final String INPUT_PARAMETER = "input";
+
+    DateFormat defaultFormat()
     {
-        return createDefaultParameterBinding("value");
+        DateFormat shortDateFormat = DateFormat.getDateInstance(DateFormat.SHORT, locale);
+
+        if (shortDateFormat instanceof SimpleDateFormat)
+        {
+            SimpleDateFormat simpleDateFormat = (SimpleDateFormat) shortDateFormat;
+
+            String pattern = simpleDateFormat.toPattern();
+
+            String revised = pattern.replaceAll("([^y])yy$", "$1yyyy");
+
+            return new SimpleDateFormat(revised);
+        }
+
+        return shortDateFormat;
     }
 
     /**
@@ -104,13 +126,61 @@
      */
     final FieldValidator defaultValidate()
     {
-
         return fieldValidatorDefaultSource.createDefaultValidator(this, resources.getId(),
                                                                   resources.getContainerMessages(), locale,
                                                                   Date.class,
                                                                   resources.getAnnotationProvider("value"));
     }
 
+    /**
+     * Ajax event handler, used when initiating the popup. The client sends the input value form the field to the server
+     * to parse it according to the server-side format. The response contains a "result" key of the formatted date in a
+     * format acceptable to the JavaScript Date() constructor.  Alternately, an "error" key indicates the the input was
+     * not formatted correct.
+     */
+    JSONObject onParse()
+    {
+        String input = request.getParameter(INPUT_PARAMETER);
+        JSONObject response = new JSONObject();
+
+        try
+        {
+            Date date = format.parse(input);
+
+            response.put(RESULT, date.toString());
+        }
+        catch (ParseException ex)
+        {
+            response.put(ERROR, ex.getMessage());
+        }
+
+        return response;
+    }
+
+    /**
+     * Ajax event handler, used after the popup completes.  The client sends the date, formatted as "MM/dd/yyyy" to the
+     * server, which reformats it according to the server side format and returns the result.
+     */
+    JSONObject onFormat()
+    {
+        String input = request.getParameter(INPUT_PARAMETER);
+
+        JSONObject response = new JSONObject();
+
+        try
+        {
+            Date date = popupFormat.parse(input);
+
+            response.put(RESULT, format.format(date));
+        }
+        catch (ParseException ex)
+        {
+            response.put(ERROR, ex.getMessage());
+        }
+
+        return response;
+    }
+
     void beginRender(MarkupWriter writer)
     {
         String value = tracker.getInput(this);
@@ -120,7 +190,7 @@
         String clientId = getClientId();
         String triggerId = clientId + ":trigger";
 
-        writer.element("input",
+        writer.element(INPUT_PARAMETER,
 
                        "type", "text",
 
@@ -156,6 +226,8 @@
         JSONObject setup = new JSONObject();
 
         setup.put("field", clientId);
+        setup.put("parseURL", resources.createEventLink("parse").toAbsoluteURI());
+        setup.put("formatURL", resources.createEventLink("format").toAbsoluteURI());
 
         support.addInit("dateField", setup);
     }
@@ -170,7 +242,7 @@
     {
         if (value == null) return "";
 
-        return outputFormat.format(value);
+        return format.format(value);
     }
 
     @Override
@@ -185,9 +257,7 @@
         try
         {
             if (InternalUtils.isNonBlank(value))
-                parsedValue =
-                        inputFormat.parse(value);
-
+                parsedValue = format.parse(value);
         }
         catch (ParseException ex)
         {

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/DateField.xdoc
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/DateField.xdoc?rev=688414&r1=688413&r2=688414&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/DateField.xdoc (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/DateField.xdoc Sat Aug 23 14:13:29 2008
@@ -19,6 +19,12 @@
             </p>
 
             <p>
+                <em>Note: these screenshots are out of date, and reflect an earlier version of Tapestry and a different
+                    third-party JavaScript calendar than is currently available.
+                </em>
+            </p>
+
+            <p>
                 <img src="datefield_ref1.png"/>
             </p>
 

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Palette.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Palette.java?rev=688414&r1=688413&r2=688414&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Palette.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Palette.java Sat Aug 23 14:13:29 2008
@@ -233,7 +233,7 @@
      * is submitted. If the value for the parameter is null, a new list will be created, otherwise the existing list
      * will be cleared. If unbound, defaults to a property of the container matching this component's id.
      */
-    @Parameter(required = true)
+    @Parameter(required = true, autoconnect = true)
     private List<Object> selected;
 
     /**
@@ -262,14 +262,6 @@
      */
     private List<String> naturalOrder;
 
-    /**
-     * Defaults the selected parameter to a container property whose name matches this component's id.
-     */
-    final Binding defaultSelected()
-    {
-        return createDefaultParameterBinding("selected");
-    }
-
     public Renderable getAvailableRenderer()
     {
         return new AvailableRenderer();
@@ -393,7 +385,6 @@
 
                 availableOptions.add(new RenderOption(optionModel));
             }
-
         };
 
         model.visit(visitor);

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Select.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Select.java?rev=688414&r1=688413&r2=688414&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Select.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Select.java Sat Aug 23 14:13:29 2008
@@ -119,7 +119,7 @@
     /**
      * The value to read or update.
      */
-    @Parameter(required = true, principal = true)
+    @Parameter(required = true, principal = true, autoconnect = true)
     private Object value;
 
     @Inject
@@ -136,7 +136,7 @@
         return TapestryInternalUtils.isEqual(clientValue, selectedClientValue);
     }
 
-    @SuppressWarnings({ "unchecked" })
+    @SuppressWarnings({"unchecked"})
     @Override
     protected void processSubmission(String elementName)
     {
@@ -209,11 +209,6 @@
                                                                   resources.getAnnotationProvider("value"));
     }
 
-    Binding defaultValue()
-    {
-        return createDefaultParameterBinding("value");
-    }
-
     Object defaultBlankLabel()
     {
         Messages containerMessages = resources.getContainerMessages();
@@ -301,6 +296,4 @@
         blankOption = option;
         blankLabel = label;
     }
-
-
 }

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java?rev=688414&r1=688413&r2=688414&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java Sat Aug 23 14:13:29 2008
@@ -56,6 +56,8 @@
 import java.io.IOException;
 import java.lang.annotation.Annotation;
 import java.net.URL;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
@@ -256,11 +258,11 @@
         // For scriptaculous, etc., this version is not the version of the library, but the version
         // bundled with Tapestry.
 
-        configuration.add("tapestry/" + version, "org/apache/tapestry5");
+        configuration.add(version + "/tapestry", "org/apache/tapestry5");
 
-        configuration.add("scriptaculous/" + version, scriptaculousPath);
+        configuration.add(version + "/scriptaculous", scriptaculousPath);
 
-        configuration.add("datepicker/" + version, datepickerPath);
+        configuration.add(version + "/datepicker", datepickerPath);
     }
 
     public static void contributeComponentClassResolver(Configuration<LibraryMapping> configuration)
@@ -431,7 +433,6 @@
         // Password and long text have special output needs.
         addDisplayBlock(configuration, "password");
         addDisplayBlock(configuration, "longtext");
-
     }
 
     private static void addEditBlock(Configuration<BeanBlockContribution> configuration, String dataType)
@@ -648,7 +649,8 @@
      * component) to {@link org.apache.tapestry5.ComponentResources} <li>String to {@link
      * org.apache.tapestry5.corelib.data.BlankOption} <li> {@link org.apache.tapestry5.ComponentResources} to {@link
      * org.apache.tapestry5.PropertyOverrides} <li>String to {@link org.apache.tapestry5.Renderable} <li>{@link
-     * org.apache.tapestry5.Renderable} to {@link org.apache.tapestry5.Block}</ul>
+     * org.apache.tapestry5.Renderable} to {@link org.apache.tapestry5.Block} <li>String to {@link
+     * java.text.DateFormat}</ul>
      */
     public static void contributeTypeCoercer(Configuration<CoercionTuple> configuration)
     {
@@ -745,6 +747,14 @@
                 return new RenderableAsBlock(input);
             }
         });
+
+        add(configuration, String.class, DateFormat.class, new Coercion<String, DateFormat>()
+        {
+            public DateFormat coerce(String input)
+            {
+                return new SimpleDateFormat(input);
+            }
+        });
     }
 
     /**
@@ -1039,7 +1049,6 @@
             Map<Class, ComponentEventResultProcessor> configuration)
     {
         return constructComponentEventResultProcessor(configuration);
-
     }
 
     private ComponentEventResultProcessor constructComponentEventResultProcessor(

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/corelib/components/datefield.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/corelib/components/datefield.js?rev=688414&r1=688413&r2=688414&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/corelib/components/datefield.js (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/corelib/components/datefield.js Sat Aug 23 14:13:29 2008
@@ -22,6 +22,8 @@
     {
         this.field = $(spec.field);
         this.trigger = $(spec.field + ":trigger");
+        this.parseURL = spec.parseURL;
+        this.formatURL = spec.formatURL;
 
         this.trigger.observe("click", this.triggerClicked.bind(this));
 
@@ -52,46 +54,58 @@
         if (value == "")
         {
             this.datePicker.setDate(null);
-        }
-        else
-        {
 
-            // TODO: This is limited and americanized (not localized) to MM/DD/YYYY
-            var re = /^\s*(\d+)\/(\d+)\/(\d{2,4})\s*$/;
-            var matches = re.exec(value);
+            this.positionPopup();
 
+            this.revealPopup();
 
-            // If the RE is bad, raise the date picker anyway, showing
-            // the last valid date, or showing no date.
+            return;
+        }
 
-            if (matches != null)
-            {
+        var resultHandler = function(result)
+        {
+            var date = new Date(result);
 
-                var month = Number(matches[1]);
-                var day = Number(matches[2])
-                var year = Number(matches[3]);
+            this.datePicker.setDate(date);
 
-            // For two digits, guestamate which century they want.
+            this.positionPopup();
 
-                if (year < 100)
-                {
-                    if (year >= 60) year += 1900
-                    else year += 2000;
-                }
+            this.revealPopup();
+        };
 
-                var date = new Date(value);
+        var errorHandler = function(message)
+        {
+            Tapestry.fieldError(this.field, message);
+            Tapestry.focus(this.field);
+        };
 
-                date.setMonth(month - 1);
-                date.setDate(day);
-                date.setFullYear(year);
+        this.sendServerRequest(this.parseURL, value, resultHandler, errorHandler);
+    },
+
+    sendServerRequest : function (url, input, resultHandler, errorHandler)
+    {
+        var successHandler = function(response)
+        {
+            var json = response.responseJSON;
+
+            var result = json.result;
 
-                this.datePicker.setDate(date);
+            if (result)
+            {
+                resultHandler.call(this, result);
+                return;
             }
-        }
 
-        this.positionPopup();
+            errorHandler.call(this, json.error);
+        }.bind(this);
 
-        this.revealPopup();
+        new Ajax.Request(url,
+        {
+            method: 'get',
+            parameters: { input: input },
+            onSuccess: successHandler,
+            onFailure: Tapestry.ajaxFailureHandler
+        });
     },
 
     createPopup : function()
@@ -106,12 +120,25 @@
 
         this.datePicker.onselect = function()
         {
-            this.field.value = this.formatDate(this.datePicker.getDate());
+            var input = this.formatDate(this.datePicker.getDate());
+
+            var resultHandler = function(result)
+            {
+                this.field.value = result;
 
-            this.hidePopup();
+                this.hidePopup();
+
+                new Effect.Highlight(this.field);
+            };
 
-            new Effect.Highlight(this.field);
+            var errorHandler = function(message)
+            {
+                Tapestry.fieldError(this.field, message);
+                Tapestry.focus(this.field);
+                this.hidePopup();
+            }
 
+            this.sendServerRequest(this.formatURL, input, resultHandler, errorHandler);
         }.bind(this);
     },
 
@@ -119,7 +146,7 @@
     {
         if (date == null) return "";
 
-        // TODO: This needs to localize; currently its Americanized (MM/DD/YYYY).
+        // Americanized format is simply transfer format.  Localization occurs on the server.
         return (date.getMonth() + 1) + "/" + date.getDate() + "/" + date.getFullYear();
     },
 
@@ -134,7 +161,6 @@
 
     hidePopup : function()
     {
-
         new Effect.Fade(this.popup, { duration: this.FADE_DURATION });
     },
 

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry.js?rev=688414&r1=688413&r2=688414&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry.js (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry.js Sat Aug 23 14:13:29 2008
@@ -193,6 +193,11 @@
         return manager;
     },
 
+    fieldError : function(field, message)
+    {
+        this.getFieldEventManager(field).addDecorations(message);
+    },
+
     /**
      * Passed the JSON content of a Tapestry partial markup response, extracts
      * the script and stylesheet information.  JavaScript libraries and stylesheets are loaded,
@@ -288,7 +293,6 @@
         return new Ajax.Request(url, { onSuccess: successHandler, onFailure: Tapestry.ajaxFailureHandler })
     },
 
-
     /**
      * Used to reconstruct a complete URL from a path that is (or may be) relative to window.location.
      * This is used when determining if a JavaScript library or CSS stylesheet has already been loaded.

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/app1/DateFieldDemo.tml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/app1/DateFieldDemo.tml?rev=688414&r1=688413&r2=688414&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/app1/DateFieldDemo.tml (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/app1/DateFieldDemo.tml Sat Aug 23 14:13:29 2008
@@ -10,7 +10,7 @@
 
             <div class="t-beaneditor-row">
                 <t:label for="birthday"/>
-                <t:datefield t:id="birthday"/>
+                <t:datefield format="d MMM yyyy" t:id="birthday"/>
             </div>
 
             <div class="t-beaneditor-row">

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java?rev=688414&r1=688413&r2=688414&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java Sat Aug 23 14:13:29 2008
@@ -573,7 +573,6 @@
 
         assertTextPresent("Howard", "Lewis Ship", "1966", "Martian", "U. S. Citizen", "***********", "line1", "line2",
                           "line3");
-
     }
 
     @Test
@@ -658,7 +657,7 @@
 
         // The lack of a leading slash indicates that the path was optimized, see TAPESTRY-1502
 
-        assertAttribute("//img[@id='title:sort']/@src", "assets/tapestry/UNKNOWN/corelib/components/sort-asc.png");
+        assertAttribute("//img[@id='title:sort']/@src", "assets/UNKNOWN/tapestry/corelib/components/sort-asc.png");
         assertAttribute("//img[@id='title:sort']/@alt", "[Asc]");
 
         clickAndWait("link=1");
@@ -667,7 +666,7 @@
 
         clickAndWait("link=Title");
 
-        assertAttribute("//img[@id='title:sort']/@src", "assets/tapestry/UNKNOWN/corelib/components/sort-desc.png");
+        assertAttribute("//img[@id='title:sort']/@src", "assets/UNKNOWN/tapestry/corelib/components/sort-desc.png");
         assertAttribute("//img[@id='title:sort']/@alt", "[Desc]");
 
         clickAndWait("link=reset the Grid");
@@ -828,8 +827,8 @@
 
         // The lack of a leading slash indicates that the path was optimized, see TAPESTRY-1502
 
-        assertAttributeSeries("//script[%d]/@src", 1, "assets/scriptaculous/UNKNOWN/prototype.js",
-                              "assets/scriptaculous/UNKNOWN/scriptaculous.js");
+        assertAttributeSeries("//script[%d]/@src", 1, "assets/UNKNOWN/scriptaculous/prototype.js",
+                              "assets/UNKNOWN/scriptaculous/scriptaculous.js");
 
         clickAndWait("link=Clear Data");
 
@@ -1046,7 +1045,6 @@
         clickAndWait("link=bad");
         assertTextPresent("An unexpected application exception has occurred.",
                           "An event handler for component org.apache.tapestry5.integration.app1.pages.Start returned the value 20 (from method org.apache.tapestry5.integration.app1.pages.Start.onActionFromBadReturnType() (at Start.java:34)). Return type java.lang.Integer can not be handled.");
-
     }
 
     @Test
@@ -1177,7 +1175,9 @@
     {
         start("DateField Demo");
 
-        type("birthday", "12/24/66");
+        // TODO: Check to see if we need to explicitly set the locale for this test to work properly.
+
+        type("birthday", "24 dec 1966");
         type("asteroidImpact", "05/28/2046");
 
         clickAndWait(SUBMIT);
@@ -1185,8 +1185,8 @@
         assertTextPresent("Birthday: [12/24/1966]");
         assertTextPresent("Impact: [05/28/2046]");
 
-        assertFieldValue("birthday", "12/24/1966");
-        assertFieldValue("asteroidImpact", "05/28/2046");
+        assertFieldValue("birthday", "24 Dec 1966");
+        assertFieldValue("asteroidImpact", "5/28/2046");
     }
 
     /**
@@ -1573,7 +1573,6 @@
         assertTextPresent("An unexpected application exception has occurred.",
                           "org.apache.tapestry5.ioc.internal.util.TapestryException",
                           "java.lang.NumberFormatException");
-
     }
 
     /**
@@ -1976,7 +1975,6 @@
         assertText("//span[@class='watch'][1]", "0");
         assertText("//span[@class='watch'][2]", "0");
         assertText("//span[@class='watch'][3]", "1");
-
     }
 
     /**
@@ -2037,7 +2035,6 @@
 
         assertFalse(time2_1.equals(time1_1),
                     "After update the nanoseconds time did not change, meaning @Cache was broken.");
-
     }
 
     @Test

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/resources/log4j.properties?rev=688414&r1=688413&r2=688414&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/resources/log4j.properties (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/resources/log4j.properties Sat Aug 23 14:13:29 2008
@@ -21,7 +21,7 @@
 log4j.appender.A1.layout=org.apache.log4j.PatternLayout
 log4j.appender.A1.layout.ConversionPattern= %d{HH:mm:ss,SSS} [%p] %c{1} %m%n
 
-log4j.category.org.apache.tapestry5.integration.app1=debug
+log4j.category.org.apache.tapestry5.integration.app2=debug
 
 # log4j.category.org.apache.tapestry5.corelib.components=debug
 

Modified: tapestry/tapestry5/trunk/tapestry-upload/src/main/java/org/apache/tapestry5/upload/components/Upload.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-upload/src/main/java/org/apache/tapestry5/upload/components/Upload.java?rev=688414&r1=688413&r2=688414&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-upload/src/main/java/org/apache/tapestry5/upload/components/Upload.java (original)
+++ tapestry/tapestry5/trunk/tapestry-upload/src/main/java/org/apache/tapestry5/upload/components/Upload.java Sat Aug 23 14:13:29 2008
@@ -31,7 +31,7 @@
 /**
  * A component to upload a file.
  */
-@SuppressWarnings({ "UnusedDeclaration" })
+@SuppressWarnings({"UnusedDeclaration"})
 public class Upload extends AbstractField
 {
     public static final String MULTIPART_ENCTYPE = "multipart/form-data";
@@ -40,7 +40,7 @@
      * The uploaded file. Note: This is only guaranteed to be valid while processing the form submission. Subsequently
      * the content may have been cleaned up.
      */
-    @Parameter(required = true, principal = true)
+    @Parameter(required = true, principal = true, autoconnect = true)
     private UploadedFile value;
 
     /**
@@ -106,7 +106,7 @@
         this.fieldValidationSupport = fieldValidationSupport;
     }
 
-    @SuppressWarnings({ "unchecked" })
+    @SuppressWarnings({"unchecked"})
     @Override
     protected void processSubmission(String elementName)
     {
@@ -157,11 +157,6 @@
         return value;
     }
 
-    Binding defaultValue()
-    {
-        return createDefaultParameterBinding("value");
-    }
-
     void injectDecorator(ValidationDecorator decorator)
     {
         setDecorator(decorator);