This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal



Feb 22, 2013, 8:24 AM
11 Posts

Copy URL of current xpage to system clipboard

  • Category: Managed Beans in NSF
  • Platform: All
  • Release: 8.5.3
  • Role: Developer
  • Tags:
  • Replies: 1
Hi
 
I have a requirement to allow users to create links between different xpages (which may be in different applications).
The xpage URL does not display the documentID parameter so it is not possible for the user to copy the URL and create their own link. I have provided a link button which calls a method of the backing bean to create a HTML <a> tag and copies this to the system clipboard. The user should then paste the link from their clipboard into the document that they want to link from.
 
My problem is that the java bean method seems to copy the link into a local clipboard rather than the system clipboard. If I get the clipboard contents from the same bean then it returns the html <a> tag as expected. If I paste the clipboard contents (in an xpage or other application) I get something different.
 
import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.ClipboardOwner;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.StringSelection;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
 
...Other bean stuff
 
    public void copyLinkToClipboard() {
        XSPUrl xspUrl = XSPContext.getXSPContext(FacesContext.getCurrentInstance()).getUrl();
        try {
            Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
            StringSelection link = new StringSelection("<a href=\"" + xspUrl.getAddress() + "?documentId=" + getDocument().getUniversalID() + "&action=editDocument" + "\">Document</a>");
            clipboard.setContents(link, null);
        } catch (NotesException e) {
            System.out.println(e.getMessage());
        }
    }

Anybody know what I am doing wrong ?

 
 
Feb 26, 2013, 8:50 PM
170 Posts
Re: Copy URL of current xpage to system clipboard
 A managed bean is runned on the server not on the client. 
So if you have written code that acess the clipboard in a managed bean, then your are accessing 
the server clipboard.  
 
/Fredrik 
www.xpagedeveloper.com 

This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal