Spring Roo
  1. Spring Roo
  2. ROO-453

Replace use of CustomDateEditor in favor of new @DateTimeFormat annotation

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.0.0.RC3
    • Fix Version/s: 1.0.0.RC4
    • Component/s: WEB MVC
    • Labels:
      None

      Description

      Currently date and time format handling in Roo applications is limited in several ways:

      • date formats can only be defined on a per-controller level and not on a field level
      • date formats rendered by Spring JS are not localized (no translation of Dojo widgets)

      By using the new @DateTimeFormat annotation we can overcome some of these shortcomings:

      • date format styles can be defined through the style attribute (ie @DateTimeFormat(style="M-") //medium date style and no time)
      • date format styles can be defined per field using the 'field date ... --dateFormat MEDIUM --timeFormat NONE' command
      • date format styles can influence the date presentation in the views (Dojo could display localized formats rather than fixed patterns)

        Activity

        Hide
        Stefan Schmidt added a comment -

        Revision 507 contains the initial functionalities, further adjustments pending.

        Show
        Stefan Schmidt added a comment - Revision 507 contains the initial functionalities, further adjustments pending.
        Hide
        Stefan Schmidt added a comment -

        The transition from a fixed server-side controller-level date pattern definition (formerly defined by the @RooWebScaffold(dateFormat="MM/dd/yyyy") attribute) towards a more flexible approach is completed with rev 512).

        As a result the RooWebScaffold.dateFormat attribute has been removed from the annotation as well as the controller command.

        Roo will now include the new Spring MVC @DateTimeFormat annotation by default to all fields of type java.util.Date or java.util.Calendar. Roo will recognize the 'style' attribute of that annotation and if a Web layer is scaffolded it will decorate the corresponding form field with a Spring JS/Dojo date picker. The form field decoration with a date picker will only take place if the format style chosen for date or time is either SHORT or MEDIUM. The first style character defines date forma and the second defines the time format:

        @DateTimeFormat(style="S-") //SHORT date, no time
        Calendar birthDay;
        
        @DateTimeFormat(style="MS") //MEDIUM date, SHORT time (hh:mm)
        Date productionDateTime;
        

        The actual date format rendered by the Dojo date picker depends on the locale selected by the user in the browser. For example selecting an English locale results the following date pattern: MM/dd/yyyy whereas selecting the German locale results in the following pattern: dd.MM.yyyy

        Finally, the field command now allows you to specify the date and time patterns with the dateFormat and timeFormat attributes:

        field date --fieldName productionDateTime --type java.util.Calendar --dateFormat MEDIUM --timeFormat SHORT
        

        The dateFormat and timeFormat attributes are optional. Not specifying them defaults in dateFormat SHORT and timeFormat NONE.

        Show
        Stefan Schmidt added a comment - The transition from a fixed server-side controller-level date pattern definition (formerly defined by the @RooWebScaffold(dateFormat="MM/dd/yyyy") attribute) towards a more flexible approach is completed with rev 512). As a result the RooWebScaffold.dateFormat attribute has been removed from the annotation as well as the controller command. Roo will now include the new Spring MVC @DateTimeFormat annotation by default to all fields of type java.util.Date or java.util.Calendar. Roo will recognize the 'style' attribute of that annotation and if a Web layer is scaffolded it will decorate the corresponding form field with a Spring JS/Dojo date picker. The form field decoration with a date picker will only take place if the format style chosen for date or time is either SHORT or MEDIUM. The first style character defines date forma and the second defines the time format: @DateTimeFormat(style= "S-" ) //SHORT date, no time Calendar birthDay; @DateTimeFormat(style= "MS" ) //MEDIUM date, SHORT time (hh:mm) Date productionDateTime; The actual date format rendered by the Dojo date picker depends on the locale selected by the user in the browser. For example selecting an English locale results the following date pattern: MM/dd/yyyy whereas selecting the German locale results in the following pattern: dd.MM.yyyy Finally, the field command now allows you to specify the date and time patterns with the dateFormat and timeFormat attributes: field date --fieldName productionDateTime --type java.util.Calendar --dateFormat MEDIUM --timeFormat SHORT The dateFormat and timeFormat attributes are optional. Not specifying them defaults in dateFormat SHORT and timeFormat NONE.

          People

          • Assignee:
            Stefan Schmidt
            Reporter:
            Stefan Schmidt
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: