Directory

← Back

JSClipboard Add-on

JSClipboard is an JS extension for Vaadin 7+ that allow to copy arbitrary text to clipboard using JavaScript only.

Author

Rating

Popularity

100+

This JavaScript extension allows copy any text to user clipboard without need to use flash integration.

Sample code

final JSClipboard clipboard = new JSClipboard();

final TextField textField = new TextField();
textField.setSizeFull();
textField.setValue("Copy to clipboard textfield value....");
textField.setId("tocopie-textfield");

Button b = new Button("Copy to clipboard");
clipboard.apply(b,area);
clipboard.addSuccessListener(new JSClipboard.SuccessListener() {

	@Override
	public void onSuccess() {
		Notification.show("Copy to clipboard successful");
	}
});
		
clipboard.addErrorListener(new JSClipboard.ErrorListener() {

	@Override
	public void onError() {
		Notification.show("Copy to clipboard unsuccessful", Notification.Type.ERROR_MESSAGE);
	}
});  
final TextField textField = new TextField();
		textField.setSizeFull();
		textField.setValue("Copy to clipboard textfield value....");
		textField.setId("tocopie-textfield");

        JSClipboardButton b = new JSClipboardButton(area,"Copy to clipboard");
        b.addSuccessListener(new JSClipboard.SuccessListener() {

            @Override
            public void onSuccess() {
                Notification.show("Copy to clipboard successful");
            }
        });
        b.addErrorListener(new JSClipboard.ErrorListener() {

            @Override
            public void onError() {
                Notification.show("Copy to clipboard unsuccessful", Notification.Type.ERROR_MESSAGE);
            }
        });
final JSClipboard clipboard = new JSClipboard();

		final Grid grid = new Grid(Person.class);
		grid.setSizeFull();
		grid.setHeightMode(HeightMode.ROW);
		grid.setHeightByRows(3);
		grid.setItems(Arrays.asList(new Person("Arthur", 12),new Person("Esther", 44),new Person("Ulises", 109)));
		grid.setId("tocopie-grid");

		Button b = new Button("Copy to clipboard");
		clipboard.apply(b,area);
		clipboard.addSuccessListener(new JSClipboard.SuccessListener() {

			@Override
			public void onSuccess() {
				Notification.show("Copy to clipboard successful");
			}
		});
		clipboard.addErrorListener(new JSClipboard.ErrorListener() {

			@Override
			public void onError() {
				Notification.show("Copy to clipboard unsuccessful", Notification.Type.ERROR_MESSAGE);
			}
		});  

Compatibility

(Loading compatibility data...)

Was this helpful? Need more help?
Leave a comment or a question below. You can also join the chat on Discord or ask questions on StackOverflow.

Version

Fix some issues reported and performing a correct release to Vaadin maven repository

Released
2018-01-18
Maturity
STABLE
License
Apache License 2.0

Compatibility

Framework
Vaadin 7.4+
Vaadin 8.0+
Vaadin 6.0+ in 0.0.1-SNAPSHOT
Browser
Firefox
Google Chrome
Internet Explorer
Internet Explorer
Internet Explorer

JSClipboard Add-on - Vaadin Add-on Directory

JSClipboard is an JS extension for Vaadin 7+ that allow to copy arbitrary text to clipboard using JavaScript only. JSClipboard Add-on - Vaadin Add-on Directory
This JavaScript extension allows copy any text to user clipboard without need to use flash integration.
Online