You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@roller.apache.org by Axelle Ziegler <ax...@gmail.com> on 2007/01/17 14:30:34 UTC

Asynchronous comments post

Hi,

We are currently working on a new roller theme and would like to be
able to post comment asynchronously on the weblog.

It's no problem to make an asynchronous call to CommentServlet and put
the comment in the database. However, displaying is a bit more tricky.
Here are our thoughts, please let me know if you have any insights on
which is the "right" way to go.

The basic problem is that we need to refresh only the newly posted
comment (or at least, the post to which it belongs). That means that
upon return of the request from CommentServlet, we need to re-render
this specific part of the post.
I don't really know how to do that, so I was going for the following method.
 My idea would be to pass a new attribute to CommentServlet which
would be say 'ajax', when this attribute is set, the Servlet would
return only the newly posted comment content (as XML or JSON for
instance), so that it can be rendered in the page.

However, I'm pretty unhappy with this solution. I guess the best would
be to get the servlet to render a velocity template which generates
the xml, but I'm not sure how to do that: maybe have it set a
parameter in the weblogmodel which states that we are just rendering a
comment, and return a different pager ? Is there a way to haver it
render a completely different template (than weblog.vm, I mean) ?
Please let me know if you have any thoughts

-- 
Axelle

Re: Asynchronous comments post

Posted by Allen Gilliland <al...@sun.com>.
Axelle,

I think this is good thing for Roller to be able to due as well.  You 
are right that the actual posting of comments to the CommentServlet 
(using the entry permalink) should be pretty easy, the only thing that 
is needed is some way to denote that the response should not be a full 
rendering of that entry which is what happens now.  This is something 
that needs to be considered for the popup comments situation as well, so 
hopefully we can solve for both situations at the same time.

For the display side I think the easiest thing to do is just provide web 
service endpoint which allows you to query for the comment data from an 
entry and get the result in either an XML or JSON format.  This is 
basically what you had suggested except that the CommentServlet is not 
what will generate the rendered content.  The CommentServlet currently 
only handles posted comments and then dispatches to other servlets for 
actual content rendering and I think that should stay the same.

So the overall process would work such that you define your weblog 
templates and setup your ajax code to use the web service endpoint for 
populating the comments.  Then when someone posts a comment it would go 
to the CommentServlet and either just return a simple http status code 
or could potentially return an XML response, but that's more 
complicated.  And obviously when someone posts a comment and it succeeds 
then you would need to refresh the comments display to include the new 
comment.

Would that fit your need?

-- Allen


Axelle Ziegler wrote:
> Hi,
> 
> We are currently working on a new roller theme and would like to be
> able to post comment asynchronously on the weblog.
> 
> It's no problem to make an asynchronous call to CommentServlet and put
> the comment in the database. However, displaying is a bit more tricky.
> Here are our thoughts, please let me know if you have any insights on
> which is the "right" way to go.
> 
> The basic problem is that we need to refresh only the newly posted
> comment (or at least, the post to which it belongs). That means that
> upon return of the request from CommentServlet, we need to re-render
> this specific part of the post.
> I don't really know how to do that, so I was going for the following 
> method.
> My idea would be to pass a new attribute to CommentServlet which
> would be say 'ajax', when this attribute is set, the Servlet would
> return only the newly posted comment content (as XML or JSON for
> instance), so that it can be rendered in the page.
> 
> However, I'm pretty unhappy with this solution. I guess the best would
> be to get the servlet to render a velocity template which generates
> the xml, but I'm not sure how to do that: maybe have it set a
> parameter in the weblogmodel which states that we are just rendering a
> comment, and return a different pager ? Is there a way to haver it
> render a completely different template (than weblog.vm, I mean) ?
> Please let me know if you have any thoughts
>