[Seaside] WAComponent and HTML Emails?

Philippe Marschall philippe.marschall at gmail.com
Sat Aug 11 09:44:36 UTC 2007


2007/8/10, Ramon Leon <ramon.leon at allresnet.com>:
> > I've rendered components to feed our PDF generator, sounds
> > like it would be similar to just get the HTML back. You'll
> > need to add a bit of context yourself, as this is ripped
> > straight out of the system, see last line there in #renderPDF
> > that would be the string you need.
> >
> >
> > Hope this helps,
> >
> > -Boris
>
> Yup, looks good (only works in 2.8), though I think this should be something
> that's easy to get to.  What about something like this added to WAComponent
> to allow printString and asString on any WAComponent?
>
> WARenderHandler>>context: aContext
>         context := aContext
>
> WAComponent>>printOn: aStream
>     "setup a fake rendering context and response so I can render myself to a
> stream for asString and printString"
>     | response handler |
>     handler := WARenderHandler root: self.
>     response := WAResponse new.
>     "had to create set accessor for context"
>     handler context: (WARenderingContext new session: WACurrentSession
> value;
>                  actionUrl: WAUrl new;
>                  yourself).
>     handler processRendering: response.
>     aStream nextPutAll: response contents contents
>
> Lukas, Phillip, any objection to me committing this?  It would become really
> easy to get the rendered html for any component, so you could do things like
> this...

We have this functionality already in several places:
Comet: one time
RSRSS: 4 times
Seaside Tests: 2 times

In most of these cases it it's more general and allows you to render
any kind of renderable object, in most cases a render block. So I'd
prefer something like one or two convenience methods in WARenderCanvas
that can used to render a full html page or the body content only.

Cheers
Philippe

> SomePage>>renderContentOn: html
>     html anchor
>         callback:[self emailPage: self printString];
>         text: 'email me this page'.
>
> SomePage>>emailMe: aPageHtml
>     SeasidePlatformSupport
>         deliverMailFrom: 'ramon.leon at onsmalltalk.com'
>         to: #('ramon.leon at onsmalltalk.com' )
>         text: (String streamContents: [:stream |
>             stream nextPutAll: 'Subject: The Page You Requested';
>                 cr; nextPutAll: 'Content-type:text/html';
>                 cr; nextPutAll: aPageHtml])
>
> The real reason I want it, is to do something like this...
>
> [self someThingThatBlowsUp]
> on:Error do:[:error |
>     self emailPage: (WAWalkback exception: error) displayString]
>
> So I can get Seaside's nice walk back page emailed to me for unexpected
> errors that happen in production.
>
> Ramon Leon
> http://onsmalltalk.com
>
> _______________________________________________
> Seaside mailing list
> Seaside at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>


More information about the seaside mailing list