0

How is it possible or what is the best way to render something before the whole request cycle of my AjaxButton onSubmit() is finished. I try to set a Progressbar visible, just after the user clicked on the AjaxButton, do some internal work and after the work is finished, I would like to set another response page. But the page get only rendered after all things are done in the onSubmit-method. I would like to show the Progressbar just after clicking the button and the handling of the internal work and the redirect should begin after. Is there a possibility to split this up or to call the setResponsePage-method from another thread?

Janus
  • 309
  • 1
  • 5
  • 18

1 Answers1

0

I have found a solution. I split the interaction in two requests:

AjaxButton confirmButton = new AjaxButton("confirmButton", layoutForm) {

@Override
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
    super.onSubmit(target, form);
    System.out.println("Second");
}
};

confirmButton.add(new AjaxEventBehavior("onclick") {

@Override
protected void onEvent(AjaxRequestTarget target) {
    System.out.println("First");
}
});
Janus
  • 309
  • 1
  • 5
  • 18