Problem with Prototype/Grails

carlosmain

New member
Hi all, im using prototype to do a periodical update. Here is the code

Code:
function startUpdater(){
        var comment = document.getElementById('lastComment').value;
        var item = document.getElementById('item').value;

        new Ajax.PeriodicalUpdater(
        'newComments',
        '/library/item/newComments',
        {
            method: 'get',
            frequency:45,
            decay: 2,
            onFailure: function(transport){
              var response = transport.responseText || "no response text";
              alert("FAIL! \n\n" + response);
            },
            parameters: { comment: comment, item: item }
        }
    );
      }

the action in my item controller is the next one
Code:
def newComments = {
        def commentList = getComment(params)

        def size = commentList.size()

        if(request.xhr){
        if(size > 0) {
           render(template:"newComments", model:[newComment:size])
        }
        }
    }

    def getComment(params){
        def item = Item.get(params.item)
        def commentList
        if(params.comment != ""){
            def comment = Comment.get(params.comment)
            commentList = Comment.findAll("from Comment where item = :item and dateCreated > :date order by dateCreated asc", [item: item, date: comment.dateCreated])
        }
        else{
            commentList = Comment.findAll("from Comment where item = :item order by dateCreated asc", [item: item])
        }

        return commentList
    }

and the part of my gsp 'show.gsp' to update is the next one
Code:
<p><b><g:message code="pastcomments" default="Past Comments" /></b></p>
            <div id="newComments">
              <g:render template="newComments" model="[newComments: size]"/>
            </div>

the problem is that every time the updater is done with a cycle it asks for a "newComments.jsp" even though i'm rendering a template and not a view, anyone knows what possibly could be wrong?

Best Regards
Carlos
 
Top