Reputation: 9
I'm trying to show a loading message that tells the user how far along they are in the loading process after they hit submit. The problem is, the loading bar shows up, but it shows "Loading 0 of 0", until the process finishes.
private AjaxButton createSubmit() {
Submit = new AjaxButton("Submit",new Model<String>()) {
private static final long serialVersionUID = 202575339939441557L;
@Override
public void onSubmit(final AjaxRequestTarget target,
final Form<?> form) {
handleSubmit(target);
}
};
Submit.setOutputMarkupId(true);
Submit.add(new PleaseWaitBehavior(new Model<String>(
"Processing Message " + loadingNumber + " of " + size)));
return Submit;
}
This is the class that handles the submit behavior. I change both numbers from 0 in the handleSubmit(target) method and iterate LoadingNumber inside a for loop in that class. The change is never reflected in the message and I have tried removing and adding back in the PleaseWaitBehavior. I am completely stumped. Does Wicket just not allow what I'm trying to do?
Upvotes: 0
Views: 162
Reputation: 17533
Submit.add(new PleaseWaitBehavior(new Model<String>(
"Processing Message " + loadingNumber + " of " + size)));
I hope you realize that here you concatenate a String that is used later in the UI. There is no code that will re-calculate this again and construct a new String for the UI.
Please read about static versus dynamic models in Wicket at https://cwiki.apache.org/confluence/display/WICKET/Working+with+Wicket+models.
For your task you need to use Ajax calls to ask the server about the progress and to repaint the message.
Here is an article that explains the problem and provides a sample solution - http://wicketinaction.com/2014/07/working-with-background-jobs/
Upvotes: 1