Closed hertaberlin closed 4 years ago
Can you paste example XHTML please?
I found this solution at the bottom of their page: https://github.com/zenorocha/clipboard.js/issues/92
Can you paste example XHTML please?
Hey. I don't know why I can't reproduce the same behavior anymore. But it's still not working with newlines :
XHTML :
<p:commandButton id="btnCut" value="Copier dans le presse papier"
icon="fa fa-cut" styleClass="cart-button" onclick="return false;" />
<pe:clipboard id="clipboard" trigger="btnCut" action="copy"
text="#{fooManagedBean.clipboardContent}">
</pe:clipboard>
Bean :
public String getClipboardContent() {
this.clipboardContent = this.items.stream().map(Item::toString).collect(Collectors.joining(System.lineSeparator()));
return this.clipboardContent;
}
When my items list contains only one item the copy button works fine. When there's more than one line, and they're joined using System.lineSeparator(), the button doesn't copy anything at all. Using joining(System.getProperty("line.separator")) results in same behavior.
Hmm if I do this right in the page it works.
<pe:clipboard id="clipAjax"
trigger="btnAjaxCopy"
action="copy"
text="PrimeFaces Clipboard\nRocks Ajax!">
Can you look at the View Source of page and see what text is being send from your server for text="#{fooManagedBean.clipboardContent}"
When you paste do you get formatted text? Like below?
PrimeFaces Clipboard Rocks Ajax!
I doesn't work for me I get the same text copied litteraly with \n in the middle.
Hmm if I do this right in the page it works.
<pe:clipboard id="clipAjax" trigger="btnAjaxCopy" action="copy" text="PrimeFaces Clipboard\nRocks Ajax!">
Can you look at the View Source of page and see what text is being send from your server for
text="#{fooManagedBean.clipboardContent}"
<script id="calendrierForm:tabView:clipboard_s" type="text/javascript">PrimeFaces.cw("ExtClipboard",
"widget_calendrierForm_tabView_clipboard",{id:"calendrierForm:tabView:clipboard"
,action:"copy",
trigger:"calendrierForm:tabView:btnCut",
text:"Jeu [details jeu 1]
Jeu [details jeu 2]"});</script>
Edit: Sorry I dont know how to format this code but the text "Jeu [details jeu 2]"});" is on a new line.
Oh yes I get "\n" your statement above says "When there's a line break in my text only the first line gets copied." and "he button doesn't copy anything at all.".
I was getting the exact copied text with a quick test. So I think you need to be more clear about exactly what is happening.
Oh yes I get "\n" your statement above says "When there's a line break in my text only the first line gets copied." and "he button doesn't copy anything at all.".
I was getting the exact copied text with a quick test. So I think you need to be more clear about exactly what is happening.
Sorry for the confusion. I did say in my first reply that I can't reproduce the same behavior anymore.
I'm getting a new behavior today which is button not working at all when I use System.lineSeparator() in my text.
I, too, get a literal "\n" when using your code but that's not what I was hoping for.
Instead of System.lineSeparator have you tried using 

which is HTML Unicode for newline.
OK I just wrote this test and it works fine and when I copied and pasted it had the proper line break.
<pe:clipboard trigger="btnAjaxCopy" action="copy" text="#{clipboardController.lineBreaks}">
private String lineBreaks = "PrimeFaces Clipboard\nRocks Ajax!";
public String getLineBreaks() {
return lineBreaks;
}
public void setLineBreaks(final String lineBreaks) {
this.lineBreaks = lineBreaks;
}
So I can't reproduce your issue with PFE 8.0.2 and PF 8.0.
Hello. When there's a line break in my text only the first line gets copied. Any way to overcome this? Thanks