com.vaadin.ui
Class DateField

java.lang.Object
  extended by com.vaadin.ui.AbstractComponent
      extended by com.vaadin.ui.AbstractField
          extended by com.vaadin.ui.DateField
All Implemented Interfaces:
Buffered, BufferedValidatable, Property, Property.Editor, Property.ReadOnlyStatusChangeNotifier, Property.ValueChangeListener, Property.ValueChangeNotifier, Property.Viewer, Validatable, Action.ShortcutNotifier, FieldEvents.BlurNotifier, FieldEvents.FocusNotifier, MethodEventSource, Paintable, Sizeable, VariableOwner, Component, Component.Focusable, Field, Serializable, EventListener
Direct Known Subclasses:
InlineDateField, PopupDateField

public class DateField
extends AbstractField
implements FieldEvents.BlurNotifier, FieldEvents.FocusNotifier

A date editor component that can be bound to any bindable Property. that is compatible with java.util.Date.

Since DateField extends AbstractField it implements the Bufferedinterface. A DateField is in write-through mode by default, so AbstractField.setWriteThrough(boolean)must be called to enable buffering.

Since:
3.0
Version:
6.3.3
Author:
IT Mill Ltd.
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class com.vaadin.ui.AbstractField
AbstractField.FocusShortcut, AbstractField.ReadOnlyStatusChangeEvent
 
Nested classes/interfaces inherited from class com.vaadin.ui.AbstractComponent
AbstractComponent.ComponentErrorEvent, AbstractComponent.ComponentErrorHandler
 
Nested classes/interfaces inherited from interface com.vaadin.ui.Field
Field.ValueChangeEvent
 
Nested classes/interfaces inherited from interface com.vaadin.data.Buffered
Buffered.SourceException
 
Nested classes/interfaces inherited from interface com.vaadin.data.Property
Property.ConversionException, Property.Editor, Property.ReadOnlyException, Property.ReadOnlyStatusChangeListener, Property.ReadOnlyStatusChangeNotifier, Property.ValueChangeListener, Property.ValueChangeNotifier, Property.Viewer
 
Field Summary
static int RESOLUTION_DAY
          Resolution identifier: days.
static int RESOLUTION_HOUR
          Resolution identifier: hours.
static int RESOLUTION_MIN
          Resolution identifier: minutes.
static int RESOLUTION_MONTH
          Resolution identifier: months.
static int RESOLUTION_MSEC
          Resolution identifier: milliseconds.
static int RESOLUTION_SEC
          Resolution identifier: seconds.
static int RESOLUTION_YEAR
          Resolution identifier: years.
protected  String type
          Specified widget type.
protected static String TYPE_INLINE
          Inline date selector (calendar).
protected static String TYPE_POPUP
          Popup date selector (calendar).
 
Constructor Summary
DateField()
          Constructs an empty DateField with no caption.
DateField(Property dataSource)
          Constructs a new DateField that's bound to the specified Property and has no caption.
DateField(String caption)
          Constructs an empty DateField with caption.
DateField(String caption, Date value)
          Constructs a new DateField with the given caption and initial text contents.
DateField(String caption, Property dataSource)
          Constructs a new DateField that's bound to the specified Property and has the given caption String.
 
Method Summary
 void addListener(FieldEvents.BlurListener listener)
          Adds a BlurListener to the Component which gets fired when a Field loses keyboard focus.
 void addListener(FieldEvents.FocusListener listener)
          Adds a FocusListener to the Component which gets fired when a Field receives keyboard focus.
 void changeVariables(Object source, Map variables)
          Called when one or more variables handled by the implementing class are changed.
 String getDateFormat()
          Reterns a format string used to format date value on client side or null if default formatting from Component.getLocale() is used.
 int getResolution()
          Gets the resolution.
 Class getType()
          Returns the type of the Property.
protected  Date handleUnparsableDateString(String dateString)
          This method is called to handle a non-empty date string from the client if the client could not parse it as a Date.
 boolean isLenient()
          Returns whether date/time interpretation is to be lenient.
 boolean isShowISOWeekNumbers()
          Checks whether ISO 8601 week numbers are shown in the date selector.
 void paintContent(PaintTarget target)
          Paints any needed component-specific things to the given UIDL stream.
 void removeListener(FieldEvents.BlurListener listener)
          Removes a BlurListener from the Component.
 void removeListener(FieldEvents.FocusListener listener)
          Removes a FocusListener from the Component.
 void setDateFormat(String dateFormat)
          Sets formatting used by some component implementations.
 void setLenient(boolean lenient)
          Specifies whether or not date/time interpretation in component is to be lenient.
 void setPropertyDataSource(Property newDataSource)
          Sets the DateField datasource.
 void setResolution(int resolution)
          Sets the resolution of the DateField.
 void setShowISOWeekNumbers(boolean showWeekNumbers)
          Sets the visibility of ISO 8601 week numbers in the date selector.
 void setValue(Object newValue)
          Sets the value of the field.
 void setValue(Object newValue, boolean repaintIsNotNeeded)
          Sets the value of the field.
 String toString()
          Returns the value of the Property in human readable textual format.
 
Methods inherited from class com.vaadin.ui.AbstractField
addListener, addListener, addShortcutListener, addValidator, attach, commit, constructField, detach, discard, fireReadOnlyStatusChange, fireValueChange, focus, getActionManager, getErrorMessage, getPropertyDataSource, getRequiredError, getTabIndex, getValidators, getValue, isEmpty, isInvalidAllowed, isInvalidCommitted, isModified, isReadOnly, isReadThrough, isRequired, isValid, isValidationVisible, isWriteThrough, removeListener, removeListener, removeShortcutListener, removeValidator, setCurrentBufferedSourceException, setInternalValue, setInvalidAllowed, setInvalidCommitted, setReadOnly, setReadThrough, setRequired, setRequiredError, setTabIndex, setValidationVisible, setWriteThrough, validate, valueChange
 
Methods inherited from class com.vaadin.ui.AbstractComponent
addListener, addListener, addListener, addListener, addListener, addStyleName, childRequestedRepaint, fireComponentErrorEvent, fireComponentEvent, fireEvent, getApplication, getCaption, getComponentError, getData, getDebugId, getDescription, getErrorHandler, getHeight, getHeightUnits, getIcon, getLocale, getParent, getStyle, getStyleName, getTag, getWidth, getWidthUnits, getWindow, handleError, isEnabled, isImmediate, isVisible, paint, removeListener, removeListener, removeListener, removeListener, removeListener, removeListener, removeStyleName, requestRepaint, requestRepaintRequests, setCaption, setComponentError, setData, setDebugId, setDescription, setEnabled, setErrorHandler, setHeight, setHeight, setHeight, setHeightUnits, setIcon, setImmediate, setLocale, setParent, setSizeFull, setSizeUndefined, setStyle, setStyleName, setVisible, setWidth, setWidth, setWidth, setWidthUnits
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.vaadin.ui.Field
getDescription, setCaption, setDescription
 

Field Detail

RESOLUTION_MSEC

public static final int RESOLUTION_MSEC
Resolution identifier: milliseconds.

See Also:
Constant Field Values

RESOLUTION_SEC

public static final int RESOLUTION_SEC
Resolution identifier: seconds.

See Also:
Constant Field Values

RESOLUTION_MIN

public static final int RESOLUTION_MIN
Resolution identifier: minutes.

See Also:
Constant Field Values

RESOLUTION_HOUR

public static final int RESOLUTION_HOUR
Resolution identifier: hours.

See Also:
Constant Field Values

RESOLUTION_DAY

public static final int RESOLUTION_DAY
Resolution identifier: days.

See Also:
Constant Field Values

RESOLUTION_MONTH

public static final int RESOLUTION_MONTH
Resolution identifier: months.

See Also:
Constant Field Values

RESOLUTION_YEAR

public static final int RESOLUTION_YEAR
Resolution identifier: years.

See Also:
Constant Field Values

TYPE_POPUP

protected static final String TYPE_POPUP
Popup date selector (calendar).

See Also:
Constant Field Values

TYPE_INLINE

protected static final String TYPE_INLINE
Inline date selector (calendar).

See Also:
Constant Field Values

type

protected String type
Specified widget type.

Constructor Detail

DateField

public DateField()
Constructs an empty DateField with no caption.


DateField

public DateField(String caption)
Constructs an empty DateField with caption.

Parameters:
caption - the caption of the datefield.

DateField

public DateField(String caption,
                 Property dataSource)
Constructs a new DateField that's bound to the specified Property and has the given caption String.

Parameters:
caption - the caption String for the editor.
dataSource - the Property to be edited with this editor.

DateField

public DateField(Property dataSource)
          throws IllegalArgumentException
Constructs a new DateField that's bound to the specified Property and has no caption.

Parameters:
dataSource - the Property to be edited with this editor.
Throws:
IllegalArgumentException

DateField

public DateField(String caption,
                 Date value)
Constructs a new DateField with the given caption and initial text contents. The editor constructed this way will not be bound to a Property unless Property.Viewer.setPropertyDataSource(Property) is called to bind it.

Parameters:
caption - the caption String for the editor.
value - the Date value.
Method Detail

paintContent

public void paintContent(PaintTarget target)
                  throws PaintException
Description copied from class: AbstractComponent
Paints any needed component-specific things to the given UIDL stream. The more general AbstractComponent.paint(PaintTarget) method handles all general attributes common to all components, and it calls this method to paint any component-specific attributes to the UIDL stream.

Overrides:
paintContent in class AbstractField
Parameters:
target - the target UIDL stream where the component should paint itself to
Throws:
PaintException - if the paint operation failed.

changeVariables

public void changeVariables(Object source,
                            Map variables)
Description copied from interface: VariableOwner
Called when one or more variables handled by the implementing class are changed.

Specified by:
changeVariables in interface VariableOwner
Overrides:
changeVariables in class AbstractField
Parameters:
source - the Source of the variable change. This is the origin of the event. For example in Web Adapter this is the request.
variables - the Mapping from variable names to new variable values.

handleUnparsableDateString

protected Date handleUnparsableDateString(String dateString)
                                   throws Property.ConversionException
This method is called to handle a non-empty date string from the client if the client could not parse it as a Date. By default, a Property.ConversionException is thrown, and the current value is not modified. This can be overridden to handle conversions, to return null (equivalent to empty input), to throw an exception or to fire an event.

Parameters:
dateString -
Returns:
parsed Date
Throws:
Property.ConversionException - to keep the old value and indicate an error

getType

public Class getType()
Description copied from interface: Property
Returns the type of the Property. The methods getValue and setValue must be compatible with this type: one must be able to safely cast the value returned from getValue to the given type and pass any variable assignable to this type as an argument to setValue.

Specified by:
getType in interface Property
Specified by:
getType in class AbstractField
Returns:
type of the Property

toString

public String toString()
Description copied from class: AbstractField
Returns the value of the Property in human readable textual format.

Specified by:
toString in interface Property
Overrides:
toString in class AbstractField
Returns:
String representation of the value stored in the Property
See Also:
Object.toString()

setValue

public void setValue(Object newValue)
              throws Property.ReadOnlyException,
                     Property.ConversionException
Description copied from class: AbstractField
Sets the value of the field.

Specified by:
setValue in interface Property
Overrides:
setValue in class AbstractField
Parameters:
newValue - the New value of the field.
Throws:
Property.ReadOnlyException - if the object is in read-only mode
Property.ConversionException - if newValue can't be converted into the Property's native type directly or through String

