Class WPhoneNumberField

    • Constructor Detail

      • WPhoneNumberField

        public WPhoneNumberField()
    • Method Detail

      • 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
      • 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 phone field's text for a specific user.
        Returns:
        the phone field's text for the given context.
      • setText

        public void setText​(String text)
        Sets the text value to be shown in the input field.
        Parameters:
        text - the text to display.
      • 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 in characters.
        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 phone number field.
      • setMinLength

        public final void setMinLength​(int minLength)
        Set the minimum number of characters that the user can enter into the phone number 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 phone number field.
      • setMaxLength

        public final void setMaxLength​(int maxLength)
        Set the maximum number of characters that the user can enter into the phone number 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.
      • getAutocomplete

        public String getAutocomplete()
        Specified by:
        getAutocomplete in interface Autocompleteable
        Returns:
        the value of the autocomplete attribute applied to the current field.
      • 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"
      • 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-*
      • validateComponent

        protected void validateComponent​(List<Diagnostic> diags)
        Override validateComponent to perform further validation.

        Override WComponent's validatorComponent in order to use the validators which have been added to this input field. Subclasses may still override this method, but it is suggested to call super.validateComponent to ensure that the validators are still used.

        Overrides:
        validateComponent in class AbstractInput
        Parameters:
        diags - the list into which any validation diagnostics are added.
      • setSuggestions

        public final void setSuggestions​(WSuggestions suggestions)
        Set the WSuggestions for this phone number field.
        Parameters:
        suggestions - the WSuggestions for this phone number field
      • 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.
      • getComponentModel

        protected WPhoneNumberField.PhoneFieldModel 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 WPhoneNumberField.PhoneFieldModel 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