• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Problem with download link in 'appendToResponse'
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: Problem with download link in 'appendToResponse'
      • From: Henrique Gomes <email@hidden>
  • Prev by Date: Re: ERModernDirectToWeb and ERXEditingContextDelegate
  • Next by Date: Re: ERModernDirectToWeb and ERXEditingContextDelegate
  • Previous by thread: Re: ERModernDirectToWeb and ERXEditingContextDelegate
  • Next by thread: Re: Problem with download link in 'appendToResponse'
  • Index(es):
    • Date
    • Thread