Project

General

Profile

Creating an XHTML only (or a json response) from an application

Added by takashi yamamoto over 15 years ago

I am new to wt (Just discovered it today), and I am considering using it for some of my work.

I would like to know one thing though - is it possible to write an application (i.e. a GUI) that renders XHTML (or preferable JSON only) instead of an HTML page?.

If yes, I would be grateful for an example (or links to an example) that show how to render XHTML (or JSON) from an application.


Replies (3)

RE: Creating an XHTML only (or a json response) from an application - Added by Koen Deforche over 15 years ago

Hey,

I am not totally certain I understand why you want you mean with XHTML or JSON only: JSON is a JavaScript format, so at least you would need JavaScript as well ?

As to XHTML versus HTML: There is a configuration option to serve XHTML. In fact, this doesn't change the output very much because Wt will output HTML-compatible XHTML in any case, but it will change the response-type and the doctype so that browsers that understand XHTML (asfaik all but IE6/7/8) will also interpret the document as XHTML.

For a session that does not support JavaScript, the only output could thus be XHTML. However, for an AJAX session, the result is then JavaScript + XHTML.

Regards,

koen

RE: Creating an XHTML only (or a json response) from an application - Added by Wim Dumon over 15 years ago

Or, if you want to generate free form data (i.e. not generated by the Wt widget tree rendering process), use a resource. See WResource, WMemoryResource, WFileResource, ... or write your own specialization of WResource.

RE: Creating an XHTML only (or a json response) from an application - Added by takashi yamamoto over 15 years ago

Wim,

Thanks I had a quick look at the documentation - it seems that resources are the way to go. Thanks once again.

    (1-3/3)