Update view fields from action-method (in controller) before the end of the method execution

Hello, I would like to update my view during the execution of a lengthy action-method controller.

I have lengthy action to do in the controller method, let say, I have a loop to go through and would like to update my view in the loop:

public class LengthyActionController {

    protected Logger log = LoggerFactory.getLogger(getClass());

    public void doAction(ActionRequest request, ActionResponse response){
        for(int i=0; i<10000;i++){
            response.setValue("actionResult", "value : " + i);
        response.setNotify("Last message");


When we set the value using response.setValue we need to specify the key i.e. field name as first parameter in which we want to set the value and second parameter is value for that field.

Now in loop you are keeping the first param same for each iteration i.e. actionResult. so the last value will be set for that field when for loop will be over. and only one field you are setting with value set from last iteration indirectly.

So for multiple fields to be set you need to develop the logic in a way that field name (first param) can be generated as required (Something like you have done with value). so key will be different and it won’t override the value assigned in previous iteration.

Or you can also set the multiple values using response.setValues function in one go in which you have to pass the map in which key will be the field name and value will be the value for that field.

Hope this will help !!
Always here to resolve the confusion.

Thank you.


Thanks for your feedback. However, my need is not to update several fields, but I want the update to be visible on the UI before the end of the http request. In order to let the user know the result of the processing in progress, a bit like JENKINS does during a build, you can see the evolution of the build in real time on the console