0
votes

I have a XPage with an data source attached to a notes document. On this XPage I have a button that calls method in a managed bean. This method retrieves a notes document from another notes database. This notes document has some attachements in a richtext field. These attachements shall be copied to my XPage.

Is there a way to achieve this?

I know how to retrieve the attachments from the notes document. But how can I attach them to my XPage?

For my task I can't use the File Upload control, because the "File Upload" should happend automaticly within my mananged bean.

I found something call AttachmentHolderValue that may fulfil my task, but unfortunately there is no documentation for this class.

1
You can copy the attechment from Document to Document, if you mean that by "These attachements shall be copied to my XPage." - Michael Saiz
No, what I meant is that I want to copy the attachemnts from a backend document to an frontend document. These are different java classes (the backend is "Document" and the frontend is "DominoDocument") - Detlef Birkholz
Ok, but what to do after you have it in the frontend? Do you want to download it or do you want to transform/work with it? I have a application where i have to split attachments from one document to seperate documents. (1 per doc) i dont do this in frontend. A other application adds a downloadable attachment form another database=>document to a view wich does not require any copying of my attachment. - Michael Saiz
In the frontend it should show up in a download control. When the frontend gets saved the copied attachements should be saved with the document. - Detlef Birkholz

1 Answers

0
votes

Ok for the donwload display you could use code like this:

<xp:this.data>
    <xp:dominoDocument var="yourNewDocument"></xp:dominoDocument>
</xp:this.data>

<xp:panel>
    <xp:this.data>
        <xp:dominoDocument ignoreRequestParam="true" var="download" action="openDocument"
            databaseName="otherDatabase" documentId="calculated">
        </xp:dominoDocument>
</xp:this.data>
    <xp:fileDownload rows="30" id="fileDownload1"
        displayLastModified="false" value="#{download.richTextItem}">
    </xp:fileDownload>
</xp:panel>

This will add you Document from the other Database as a dominoDocument dataSource wich you can use to bind a <xp:fileDownload> to.

Then you could add something to select the Attachments what you want to copy to your new Document for that i would recoment a repeatcontrol and use it like:

    <xp:repeat id="repeat1" rows="30"
        value="#{javascript:download.getAttachmentList('richTextItem');}"
        var="attachment">
    <xp:panel>
        <xp:label value="#{javascript:attachment.getName() }" id="label1"></xp:label>
        <xp:br></xp:br></xp:panel></xp:repeat>

Insted of a label you could add a checkbox and in the onSave event you can run some code wich copys the selected elements to the new Document (have to look it up in my app).

You can copy them Using NotesDocument.copyAllItems() or saving the attachments to your server disk and add them with ritem.embedObject to your new's documents richTextItem. But i recomend doing the attachment copy in backend in my expirience working with attachments can be a very tricky part.