[Seaside] WAComponent and HTML Emails?

Philippe Marschall philippe.marschall at gmail.com
Sun Aug 12 10:35:10 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...

Can you have a look at Seaside2.8a1-pmm.434. It introduces the
somewhat unfortunatetly named WAHtmlBuilder (I'm open for better
suggestions). This already helped to reduce duplication in tests and
could further reduce duplaction in Coment and RSRSS2.

htmlString would look somehting like this:

htmlString
    ^WAHtmlCanvas builder
        fullDocument: true;
        rootBlock: [ :root | self updateRoot: root ];
        render: self

> 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.

Wouldn't you want something more customed that includes the full stack
and not html?

Cheers
Philippe

> 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