We are developing a Vaadin application, running it on oc4j 10.1.3. There is a window, where the results of a query can be exported as a csv file. After creating the csv file as a vaadin FileResource, opening the file fails. Here is the snippet:
File file = exporter.exportToFile();
final FileResource resource = new FileResource(file, getApplication());
resource.setCacheTime(0);
resource.getStream().setParameter("Content-Disposition", "attachment;filename=\""+file.getName()+"\"");
event.getButton().getWindow().open(resource);
At this point, the resource's uri is: app://APP/1/xy.csv
We have a filter for redirecting the "/" path for "/VAADIN". When this filter gets invoked, the file's uri is /VAADIN/APP/1/xy.csv
instead of /APP/1/xy.csv
, so i'm removing the unnecessary /VAADIN part, and calling requestdispatcher.forward
with the new uri.
But here's the fun part, the application still fails, it says in the log:
Aug 13, 2012 1:55:58 PM com.vaadin.terminal.gwt.server.AbstractApplicationServlet serveStaticResourcesInVAADIN
INFO: Requested resource [VAADIN/APP/1/xy.csv] not found from filesystem or through class loader. Add widgetset and/or theme JAR to your classpath or add files to WebContent/VAADIN folder.
So the uri is wrong again. It appears in the address bar, and the application resets to the main page. However, with this uri still in the address bar, when i try to create the csv file again, doing either same of some other query in the app, the export part does give back a file, the previously generated one. If i try to do another query again (with the previous url still in the address bar of the browser), it seems to generate the new csv file, but gives back the first file again.
Is it a vaadin bug or some oc4j magic? :)