}
};
form.add(bar = new ProgressBar("bar", progressionModel) {
@Override
protected void onFinished(AjaxRequestTarget target) {
ITaskService taskService = getExampleApplication()
.getTaskService();
// finish the task!
taskService.finish(progressionModel.getTaskId());
// Hide progress bar after finish
setVisible(false);
// Add some JavaScript after finish
target.appendJavaScript("alert('Task done and finished!')");
// re-enable button
Component button = form.get("submit");
button.setEnabled(true);
target.addComponent(button);
}
});
// Hide progress bar initially
bar.setVisible(false);
form.add(new IndicatingAjaxButton("submit", form) {
@Override
protected void onSubmit(AjaxRequestTarget target, Form form) {
ITaskService taskService = getExampleApplication()
.getTaskService();
// Schedule and start a new task
Long taskId = taskService.scheduleAndStart(new DummyTask(60));
// Set taskId for model
progressionModel.setTaskId(taskId);
// Start the progress bar, will set visibility to true
bar.start(target);