cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Thorsten Scherler (JIRA)" <>
Subject [jira] [Commented] (COCOON3-75) REST and asynchronous server side operations
Date Mon, 22 Aug 2011 15:14:40 GMT


Thorsten Scherler commented on COCOON3-75:

In the abstract class we provide the infrastructure to
In POST: Create a progress object and store it in the session context with a unique id. 
In GET: retrieve object and get the current progress

In our code we do the following as implementation: 

public class ProcessService extends AbstractAsyncronService {

public RestResponse doGet() throws Exception {
 Object progress = getProgress();
 return new TextResponse("{\"progress\":"+progress.toString()+" }", "application/json");

public RestResponse doPost() throws Exception {
// execute business logic in background
// Answer the client, reporting we have done 2%
 return new TextResponse("{\"progress\":2"}", "application/json");

// long running action that will be done in a seperate thread
public void run() {
// if we reach here we have done 5% progress
//... do business logic and finish progress with 

Our client is based on jquery ui progress bar. Where we post the form 
 $.post('rest/ProcessService', {
            name: input
        }, function(data){
        }, "json");

and in the onSuccess we invoke a loop to get the status like
 window.progressIntervalId = window.setInterval(function(){
        //Getting current operation progress
        $.get('rest/ProcessService', {
            name: input
        }, function(data){
            //Updating progress
            $("#progressbar").progressbar('value', data.progress);
            //If operation is complete
            if (data.progress == 100) {
                //Clear timer
    }, 500);

If you see this useful I can add the class and an example to the cocoon-rest module. 

> REST and asynchronous server side operations
> --------------------------------------------
>                 Key: COCOON3-75
>                 URL:
>             Project: Cocoon 3
>          Issue Type: New Feature
>          Components: cocoon-rest
>            Reporter: Thorsten Scherler
>            Assignee: Thorsten Scherler
>         Attachments:
> I am looking into implementing reporting server side operation progress with jQuery UI
Progressbar with our REST framework.
> My basic idea as starting point is to use the GET to ask for the
> progress of the processing and POST to invoke the work which reports the
> progress. 

This message is automatically generated by JIRA.
For more information on JIRA, see:


View raw message