Class Share

java.lang.Object
org.vaadin.firitin.util.Share

@Deprecated(since="3.6", forRemoval=true) public class Share extends Object
Deprecated, for removal: This API element is subject to removal in a future version.
Vaadin 25.2 ships a native Web Share API, com.vaadin.flow.component.webshare.WebShare. Arm sharing with WebShare.onClick(button).share(content, onSuccess, onError) (once at construction, within the user-gesture window) and build the payload with ShareContent.create().title(..).text(..).url(..); feature detection is via WebShare.supportSignal().

Migration caveat: this Viritin Share has a built-in fallback for browsers without the API (notably Firefox desktop), configurable via setFirefoxFallbackNotification(Runnable). The native WebShare has no built-in fallback — you must handle the UNSUPPORTED case yourself via WebShare.supportSignal() so the fallback behavior is not silently lost.

A simple wrapper for the Web Share API. Allows sharing text and URLs quickly via OS native share dialog, if the browser supports the Web Share (~ all but FF).

On Firefox (which does not support the Web Share API), it falls back to copying the text and URL to the clipboard and showing a notification on the screen.

See also: https://developer.mozilla.org/en-US/docs/Web/API/Web_Share_API

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final record 
    Deprecated, for removal: This API element is subject to removal in a future version.
    Part of the deprecated Share helper.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Deprecated, for removal: This API element is subject to removal in a future version.
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    setFirefoxFallbackNotification(Runnable firefoxFallbackNotification)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Sets the action executed when the Web Share API is not supported (e.g. on Firefox).
    static com.vaadin.flow.component.page.PendingJavaScriptResult
    share(String title, String text, String url)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Share a link using the Web Share API.
    static com.vaadin.flow.component.page.PendingJavaScriptResult
    share(String title, String text, URI url)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Share a link using the Web Share API.
    static com.vaadin.flow.component.page.PendingJavaScriptResult
    Deprecated, for removal: This API element is subject to removal in a future version.
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Share

      public Share()
      Deprecated, for removal: This API element is subject to removal in a future version.
  • Method Details

    • setFirefoxFallbackNotification

      public static void setFirefoxFallbackNotification(Runnable firefoxFallbackNotification)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Sets the action executed when the Web Share API is not supported (e.g. on Firefox). By default, it shows a notification that the URL has been copied to clipboard. Use e.g. to show a custom message.
      Parameters:
      firefoxFallbackNotification - the action to execute when the Web Share API is not supported.
    • share

      public static com.vaadin.flow.component.page.PendingJavaScriptResult share(String title, String text, URI url)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Share a link using the Web Share API.
      Parameters:
      title - The title of the document being shared. May be ignored by the target.
      text - Arbitrary text that forms the body of the message being shared.
      url - A URL string referring to a resource being shared.
    • share

      public static com.vaadin.flow.component.page.PendingJavaScriptResult share(String title, String text, String url)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Share a link using the Web Share API.
      Parameters:
      title - The title of the document being shared. May be ignored by the target.
      text - Arbitrary text that forms the body of the message being shared.
      url - A URL string referring to a resource being shared.
    • share

      public static com.vaadin.flow.component.page.PendingJavaScriptResult share(Share.ShareData data)
      Deprecated, for removal: This API element is subject to removal in a future version.