com.smartgwt.client.widgets.form.fields
Class DateItem

java.lang.Object
  extended by com.smartgwt.client.core.JsObject
      extended by com.smartgwt.client.core.DataClass
          extended by com.smartgwt.client.core.RefDataClass
              extended by com.smartgwt.client.widgets.form.fields.FormItem
                  extended by com.smartgwt.client.widgets.form.fields.DateItem
All Implemented Interfaces:
HasHandlers, HasBlurHandlers, HasChangedHandlers, HasChangeHandlers, HasClickHandlers, HasDoubleClickHandlers, HasFocusHandlers, HasIconClickHandlers, HasIconKeyPressHandlers, HasItemHoverHandlers, HasKeyDownHandlers, HasKeyPressHandlers, HasKeyUpHandlers, HasTitleHoverHandlers

public class DateItem
extends FormItem

Item for manipulating Dates.

Can be rendered as a text field, or as 3 selects for day, month, year. Includes optional pop-up picker.


Field Summary
 
Fields inherited from class com.smartgwt.client.core.JsObject
jsObj
 
Constructor Summary
DateItem()
           
DateItem(com.google.gwt.core.client.JavaScriptObject jsObj)
           
DateItem(java.lang.String name)
           
DateItem(java.lang.String name, java.lang.String title)
           
 
Method Summary
 int getCenturyThreshold()
          Only used if we're showing the date in a text field.
 DateDisplayFormat getDateFormatter()
          Inapplicable for DateItems.
 DateDisplayFormat getDisplayFormat()
          If useTextField is true this property can be used to customize the format in which dates are displayed.
Should be set to a standard DateDisplayFormat or a function which will return a formatted date string. Default setting is "toShortDate" which ensures that if the standard shortDate format is modified via com.smartgwt.client..Date#setShortDisplayFormat this format will be picked up.
 java.util.Date getEndDate()
          Maximum date the selectors will allow the user to pick.
 java.lang.Boolean getEnforceDate()
          Can this field be set to a non-date value [other than null]?
 java.lang.String getInputFormat()
          If useTextField is true this property can be used to specify the input format for date strings.
 java.lang.String getInvalidDateStringMessage()
          Validation error message to display if the user enters an invalid date
static DateItem getOrCreateRef(com.google.gwt.core.client.JavaScriptObject jsObj)
           
 java.lang.String getPickerIconPrompt()
          Prompt to show when the user hovers the mouse over the picker icon for this DateItem.
 java.lang.String getSelectorFormat()
          If showing date selectors rather than the date text field (so when this.useTextField is false), this property allows customization of the order of the day, month and year selector fields.
 java.util.Date getStartDate()
          Minimum date the selectors will allow the user to pick.
 Alignment getTextAlign()
          If useTextField is true this property governs the alignment of text within the text field.
 java.lang.Boolean getUseTextField()
          Should we show the date in a text field, or as 3 select boxes?
 void setCenturyThreshold(int centuryThreshold)
          Only used if we're showing the date in a text field.
 void setDateFormatter(DateDisplayFormat dateFormatter)
          Inapplicable for DateItems.
 void setDisplayFormat(DateDisplayFormat displayFormat)
          If useTextField is true this property can be used to customize the format in which dates are displayed.
Should be set to a standard DateDisplayFormat or a function which will return a formatted date string. Default setting is "toShortDate" which ensures that if the standard shortDate format is modified via com.smartgwt.client..Date#setShortDisplayFormat this format will be picked up.
 void setEndDate(java.util.Date endDate)
          Maximum date the selectors will allow the user to pick.
 void setEnforceDate(java.lang.Boolean enforceDate)
          Can this field be set to a non-date value [other than null]?
 void setInputFormat(java.lang.String inputFormat)
          If useTextField is true this property can be used to specify the input format for date strings.
 void setInvalidDateStringMessage(java.lang.String invalidDateStringMessage)
          Validation error message to display if the user enters an invalid date
 void setPickerIconPrompt(java.lang.String pickerIconPrompt)
          Prompt to show when the user hovers the mouse over the picker icon for this DateItem.
 void setSelectorFormat(java.lang.String selectorFormat)
          If showing date selectors rather than the date text field (so when this.useTextField is false), this property allows customization of the order of the day, month and year selector fields.
 void setStartDate(java.util.Date startDate)
          Minimum date the selectors will allow the user to pick.
 void setTextAlign(Alignment textAlign)
          If useTextField is true this property governs the alignment of text within the text field.
 void setUseTextField(java.lang.Boolean useTextField)
          Should we show the date in a text field, or as 3 select boxes?
 
Methods inherited from class com.smartgwt.client.widgets.form.fields.FormItem
addBlurHandler, addChangedHandler, addChangeHandler, addClickHandler, addDoubleClickHandler, addFocusHandler, addIconClickHandler, addIconKeyPressHandler, addItemHoverHandler, addKeyDownHandler, addKeyPressHandler, addKeyUpHandler, addTitleHoverHandler, blurItem, disable, enable, focusInItem, getAccessKey, getAlign, getAttribute, getAttributeAsBoolean, getAttributeAsDate, getAttributeAsDouble, getAttributeAsFloat, getAttributeAsInt, getAttributeAsJavaScriptObject, getAttributeAsString, getCellStyle, getConfig, getCriteriaField, getCriterion, getDefaultIconSrc, getDisabled, getDisplayField, getDisplayFieldName, getDisplayValue, getDisplayValue, getEmptyDisplayValue, getEmptyValueIcon, getEndRow, getErrorIconHeight, getErrorIconSrc, getErrorIconWidth, getErrorMessageWidth, getFetchMissingValues, getFieldName, getFilterLocally, getGlobalTabIndex, getHeight, getHint, getHintStyle, getHoverAlign, getHoverDelay, getHoverHeight, getHoverOpacity, getHoverStyle, getHoverVAlign, getHoverWidth, getIconHeight, getIconPageRect, getIconPrompt, getIconRect, getIconVAlign, getIconWidth, getImageURLPrefix, getImageURLSuffix, getLeft, getName, getOperator, getPickerIconHeight, getPickerIconSrc, getPickerIconWidth, getPrompt, getRejectInvalidValueOnChange, getRequired, getRowSpan, getSelectOnFocus, getShouldSaveValue, getShowDisabled, getShowErrorIcon, getShowErrorStyle, getShowErrorText, getShowFocused, getShowFocusedIcons, getShowFocusedPickerIcon, getShowHint, getShowIcons, getShowOverIcons, getShowPickerIcon, getShowTitle, getShowValueIconOnly, getStartRow, getSuppressValueIcon, getTabIndex, getTextBoxStyle, getTimeFormatter, getTitle, getTitleAlign, getTitleOrientation, getTitleStyle, getTooltip, getTop, getType, getValidateOnChange, getValue, getValueField, getValueFieldName, getValueIconHeight, getValueIconLeftPadding, getValueIconRightPadding, getValueIconSize, getValueIconWidth, getVisible, getWidth, getWrapTitle, hide, isCreated, isDisabled, isDrawn, redraw, setAccessKey, setAlign, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setCellStyle, setColSpan, setColSpan, setCriteriaField, setDefaultIconSrc, setDefaultValue, setDefaultValue, setDefaultValue, setDefaultValue, setDefaultValue, setDisabled, setDisplayField, setEditorType, setEmptyDisplayValue, setEmptyValueIcon, setEndRow, setErrorFormatter, setErrorIconHeight, setErrorIconSrc, setErrorIconWidth, setErrorMessageWidth, setErrorOrientation, setFetchMissingValues, setFilterLocally, setGlobalTabIndex, setHeight, setHeight, setHint, setHintStyle, setHoverAlign, setHoverDelay, setHoverHeight, setHoverOpacity, setHoverStyle, setHoverVAlign, setHoverWidth, setIconHeight, setIconPrompt, setIcons, setIconVAlign, setIconWidth, setImageURLPrefix, setImageURLSuffix, setInputTransformer, setItemHoverFormatter, setItemTitleHoverFormatter, setLeft, setName, setOperator, setOptionDataSource, setPickerIconHeight, setPickerIconSrc, setPickerIconWidth, setPrompt, setProperty, setProperty, setProperty, setProperty, setRedrawOnChange, setRejectInvalidValueOnChange, setRequired, setRowSpan, setSelectOnFocus, setShouldSaveValue, setShowDisabled, setShowErrorIcon, setShowErrorStyle, setShowErrorText, setShowFocused, setShowFocusedIcons, setShowFocusedPickerIcon, setShowHint, setShowIcons, setShowIfCondition, setShowOverIcons, setShowPickerIcon, setShowTitle, setShowValueIconOnly, setStartRow, setSuppressValueIcon, setTabIndex, setTextBoxStyle, setTimeFormatter, setTitle, setTitleAlign, setTitleOrientation, setTitleStyle, setTooltip, setTop, setType, setValidateOnChange, setValidators, setValue, setValue, setValue, setValue, setValue, setValue, setValueField, setValueIconHeight, setValueIconLeftPadding, setValueIconRightPadding, setValueIcons, setValueIconSize, setValueIconWidth, setValueMap, setValueMap, setVisible, setWidth, setWidth, setWrapTitle, show, stopHover, updateState
 
Methods inherited from class com.smartgwt.client.core.RefDataClass
getRef, getRef
 
Methods inherited from class com.smartgwt.client.core.DataClass
doAddHandler, fireEvent, getAttributeAsIntArray, getAttributeAsMap, getAttributeAsObject, getAttributeAsStringArray, getAttributes, getHandlerCount, getJsObj, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute
 
Methods inherited from class com.smartgwt.client.core.JsObject
setJsObj
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.google.gwt.event.shared.HasHandlers
fireEvent
 
Methods inherited from interface com.google.gwt.event.shared.HasHandlers
fireEvent
 
Methods inherited from interface com.google.gwt.event.shared.HasHandlers
fireEvent
 
Methods inherited from interface com.google.gwt.event.shared.HasHandlers
fireEvent
 
Methods inherited from interface com.google.gwt.event.shared.HasHandlers
fireEvent
 
Methods inherited from interface com.google.gwt.event.shared.HasHandlers
fireEvent
 
Methods inherited from interface com.google.gwt.event.shared.HasHandlers
fireEvent
 
Methods inherited from interface com.google.gwt.event.shared.HasHandlers
fireEvent
 
Methods inherited from interface com.google.gwt.event.shared.HasHandlers
fireEvent
 
Methods inherited from interface com.google.gwt.event.shared.HasHandlers
fireEvent
 
Methods inherited from interface com.google.gwt.event.shared.HasHandlers
fireEvent
 
Methods inherited from interface com.google.gwt.event.shared.HasHandlers
fireEvent
 
Methods inherited from interface com.google.gwt.event.shared.HasHandlers
fireEvent
 

Constructor Detail

DateItem

public DateItem()

DateItem

public DateItem(com.google.gwt.core.client.JavaScriptObject jsObj)

DateItem

public DateItem(java.lang.String name)

DateItem

public DateItem(java.lang.String name,
                java.lang.String title)
Method Detail

getOrCreateRef

public static DateItem getOrCreateRef(com.google.gwt.core.client.JavaScriptObject jsObj)

setUseTextField

public void setUseTextField(java.lang.Boolean useTextField)
Should we show the date in a text field, or as 3 select boxes?

Parameters:
useTextField - useTextField Default value is false

getUseTextField

public java.lang.Boolean getUseTextField()
Should we show the date in a text field, or as 3 select boxes?

Returns:
Boolean

setTextAlign

public void setTextAlign(Alignment textAlign)
If useTextField is true this property governs the alignment of text within the text field.

Overrides:
setTextAlign in class FormItem
Parameters:
textAlign - textAlign Default value is Canvas.RIGHT

getTextAlign

public Alignment getTextAlign()
If useTextField is true this property governs the alignment of text within the text field.

Overrides:
getTextAlign in class FormItem
Returns:
Alignment

setEnforceDate

public void setEnforceDate(java.lang.Boolean enforceDate)
Can this field be set to a non-date value [other than null]?

When set to true, FormItem.setValue(int) will return false without setting the item value and log a warning if passed something other than a valid date value. If a user enters a text value which cannot be parsed into a valid date, the item will automatically redraw and display the invalidDateStringMessage (though at this point calling FormItem.getValue() will return the string entered by the user).

When set to false, a user may enter value that is not a valid date (for example, "Not applicable") and the value will not immediately be flagged as an error. However note that for the value to actually pass validation you would need to declare the field as not of "date" type, for example:

     {name:"startDate", type:"dateOrOther", editorType:"DateItem", useTextField:true },
 
The type "dateOrOther" could be declared as a SimpleType, with validators that will accept either a valid date or certain special Strings (like "Not Available").

Only applies to dateItems where useTextField is true. Non-Date values are never supported in items where useTextField is false.

Note : This is an advanced setting

Parameters:
enforceDate - enforceDate Default value is false

getEnforceDate

public java.lang.Boolean getEnforceDate()
Can this field be set to a non-date value [other than null]?

When set to true, FormItem.setValue(int) will return false without setting the item value and log a warning if passed something other than a valid date value. If a user enters a text value which cannot be parsed into a valid date, the item will automatically redraw and display the invalidDateStringMessage (though at this point calling FormItem.getValue() will return the string entered by the user).

When set to false, a user may enter value that is not a valid date (for example, "Not applicable") and the value will not immediately be flagged as an error. However note that for the value to actually pass validation you would need to declare the field as not of "date" type, for example:

     {name:"startDate", type:"dateOrOther", editorType:"DateItem", useTextField:true },
 
The type "dateOrOther" could be declared as a SimpleType, with validators that will accept either a valid date or certain special Strings (like "Not Available").

Only applies to dateItems where useTextField is true. Non-Date values are never supported in items where useTextField is false.

Returns:
Boolean

setInvalidDateStringMessage

public void setInvalidDateStringMessage(java.lang.String invalidDateStringMessage)
Validation error message to display if the user enters an invalid date

Parameters:
invalidDateStringMessage - invalidDateStringMessage Default value is "Invalid date"

getInvalidDateStringMessage

public java.lang.String getInvalidDateStringMessage()
Validation error message to display if the user enters an invalid date

Returns:
String

setPickerIconPrompt

public void setPickerIconPrompt(java.lang.String pickerIconPrompt)
Prompt to show when the user hovers the mouse over the picker icon for this DateItem. May be overridden for localization of your application.

Parameters:
pickerIconPrompt - pickerIconPrompt Default value is "Show Date Chooser"

getPickerIconPrompt

public java.lang.String getPickerIconPrompt()
Prompt to show when the user hovers the mouse over the picker icon for this DateItem. May be overridden for localization of your application.

Returns:
String

setStartDate

public void setStartDate(java.util.Date startDate)
Minimum date the selectors will allow the user to pick.

Parameters:
startDate - startDate Default value is 1/1/1995

getStartDate

public java.util.Date getStartDate()
Minimum date the selectors will allow the user to pick.

Returns:
java.util.Date

setEndDate

public void setEndDate(java.util.Date endDate)
Maximum date the selectors will allow the user to pick.

Parameters:
endDate - endDate Default value is 12/31/2015

getEndDate

public java.util.Date getEndDate()
Maximum date the selectors will allow the user to pick.

Returns:
java.util.Date

setCenturyThreshold

public void setCenturyThreshold(int centuryThreshold)
Only used if we're showing the date in a text field. When parsing a date, if the year is specified with only 2 digits and is less than the centuryThreshold, then the year will be assumed to be 20xx; otherwise it will be interpreted according to default browser behaviour, which will consider it to be 19xx.

Parameters:
centuryThreshold - centuryThreshold Default value is 25

getCenturyThreshold

public int getCenturyThreshold()
Only used if we're showing the date in a text field. When parsing a date, if the year is specified with only 2 digits and is less than the centuryThreshold, then the year will be assumed to be 20xx; otherwise it will be interpreted according to default browser behaviour, which will consider it to be 19xx.

Returns:
int

setDisplayFormat

public void setDisplayFormat(DateDisplayFormat displayFormat)
If useTextField is true this property can be used to customize the format in which dates are displayed.
Should be set to a standard DateDisplayFormat or a function which will return a formatted date string. Default setting is "toShortDate" which ensures that if the standard shortDate format is modified via com.smartgwt.client..Date#setShortDisplayFormat this format will be picked up.

NOTE: you may need to update the inputFormat to ensure the DateItem is able to parse user-entered date strings back into Dates

Parameters:
displayFormat - displayFormat Default value is "toShortDate"

getDisplayFormat

public DateDisplayFormat getDisplayFormat()
If useTextField is true this property can be used to customize the format in which dates are displayed.
Should be set to a standard DateDisplayFormat or a function which will return a formatted date string. Default setting is "toShortDate" which ensures that if the standard shortDate format is modified via com.smartgwt.client..Date#setShortDisplayFormat this format will be picked up.

NOTE: you may need to update the inputFormat to ensure the DateItem is able to parse user-entered date strings back into Dates

Returns:
DateDisplayFormat

setInputFormat

public void setInputFormat(java.lang.String inputFormat)
If useTextField is true this property can be used to specify the input format for date strings. If unset, the input format will be determined based on the specified displayFormat if possible (see getInputFormat()), otherwise picked up from the Date class (see com.smartgwt.client..Date#setInputFormat).

Should be set to a standard com.smartgwt.client..DateInputFormat or a function which will take a date string as a parameter and return a Javascript Date object.

Parameters:
inputFormat - inputFormat Default value is null

getInputFormat

public java.lang.String getInputFormat()
If useTextField is true this property can be used to specify the input format for date strings. If unset, the input format will be determined based on the specified displayFormat if possible (see getInputFormat()), otherwise picked up from the Date class (see com.smartgwt.client..Date#setInputFormat).

Should be set to a standard com.smartgwt.client..DateInputFormat or a function which will take a date string as a parameter and return a Javascript Date object.

Returns:
If useTextField is true this method returns a standard com.smartgwt.client..DateInputFormat, or parsing function, determining how values entered by the user are to be converted to Javascript Date objects.

If an explicit inputFormat has been specified it will be returned.

Otherwise, if an explicit displayFormat has been specified as one of toUSShortDate, toEuropeanShortDate or toJapanShortDate this method will return the appropriate DateInputFormat to parse strings entered in the specified displayFormat.

If no inputFormat can be derived, the method will return null, meaning the standard input format for Date objects (specified via com.smartgwt.client..Date#setInputFormat) will be used.


setDateFormatter

public void setDateFormatter(DateDisplayFormat dateFormatter)
Inapplicable for DateItems. Use displayFormat instead.

Note : This is an advanced setting

Overrides:
setDateFormatter in class FormItem
Parameters:
dateFormatter - dateFormatter Default value is null

getDateFormatter

public DateDisplayFormat getDateFormatter()
Inapplicable for DateItems. Use displayFormat instead.

Overrides:
getDateFormatter in class FormItem
Returns:
DateDisplayFormat

setSelectorFormat

public void setSelectorFormat(java.lang.String selectorFormat)
If showing date selectors rather than the date text field (so when this.useTextField is false), this property allows customization of the order of the day, month and year selector fields. If unset these fields will match the specified inputFormat for this item.

Parameters:
selectorFormat - selectorFormat Default value is null

getSelectorFormat

public java.lang.String getSelectorFormat()
If showing date selectors rather than the date text field (so when this.useTextField is false), this property allows customization of the order of the day, month and year selector fields. If unset these fields will match the specified inputFormat for this item.

Returns:
String