Herbert König | 5 Oct 2010 22:16
Picon

Re: Returning content of different types (was How to download a stream)

Hi Janko,

thanks, it helped. And I found the class comment of WebNonHTMLResource
which explained why my downloads still started with a html extension.

Cheers,

Herbert                            mailto:herbertkoenig <at> gmx.net

JM> Hi Herbert,

JM> A bit but hope not too late answer:

JM> Returning an answer in a content type other that HTML is actually pretty
JM> simple. Let me explain with example returning an XML:

JM> 1. make a new class, say XMLContent as subclass of WebElement
JM> 2. ovveride method #aidaContentType to return appropriate content type:

JM>   XMLContent>>aidaContentType
JM>     ^'text/xml'

3. MyApp>>>viewAsXml
JM>   | xml |
JM>   xml := '<xml>some XML content</xml>.
JM>   e := XMLContent new.
JM>   e addText: xml.
JM>   ^e

JM> 4.in browser open something like:

JM> 	http://localhost:8888/myobject?view=asXml

JM> To explain a bit: if App view method return an element with content type
JM> different than default, this content type will be set in a header of
JM> response to your web request. This way we can very simply return content
JM> in any content type we like, like XML, CVS, JPG etc.

JM> I put this explanation on our website in FAQ too:

JM> 	http://www.aidaweb.si/faq.html#h-20

JM> Best regards
JM> Janko


Gmane