Tapestry: Redirect-after-post messing my StreamResponse in onSuccess() -


After uploading the file to a user, I read the file, processed it and received a CSV (stream response) Sent back I am facing problems getting back the results. In the firebug I see the post response as '302 temporarily taken' and my page does not show the streaming file again, it loads again I think tapestry redirect-post-post send me the file back streaming Instead of reloading the page. Is this happening? How can it be fixed?

This is my code:

(only by cutting the body)

  @log stream Response onsut () throws IOException {file tmpFile = File.createTempFile (urlFile.getFileName (), blank); BufferedWriter br = new BufferedWriter (new FileWriter (tmpFile)); Br.append ("The second line to test" is something to test) ;; Br.flush (); Br.close (); New CsvStreamResponse (new FileInputStream (tmpFile.getAbsolutePath ()), "results_file" Return;} public class implements CsvStreamResponse StreamResponse {private InputStream; private String filename; public CsvStreamResponse (the InputStream, string filename) is {this.is = ; This.filename = filename;} public string getContentType () {return "text / csv";} public input stream GetStream () that throws IOException {return;} public void prepare Rispons (North response) {response.setHeader ( "content -Web "," Attachment; File No " In = "+ filename +" .csv ");}}   

My TML

  & lt; Form t: type = "form" t: id = "analysis" & gt; & lt; t: upload t: id = "urlFile" class = "margin right" valid = "required" />  : Submit class = "marginRight white button medium" value = "$ {message: button. Upload}" t: id = "upload" />    < / Div> 

I have never done that, from where you get a stream from

StreamResponse a form handler legal situation if you ask me if it's possible should be there. By checking the API, you will see that there is a setStatus (int sc) method in the response I have not tested it, but if you change your prepareResponse () method to the following , so it should work:
  public void ready response (response) {response.setStatus (HttpServletResponse.SC_OK); Response.setHeader ("content-dispute", "attachment; file name =" + file name + ".csv"); }   

Disclaimer: I have not tried to do it myself.

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -