On Wed, Jan 27, 2010 at 10:21, Vidar Ramdal <[email protected]> wrote:
> It would be nice if there was a way to get JSON output from the
> standard SlngPostServlet, so that way we could leverage current
> SlingPostOperations.  I have looked into it briefly. The HtmlResponse
> object that is passed to SlingPostOperations is a bit of a turn-off in
> this sense, but AFAICT only HtmlResponse.send() actually produces
> HTML.
> We could abstract HtmlResponse to some output-agnostic Response
> object, and then let SlingPostServlet decide (how?) which output
> format to return.

That would be a good idea. The return format should be selected via
the extension (POST foobar.html vs. POST foobar.json).

But some background on the html response: The reason why it was chosen
is because it is the only response that works, ie. that is parseable
by a javascript browser client, when you post a form to the
SlingPostServlet via a hidden iframe (to post forms in an ajax style
_and_ support file uploads). With an iframe, the response cannot be
json, but only html. The structured html of the sling html response
allows you to parse out the message, status, etc.

So in the end, the usable combinations for the SlingPostServlet will
probably be:
form post => html response
json post => json response

Regards,
Alex

-- 
Alexander Klimetschek
[email protected]

Reply via email to