I’m not sure if this is even possible. It would seem like there would be a way to do this when you click a “submit” button.
private Button getButton(String id)
{
return new AjaxButton(id)
{
private static final long serialVersionUID = 1L;
{
setEnabled(true);
}
@Override
protected void onSubmit(AjaxRequestTarget target, Form<?> form)
{
debug = "Beginning a process....";
target.addComponent(debugLabel);
//Perform the first process
debug = "Beginning second process....";
target.addComponent(debugLabel);
//Perform the second process
debug = "Finishing....";
target.addComponent(debugLabel);
//Perform the third process
debug = "Done.";
target.addComponent(debugLabel);
}
@Override
protected void onError(AjaxRequestTarget target, Form form)
{
//NO-OP
}
};
}
}
If it’s not possible is there an alternative to multiple real-time updates? I want it so there is a status label on the bottom updating and telling you how much progress is done in that one method.
Just use AjaxTimerBehavior, so that it updates your label every 1-2 seconds.
Code:
Obviously this solution uses dumb AJAX polling, so it is only advisable to use it on an intranet or other low traffic site.