Class WDateField

    • Constructor Detail

      • WDateField

        public WDateField()
        Creates a WDateField that does not allow lenient parsing.
      • WDateField

        public WDateField​(boolean lenient)
        Creates a WDateField.
        Parameters:
        lenient - If true, date parsing will be lenient.
    • 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 interface DataBound
        Overrides:
        setData in class WBeanComponent
        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 by DataBound.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 interface Input
        Overrides:
        getValue in class AbstractInput
        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 interface Input
        Overrides:
        getValueAsString in class AbstractInput
        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 class AbstractInput
        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 value
        valid - true if valid value
        text - 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 interface Input
        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 class AbstractInput
        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.
      • 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 class AbstractInput
        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 class AbstractInput
        Returns:
        the model for this component
      • setAutocomplete

        public void setAutocomplete​(DateType value)
        Description copied from interface: AutocompleteableDate
        Set the autocompletes attribute for a type of date input.
        Specified by:
        setAutocomplete in interface AutocompleteableDate
        Parameters:
        value - the type of date to auto-fill, currently only "bday" is supported.
      • getAutocomplete

        public String getAutocomplete()
        Specified by:
        getAutocomplete in interface Autocompleteable
        Returns:
        the value of the autocomplete attribute applied to the current field.
      • addAutocompleteSection

        public void addAutocompleteSection​(String sectionName)
        Description copied from interface: Autocompleteable
        Pre-pend an autocomplete section to the value of an autocomplete attribute for the current field.
        Specified by:
        addAutocompleteSection in interface Autocompleteable
        Parameters:
        sectionName - the name of the section being the part which would replace the asterisk in the form section-*