1

Closed

Returning fileattachments from actions that accept parameters

description

Hi

Returning file attachments from actions that accept parameter(s) does not work. Returning file attachments from actions that take no parameters works as expected, the user being prompted to open or save the attachment i.e. a Word doc.

When an action that returns a FileAttachment and takes a parameter (e.g. string, enum) is selected, the UI initially displays the old style embedded dialog. After a small delay the screen then jumps to the application home page where, after another small delay, it displays the expected popup dialog.

Once this is ok'd, a blank screen with what looks like the action signature with the required parameters populated is displayed.

Inspecting using firebug returns the following error when attempting to return a fileattachment

Error message: TypeError: response.match is not a function
URL: http://localhost/Scripts/NakedObjects-Ajax.js
Line Number: 466

Thanks
Closed Mar 21, 2014 at 3:30 PM by RichardPawson

comments

RichardPawson wrote Dec 16, 2013 at 10:08 AM

There are two issues here.
  • The first is clearly a bug: it should be possible to return a FileAttachment from an action that takes params. ( I have confirmed the behaviour you describe - and that it is not a browser-specific issue).
  • The second ...
the UI initially displays the old style embedded dialog. After a small delay the screen then jumps to the application home page where, after another small delay, it displays the expected popup dialog
This is very ugly but - at this point - is the correct behaviour of the framework. At present, File Attachments are handled by the server delegating back to the browser, hence the brief switch out of Ajax mode, then back in. We don't like this either!

We have done some work (as part of the Spiro project) on a better way to handle File Attachments. We should really look at how to bring that capability back into NO MVC and get rid of this ugly switching behaviour altogether. It probably makes sense for us to do that before fixing the bug (actions with params) as the latter might just disappear with that new approach.

scascarini wrote Jan 14, 2014 at 8:22 AM

Reworked to use HTML5/Blobs for file upload and download.

Currently works - UI needs further refinement.