Problem with download link in 'appendToResponse'
Problem with download link in 'appendToResponse'
- Subject: Problem with download link in 'appendToResponse'
- From: Juergen Lorenz Simon <email@hidden>
- Date: Wed, 25 Apr 2012 17:06:59 +0200
Hi,
I'm trying to generate some file content on the fly and return it when the user clicks a link. I'm doing this in a D2W context, the component is a propoerty level component. I had some success by overwriting appendToResponse like so:
public void appendToResponse(com.webobjects.appserver.WOResponse response, WOContext context) { if ( shouldDownloadFile )
String fileName = "generated.properties";
String contentType = "text/ascii";
response.setHeader( contentType + "; name=\"" + fileName + "\"", "Content-Type" );
response.setHeader( "attachment; filename=\"" + fileName + "\"", "Content-Disposition");
String content = this.configuration(); response.setContent( content );
} else { super.appendToResponse( response, context ); } }
The flag 'shouldDownloadFile' is set to true when the link contained in the component is clicked (normal action binding).
However, instead of only the generated content, I also get some other generated HTML in the file. Does somebody know what the problem is?
Kind Regards, J.L.Simon
|
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden