THIS
- Self-referential generic THISpublic interface FluentComposite<THIS extends FluentComposite<THIS>> extends FluentAbstractComponent<THIS>, FluentHasComponents<THIS>
Composite
Composite
FluentHasComponents.FluentComponentAttachDetachNotifier<THIS extends FluentHasComponents<THIS>>
com.vaadin.ui.HasComponents.ComponentAttachDetachNotifier, com.vaadin.ui.HasComponents.ComponentAttachEvent, com.vaadin.ui.HasComponents.ComponentAttachListener, com.vaadin.ui.HasComponents.ComponentDetachEvent, com.vaadin.ui.HasComponents.ComponentDetachListener
FluentComponent.FluentFocusable<C extends FluentComponent.FluentFocusable<C>>
com.vaadin.ui.Component.ErrorEvent, com.vaadin.ui.Component.Event, com.vaadin.ui.Component.Focusable, com.vaadin.ui.Component.Listener
com.vaadin.server.ClientConnector.AttachEvent, com.vaadin.server.ClientConnector.AttachListener, com.vaadin.server.ClientConnector.ConnectorErrorEvent, com.vaadin.server.ClientConnector.DetachEvent, com.vaadin.server.ClientConnector.DetachListener
Modifier and Type | Method and Description |
---|---|
default THIS |
withCaption(String caption)
Sets the caption of the component.
|
default THIS |
withCaption(String caption,
boolean captionAsHtml) |
default THIS |
withCaptionAsHtml(boolean captionAsHtml)
Sets whether the caption is rendered as HTML.
|
default THIS |
withComponentError(com.vaadin.server.ErrorMessage componentError)
Sets the component'THIS error message.
|
default THIS |
withDescription(String description)
Sets the component'THIS description.
|
default THIS |
withDescription(String description,
com.vaadin.shared.ui.ContentMode mode)
Sets the component's description using given content
mode . |
default THIS |
withFullHeight()
Sets the height to 100%.
|
default THIS |
withFullSize()
Sets the size to 100% x 100%.
|
default THIS |
withFullWidth()
Sets the width to 100%.
|
default THIS |
withHeight(float height,
com.vaadin.server.Sizeable.Unit unit)
Sets the height of the object.
|
default THIS |
withHeight(String height)
Sets the height of the component using String presentation.
|
default THIS |
withIcon(com.vaadin.server.Resource icon)
Sets the icon of the component.
|
default THIS |
withId(String id)
Adds an unique id for component that is used in the client-side for
testing purposes.
|
default THIS |
withPrimaryStyleName(String style)
Changes the primary style name of the component.
|
default THIS |
withSize(String width,
String height) |
default THIS |
withStyleName(String style)
Sets one or more user-defined style names of the component, replacing any
previous user-defined styles.
|
default THIS |
withStyleName(String style,
boolean add)
Adds or removes a style name.
|
default THIS |
withUndefinedHeight()
Clears any defined height
|
default THIS |
withUndefinedSize()
Clears any size settings.
|
default THIS |
withUndefinedWidth()
Clears any defined width
|
default THIS |
withWidth(float width,
com.vaadin.server.Sizeable.Unit unit)
Sets the width of the object.
|
default THIS |
withWidth(String width)
Sets the width of the component using String presentation.
|
withData, withLocale, withResponsive, withShortcutListener
withAttachListener, withDetachListener
withContextClickListener
addContextClickListener, removeContextClickListener
forEach, spliterator
withEnabled, withParent, withStyleName, withVisible
addListener, addStyleName, addStyleNames, attach, getCaption, getDescription, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getStyleName, getUI, isEnabled, isVisible, readDesign, removeListener, removeStyleName, removeStyleNames, setCaption, setEnabled, setIcon, setId, setParent, setPrimaryStyleName, setStyleName, setVisible, writeDesign
addAttachListener, addDetachListener, beforeClientResponse, detach, encodeState, getErrorHandler, getExtensions, getRpcManager, getStateType, handleConnectorRequest, isAttached, isConnectorEnabled, markAsDirty, markAsDirtyRecursive, removeAttachListener, removeDetachListener, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler
default THIS withCaption(String caption)
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.
The caption can usually also be given as the first parameter to a constructor, though some components do not support it.
RichTextArea area = new RichTextArea(); area.setCaption("You can edit stuff here"); area.setValue("<h1>Helpful Heading</h1>" + "<p>All this is for you to edit.</p>");
The contents of a caption are automatically quoted, so no raw HTML can be rendered in a caption. The validity of the used character encoding, usually UTF-8, is not checked.
The caption of a component is, by default, managed and displayed by the
layout component or component container in which the component is placed.
For example, the VerticalLayout
component shows the captions
left-aligned above the contained components, while the FormLayout
component shows the captions on the left side of the vertically laid
components, with the captions and their associated components
left-aligned in their own columns. The CustomComponent
does not
manage the caption of its composition root, so if the root component has
a caption, it will not be rendered. Some components, such as
Button
and Panel
, manage the caption themselves and
display it inside the component.
A reimplementation should call the superclass implementation.
withCaption
in interface FluentComponent<THIS extends FluentComposite<THIS>>
caption
- the new caption for the component. If the caption is
null
, no caption is shown and it does not normally
take any spaceComposite.setCaption(java.lang.String)
default THIS withIcon(com.vaadin.server.Resource icon)
An icon is an explanatory graphical label accompanying a user interface
component, usually shown above, left of, or inside the component. Icon is
closely related to caption (see setCaption()
)
and is usually displayed horizontally before or after it, depending on
the component and the containing layout.
The image is loaded by the browser from a resource, typically a
ThemeResource
.
// Component with an icon from a custom theme TextField name = new TextField("Name"); name.setIcon(new ThemeResource("icons/user.png")); layout.addComponent(name); // Component with an icon from another theme ('runo') Button ok = new Button("OK"); ok.setIcon(new ThemeResource("../runo/icons/16/ok.png")); layout.addComponent(ok);
The icon of a component is, by default, managed and displayed by the
layout component or component container in which the component is placed.
For example, the VerticalLayout
component shows the icons
left-aligned above the contained components, while the FormLayout
component shows the icons on the left side of the vertically laid
components, with the icons and their associated components left-aligned
in their own columns. The CustomComponent
does not manage the
icon of its composition root, so if the root component has an icon, it
will not be rendered.
An icon will be rendered inside an HTML element that has the
v-icon
CSS style class. The containing layout may enclose an icon
and a caption inside elements related to the caption, such as
v-caption
.
withIcon
in interface FluentComponent<THIS extends FluentComposite<THIS>>
icon
- the icon of the component. If null, no icon is shown and it
does not normally take any space.Composite.setIcon(com.vaadin.server.Resource)
default THIS withId(String id)
withId
in interface FluentComponent<THIS extends FluentComposite<THIS>>
id
- An alphanumeric idComposite.setId(java.lang.String)
default THIS withPrimaryStyleName(String style)
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.
To preserve the original style of the component when changing to a new primary style you should make your new primary style inherit the old primary style using the SASS @include directive. See more in the SASS tutorials.
withPrimaryStyleName
in interface FluentComponent<THIS extends FluentComposite<THIS>>
style
- The new primary style nameComposite.setPrimaryStyleName(java.lang.String)
default THIS withStyleName(String style)
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 Button
component and give it "mystyle
" style, the
component will have both "mystyle
" and "v-button-mystyle
"
styles. You could then style the component either with:
.myonestyle {background: blue;}
or
.v-button-myonestyle {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.
withStyleName
in interface FluentComponent<THIS extends FluentComposite<THIS>>
style
- the new style or styles of the component as a space-separated
listComposite.getStyleName()
,
Composite.addStyleName(String)
,
Composite.removeStyleName(String)
default THIS withStyleName(String style, boolean add)
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 Composite.addStyleName(String)
or
Composite.removeStyleName(String)
withStyleName
in interface FluentAbstractComponent<THIS extends FluentComposite<THIS>>
style
- the style name to be added or removedadd
- true
to add the given style, false
to remove itComposite.addStyleName(String)
,
Composite.removeStyleName(String)
default THIS withCaptionAsHtml(boolean captionAsHtml)
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.
withCaptionAsHtml
in interface FluentAbstractComponent<THIS extends FluentComposite<THIS>>
captionAsHtml
- true if the captions are rendered as HTML, false if rendered
as plain textComposite.setCaptionAsHtml(boolean)
default THIS withDescription(String description)
Component.getDescription()
for more
information on what the description is.
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.withDescription
in interface FluentAbstractComponent<THIS extends FluentComposite<THIS>>
description
- the new description string for the component.Composite.setDescription(java.lang.String)
default THIS withDescription(String description, com.vaadin.shared.ui.ContentMode mode)
FluentAbstractComponent
mode
. See
Component.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.
withDescription
in interface FluentAbstractComponent<THIS extends FluentComposite<THIS>>
description
- the new description string for the component.mode
- the content mode for the descriptionAbstractComponent.setDescription(String, ContentMode)
default THIS withComponentError(com.vaadin.server.ErrorMessage componentError)
withComponentError
in interface FluentAbstractComponent<THIS extends FluentComposite<THIS>>
componentError
- the new ErrorMessage
of the component.Composite.setComponentError(com.vaadin.server.ErrorMessage)
default THIS withHeight(String height)
withHeight
in interface FluentSizeable<THIS extends FluentComposite<THIS>>
height
- in CSS style string representationComposite.setHeight(java.lang.String)
default THIS withHeight(float height, com.vaadin.server.Sizeable.Unit unit)
withHeight
in interface FluentSizeable<THIS extends FluentComposite<THIS>>
height
- the height of the object.unit
- the unit used for the width.Composite.setHeight(float, com.vaadin.server.Sizeable.Unit)
default THIS withWidth(String width)
withWidth
in interface FluentSizeable<THIS extends FluentComposite<THIS>>
width
- in CSS style string representation, null or empty string to
resetComposite.setWidth(java.lang.String)
default THIS withWidth(float width, com.vaadin.server.Sizeable.Unit unit)
withWidth
in interface FluentSizeable<THIS extends FluentComposite<THIS>>
width
- the width of the object.unit
- the unit used for the width.Composite.setWidth(float, com.vaadin.server.Sizeable.Unit)
default THIS withFullSize()
withFullSize
in interface FluentSizeable<THIS extends FluentComposite<THIS>>
Composite.setSizeFull()
default THIS withFullWidth()
withFullWidth
in interface FluentSizeable<THIS extends FluentComposite<THIS>>
default THIS withFullHeight()
withFullHeight
in interface FluentSizeable<THIS extends FluentComposite<THIS>>
default THIS withUndefinedSize()
withUndefinedSize
in interface FluentSizeable<THIS extends FluentComposite<THIS>>
Composite.setSizeUndefined()
default THIS withUndefinedWidth()
withUndefinedWidth
in interface FluentSizeable<THIS extends FluentComposite<THIS>>
Composite.setWidthUndefined()
default THIS withUndefinedHeight()
withUndefinedHeight
in interface FluentSizeable<THIS extends FluentComposite<THIS>>
Composite.setHeightUndefined()
default THIS withSize(String width, String height)
withSize
in interface FluentSizeable<THIS extends FluentComposite<THIS>>
default THIS withCaption(String caption, boolean captionAsHtml)
withCaption
in interface FluentAbstractComponent<THIS extends FluentComposite<THIS>>
Copyright © 2017 Jean-Christophe Fortier. All rights reserved.