You can have a D2W component with a link to downloadable content, but that link 
needs to return a component that only vends the downloadable file. At least 
that's the way I've done always.
Create an empty component (does not need any html, just the .java and .api) and 
place the appendToResponse code on that component.

HG


On Apr 25, 2012, at 4:06 PM, Juergen Lorenz Simon wrote:

> 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 protected])
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/webobjects-dev/lists%40farol.pt
> 
> This email sent to [email protected]


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to