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
AbstractComponent interface in
framework 7 and 8. Implementing class must be a Component.-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface com.vaadin.featurepack.server.ClientConnector
ClientConnector.AttachEvent, ClientConnector.AttachListener, ClientConnector.DetachEvent, ClientConnector.DetachListenerNested classes/interfaces inherited from interface com.vaadin.featurepack.server.FAbstractClientConnector
FAbstractClientConnector.LegacyMethodEvent -
Method Summary
Modifier and TypeMethodDescriptiondefault com.vaadin.flow.shared.RegistrationAdds a context click listener that gets notified when a context click happens.default com.vaadin.flow.shared.RegistrationaddListener(Listener listener) Registers a new (generic) component event listener for the component.default com.vaadin.flow.shared.RegistrationaddShortcutListener(ShortcutListener listener) default voidaddStyleName(String style) Adds one or more style names to the classic component.default voidaddStyleNames(String... styles) Adds one or more style names to this classic component by using one or multiple parameters.default voidbeforeClientResponse(boolean initial) Called before the response is written to client side.default StringGets the caption of the component.default ErrorMessageGets the component's error message.getCustomStyles(com.vaadin.flow.component.Component component) default ObjectgetData()Gets the application specific data.default StringGets the components description, used in tooltips and can be displayed directly in certain other components such as forms.default com.vaadin.flow.component.ComponentGet the error indicator component for this component.default ErrorMessageGets the error message for this component in Vaadin 7/8 way.default StringgetFId()Gets currently set element id, aka debug identifier in Vaadin 7/8.default HasComponentsGets the parent component of the component if it is instance of feature-pack specificHasComponents.default com.vaadin.flow.component.ComponentgetIcon()Gets the icon component of the component.default ResourceGets the icon resource of the component in Vaadin 7/8 style.getInternalStyles(com.vaadin.flow.component.Component component) default StringGets the primary style name of the classic component.default StringGets all user-defined CSS style names of a classic component.default booleanChecks whether captions are rendered as HTMLdefault booleanReturns the immediate mode of the component.default booleanReturns true if the component is responsivedefault voidThis method is executed when a style name is added or removed, mainly used to mark the parent as dirty.default voidRemoves a context click listener that was previously added with addContextClickListener(ContextClickEvent.default voidremoveShortcutListener(ShortcutListener listener) default voidremoveStyleName(String style) Removes one or more style names from the classic component.default voidremoveStyleNames(String... styles) Removes one or more style names from the classic component.default voidsetCaption(String caption) Sets the caption of the component.default voidsetCaptionAsHtml(boolean captionAsHtml) Sets whether the caption is rendered as HTML.default voidsetComponentError(ErrorMessage componentError) Sets the component's error message.default voidSets the data object, that can be used for any application specific data.default voidsetDescription(String description) Sets the component's description.default voidsetDescription(String description, ContentMode mode) Sets the component's description using given contentmode.default voidsetIcon(com.vaadin.flow.component.icon.Icon icon) Sets the component's icon component.default voidsetIcon(com.vaadin.flow.component.icon.IconFactory icon) Sets the component's icon component.default voidsetIconResource(Resource icon) Sets the component's icon resource in Vaadin 7/8 style.default voidsetImmediate(boolean immediate) Sets the component's immediate mode to the specified status.static voidsetInternalStyles(com.vaadin.flow.component.Component component, List<String> customStyles) default voidsetLabelComponent(com.vaadin.flow.component.Component labelComponent) Sets the component's label component.default voidSets the locale of this component.default voidsetPrimaryStyleName(String style) Changes the primary style name of the classic component.default voidsetResponsive(boolean responsive) Toggles responsiveness server state of this component.default voidsetStyleName(String style) Sets one or more user-defined style names of the classic component, replacing any previous user-defined styles.default voidsetStyleName(String style, boolean add) Adds or removes a style name.Methods inherited from interface com.vaadin.featurepack.server.FAbstractClientConnector
addLegacyAttachListener, addLegacyDetachListener, addListener, addListener, attach, detach, doConnectorOnAttach, doConnectorOnDetach, fireEvent, fireEvent, getAllChildrenIterable, getFListeners, getFlowComponent, getResource, hasListeners, isAttached, isConnectorEnabled, markAsDirty, markAsDirtyRecursive, removeAttachListener, removeDetachListener, removeListener, removeListener, setResourceMethods inherited from interface com.vaadin.featurepack.server.FSizeable
getFHeight, getFWidth, getHeightUnits, getWidthUnits, setHeight, setHeight, setHeightFull, setHeightUndefined, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFull, setWidthUndefinedMethods inherited from interface com.vaadin.flow.component.HasElement
getElementMethods inherited from interface com.vaadin.flow.component.HasEnabled
bindEnabled, isEnabled, setEnabled
-
Method Details
-
getFId
Gets currently set element id, aka debug identifier in Vaadin 7/8. Same as callingComponent.getId().- Returns:
- debug identifier
-
getFParent
Gets the parent component of the component if it is instance of feature-pack specificHasComponents. For FLow layouts, call getParent().orElse(null).- Specified by:
getFParentin interfaceClientConnector- Returns:
- the parent component
-
beforeClientResponse
default void beforeClientResponse(boolean initial) Description copied from interface:ClientConnectorCalled 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
initialisfalsewhen the component is attached again to a newUIwhenPreserveOnRefreshis used.- Specified by:
beforeClientResponsein interfaceClientConnector- Specified by:
beforeClientResponsein interfaceFAbstractClientConnector- Parameters:
initial-trueif the client-side connector will be created and initialized after this method has been invoked.falseif there is already an initialized client-side connector.
-
addListener
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
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
Gets the application specific data. SeesetData(Object).- Returns:
- the Application specific data set with setData function.
-
setLocale
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
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
Gets the caption of the component.See
setCaption(String)for a detailed description of the caption.- Returns:
- the caption of the component or
nullif 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 HTMLThe 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
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
Sets the component's description. SeegetDescription()for more information on what the description is.- Parameters:
description- the new description string for the component.- See Also:
-
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
nullif the component has no icon - See Also:
-
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
nullif 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
Sets the component's icon resource in Vaadin 7/8 style.- Parameters:
icon- the icon to be shown with the component's caption.
-
getCustomStyles
-
getInternalStyles
-
setInternalStyles
-
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
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
Labelcomponent 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
Adds or removes a style name. Multiple styles can be specified as a space-separated list of style names.If the
addparameter is true, the style name is added to the component. If theaddparameter is false, the style name is removed from the component.Functionally this is equivalent to using
addStyleName(String)orremoveStyleName(String)- Parameters:
style- the style name to be added or removedadd-trueto add the given style,falseto remove it- See Also:
-
addStyleName
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
Labelcomponent 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
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
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()orsetStyleName()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
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
Gets the primary style name of the classic component. SeesetPrimaryStyleName(String)for a better description of the primary stylename. -
setPrimaryStyleName
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
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
Gets the component's error message.- Returns:
- the component's error message.
-
setComponentError
Sets the component's error message. The message may contain certain XML tags, for more information see- Parameters:
componentError- the newErrorMessageof the component.
-
getFErrorIndicator
default com.vaadin.flow.component.Component getFErrorIndicator()Get the error indicator component for this component.- Returns:
- the error indicator component
-
addShortcutListener
-
removeShortcutListener
-
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
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:
-