Interface FAbstractComponent

All Superinterfaces:
ClientConnector, FAbstractClientConnector, FSizeable, com.vaadin.flow.component.HasElement, com.vaadin.flow.component.HasEnabled, Serializable
All Known Subinterfaces:
FAbstractTextField
All Known Implementing Classes:
AbsoluteLayout, AbstractComponent, AbstractComponentContainer, AbstractField, AbstractLayout, AbstractOrderedLayout, AbstractSingleComponentContainer, CssLayout, CustomComponent, CustomField, FButton, FCheckBox, FComboBox, FDateField, FGrid, FImage, FListSelect, FMenuBar, FormLayout, FPasswordField, FTabSheet, FTextArea, FTextField, FTokenField, FTwinColSelect, GridLayout, HorizontalLayout, Label, Panel, Table, VerticalLayout

@CssImport("./tooltip.css") @CssImport("./errors.css") public interface FAbstractComponent extends FAbstractClientConnector, FSizeable, com.vaadin.flow.component.HasEnabled, Serializable
An interface for legacy components. In addition to its own legacy API, introduces the API from the legacy AbstractComponent interface in framework 7 and 8. Implementing class must be a Component.
  • Method Details

    • getFId

      default String getFId()
      Gets currently set element id, aka debug identifier in Vaadin 7/8. Same as calling Component.getId().
      Returns:
      debug identifier
    • getFParent

      default HasComponents getFParent()
      Gets the parent component of the component if it is instance of feature-pack specific HasComponents. For FLow layouts, call getParent().orElse(null).
      Specified by:
      getFParent in interface ClientConnector
      Returns:
      the parent component
    • beforeClientResponse

      default void beforeClientResponse(boolean initial)
      Description copied from interface: ClientConnector
      Called before the response is written to client side. Gives the legacy connector an opportunity to set computed/dynamic state values.

      This is implemented for the legacy components to keep consistent behavior and e.g. legaze size calculations working.

      NOTE: the parameter initial is false when the component is attached again to a new UI when PreserveOnRefresh is used.

      Specified by:
      beforeClientResponse in interface ClientConnector
      Specified by:
      beforeClientResponse in interface FAbstractClientConnector
      Parameters:
      initial - true if the client-side connector will be created and initialized after this method has been invoked. false if there is already an initialized client-side connector.
    • addListener

      default com.vaadin.flow.shared.Registration addListener(Listener listener)
      Registers a new (generic) component event listener for the component.
       class Listening extends CustomComponent implements Listener {
           // Stored for determining the source of an event
           Button ok;
      
           Label status; // For displaying info about the event
      
           public Listening() {
               VerticalLayout layout = new VerticalLayout();
      
               // Some miscellaneous component
               TextField name = new TextField("Say it all here");
               name.addListener(this);
               layout.addComponent(name);
      
               // Handle button clicks as generic events instead
               // of Button.ClickEvent events
               ok = new Button("OK");
               ok.addListener(this);
               layout.addComponent(ok);
      
               // For displaying information about an event
               status = new Label("");
               layout.addComponent(status);
      
               setCompositionRoot(layout);
           }
      
           public void componentEvent(Event event) {
               // Act according to the source of the event
               if (event.getSource() == ok)
                   getWindow().showNotification("Click!");
      
               status.setValue(
                       "Event from " + event.getSource().getClass().getName()
                               + ": " + event.getClass().getName());
           }
       }
      
       Listening listening = new Listening();
       layout.addComponent(listening);
       
      Parameters:
      listener - the new Listener to be registered.
      Returns:
      a registration object for removing this listener
      See Also:
    • setData

      default void setData(Object data)
      Sets the data object, that can be used for any application specific data. The component does not use or modify this data.
      Parameters:
      data - the Application specific data.
    • getData

      default Object getData()
      Gets the application specific data. See setData(Object).
      Returns:
      the Application specific data set with setData function.
    • setLocale

      default void setLocale(Locale locale)
      Sets the locale of this component.
       // Component for which the locale is meaningful
       InlineDateField date = new InlineDateField("Datum");
      
       // German language specified with ISO 639-1 language
       // code and ISO 3166-1 alpha-2 country code.
       date.setLocale(new Locale("de", "DE"));
      
       date.setResolution(DateField.RESOLUTION_DAY);
       layout.addComponent(date);
       
      Parameters:
      locale - the locale to become this component's locale.
    • setCaption

      default void setCaption(String caption)
      Sets the caption of the component.

      A caption is an explanatory textual label accompanying a user interface component, usually shown above, left of, or inside the component. Icon (see setIcon() is closely related to caption and is usually displayed horizontally before or after it, depending on the component and the containing layout.

      Parameters:
      caption - the new caption for the component.
    • setLabelComponent

      default void setLabelComponent(com.vaadin.flow.component.Component labelComponent)
      Sets the component's label component. Flow components that support caption component usually overrides this.
      Parameters:
      labelComponent - the new label component for the component.
    • getCaption

      default String getCaption()
      Gets the caption of the component.

      See setCaption(String) for a detailed description of the caption.

      Returns:
      the caption of the component or null if the caption is not set.
      See Also:
    • setCaptionAsHtml

      default void setCaptionAsHtml(boolean captionAsHtml)
      Sets whether the caption is rendered as HTML.

      If set to true, the captions are rendered in the browser as HTML and the developer is responsible for ensuring no harmful HTML is used. If set to false, the caption is rendered in the browser as plain text.

      The default is false, i.e. to render that caption as plain text.

      Parameters:
      captionAsHtml - true if the captions are rendered as HTML, false if rendered as plain text
    • isCaptionAsHtml

      default boolean isCaptionAsHtml()
      Checks whether captions are rendered as HTML

      The default is false, i.e. to render that caption as plain text.

      Returns:
      true if the captions are rendered as HTML, false if rendered as plain text
    • getDescription

      default String getDescription()

      Gets the components description, used in tooltips and can be displayed directly in certain other components such as forms. The description can be used to briefly describe the state of the component to the user. The description string may contain HTML:

      Returns:
      component's description String
    • setDescription

      default void setDescription(String description)
      Sets the component's description. See getDescription() for more information on what the description is.
      Parameters:
      description - the new description string for the component.
      See Also:
    • setDescription

      default void setDescription(String description, ContentMode mode)
      Sets the component's description using given content mode. See getDescription() for more information on what the description is.

      If the content mode is ContentMode.HTML the description is displayed as HTML in tooltips or directly in certain components so care should be taken to avoid creating the possibility for HTML injection and possibly XSS vulnerabilities.

      Parameters:
      description - the new description string for the component.
      mode - the content mode for the description
    • getIcon

      default com.vaadin.flow.component.Component getIcon()
      Gets the icon component of the component. Returns Component type to be compatible with Flow Button component.

      See setIcon(Icon) for a detailed description of the icon.

      Returns:
      the icon component of the component or null if the component has no icon
      See Also:
    • getIconResource

      default Resource getIconResource()
      Gets the icon resource of the component in Vaadin 7/8 style.

      See setIconResource(Resource) for a detailed description of the icon.

      Returns:
      the icon resource of the component or null if the component has no icon
      See Also:
    • setIcon

      default void setIcon(com.vaadin.flow.component.icon.Icon icon)
      Sets the component's icon component.
      Parameters:
      icon - the icon to be shown with the component's caption.
    • setIcon

      default void setIcon(com.vaadin.flow.component.icon.IconFactory icon)
      Sets the component's icon component.
      Parameters:
      icon - the icon to be shown with the component's caption.
    • setIconResource

      default void setIconResource(Resource icon)
      Sets the component's icon resource in Vaadin 7/8 style.
      Parameters:
      icon - the icon to be shown with the component's caption.
    • getCustomStyles

      static List<String> getCustomStyles(com.vaadin.flow.component.Component component)
    • getInternalStyles

      static List<String> getInternalStyles(com.vaadin.flow.component.Component component)
    • setInternalStyles

      static void setInternalStyles(com.vaadin.flow.component.Component component, List<String> customStyles)
    • getStyleName

      default String getStyleName()
      Gets all user-defined CSS style names of a classic component. If the component has multiple style names defined, the return string is a space-separated list of style names. Built-in style names defined in Vaadin or GWT are not returned.

      The style names are returned only in the basic form in which they were added; each user-defined style name shows as two CSS style class names in the rendered HTML: one as it was given and one prefixed with the component-specific style name. Only the former is returned.

      Returns:
      the style name or a space-separated list of user-defined style names of the component
      See Also:
    • setStyleName

      default void setStyleName(String style)
      Sets one or more user-defined style names of the classic component, replacing any previous user-defined styles. Multiple styles can be specified as a space-separated list of style names. The style names must be valid CSS class names and should not conflict with any built-in style names in Vaadin or GWT.
       Label label = new Label("This text has a lot of style");
       label.setStyleName("myonestyle myotherstyle");
       

      Each style name will occur in two versions: one as specified and one that is prefixed with the style name of the component. For example, if you have a Label component and give it "mystyle" style, the component will have both "mystyle" and "v-label-mystyle" styles. You could then style the component either with:

       .mystyle {background: blue;}
       

      or

       .v-label-mystyle {background: blue;}
       

      It is normally a good practice to use addStyleName() rather than this setter, as different software abstraction layers can then add their own styles without accidentally removing those defined in other layers.

      Parameters:
      style - the new style or styles of the component as a space-separated list
      See Also:
    • setStyleName

      default void setStyleName(String style, boolean add)
      Adds or removes a style name. Multiple styles can be specified as a space-separated list of style names.

      If the add parameter is true, the style name is added to the component. If the add parameter is false, the style name is removed from the component.

      Functionally this is equivalent to using addStyleName(String) or removeStyleName(String)

      Parameters:
      style - the style name to be added or removed
      add - true to add the given style, false to remove it
      See Also:
    • addStyleName

      default void addStyleName(String style)
      Adds one or more style names to the classic component. Multiple styles can be specified as a space-separated list of style names. The style name will be rendered as a HTML class name, which can be used in a CSS definition.
       Label label = new Label("This text has style");
       label.addStyleName("mystyle");
       

      Each style name will occur in two versions: one as specified and one that is prefixed with the style name of the component. For example, if you have a Label component and give it "mystyle" style, the component will have both "mystyle" and "v-label-mystyle" styles. You could then style the component either with:

       .mystyle {font-style: italic;}
       

      or

       .v-label-mystyle {font-style: italic;}
       
      Parameters:
      style - the new style to be added to the component
      See Also:
    • addStyleNames

      default void addStyleNames(String... styles)
      Adds one or more style names to this classic component by using one or multiple parameters.
      Parameters:
      styles - the style name or style names to be added to the component
      See Also:
    • removeStyleName

      default void removeStyleName(String style)
      Removes one or more style names from the classic component. Multiple styles can be specified as a space-separated list of style names.

      The parameter must be a valid CSS style name. Only user-defined style names added with addStyleName() or setStyleName() can be removed; built-in style names defined in Vaadin or GWT can not be removed.

      Parameters:
      style - the style name or style names to be removed
      See Also:
    • removeStyleNames

      default void removeStyleNames(String... styles)
      Removes one or more style names from the classic component. Multiple styles can be specified by using multiple parameters.
      Parameters:
      styles - the style name or style names to be removed
      See Also:
    • getPrimaryStyleName

      default String getPrimaryStyleName()
      Gets the primary style name of the classic component. See setPrimaryStyleName(String) for a better description of the primary stylename.
    • setPrimaryStyleName

      default void setPrimaryStyleName(String style)
      Changes the primary style name of the classic component.

      The primary style name identifies the component when applying the CSS theme to the Component. By changing the style name all CSS rules targeted for that style name will no longer apply, and might result in the component not working as intended.

      Parameters:
      style - The new primary style name
    • notifyParentAboutStyleChanges

      default void notifyParentAboutStyleChanges()
      This method is executed when a style name is added or removed, mainly used to mark the parent as dirty. The default implementation marks the parent as dirty if it's an AbstractOrderedLayout.
    • setImmediate

      default void setImmediate(boolean immediate)
      Sets the component's immediate mode to the specified status.

      Shows warning in log about unsupported feature if called with false. Client-side acts always as if it was set to true.

      Parameters:
      immediate - the boolean value specifying if the component should be in the immediate mode after the call.
    • isImmediate

      default boolean isImmediate()
      Returns the immediate mode of the component.

      Certain operations such as adding a value change listener will set the component into immediate mode if setImmediate(boolean) has not been explicitly called with false.

      setImmediate shows warning in log about unsupported feature if called with false. Client-side acts always as if it was set to true.

      Returns:
      true if the component is in immediate mode (explicitly or implicitly set), false if the component is not in immediate mode
    • getFErrorMessage

      default ErrorMessage getFErrorMessage()
      Gets the error message for this component in Vaadin 7/8 way. Renamed to getFErrorMessage to avoid conflicts with Flow API.
      Returns:
      ErrorMessage containing the description of the error state of the component or null, if the component contains no errors. Extending classes should override this method if they support other error message types such as validation errors or buffering errors. The returned error message contains information about all the errors.
    • getComponentError

      default ErrorMessage getComponentError()
      Gets the component's error message.
      Returns:
      the component's error message.
    • setComponentError

      default void setComponentError(ErrorMessage componentError)
      Sets the component's error message. The message may contain certain XML tags, for more information see
      Parameters:
      componentError - the new ErrorMessage of the component.
    • getFErrorIndicator

      default com.vaadin.flow.component.Component getFErrorIndicator()
      Get the error indicator component for this component.
      Returns:
      the error indicator component
    • addShortcutListener

      default com.vaadin.flow.shared.Registration addShortcutListener(ShortcutListener listener)
    • removeShortcutListener

      default void removeShortcutListener(ShortcutListener listener)
    • addContextClickListener

      default com.vaadin.flow.shared.Registration addContextClickListener(ContextClickEvent.ContextClickListener listener)
      Adds a context click listener that gets notified when a context click happens.
      Parameters:
      listener - the context click listener to add
      Returns:
      a registration for the listener
    • removeContextClickListener

      default void removeContextClickListener(ContextClickEvent.ContextClickListener listener)
      Removes a context click listener that was previously added with addContextClickListener(ContextClickEvent. ContextClickListener).
      Parameters:
      listener - the listener to remove
    • setResponsive

      default void setResponsive(boolean responsive)
      Toggles responsiveness server state of this component. Feature-pack does nothing on client side. Responsive V7/8 CSS syntax like .foo[width-range~="500px-"] is not supported. Use CSS container queries instead .
      Parameters:
      responsive - boolean enables responsiveness server state, false disables
    • isResponsive

      default boolean isResponsive()
      Returns true if the component is responsive
      Returns:
      true if the component is responsive
      See Also: