File download from another database with xpages

Hi,

I have an xpage with a document datasource that is bound to a document in another database. Opening and editing works fine except when I use the file download control to display attachments, then I get an Error 500 HTTP Web Server: Command Not Handled Exception (the default error page is not used to display the error, although I have it checked in the aplication properties and it is displayed with other errors).

The URL that is generated to open the attachment looks a bit strange:

http://servername/path/db_with_xpage.nsf/xsp/.ibmmodres/domino/OpenAttachment/db_with_attachment.nsf/0FACE686E0BCD5A8C125732B002AA021/Body/John%20Doe.doc

Funny thing is when I create a second attachment it works fine and it uses a URL that looks like:

http://servername/path/db_with_xpage.nsf/xsp/.ibmmodres/persistence/DominoDoc-19-Body/John%20Doe.doc

When I try to experiment some more I get too confused with the results to make anything out of it. Sometimes all attachment-links seem to work when I open a document and then nothing seems to work or something inbetween. The first attachment I create on a document always creates an error when I try to open it. It doesn’t seem to mather if i create the attachments with the notes client or with a file upload control on the xpage.

I have tried with attachments in the same database and then it works fine.

When it was just opening attachments I could probably create some links using @attachmentNames, but I also want the users to be able to delete the attachments and I don’t think the %%Detach checkbox will work on a xpage (haven’t tried it though). And besides when it works it is a really nice control, so if someone knows a way I can maybe program the FileNameHrefValue property with the proper URL that would be a great help.

Rene.

Subject: Saw this error in the Discussion Database Template as well

See these posts:

http://www-10.lotus.com/ldd/nd85forum.nsf/DateAllThreadedWeb/16ba5c36bb5d0dd785257558006fafa8?OpenDocument

and

http://www-10.lotus.com/ldd/nd85forum.nsf/DateAllThreadedWeb/4880d93741490ff58525755400839508?OpenDocument

The best I can make out is that it is an issue with the file download “core control”.

Hopefully someone who has access to submits a PMR or bug report or whatever it is called.

Elijah

Subject: program fileNameHrefValue property

After struggling with the control for a few hours, I found a workaround.

First problem - the attachment links aren’t generated properly for databases that are located in a subfolder of the DATA folder (the subfolder name is missing in the URL).

Workaround - to move database to the root.

Second problem - after resolving first issue, I found that any Word and Excel attachments don’t open properly in IE. IE treats those attachments as html and opens in the browser with all data mixed with tags etc. PDF and jpegs were fine.

The same attachments work just fine if referenced the old way.

Here is an example of URL from Download control:

http://servername/path/db_with_xpage.nsf/xsp/.ibmmodres/domino/OpenAttachment/db_with_attachment.nsf/0FACE686E0BCD5A8C125732B002AA021/Body/John%20Doe.doc

and the old way:

http://servername/path/db_with_xpage.nsf/0/0FACE686E0BCD5A8C125732B002AA021/$FILE/John%20Doe.doc

The FileDownload control has two properties similar to the repeat control:

var and indexVar.

The first one (var) is a request scope attribute under which a row data is made available.

So basically it references the object that is repeated in the FileDownload control (FileRowData).

This FileRowData object has a property we can use - “getName()” which returns the file name.

So the fileNameHrefValue property can now be computed:

“0/” + dominoDocument1.getDocument().getUniversalID() + “/$FILE/” +rowData.getName()

where rowData is the variable name that was assigned for the FileDownload control var attribute.

<xp:fileDownload id=“downloadOtherDocumentation” displayLastModified=“false”

value=“#{dominoDocument1.lnkOtherDocumentation}”

hideWhen=“true” displayCreated=“false”

allowDelete=“true”

displaySize=“true” displayType=“false” var=“rowData”

indexVar=“rowIndex”>

xp:this.fileNameHrefValue<![CDATA[#{javascript:try{

return “0/” + dominoDocument1.getDocument().getUniversalID() + “/$FILE/” +rowData.getName()

}catch (e) {

}}]]>

</xp:this.fileNameHrefValue>

</xp:fileDownload>

It solves both problems, but has some limitations - doesn’t allow to have two files with the same name.

Hope this helps.

Irina

Subject: Investigating…

Hi Rene,Thank you for the details to your query which I’m investigating. I will post another reply when I’ve finished.

regards,

Paul.

Subject: Any news about your investigation?

Subject: Worked for me, or am I missing something…

Hi,I created 2 new applications to test this out. The first created from the discussion8 template (with the ACL wide open), and the second a blank application.

In the second app, I created two XPages (see markup below). The first contains two action buttons (one to create a new document and the other to delete selected documents in the view panel), and a view panel which uses the $All View from discussion application, the first app, as a data source.

On the second XPage, I’ve bound it to the Main Topic form on the other application and included within the XPages is the file upload and download controls both bound to the ‘body’ field in the data source.

At runtime, I’m able to create new documents with attachments. Delete these attachments in edit mode. And view existing attachments in documents created in the client.

So it all seems to work or am I missing something real obvious?

Regards,

Paul.

1st XPage (p01)

<?xml version="1.0" encoding="UTF-8"?>

<xp:view xmlns:xp=“http://www.ibm.com/xsp/core”>

<xp:button value="New" id="button1">

	<xp:eventHandler event="onclick" submit="true"

		refreshMode="complete">

		<xp:this.action>

			<xp:openPage name="/p02.xsp" target="newDocument"></xp:openPage>

		</xp:this.action>

	</xp:eventHandler>

</xp:button>

<xp:button value="Del" id="button2">

	<xp:eventHandler event="onclick" submit="true"

		refreshMode="complete">

		<xp:this.action>

			<xp:deleteSelectedDocuments view="viewPanel1"

				message="Del?"></xp:deleteSelectedDocuments>

		</xp:this.action>

	</xp:eventHandler>

</xp:button>

<xp:viewPanel rows="30" id="viewPanel1" pageName="/p02.xsp">

	<xp:this.facets>

		<xp:pager layout="Previous Group Next" xp:key="headerPager"

			id="pager1">

		</xp:pager>

	</xp:this.facets>

	<xp:this.data>

		<xp:dominoView var="all" databaseName="b090211a.nsf"

			viewName="($All)">

		</xp:dominoView>

	</xp:this.data>

	<xp:viewColumn columnName="Date" id="viewColumn1">

		<xp:viewColumnHeader value="Date" id="viewColumnHeader1"></xp:viewColumnHeader>

	</xp:viewColumn>

	<xp:viewColumn columnName="Topic" id="viewColumn2"

		showCheckbox="true" displayAs="link" openDocAsReadonly="true">

		<xp:viewColumnHeader value="Topic" id="viewColumnHeader2"

			showCheckbox="true"></xp:viewColumnHeader>

	</xp:viewColumn>

</xp:viewPanel>

</xp:view>

2nd XPage (p02)

<?xml version="1.0" encoding="UTF-8"?>

<xp:view xmlns:xp=“http://www.ibm.com/xsp/core”>

<xp:this.data>

	<xp:dominoDocument var="document1" databaseName="b090211a.nsf"

		formName="MainTopic" computeWithForm="onsave">

	</xp:dominoDocument>

</xp:this.data>

<xp:button value="save" id="button1">

	<xp:eventHandler event="onclick" submit="true"

		refreshMode="complete">

		<xp:this.action>

			<xp:save name="/p01.xsp"></xp:save>

		</xp:this.action>

	</xp:eventHandler>

</xp:button>

<xp:button value="edit" id="button2">

	<xp:eventHandler event="onclick" submit="true"

		refreshMode="complete">

		<xp:this.action>

			<xp:changeDocumentMode mode="edit"></xp:changeDocumentMode>

		</xp:this.action>

	</xp:eventHandler>

</xp:button>

<xp:button value="cancel" id="button3">

	<xp:eventHandler event="onclick" submit="true"

		refreshMode="complete" immediate="true" save="false">

		<xp:this.action>

			<xp:openPage name="/p01.xsp"></xp:openPage>

		</xp:this.action>

	</xp:eventHandler>

</xp:button>

<xp:table>

	<xp:tr>

		<xp:td>

			<xp:label value="Subject:" id="Subject_Label1" for="Subject1">

			</xp:label>

		</xp:td>

		<xp:td>

			<xp:inputText value="#{document1.Subject}" id="Subject1">

			</xp:inputText>

		</xp:td>

	</xp:tr>

</xp:table>

<xp:table>

	<xp:tr>

		<xp:td>

			<xp:label value="Categories:" id="Categories_Label1" for="Categories1">

			</xp:label>

		</xp:td>

		<xp:td>

			<xp:inputText value="#{document1.Categories}" id="Categories1">

			</xp:inputText>

		</xp:td>

	</xp:tr>

</xp:table>

<xp:table>

	<xp:tr>

		<xp:td>

		</xp:td>

		<xp:td>

			

		<xp:fileUpload id="fileUpload1" value="#{document1.Body}"></xp:fileUpload>

		</xp:td>

	</xp:tr>

	<xp:tr>

		<xp:td></xp:td>

		<xp:td>

			<xp:fileDownload rows="30" id="fileDownload1"

				displayLastModified="false" value="#{document1.Body}" allowDelete="true"></xp:fileDownload>

		</xp:td>

	</xp:tr>

</xp:table>

<xp:inputRichText id="inputRichText1" value="#{document1.Body}"></xp:inputRichText>

</xp:view>

Subject: Repeated your test without success

Hello Paul,

Thank you very much for your efforts. I repeated your test and created a new blank application with two xpages and copied your source-code in them. The only adjustment I made was pointing the view-datasource in p01 and the document datasource in p02 to the discussion database on our server.

Then I created a new discussion item with an attachment, opened the new document, held my breath and clicked on the attachmentlink… and bursted into tears because all i saw was “Error 500 HTTP Web Server: Command Not Handled Exception”.

This is the URL that was generated:

http://servername/dmt/xpages/playaround.nsf/xsp/.ibmmodres/domino/OpenAttachment/discussion.nsf/DE49A67B09C32FB0C125755C004F6B20/Body/John%20Doe.doc

http://servername/dmt/xpages/playaround.nsf is the new blanc application, discussion.nsf is in the same directory.

The server is version 8.5 HF1 on Windows 2003.

I created several more attachments and new documents in Firefox and Internet Explorer but this time I didn’t manage to create even 1 working link.

I checked to be sure there is a default view in both databases. Both ACL’s are open (default manager access).

I can’t think of anything more that can cause this, but I’ll be happy to try out any suggestions you might have.

Thanks again for your trouble.

Regards,

Rene.

Subject: The same file link error

Hi Paul,

I’m facing the exact same problem at a customer site. The URL’s that the fileupload control generates are very weird, but you can get to the attachments by changing the URL’s to something like:

http://server/path/database.nsf/0//$file/<FILEATTACHMENTNAME.EXTENSION>

For your reference they are running:

  • Microsoft Windows Server 2003

  • WITHOUT the Internet Sites configuration

  • Using SSO and LTPAToken’s

Subject: Server crashes

When users click on images or other attachments in the discussion forum they are linked to the following URL syntax:

http://server/path/database.nsf/xsp/.ibmmodres/domino/OpenAttachment/database.nsf//Body/<FILENAME.EXTENSION>

This generates the following log entries on the server:

HTTP JVM: SEVERE: CLFAD####E: Exception thrown

HTTP JVM: SEVERE: CLFAD####E: Exception occurred servicing request for:

http://server/path/database.nsf/xsp/.ibmmodres/domino/OpenAttachment/database.nsf//Body/<FILENAME.EXTENSION>

HTTP Web Server: Command Not Handled Exception

http://server/path/database.nsf/xsp/.ibmmodres/domino/OpenAttachment/database.nsf//Body/<FILENAME.EXTENSION>

Hope this can help further investigating the issue which means one or two daily restarts of the server :frowning:

Subject: Are you using XPages?

We have seen this issue with certain XPages applications and have reported it to IBM and have an open SPR for it.

Regards,

Bruce

http://elguji.com

Subject: Yes - we are using XPages

The error occurs in the default Domino 8.5 Discussion database with no modifications at all :-/

Do you have the SPR# ?

Subject: Same problem here

I am having the same issue described above

Subject: Any news about your investigation, Paul?

Paul did your investigation get you any further in the progress of finding out what the problem is?

Our customer have several discussion databases that we have taken offline after a successfull introduction to the employees. This is of big frustration and they really, really want to know if a solution is on the way or if they should switch to another solution for discussions.

Subject: Same problem with File Download icontrol…

I have the same problem…

I move the database from a subfolder to the root Data folder, and it works to open de files… It works with .PDF, JPG…

But, it doesn`t open word or excel files with their application(Microsoft Word or Microsoft Excel), it shows a lot of characters as follow:

ÐÏࡱá>þÿ lnþÿÿÿijkÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿì¥Á€ ø¿Ybjbj õ õ 7hŸhŸYÿÿÿÿÿÿ·RR™™™™™ÿÿÿÿ­­­­ ¹ ­…fÅÅÅÅÅ   $뢍>™     ™™ÅÅÛ?ÌÌÌ ™Å™ÅÌ ÌÌÌÅÿÿÿÿ°T!N#É­¶ÌðU0…ÌËÌËÌË™Ì$  Ì     Ì   … …

Subject: is it a bug?

Subject: Any one solve this?

I have the same issue. App #1 showing document with attachment from App #2. the URL to the attachment is wrong. If I fix the path to the attachment in the url it works fine.I am using 8.5.2 Fp3.

What it generates:

Should have been:

Note: my document and attachments was all done in notes client not XPages

Subject: Found a workaround

Look here for what appears to be a good work around for the problem where the document with the attachment is in a different db than the XPage that displays it.