• Settings
    • Locale
    • Change the locale of the datepicker, schedule and client side validation messages.

      Language
      English
      English
      English
      French
      German
      German
      German
      Italian
      Korean
      Spanish
      Catalan
      Dutch
      Portuguese
      Portuguese
      Arabic
      Arabic
      Bulgarian
      Bangla
      Bosnian
      Czech
      Greek
      Estonian
      Persian
      Finnish
      Danish
      Hindi
      Indonesian
      Icelandic
      Croatian
      Japanese
      Hungarian
      Hebrew
      Georgian
      Central Kurdish
      Khmer
      Kyrgyz
      Kazakh
      Lithuanian
      Latvian
      Malay
      Norwegian
      Polish
      Romanian
      Russian
      Slovak
      Slovenian
      Serbian
      Serbian
      Swedish
      Thai
      Turkish
      Ukrainian
      Uzbek
      Vietnamese
      Chinese
      Chinese
  • Resources

Clipboard

Clipboard copies or cuts text to the OS clipboard. It shouldn't be hard and it shouldn't require dozens of steps to configure or hundreds of KBs to load, and it doesn't depend on Flash or any bloated framework. Based on Clipboard.js by Zeno Rocha.

Clipboard Tag Documentation

Clipboard provides copy/cut to clipboard functionality for text or elements.

NameTypeRequiredDefaultDescription
id String false generated Unique identifier of the component in a namingContainer.
rendered boolean false true Boolean value to specify the rendering of the component, when set to false component will not be rendered.
binding UIComponent false generated An EL expression referring to a server side UIComponent instance in a backing bean.
widgetVar String false generated ('widget_' + componentClientId) Name of the client side widget.
action String false copy Clipboard action: 'copy' or 'cut'.
onerror String false Client-side callback when the copy/cut action fails.
onsuccess String false Client-side callback when the copy/cut action succeeds.
target String false Search expression for the element whose content is copied/cut.
text String false PrimeFaces Rocks! Text to copy when no target is specified.
trigger String true Search expression for the element that triggers the clipboard action.
Tag Documentation Widget Source
Basic Usage

A pe:clipboard can have a fixed text or point to a text component with target. The success and error events are sent to the server. Clipboard can be used in menu options too: right click the page background to show the context menu.

Copy
Cut
Right click me to view the menu options!

Usage


<div class="card">
    <h5>Basic Usage</h5>
    <p>A <code>pe:clipboard</code> can have a fixed <code>text</code> or point to a text component with <code>target</code>.
        The <i>success</i> and <i>error</i> events are sent to the server. Clipboard can be used in menu options too: right click the
        page background to show the context menu.</p>
    <h:form id="formBasicUsage">
        <p:growl id="growl" showDetail="true" showSummary="true">
            <p:autoUpdate/>
        </p:growl>

        <h:panelGrid columns="4">
            <h:outputText value="Copy"/>
            <p:inputText id="txtCopy" value="#{clipboardController.copyInput}"/>
            <p:commandButton id="btnCopy" value="Copy" icon="pi pi-copy"/>
            <pe:clipboard id="clipCopy" trigger="btnCopy" action="copy" target="txtCopy">
                <p:ajax event="success" listener="#{clipboardController.successListener}"/>
                <p:ajax event="error" listener="#{clipboardController.errorListener}"/>
            </pe:clipboard>

            <h:outputText value="Cut"/>
            <p:inputText id="txtCut" value="#{clipboardController.cutInput}"/>
            <p:commandButton id="btnCut" value="Cut" icon="pi pi-clipboard"/>
            <pe:clipboard id="clipCut" trigger="btnCut" action="cut" target="txtCut">
                <p:ajax event="success" listener="#{clipboardController.successListener}"/>
                <p:ajax event="error" listener="#{clipboardController.errorListener}"/>
            </pe:clipboard>
        </h:panelGrid>

        <h:panelGroup layout="block" style="text-align:left;margin:10px;">
            <p:commandButton id="btnAjaxCopy" value="Ajax Copy" icon="pi pi-copy" onclick="return false;"/>
            <pe:clipboard id="clipAjax" trigger="btnAjaxCopy" action="copy" text="#{clipboardController.lineBreaks}">
                <p:ajax event="success" listener="#{clipboardController.successListener}"/>
                <p:ajax event="error" listener="#{clipboardController.errorListener}"/>
            </pe:clipboard>

            <p:button id="btnNonAjax" value="Non-Ajax Copy" icon="pi pi-copy" href="#"/>
            <pe:clipboard id="clipNonAjax" trigger="btnNonAjax" action="copy" text="PrimeFaces Clipboard Rocks Without Ajax!"
                          onsuccess="alert('Action: ' + this.action + ' Text:' + this.text);"
                          onerror="alert('Action: ' + this.action + ' FAILED!');"/>
        </h:panelGroup>

        <h:panelGroup layout="block" style="text-align:left;margin:10px;">
            <h:outputText id="lblRightClick">Right click me to view the menu options!</h:outputText>

            <p:contextMenu>
                <p:menuitem id="mnuCopy" value="Copy" url="javascript:void(0);" icon="pi pi-copy"/>
            </p:contextMenu>

            <pe:clipboard id="clipContextCopy" trigger="mnuCopy" action="copy" text="#{clipboardController.copyInput}">
                <p:ajax event="success" listener="#{clipboardController.successListener}"/>
                <p:ajax event="error" listener="#{clipboardController.errorListener}"/>
            </pe:clipboard>
        </h:panelGroup>
    </h:form>
</div>