[aida] Returning content of different types (was How to download a stream)
Herbert König
herbertkoenig at gmx.net
Tue Oct 5 22:16:38 CEST 2010
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
More information about the Aida
mailing list