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 classWDateField.DateFieldModelDateFieldModel 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 voidaddAutocompleteSection(String sectionName)Pre-pend anautocompletesection to the value of anautocompleteattribute for the current field.voidclearAutocomplete()Clear theautocompleteattribute.protected booleandoHandleRequest(Request request)Specific handle request processing for an input component is provided here.StringgetAutocomplete()protected WDateField.DateFieldModelgetComponentModel()Returns the effective component model for this component.DategetDate()Returns the text entered into the WDateField as a java date.DategetMaxDate()Retrieves the maximum allowable value for this date field.DategetMinDate()Retrieves the minimum allowable value for this date field.protected WDateField.DateFieldModelgetOrCreateComponentModel()Retrieves the model for this component so that it can be modified.DategetRequestValue(Request request)Provide the value of the component on the Request.StringgetText()Retrieves the text entered into the field by a specific user.DategetValue()Provide the value of the component returned byDataBound.getData()in the correct format.StringgetValueAsString()Retrieves a String representation of the date field's value.protected voidhandleRequestValue(Date value, boolean valid, String text)Set the request value.booleanisParseable()Indicates whether the text value held in this field is a valid date.protected WDateField.DateFieldModelnewComponentModel()Creates a new DateFieldModel holds Extrinsic state management of the field.voidsetAutocomplete(DateType value)Set theautocompletes attribute for a type of date input.voidsetAutocompleteOff()Turnautocompleteoff for the current field.voidsetData(Object data)Sets the data that this component displays/edits.voidsetDate(Date date)Set the value of the date field.voidsetInvalidDateErrorMessage(String errorMessage)Sets the validation error message.voidsetMaxDate(Date maxDate)Sets the maximum allowable value for this date field.voidsetMinDate(Date minDate)Sets the minimum allowable value for this date field.protected voidvalidateComponent(List<Diagnostic> diags)Override WInput's validateComponent to perform further validation on the date.protected voidvalidateDate(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:
setDatain interfaceDataBound- Overrides:
setDatain 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:
getValuein interfaceInput- Overrides:
getValuein 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:
getValueAsStringin interfaceInput- Overrides:
getValueAsStringin 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:
doHandleRequestin 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:
getRequestValuein 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:
validateComponentin 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:
newComponentModelin 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:
getComponentModelin 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:
getOrCreateComponentModelin classAbstractInput- Returns:
- the model for this component
-
setAutocomplete
public void setAutocomplete(DateType value)
Description copied from interface:AutocompleteableDateSet theautocompletes attribute for a type of date input.- Specified by:
setAutocompletein interfaceAutocompleteableDate- Parameters:
value- the type of date to auto-fill, currently only "bday" is supported.
-
getAutocomplete
public String getAutocomplete()
- Specified by:
getAutocompletein interfaceAutocompleteable- Returns:
- the value of the
autocompleteattribute applied to the current field.
-
setAutocompleteOff
public void setAutocompleteOff()
Description copied from interface:AutocompleteableTurnautocompleteoff for the current field.- Specified by:
setAutocompleteOffin interfaceAutocompleteable
-
addAutocompleteSection
public void addAutocompleteSection(String sectionName)
Description copied from interface:AutocompleteablePre-pend anautocompletesection to the value of anautocompleteattribute for the current field.- Specified by:
addAutocompleteSectionin 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:AutocompleteableClear theautocompleteattribute.- Specified by:
clearAutocompletein interfaceAutocompleteable
-
-