Tapestry
  1. Tapestry
  2. TAPESTRY-1105

DropdownDatePicker.java uses wrong format to pass date value to DoJo

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 4.1.1
    • Fix Version/s: 4.1.1
    • Component/s: JavaScript, tapestry-core
    • Labels:
      None

      Description

      Line 85 of DropdownDatePicker.java:

      json.put("date", getTranslatedFieldSupport().format(this, getValue()));

      however, this generates these errors in the browser from DoJo:

      DEBUG: invalid date string: 10/02/06
      DEBUG: DEPRECATED: dojo.widget.DropdownDatePicker date attributes must be passed in Rfc3339 format – will be removed in version: 0.5

      This is because I defined a custom Translator for the field. It is picking up it's format string for the parse/validation phase, but the date value is the initial displayed value used when generating the text box, and needs to be in "yyyy-MM-dd" format.

      When changing this, don't use a static DateFormat, of course, as they aren't thread safe. Been bitten by that before - took a serious debug effort to track that one down. You can use an Object pool or ThreadLocal, however.

        Activity

        Greg Woolsey created issue -
        Jesse Kuhnert made changes -
        Field Original Value New Value
        Assignee Jesse Kuhnert [ jkuhnert ]
        Hide
        Jesse Kuhnert added a comment -

        It's worse than that.....The widget is trying to force you to give it a date in "rfc3339" format, but display it in another. I fought the good fight but the IBM people appear to be winning so far.

        I'll be duping this particular widget into tapestry and taking out all of this rfc3339 crap..

        Show
        Jesse Kuhnert added a comment - It's worse than that.....The widget is trying to force you to give it a date in "rfc3339" format, but display it in another. I fought the good fight but the IBM people appear to be winning so far. I'll be duping this particular widget into tapestry and taking out all of this rfc3339 crap..
        Hide
        Greg Woolsey added a comment -

        Actually, it doesn't look that bad. I think all it needs, since the format to display/parse in is passed seperately, all that is needed is to change line 85 to this:

        json.put("date", new SimpleDateFormat("yyyy-MM-dd").format(getValue());

        or whatever the equivalent is that handles format errors properly. This is only involved in passing the Dojo widget the initial value, not used in it's parsing or formating of returned user input. I don't think you need to go to the trouble of building a new widget for Tapestry.

        Like I said above, date format objects are a bit expensive to build, but not thread safe, so you may want to use a ThreadLocal field for the RFC date format.

        Show
        Greg Woolsey added a comment - Actually, it doesn't look that bad. I think all it needs, since the format to display/parse in is passed seperately, all that is needed is to change line 85 to this: json.put("date", new SimpleDateFormat("yyyy-MM-dd").format(getValue()); or whatever the equivalent is that handles format errors properly. This is only involved in passing the Dojo widget the initial value, not used in it's parsing or formating of returned user input. I don't think you need to go to the trouble of building a new widget for Tapestry. Like I said above, date format objects are a bit expensive to build, but not thread safe, so you may want to use a ThreadLocal field for the RFC date format.
        Hide
        Jesse Kuhnert added a comment -

        I think this was already solved in the last snapshot. Must've forgotten to update the ticket.

        Show
        Jesse Kuhnert added a comment - I think this was already solved in the last snapshot. Must've forgotten to update the ticket.
        Jesse Kuhnert made changes -
        Resolution Fixed [ 1 ]
        Fix Version/s 4.1.1 [ 12312021 ]
        Status Open [ 1 ] Resolved [ 5 ]
        Mark Thomas made changes -
        Workflow jira [ 12386007 ] Default workflow, editable Closed status [ 12567898 ]
        Mark Thomas made changes -
        Workflow Default workflow, editable Closed status [ 12567898 ] jira [ 12591025 ]
        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open Resolved Resolved
        6d 9h 25m 1 Jesse Kuhnert 09/Oct/06 05:42

          People

          • Assignee:
            Jesse Kuhnert
            Reporter:
            Greg Woolsey
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development