Re: DocumentHandler

Esteban Maringolo <[email protected]> Tue, 2 Jun 2020 08:47:12 -0300
Newsgroups gmane.comp.lang.smalltalk.squeak.seaside
Message-ID <CAJMgPC+Ys7LA9q8z+z-hxK8tysn5uLa6HzWm3MMZFcUQ2NZt-Q@mail.gmail.com>
If instead of setting a callback on an anchor, you set a document, it
will be treated slightly different.

E.g.

You can do something like:

html anchor
  document: documentContents mimeType:  ( Seaside.WAMimeType main:
'application' sub: 'pdf' ) fileName: 'YourFile.pdf';
  with: 'Download PDF'

This will be handled differently to a regular action continuation of a
callback and will trigger the download immediately, also the document
will be returned as a response to never expire.

In some cases you want to use `document:` and in others it could be
more flexible to use a regular `respond:` from the
WACurrentRequestContext (e.g. if the decision on the file format or
other things are deep down in the logic, away from the anchor).

E.g.

WACurrentRequestContext value respond: [:response |
  response
    attachmentWithFileName: self exportedFilename , '.pdf';
    doNotCache;
    contentType: ( Seaside.WAMimeType main: 'application' sub: 'pdf' );
    binary;
    nextPutAll: pdfContents;
    respond
]

Or directly pass an instance of WAMimeDocument to the response.

WACurrentRequestContext value respond: [:response |
  response document: aWAMimeDocument
]

Best regards,

Esteban A. Maringolo

On Tue, Jun 2, 2020 at 6:20 AM Annick Fron <[email protected]> wrote:
>
> Hi, I would like to serve a custom dynamically generated PDF file, what is the best option ? Use a DocumentHandler ?
> If yes how ?
>
> Annick
> _______________________________________________
> seaside mailing list
> [email protected]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
_______________________________________________
seaside mailing list
[email protected]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside