com.vaadin.ui.

Class AbstractTextField

    • Constructor Detail

      • AbstractTextField

        protected AbstractTextField()

        Creates a new instance.

    • Method Detail

      • getMaxLength

        public int getMaxLength()

        Returns the maximum number of characters in the field. Value -1 is considered unlimited. Terminal may however have some technical limits.

        Returns:

        the maxLength

      • setMaxLength

        public void setMaxLength​(int maxLength)

        Sets the maximum number of characters in the field. Value -1 is considered unlimited. Terminal may however have some technical limits.

        Parameters:

        maxLength - the maxLength to set

      • getPlaceholder

        public String getPlaceholder()

        Returns the current placeholder text.

        Returns:

        the placeholder text

        See Also:

        setPlaceholder(String)

      • setPlaceholder

        public void setPlaceholder​(String placeholder)

        Sets the placeholder text. The placeholder is text that is displayed when the field would otherwise be empty, to prompt the user for input.

        Parameters:

        placeholder - the placeholder text to set

        Since:

        8.0

      • getValue

        public String getValue()

        Description copied from interface: HasValue

        Returns the current value of this object.

        Implementation note: the implementing class should document whether null values may be returned or not.

        Specified by:

        getValue in interface HasValue<String>

        Returns:

        the current value

      • selectAll

        public void selectAll()

        Selects all text in the field.

        As a side effect the field will become focused.

      • setSelection

        public void setSelection​(int start,
                                 int length)

        Sets the range of text to be selected.

        As a side effect the field will become focused.

        Parameters:

        start - the position of the first character to be selected

        length - the number of characters to be selected

      • setCursorPosition

        public void setCursorPosition​(int pos)

        Sets the cursor position in the field. As a side effect the field will become focused.

        Parameters:

        pos - the position for the cursor

      • getCursorPosition

        public int getCursorPosition()

        Returns the last known cursor position of the field.

        Returns:

        the last known cursor position

      • readDesign

        public void readDesign​(org.jsoup.nodes.Element design,
                               DesignContext designContext)

        Description copied from interface: Component

        Reads the component state from the given design.

        The component is responsible not only for updating its own state but also for ensuring that its children update their state based on the design.

        It is assumed that the component is in its default state when this method is called. Reading should only take into consideration attributes specified in the design and not reset any unspecified attributes to their defaults.

        This method must not modify the design.

        Specified by:

        readDesign in interface Component

        Overrides:

        readDesign in class AbstractField<String>

        Parameters:

        design - The element to obtain the state from

        designContext - The DesignContext instance used for parsing the design

      • getState

        protected AbstractTextFieldState getState()

        Description copied from class: AbstractComponent

        Returns the shared state bean with information to be sent from the server to the client. Subclasses should override this method and set any relevant fields of the state returned by super.getState().

        Overrides:

        getState in class AbstractField<String>

        Returns:

        updated component shared state

      • doSetValue

        protected void doSetValue​(String value)

        Description copied from class: AbstractField

        Sets the value of this field. May do sanitization or throw IllegalArgumentException if the value is invalid. Typically saves the value to shared state.

        Specified by:

        doSetValue in class AbstractField<String>

        Parameters:

        value - the new value of the field

      • writeDesign

        public void writeDesign​(org.jsoup.nodes.Element design,
                                DesignContext designContext)

        Description copied from interface: Component

        Writes the component state to the given design.

        The component is responsible not only for writing its own state but also for ensuring that its children write their state to the design.

        This method must not modify the component state.

        Specified by:

        writeDesign in interface Component

        Overrides:

        writeDesign in class AbstractField<String>

        Parameters:

        design - The element to write the component state to. Any previous attributes or child nodes are not cleared.

        designContext - The DesignContext instance used for writing the design