PermaLink XPages and 8.5 Discussion Template - a Fix for the File Download Control04/28/2009 07:49 AM
Domino 8.5
Many people have been asking for my help with a problem with the 8.5 Discussion template's File Download control.  The reason is that I have an example of a Custom Control for storing file attachments in a central database which uses the File Download control and has the same issue.

The issue with the File Download control in XPages is that it does not launch Microsoft attachments properly when using Internet Explorer.  The secondary issue is that it throws an exception if your database is in a subdirectory.  You can read the details here in the 8.5 Discussion forum.  

Last week Irina Kojevnikova posted a solution to the problem.  Her solution overrides the File Download control's HREF for each attachment.  

Here is a description of the solution:

On the All Properties tab for the File Download control, there is a property fileNameHrefValue which is computable.

Image:John's Blog - XPages and 8.5 Discussion Template - a Fix for the File Download Control


The JavaScript for the value computes the url for each attachment by referencing the current row using the data->var property value rowData.  As the control loops through the attachments, we can get the name of each attachment by using rowData.getName(). Now we can use the filename to build a new url for each attachment.

Image:John's Blog - XPages and 8.5 Discussion Template - a Fix for the File Download Control


The data var property is set on the All properties tab under the data section.
Image:John's Blog - XPages and 8.5 Discussion Template - a Fix for the File Download Control

The end result is a url similar to: http://localhost/TestDiscussion.nsf/0/A8364817576EF43F852575A30043E76D/%24FILE/JohnExcel.xls

One issue I could not completely resolve was that if the user attaches files and the document has not been saved yet, the new url will not work since it is using the universalID.  Most likely the person that uploads a file will not try and launch it immediately, though they might want to delete it.  So I replaced the href with "#" if it is a new document so there will not be an error message if the user clicks on the file...it will do nothing.  If anyone has a suggestion on a different approach, please let me know.

I updated the discussion8.ntf template with the fix and you can download that here: discussion8.ntf.  You will need to sign the database with a production id for use on your server, or sign the 3 custom controls I updated: mainTopic, response, and viewTopic.  I also updated my Custom Control for storing file attachments in a central database with the fix.

Thank you to Irina for putting together a solution!  Also, a special thanks to Richard Cotrim who spent some time this weekend testing the solution.

-John

Technorati:
This page has been accessed 1296 times. .
Comments :v

1. Elijah Lapson04/28/2009 01:17:53 PM


Thanks this is huge. We are rolling out the new discussion template in an alternate directory (image that) and this bug was a killer.

The code works like a charm.

Elijah




2. Jamie Jenkins04/28/2009 06:22:41 PM


I, like Elijah, had wanted to update discussion databases with the XPage template but have been unable to do so.

Hopefully this update gets back to IBM as when I opened a case about this issue it took several weeks and the server team said the only fix was for me to remove and reinstall the Domino code.....

Good work, and thanks much.




3. Edwin Liu07/20/2009 12:02:06 AM


Hi John

That's great, thank you very much.
And I'd like to ask for your help if it's impossible to set the file type limitation for file upload control. For example, only *.ODF can be chosen.

Thanks & Regards
Edwin




Search
Partner with us
Need help on your XPages projects?

Talk to the experts! Read more...
XPage Examples
By Category
About Me
Downloads
My Links
Monthly Archive
Powered by
Blogsphere
Lotus Domino ND7 RSS News Feed RSS Comments Feed Geo URL netcraft RSS Validator Lotus Geek Chris. A. Brandlehner OpenNTF BlogSphere