Class WTextField

    • Constructor Detail

      • WTextField

        public WTextField()
    • Method Detail

      • doHandleRequest

        protected boolean doHandleRequest​(Request request)
        Override handleRequest in order to perform processing for this component. This implementation updates the text field's text if it has changed.
        Specified by:
        doHandleRequest in class AbstractInput
        Parameters:
        request - the request being responded to.
        Returns:
        true if the text field has changed, otherwise false
      • 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.
      • 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.
      • getText

        public String getText()
        Retrieves the text field's text.
        Returns:
        the text field's text.
      • setText

        public void setText​(String text)
        Sets the text value to be shown in the input field for the given user.
        Parameters:
        text - the text to display for the given context.
      • setPlaceholder

        public void setPlaceholder​(String placeholder)
        Set placeholder text which will appear in the field if it is editable and has no content.
        Specified by:
        setPlaceholder in interface Placeholderable
        Parameters:
        placeholder - The text to set as the placeholder.
      • getPlaceholder

        public String getPlaceholder()
        Get the placeholder text, if explicitly set.
        Specified by:
        getPlaceholder in interface Placeholderable
        Returns:
        The placeholder text, if set.
      • getColumns

        public int getColumns()
        Returns:
        the width of the input field in characters.
      • setColumns

        public void setColumns​(int columns)
        Sets the width of the input field more-or-less in characters. The actual width of the input will vary from browser to browser bit will be in the region of 1.4 × columns.
        Parameters:
        columns - the number of characters to display.
      • getMinLength

        public int getMinLength()
        Returns:
        the minimum number of characters that the user can enter into the text field.
      • setMinLength

        public void setMinLength​(int minLength)

        Set the minimum number of characters that the user can enter into the text field.

        Setting the minimum number of characters will not make a field mandatory as the validation is only applied once the user has entered some text. Use AbstractInput.setMandatory(boolean) to make a field mandatory, which can be used in combination with setMinLength.

        Parameters:
        minLength - the minimum number of characters to allow.
      • getMaxLength

        public int getMaxLength()
        Returns:
        the maximum number of characters that the user can enter into the text field.
      • setMaxLength

        public final void setMaxLength​(int maxLength)
        Set the maximum number of characters that the user can enter into the text field.
        Parameters:
        maxLength - the maximum number of characters to allow.
      • setPattern

        public final void setPattern​(String pattern)
        The pattern to validate against.

        The pattern must be supported natively by your target user agent (e.g. browser).

        It is expected the WLabel for this component describes the required format of the component.

        Parameters:
        pattern - the pattern to validate against.
      • getPattern

        public String getPattern()
        Returns:
        the pattern to validate against.
      • setSuggestions

        public final void setSuggestions​(WSuggestions suggestions)
        Set the WSuggestions for this textfield.
        Parameters:
        suggestions - the WSuggestions for this textfield
      • validateComponent

        protected void validateComponent​(List<Diagnostic> diags)
        Override validateComponent to perform further validation.
        Overrides:
        validateComponent in class AbstractInput
        Parameters:
        diags - the list into which any validation diagnostics are added.
      • getComponentModel

        protected WTextField.TextFieldModel 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 WTextField.TextFieldModel 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

        protected void setAutocomplete​(String autocompleteValue)
        Set the value of the autocomplete attribute for the current field.
        Parameters:
        autocompleteValue - the value to set as a (optionally space delimited list of) String value(s).
      • 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-*
      • 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.
      • setAutocomplete

        public void setAutocomplete​(Email value)
        Description copied from interface: AutocompleteableEmail
        Set the autocomplete attribute to a specific "email" value. Currently only value "email" is supported.
        Specified by:
        setAutocomplete in interface AutocompleteableEmail
        Parameters:
        value - the auto-fill hint value
      • setAutocomplete

        public void setAutocomplete​(Url value)
        Description copied from interface: AutocompleteableURL
        Set the autocomplete attribute to a specific URL auto-fill type: "url", "impp" or "photo".
        Specified by:
        setAutocomplete in interface AutocompleteableURL
        Parameters:
        value - the auto-fill hint value
      • setAutocomplete

        public void setAutocomplete​(Telephone phone,
                                    PhoneFormat phoneType)
        Description copied from interface: AutocompleteablePhone
        Set the autocomplete attribute to an appropriate value for a particular type of phone number, in either of a full or local format.
        Specified by:
        setAutocomplete in interface AutocompleteablePhone
        Parameters:
        phone - the telephone auto-fill variant, being full (including international prefix) or local (without international prefix)
        phoneType - the type of phone to which the number belongs, for example "mobile" or "fax"
      • setPhoneSegmentAutocomplete

        public void setPhoneSegmentAutocomplete​(PhoneFormat phoneType,
                                                PhonePart phoneSegment)
        Description copied from interface: AutocompleteableText
        Set the autocomplete attribute value relevant for a specified telephone number type and segment.
        Specified by:
        setPhoneSegmentAutocomplete in interface AutocompleteableText
        Parameters:
        phoneType - the type of phone number
        phoneSegment - the phone number segment
      • setAddressAutocomplete

        public void setAddressAutocomplete​(AddressType addressType,
                                           AddressPart addressPart)
        Description copied from interface: AutocompleteableText
        Set values for the autocomplete attribute applicable to an address or part thereof.
        Specified by:
        setAddressAutocomplete in interface AutocompleteableText
        Parameters:
        addressType - the type of address being auto-filled
        addressPart - the address segment for the field