3

Do you have any idea how can I use xp:fileDownload control in a xp:repeat control ?

I binded xp:repeat control to view. So I am available to get NotesViewEntry per line.

But I didnt get attachments using var variable in xp:fileDownload control.

I placed xp:repeat in xp:panel and created data document in panel object. I placed fileDownload control inside this panel. And binded document data source to fileDownload.

Not worked !

Have an idea ?

I have 10 documents and every document has one more attachment. I want to show these files using filedownload control.

<xp:this.data>
<xp:dominoView var="viewReviews" viewName="vwLookupGoruslerHepsi"></xp:dominoView>
</xp:this.data>

<xp:repeat id="repeat1" value="#{viewReviews}" var="viewEntry">
<xp:table style="width:100%;border:1px solid #ddd;margin-bottom:5px;"
    cellpadding="2">
    <xp:tr valign="top">
        <xp:td rowspan="5" style="width:250px">
            <xp:text id="computedField9" tagName="h4" escape="true">
                <xp:this.value><![CDATA[#{viewEntry["GorusBildirecek_CN"]}]]></xp:this.value>
            </xp:text>
        </xp:td>
    </xp:tr>
    <xp:tr valign="top">
        <xp:td>
            <xp:panel id="panelGorusEkler">
                <xp:this.data>
                    <xp:dominoDocument var="docGorus" formName="frmGorus"
                        action="openDocument" documentId="#{javascript:viewEntry.getNoteID()}">
                    </xp:dominoDocument>
                </xp:this.data>
                <xp:text escape="true" id="computedField1"
                    value="#{docGorus.GorusBildiren_OU1_NAME}">
                </xp:text>
                <xp:fileDownload rows="30" id="fileDownload3"
                    var="rowFile" indexVar="rowIndex" value="#{docGorus.Ekler}">
                </xp:fileDownload>
            </xp:panel>
        </xp:td>
    </xp:tr>
</xp:table>
</xp:repeat>

Thanks

Alternative Solution fileDownloadLinks in xp:repeat Control

Alternative way to solve this need.

I added a column which includes @AttachmentNames values. (Column Name : $Ekler)

<xp:tr valign="top">
<xp:this.rendered><![CDATA[#{!empty viewEntry["$Ekler"]}]]></xp:this.rendered>
<xp:td>
    <xp:repeat id="repeat2" value="#{viewEntry.$Ekler}" var="embeddedFile">
        <xp:link escape="true" id="link1" style="margin-right:10px">
            <xp:this.text><![CDATA[#{javascript:var aSizes:Array = ['bytes', 'KB', 'MB', 'GB', 'TB', 'PB'];
            var embedFile:NotesEmbeddedObject = viewEntry.getDocument().getAttachment(embeddedFile);
            var calcnr:Number = Math.floor(Math.log(embedFile.getFileSize())/Math.log(1024));
            var fSize = (embedFile.getFileSize()/Math.pow(1024, Math.floor(calcnr))).toFixed(2)+" "+ aSizes[calcnr];
            return embedFile.getName() + " (" + fSize + ")"}]]></xp:this.text>
            <xp:this.value><![CDATA[#{javascript:"/" + facesContext.getExternalContext().getRequestContextPath() + "/xsp/.ibmmodres/domino/OpenAttachment/" + facesContext.getExternalContext().getRequestContextPath() + "/" + viewEntry.getDocument().getUniversalID() + "/Ekler/" + embeddedFile;}]]></xp:this.value>
        </xp:link>
    </xp:repeat>
</xp:td>

  • Is Ekler a RichText field? Are the attachments in there? – stwissel Nov 01 '12 at 17:14
  • You could hand-craft your links: http://www.wissel.net/blog/d6plinks/SHWL-86QKNM (but you would need to take care of the icons yourself: http://stackoverflow.com/questions/1298518/where-can-i-find-good-mimetype-icons – stwissel Nov 01 '12 at 17:19
  • Maybe your attachments are not stored in the richtext item – Thomas Adrian Nov 02 '12 at 06:11
  • @Wissel; Ekler is Rich-Text item I am sure :) and has two attachments. I created custom file listing using html techniques and looks like that. (not used fileDownload) -> http://www.bestcoder.net/wp-content/uploads/2012/11/Ekler.png By the way, If I can use fileDownload, It will be simplest. Attachments are in RichText element. Images (http://www.bestcoder.net/wp-content/uploads/2012/11/Ekler2.png -- http://www.bestcoder.net/wp-content/uploads/2012/11/Ekler3.png) – BestCoder.NET Nov 02 '12 at 07:58

1 Answers1

1

If you're using a dominoDocument datasource, I'm pretty sure you'll need to set ignoreRequestParam="true" if you're passing a documentId in. Otherwise it looks to the query string parameter. Then the file download should work.

For the second option, is the column set to show multiple values as separate entries? If the repeat is receiving a comma-delimited string value, it won't work: repeats expect a collection, not a single string. Check to make sure your columnValues() property of the NotesViewEntry is multi-value. Even then, I'd expect it to fail if there's only one attachment.

Rather than using a column value, pass the repeat the NotesEmbeddedObject collection retrieved directly from viewEntry.getDocument(). Each element in your repeat will then be a NotesEmbeddedObject.

Paul Stephen Withers
  • 15,699
  • 1
  • 15
  • 33
  • ignoreRequestParam="true" parameter is solved the problem about fileDownload control. simple but perfect :) Thanks Paul. – BestCoder.NET Nov 03 '12 at 03:25