Joined: 17/Aug/2011 10:08:42
we are severely struggeling with implementing a smooth error handling wit ace:dynamicResource.
Our case is, that we present the user a list of (quite huge) files loadable from a remote server. The user can download individual files.
When starting the transfer in getInputStream() there may occur various network errors or the file may have been deleted in the meantime Thus we would like to react positively and show an error message to the user.
We have identified various options:
[list]When an error occurs, we would like to return an input stream with an HTML-encoded error message. This would also require to return the contenttype "text/html". However the method getContentType() is already called for each resource, during rendering the list of files.
[list]The other option would be, to set Status 302 and add an redirect to an error page in getInputStream(). Is this a valid option, or would this interfere with other output handling?
Both solutions fail because the method getContentType(), getHeaders(), etc. are already called for each resource, during rendering the list of files. I have no idea, why this is necessary. At that point in time, we have no chance to check the availability of the input stream.
If we can be sure that these methods are called, only just before the output of the resource, we could store the result of the getInputStream() and take approiate action.