Class DateTextField

All Implemented Interfaces:
Serializable, Iterable<Component>, IEventSink, IEventSource, IFeedbackContributor, IConverterLocator, IGenericComponent<Date,FormComponent<Date>>, IMetadataContext<Serializable,Component>, AbstractTextComponent.ITextFormatProvider, IFormModelUpdateListener, IFormVisitorParticipant, ILabelProvider<String>, IHeaderContributor, IRequestableComponent, IHierarchical<Component>, IClusterable

public class DateTextField extends TextField<Date> implements AbstractTextComponent.ITextFormatProvider
A TextField that is mapped to a java.util.Date object and that uses Joda time to parse and format values.

You should use on of the factory methods to construct the kind you want or use the public constructor and pass in the converter to use.

This component tries to apply the time zone difference between the client and server. See the date converter of this package for more information on that.

Author:
eelcohillenius
See Also:
  • Constructor Details

    • DateTextField

      public DateTextField(String id, IModel<Date> model, DateConverter converter)
      Construct with a converter.
      Parameters:
      id - The component id
      model - The model
      converter - The converter to use
    • DateTextField

      public DateTextField(String id, DateConverter converter)
      Construct with a converter, and a null model.
      Parameters:
      id - The component id
      converter - The converter to use
  • Method Details

    • forDatePattern

      public static DateTextField forDatePattern(String id, IModel<Date> model, String datePattern)
      Creates a new DateTextField defaulting to using a short date pattern
      Parameters:
      id - The id of the text field
      model - The model
      datePattern - The pattern to use. Must be not null. See SimpleDateFormat for available patterns.
      Returns:
      DateTextField
    • forDatePattern

      public static DateTextField forDatePattern(String id, String datePattern)
      Creates a new DateTextField defaulting to using a short date pattern
      Parameters:
      id - The id of the text field
      datePattern - The pattern to use. Must be not null. See SimpleDateFormat for available patterns.
      Returns:
      DateTextField
    • forDateStyle

      public static DateTextField forDateStyle(String id, IModel<Date> model, String dateStyle)
      Creates a new DateTextField using the provided date style.
      Parameters:
      id - The id of the text field
      model - The model
      dateStyle - Date style to use. The first character is the date style, and the second character is the time style. Specify a character of 'S' for short style, 'M' for medium, 'L' for long, and 'F' for full. A date or time may be ommitted by specifying a style character '-'. See DateTimeFormat.forStyle(String).
      Returns:
      DateTextField
    • forDateStyle

      public static DateTextField forDateStyle(String id, String dateStyle)
      Creates a new DateTextField using the provided date style.
      Parameters:
      id - The id of the text field
      dateStyle - Date style to use. The first character is the date style, and the second character is the time style. Specify a character of 'S' for short style, 'M' for medium, 'L' for long, and 'F' for full. A date or time may be ommitted by specifying a style character '-'. See DateTimeFormat.forStyle(String).
      Returns:
      DateTextField
    • forShortStyle

      public static DateTextField forShortStyle(String id)
      Creates a new DateTextField defaulting to using a short date pattern
      Parameters:
      id - The id of the text field
      Returns:
      DateTextField
    • forShortStyle

      public static DateTextField forShortStyle(String id, IModel<Date> model, boolean applyTimeZoneDifference)
      Creates a new DateTextField defaulting to using a short date pattern
      Parameters:
      id - The id of the text field
      model - The model
      applyTimeZoneDifference - Whether to apply the time zone difference between client and server
      Returns:
      DateTextField
    • withConverter

      public static DateTextField withConverter(String id, DateConverter converter)
      Creates a new DateTextField using the provided converter.
      Parameters:
      id - The id of the text field
      converter - the date converter
      Returns:
      DateTextField
    • withConverter

      public static DateTextField withConverter(String id, IModel<Date> model, DateConverter converter)
      Creates a new DateTextField using the provided converter.
      Parameters:
      id - The id of the text field
      model - The model
      converter - the date converter
      Returns:
      DateTextField
    • createConverter

      protected IConverter<?> createConverter(Class<?> clazz)
      Overrides:
      createConverter in class Component
      Returns:
      The specialized converter.
      See Also:
    • getTextFormat

      public final String getTextFormat()
      Specified by:
      getTextFormat in interface AbstractTextComponent.ITextFormatProvider
      See Also: