Class WDateField
- java.lang.Object
-
- com.github.bordertech.wcomponents.AbstractWComponent
-
- com.github.bordertech.wcomponents.WBeanComponent
-
- com.github.bordertech.wcomponents.AbstractInput
-
- com.github.bordertech.wcomponents.WDateField
-
- All Implemented Interfaces:
AjaxTarget
,AjaxTrigger
,Autocompleteable
,AutocompleteableDate
,BeanAware
,BeanBound
,BeanProviderBound
,DataBound
,Diagnosable
,Disableable
,Input
,Labelable
,Mandatable
,SubordinateTarget
,SubordinateTrigger
,WComponent
,WebComponent
,Serializable
public class WDateField extends AbstractInput implements AjaxTrigger, AjaxTarget, SubordinateTrigger, SubordinateTarget, AutocompleteableDate
This component is a date entry component. Individual themes may add features such as automatic text formatting and date picker widgets. Convenience methods exist to set and get the value as a java date object.
- Since:
- 1.0.0
- Author:
- Ming Gao, Jonathan Austin, Mark Reeves
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
WDateField.DateFieldModel
DateFieldModel holds Extrinsic state management of the field.-
Nested classes/interfaces inherited from class com.github.bordertech.wcomponents.AbstractInput
AbstractInput.InputModel
-
Nested classes/interfaces inherited from class com.github.bordertech.wcomponents.AbstractWComponent
AbstractWComponent.WComponentRef
-
-
Field Summary
-
Fields inherited from interface com.github.bordertech.wcomponents.WComponent
DEFAULT_APPLICATION_ID, DEFAULT_INTERNAL_ID, DEFAULT_NO_ID, ID_CONTEXT_SEPERATOR, ID_FRAMEWORK_ASSIGNED_SEPERATOR, ID_VALIDATION_PATTERN
-
-
Constructor Summary
Constructors Constructor Description WDateField()
Creates a WDateField that does not allow lenient parsing.WDateField(boolean lenient)
Creates a WDateField.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addAutocompleteSection(String sectionName)
Pre-pend anautocomplete
section to the value of anautocomplete
attribute for the current field.void
clearAutocomplete()
Clear theautocomplete
attribute.protected boolean
doHandleRequest(Request request)
Specific handle request processing for an input component is provided here.String
getAutocomplete()
protected WDateField.DateFieldModel
getComponentModel()
Returns the effective component model for this component.Date
getDate()
Returns the text entered into the WDateField as a java date.Date
getMaxDate()
Retrieves the maximum allowable value for this date field.Date
getMinDate()
Retrieves the minimum allowable value for this date field.protected WDateField.DateFieldModel
getOrCreateComponentModel()
Retrieves the model for this component so that it can be modified.Date
getRequestValue(Request request)
Provide the value of the component on the Request.String
getText()
Retrieves the text entered into the field by a specific user.Date
getValue()
Provide the value of the component returned byDataBound.getData()
in the correct format.String
getValueAsString()
Retrieves a String representation of the date field's value.protected void
handleRequestValue(Date value, boolean valid, String text)
Set the request value.boolean
isParseable()
Indicates whether the text value held in this field is a valid date.protected WDateField.DateFieldModel
newComponentModel()
Creates a new DateFieldModel holds Extrinsic state management of the field.void
setAutocomplete(DateType value)
Set theautocomplete
s attribute for a type of date input.void
setAutocompleteOff()
Turnautocomplete
off for the current field.void
setData(Object data)
Sets the data that this component displays/edits.void
setDate(Date date)
Set the value of the date field.void
setInvalidDateErrorMessage(String errorMessage)
Sets the validation error message.void
setMaxDate(Date maxDate)
Sets the maximum allowable value for this date field.void
setMinDate(Date minDate)
Sets the minimum allowable value for this date field.protected void
validateComponent(List<Diagnostic> diags)
Override WInput's validateComponent to perform further validation on the date.protected void
validateDate(List<Diagnostic> diags)
Performs validation of the date.-
Methods inherited from class com.github.bordertech.wcomponents.AbstractInput
addValidator, beforeHandleRequest, createMandatoryDiagnostic, doHandleChanged, getActionCommand, getActionObject, getActionOnChange, getDefaultSubmitButton, getDiagnostics, getValidators, handleRequest, isChangedInLastRequest, isCurrentAjaxTrigger, isDisabled, isEmpty, isMandatory, isPresent, isReadOnly, setActionObject, setActionOnChange, setChangedInLastRequest, setDefaultSubmitButton, setDisabled, setMandatory, setMandatory, setReadOnly, showErrorIndicatorsForComponent, showIndicatorsForComponent, showWarningIndicatorsForComponent, toString
-
Methods inherited from class com.github.bordertech.wcomponents.WBeanComponent
addBeanToScratchMap, doUpdateBeanValue, getBean, getBeanFromScratchMap, getBeanId, getBeanProperty, getBeanProvider, getBeanScratchMap, getBeanValue, getData, isBeanInScratchMap, isChanged, isSearchAncestors, isUseRequestScopeScratchMap, removeBeanFromScratchMap, resetData, setBean, setBeanId, setBeanProperty, setBeanProvider, setSearchAncestors, updateBeanValue
-
Methods inherited from class com.github.bordertech.wcomponents.AbstractWComponent
addHtmlClass, addHtmlClass, addNotify, afterPaint, assertAddSupported, beforePaint, createErrorDiagnostic, createErrorDiagnostic, forward, getAccessibleText, getAttribute, getBaseUrl, getDefaultModel, getEnvironment, getHeaders, getHtmlClass, getHtmlClasses, getId, getIdName, getInternalId, getLabel, getName, getParent, getScratchMap, getTabIndex, getTag, getTemplate, getTemplateMarkUp, getToolTip, hasNoComponentModel, hasTabIndex, initialiseComponentModel, invokeLater, invokeLaters, isDebugStructure, isDefaultState, isFlagSet, isHidden, isInitialised, isLocked, isTracking, isTrackingEnabled, isValidate, isVisible, paint, paintComponent, preparePaint, preparePaintComponent, removeAttribute, removeComponentModel, removeHtmlClass, removeHtmlClass, removeNotify, replaceWComponent, reset, serviceRequest, setAccessibleText, setAttribute, setEnvironment, setFlag, setFocussed, setHidden, setHtmlClass, setHtmlClass, setIdName, setInitialised, setLocked, setTag, setToolTip, setTrackingEnabled, setValidate, setVisible, showErrorIndicators, showWarningIndicators, tidyUpUIContext, tidyUpUIContextForTree, validate, writeReplace
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.github.bordertech.wcomponents.autocomplete.Autocompleteable
isAutocompleteOff
-
Methods inherited from interface com.github.bordertech.wcomponents.autocomplete.AutocompleteableDate
setBirthdayAutocomplete
-
Methods inherited from interface com.github.bordertech.wcomponents.BeanAware
getBean, getBeanProperty, getBeanValue, setBeanProperty
-
Methods inherited from interface com.github.bordertech.wcomponents.BeanBound
isSearchAncestors, setBean
-
Methods inherited from interface com.github.bordertech.wcomponents.BeanProviderBound
getBeanId, setBeanId, setBeanProvider
-
Methods inherited from interface com.github.bordertech.wcomponents.WComponent
addHtmlClass, addHtmlClass, forward, getAccessibleText, getAttribute, getBaseUrl, getEnvironment, getHeaders, getHtmlClass, getHtmlClasses, getId, getIdName, getInternalId, getLabel, getName, getParent, getTabIndex, getTag, getToolTip, handleRequest, hasTabIndex, invokeLater, isDefaultState, isHidden, isInitialised, isLocked, isTracking, isTrackingEnabled, isValidate, isVisible, paint, preparePaint, removeAttribute, removeHtmlClass, removeHtmlClass, reset, serviceRequest, setAccessibleText, setAttribute, setEnvironment, setFocussed, setHtmlClass, setHtmlClass, setIdName, setInitialised, setLocked, setTag, setToolTip, setTrackingEnabled, setValidate, setVisible, showErrorIndicators, showWarningIndicators, tidyUpUIContextForTree, validate
-
-
-
-
Method Detail
-
setData
public void setData(Object data)
Sets the data that this component displays/edits. For bean aware components, this should only be called from handleRequest to set user-entered data.- Specified by:
setData
in interfaceDataBound
- Overrides:
setData
in classWBeanComponent
- Parameters:
data
- the data to set
-
setDate
public void setDate(Date date)
Set the value of the date field.- Parameters:
date
- the date to set.
-
getDate
public Date getDate()
Returns the text entered into the WDateField as a java date. Returns null if the data cannot be converted into a java date.- Returns:
- the java date or null
-
getValue
public Date getValue()
Provide the value of the component returned byDataBound.getData()
in the correct format.If required, this method can convert the data into the correct type and also do any validation before the value is used.
- Specified by:
getValue
in interfaceInput
- Overrides:
getValue
in classAbstractInput
- Returns:
- the value of the component returned by
DataBound.getData()
in the correct format.
-
getText
public String getText()
Retrieves the text entered into the field by a specific user. This is not necessarily a valid date.- Returns:
- the text field's text for the given context.
-
isParseable
public boolean isParseable()
Indicates whether the text value held in this field is a valid date.- Returns:
- true if the field contains text which is a valid date, false otherwise.
-
getValueAsString
public String getValueAsString()
Retrieves a String representation of the date field's value. The date value will be returned using its default String representation.- Specified by:
getValueAsString
in interfaceInput
- Overrides:
getValueAsString
in classAbstractInput
- Returns:
- the date value, or the text entered by the user if there is no valid date.
-
doHandleRequest
protected boolean doHandleRequest(Request request)
Specific handle request processing for an input component is provided here.Input components are required to determine if the component has changed in the request, set the component data to the new value (if changed) and return the changed flag.
- Specified by:
doHandleRequest
in classAbstractInput
- Parameters:
request
- the request being responded to.- Returns:
- true if the input component has changed, otherwise return false
-
handleRequestValue
protected void handleRequestValue(Date value, boolean valid, String text)
Set the request value.- Parameters:
value
- the date valuevalid
- true if valid valuetext
- the user text
-
getRequestValue
public Date getRequestValue(Request request)
Provide the value of the component on the Request.If the component is not on the request, the components current value will be provided.
- Specified by:
getRequestValue
in interfaceInput
- Parameters:
request
- the request being responded to.- Returns:
- the value of this component on the Request, or its current state if it is not on the request.
-
setInvalidDateErrorMessage
public void setInvalidDateErrorMessage(String errorMessage)
Sets the validation error message.- Parameters:
errorMessage
- The errorMessage to set, or null to use the default error message.
-
validateComponent
protected void validateComponent(List<Diagnostic> diags)
Override WInput's validateComponent to perform further validation on the date.- Overrides:
validateComponent
in classAbstractInput
- Parameters:
diags
- the list into which any validation diagnostics are added.
-
validateDate
protected void validateDate(List<Diagnostic> diags)
Performs validation of the date. Validation ensures that the entered date is between the minimum/maximum values (if applicable).
Subclasses can override this method to perform more specific validation.
- Parameters:
diags
- the list into which any validation diagnostics are added.
-
getMinDate
public Date getMinDate()
Retrieves the minimum allowable value for this date field. The minimum value is enforced server-side using the WComponent validation framework, and may be enforced client-side.- Returns:
- the minimum allowable value, or null if there is no minimum.
-
setMinDate
public void setMinDate(Date minDate)
Sets the minimum allowable value for this date field.- Parameters:
minDate
- the minimum allowable value.
-
getMaxDate
public Date getMaxDate()
Retrieves the maximum allowable value for this date field. The maximum value is enforced server-side using the WComponent validation framework, and may be enforced client-side.- Returns:
- the maximum allowable value, or null if there is no maximum.
-
setMaxDate
public void setMaxDate(Date maxDate)
Sets the maximum allowable value for this date field.- Parameters:
maxDate
- the maximum allowable value.
-
newComponentModel
protected WDateField.DateFieldModel newComponentModel()
Creates a new DateFieldModel holds Extrinsic state management of the field.- Overrides:
newComponentModel
in classAbstractInput
- Returns:
- a new DateFieldModel
-
getComponentModel
protected WDateField.DateFieldModel getComponentModel()
Returns the effective component model for this component. Subclass may override this method to narrow the return type to their specific model type.- Overrides:
getComponentModel
in classAbstractInput
- Returns:
- the effective component model
-
getOrCreateComponentModel
protected WDateField.DateFieldModel getOrCreateComponentModel()
Retrieves the model for this component so that it can be modified. If this method is called during request processing, and a session specific model does not yet exist, then a new model is created. Subclasses may override this method to narrow the return type to their specific model type.- Overrides:
getOrCreateComponentModel
in classAbstractInput
- Returns:
- the model for this component
-
setAutocomplete
public void setAutocomplete(DateType value)
Description copied from interface:AutocompleteableDate
Set theautocomplete
s attribute for a type of date input.- Specified by:
setAutocomplete
in interfaceAutocompleteableDate
- Parameters:
value
- the type of date to auto-fill, currently only "bday" is supported.
-
getAutocomplete
public String getAutocomplete()
- Specified by:
getAutocomplete
in interfaceAutocompleteable
- Returns:
- the value of the
autocomplete
attribute applied to the current field.
-
setAutocompleteOff
public void setAutocompleteOff()
Description copied from interface:Autocompleteable
Turnautocomplete
off for the current field.- Specified by:
setAutocompleteOff
in interfaceAutocompleteable
-
addAutocompleteSection
public void addAutocompleteSection(String sectionName)
Description copied from interface:Autocompleteable
Pre-pend anautocomplete
section to the value of anautocomplete
attribute for the current field.- Specified by:
addAutocompleteSection
in interfaceAutocompleteable
- Parameters:
sectionName
- the name of the section being the part which would replace the asterisk in the formsection-*
-
clearAutocomplete
public void clearAutocomplete()
Description copied from interface:Autocompleteable
Clear theautocomplete
attribute.- Specified by:
clearAutocomplete
in interfaceAutocompleteable
-
-