Class ClipboardContent

java.lang.Object
com.vaadin.flow.component.clipboard.ClipboardContent
All Implemented Interfaces:
Serializable

public final class ClipboardContent extends Object implements Serializable
Multi-format payload for ClipboardBinding.write(com.vaadin.flow.component.clipboard.ClipboardContent). Any combination of text/plain and text/html can be set; each accessor returns null when the corresponding slot is empty.

Use the static factory:


 Clipboard.onClick(button)
         .write(ClipboardContent.create().text("Hello").html("<b>Hello</b>"));
 
See Also:
  • Method Details

    • create

      public static ClipboardContent create()
      Creates a new empty content builder.
      Returns:
      a new builder
    • text

      public ClipboardContent text(String literal)
      Sets the plain text to be written to the clipboard.
      Parameters:
      literal - the value, not null
      Returns:
      this builder
    • text

      public <C extends Component & HasValue<?, String>> ClipboardContent text(C source)
      Sets the plain text to be written to the clipboard, taken from the value property of the given component (typically an input field). The value is read on the client when the trigger fires.
      Type Parameters:
      C - component type implementing HasValue<?, String>
      Parameters:
      source - the component whose value property should be read, not null
      Returns:
      this builder
    • html

      public ClipboardContent html(String literal)
      Sets the HTML to be written to the clipboard.
      Parameters:
      literal - the value, not null
      Returns:
      this builder