Class WPartialDateField

    • Constructor Detail

      • WPartialDateField

        public WPartialDateField()
        Creates a WPartialDateField with no date specified.
      • WPartialDateField

        public WPartialDateField​(char paddingChar)
        Creates a WPartialDateField with a specific padding character. The padding character used in the partial date value. The default padding character is a space. If the padding character is a space, then the date value will be right trimmed to remove the trailing spaces.
        Parameters:
        paddingChar - the padding character used in the partial date value.
      • WPartialDateField

        public WPartialDateField​(Integer day,
                                 Integer month,
                                 Integer year)
        Creates a WPartialDateField with the specified date.
        Parameters:
        day - A number from 1 to 31 or null if unknown.
        month - A number from 1 to 12, or null if unknown.
        year - A number, or null if unknown.
      • WPartialDateField

        public WPartialDateField​(Integer day,
                                 Integer month,
                                 Integer year,
                                 char paddingChar)
        Creates a WPartialDateField with the specified date and padding character.
        Parameters:
        day - A number from 1 to 31 or null if unknown.
        month - A number from 1 to 12, or null if unknown.
        year - A number, or null if unknown.
        paddingChar - the padding character used in the partial date value.
    • Method Detail

      • setPartialDate

        public void setPartialDate​(Integer day,
                                   Integer month,
                                   Integer year)
        Set the WPartialDateField with the given day, month and year. Each of the day, month and year parameters that make up the partial date are optional.
        Parameters:
        day - A number from 1 to 31 or null if unknown.
        month - A number from 1 to 12, or null if unknown.
        year - A number, or null if unknown.
      • getPaddingChar

        public char getPaddingChar()
        The padding character used in the partial date value. The default padding character is a space. If the padding character is a space, then the date value will be right trimmed to remove the trailing spaces.
        Returns:
        the padding character used in the partial date value
      • setPaddingChar

        @Deprecated
        public void setPaddingChar​(char paddingChar)
        Deprecated.
        will be removed so padding character is immutable
        The padding character used in the partial date value. The default padding character is a space. If the padding character is a space, then the date value will be right trimmed to remove the trailing spaces.
        Parameters:
        paddingChar - the padding character used in the partial date value.
      • 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​(String 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 String 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 message)
        Sets the validation error message.
        Parameters:
        message - 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. A partial date is invalid if there was text submitted but no date components were parsed.
        Overrides:
        validateComponent in class AbstractInput
        Parameters:
        diags - the list into which any validation diagnostics are added.
      • setDate

        public void setDate​(Date date)
        Set the WPartialDateField with the given java date.
        Parameters:
        date - the date
      • getValue

        public String 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.
      • getPartialDate

        public String getPartialDate()
        Get the partial date as its formatted string.

        The expected format of the partial date is "yyyyMMdd", where parts of the date that do not have a value are padded with the padding character.

        Returns:
        the partial data formatted as a string, or null
      • 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
      • getDay

        public Integer getDay()
        Returns the day of the month value.
        Returns:
        the day of the month, or null if unspecified.
      • getMonth

        public Integer getMonth()
        Returns the month value.
        Returns:
        the month, or null if unspecified.
      • getYear

        public Integer getYear()
        Returns the year value.
        Returns:
        the year, or null if unspecified.
      • getDate

        public Date getDate()
        Returns the java date value, else null if the value cannot be parsed.
        Returns:
        the java date or null
      • getText

        public String getText()
        Retrieves the text as entered by the user. This is not necessarily a valid date.
        Returns:
        the text, as entered by the user.
      • isValidDate

        public boolean isValidDate()
        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.
      • getOrCreateComponentModel

        protected WPartialDateField.PartialDateFieldModel 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