I need to add an ‘export’ function to an existing web app using seam. The purpose is to export search results to a csv file. I have no problem generating a csv, but I do not know how the send the csv back to the user.
I do not want to store the csv on the server because that would be waisted storage space. How could I achieve this in jboss seam?
I need to add an ‘export’ function to an existing web app using seam.
Share
Use the Document Store Servlet provided by Seam.
Almost copying and pasting from the reference doc, declare the servlet in
web.xmllike this:Then create a
export.xhtmlfile with only<s:resource>tag:Generate link for downloading the file in your page with
<s:download>:Finally, implement
getCsvData()andgetCsvFileName()methods in your component:Note that
<s:download>propagates conversation (unless you setpropagation=none). If you propagate the conversation context probably you won’t need to pass any parameter. For large data set it may be preferable to not propagate the conversation and pass parameter to select the data in a request scoped component.