setValue

public void setValue(Object newValue,
                     boolean repaintIsNotNeeded)
              throws Property.ReadOnlyException,
                     Property.ConversionException
Description copied from class: AbstractField
Sets the value of the field.

Overrides:
setValue in class AbstractField
Parameters:
newValue - the New value of the field.
repaintIsNotNeeded - True iff caller is sure that repaint is not needed.
Throws:
Property.ReadOnlyException
Property.ConversionException

setPropertyDataSource

public void setPropertyDataSource(Property newDataSource)
Sets the DateField datasource. Datasource type must assignable to Date.

Specified by:
setPropertyDataSource in interface Property.Viewer
Overrides:
setPropertyDataSource in class AbstractField
Parameters:
newDataSource - the new data source Property.
See Also:
Property.Viewer.setPropertyDataSource(Property)

getResolution

public int getResolution()
Gets the resolution.

Returns:
int

setResolution

public void setResolution(int resolution)
Sets the resolution of the DateField.

Parameters:
resolution - the resolution to set.

setDateFormat

public void setDateFormat(String dateFormat)
Sets formatting used by some component implementations. See SimpleDateFormat for format details. By default it is encouraged to used default formatting defined by Locale, but due some JVM bugs it is sometimes necessary to use this method to override formatting. See Vaadin issue #2200.

Parameters:
dateFormat - the dateFormat to set
See Also:
com.vaadin.ui.AbstractComponent#setLocale(Locale))

getDateFormat

public String getDateFormat()
Reterns a format string used to format date value on client side or null if default formatting from Component.getLocale() is used.

Returns:
the dateFormat

setLenient

public void setLenient(boolean lenient)
Specifies whether or not date/time interpretation in component is to be lenient.

Parameters:
lenient - true if the lenient mode is to be turned on; false if it is to be turned off.
See Also:
Calendar.setLenient(boolean), isLenient()

isLenient

public boolean isLenient()
Returns whether date/time interpretation is to be lenient.

Returns:
true if the interpretation mode of this calendar is lenient; false otherwise.
See Also:
setLenient(boolean)

addListener

public void addListener(FieldEvents.FocusListener listener)
Description copied from interface: FieldEvents.FocusNotifier
Adds a FocusListener to the Component which gets fired when a Field receives keyboard focus.

Specified by:
addListener in interface FieldEvents.FocusNotifier
See Also:
FieldEvents.FocusListener

removeListener

public void removeListener(FieldEvents.FocusListener listener)
Description copied from interface: FieldEvents.FocusNotifier
Removes a FocusListener from the Component.

Specified by:
removeListener in interface FieldEvents.FocusNotifier
See Also:
FieldEvents.FocusListener

addListener

public void addListener(FieldEvents.BlurListener listener)
Description copied from interface: FieldEvents.BlurNotifier
Adds a BlurListener to the Component which gets fired when a Field loses keyboard focus.

Specified by:
addListener in interface FieldEvents.BlurNotifier
See Also:
FieldEvents.BlurListener

removeListener

public void removeListener(FieldEvents.BlurListener listener)
Description copied from interface: FieldEvents.BlurNotifier
Removes a BlurListener from the Component.

Specified by:
removeListener in interface FieldEvents.BlurNotifier
See Also:
FieldEvents.BlurListener

isShowISOWeekNumbers

public boolean isShowISOWeekNumbers()
Checks whether ISO 8601 week numbers are shown in the date selector.

Returns:
true if week numbers are shown, false otherwise.

setShowISOWeekNumbers

public void setShowISOWeekNumbers(boolean showWeekNumbers)
Sets the visibility of ISO 8601 week numbers in the date selector. ISO 8601 defines that a week always starts with a Monday so the week numbers are only shown if this is the case.

Parameters:
showWeekNumbers - true if week numbers should be shown, false otherwise.


Copyright © 2000-2010 IT Mill Ltd. All Rights Reserved.