[Seaside] Re: Noob wants to render dynamic png file
johnhwoods
johnhwoods+nabble at gmail.com
Sun Jul 17 10:01:41 UTC 2011
Hi James, Lukas -
Thanks very much for the quick replies. I think the main problem is
probably that I'm trying to run before I can walk, so I may not have been
clear enough in my question - but the two replies, taken together, showed me
what to do.
James pointed me at this:
> MyWAComponent>>#'returnCSV'
> | response |
> response := WAResponse
> document: self asCSV
> mimeType: (WAFileLibrary mimetypeFor: 'csv')
> fileName: self caption , ' (' , DateAndTime now printString , ').csv'.
> response doNotCache.
> self session returnResponse: response.
>
This enabled me to put an anchor 'Get the .png' which, when clicked,
returned the image. Not quite what I wanted, because I wanted it displayed
on the page and not offered as a download when a link was clicked. But it
did show me how to set up a MIME document.
Lukas pointed me at this:
> ComponentWithForm>>renderContentOn: html
> html image form: (EllipseMorph new
> color: Color orange;
> extent: 200 @ 100;
> borderWidth: 3;
> imageForm)
>
Unfortunately I don't have WAImage>form: (is it Pharo-specific?) but I
could combine this with James' help to give me this:
> MyWAComponent>>renderContentOn: html
> html image width: 400; document: self getPngBytes mimeType:
> 'image/png' fileName: 'output.png'.
> html horizontalRule.
> (html anchor) callback: [self prev]; with: 'previous image'.
> html space.
> (html anchor) callback: [self next]; with: 'next image'.
>
...where prev and next decrement/increment a counter which determines what
bytes are served by getPngBytes. Hope I have done the right thing
design-wise but it seems to work. Thanks again for your very useful and
quick responses.
John
--
View this message in context: http://forum.world.st/Noob-wants-to-render-dynamic-png-file-tp3672518p3673148.html
Sent from the Seaside General mailing list archive at Nabble.com.
More information about the seaside
mailing list