Hi,
I have formatted using stringBuilder and finally i am trying to add JavaScript.getCurrent().execute(“window.clipboardData.setData(‘Text’,” +stringBuilder.toString()+“)”);
But it was not working.
Don’t bum your post so often. Don’t expect to always have an answer after a day.
Are you sure that Javascript code works even, or whether you may need another JS library for it?
I tested it by making a simple html file with this JS code and no browser could process it window.clipboardData is undefined.
Hi, what exactly do you mean by “aligned”? What is the expected result, and what is the actual result? I’m afraid we can’t help you without more information.
I have data in StringBuilder like: I have already formated using \t and \n in Java. I want to output to be ClipBoard.
I am using Vaadin7. But We have addon only Vaadin6. So I tried to use above concept. But not able to integrate vaadin with Javascript. Please look at my below code whici would be helpful.
I have one button "
CopyToClipBoard " When I click that button. The Above format should be copied and when I click on CTRL+V same will be pasted in WordDocument.
I wrote the following test UI that seems to work fine (tried with IE 11, pasted to WordPad):
public class ClipboardTest extends UI {
@Override
protected void init(VaadinRequest request) {
setContent(new Button("Click here", new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
StringBuilder sb = new StringBuilder();
// note that we don't use \t and \n directly because
// the newlines would result in incorrect javascript
sb.append("FOO\\tBAR\\tBAZ\\n");
sb.append("1\\t2\\t3\\n");
sb.append("4\\t5\\t6\\n");
StringBuilder js = new StringBuilder();
js.append("var controlValue = '");
js.append(sb.toString());
js.append("';window.clipboardData.setData('Text', controlValue);");
JavaScript.getCurrent().execute(js.toString());
}
}));
}
}