In my form I have a ProgessBar component from the Wiquery project(http://code.google.com/p/wiquery/) and the ProgressBar’s visible is set to false on the beginning.
I also have the AjaxButton on the form too, and I need to do a few things within his onSubmit() method:
- Firstly, I need to show ProgressBar which value is set to 0 (set visible to true).
- Secondly, I need to perform the annotation of a page, that will take a few seconds.
- Finally, I need to update the ProgressBar from value 0 to value 100 during the process of annotation and I need to hide the ProgressBar component on the end of the annotation process.
Bellow is the code that I need to improve. I have also tried to use the UploadProgressBar component, but there is the message “Upload starting…” that is not necessary here. Is there a way to change this message?
progressBar = new ProgressBar("progress");
progressBar.setValue(0);
progressBar.setOutputMarkupId(true);
progressBar.setVisible(false);
form.add(progressBar);
semAnnButton = new AjaxButton("semAnnButton"){
private static final long serialVersionUID = 1L;
@Override
protected void onSubmit(AjaxRequestTarget target,
Form<?> form) {
progressBar.setVisible(true);
target.addComponent(progressBar);
performAnnotation(webPageURL);
progressBar.increment(target, 100);
}};
semAnnButton.setOutputMarkupId(true);
semAnnButton.setOutputMarkupPlaceholderTag(true);
semAnnButton.setVisible(true);
form.add(semAnnButton);
The problem you have is that the
onSubmitmethod will get run before returning to the client, by this time you will have set the progress bar to100.I don’t think the progress bar is what you want for this, there are no steps at which you can say this is x% complete. It is either complete or not complete, as such there is no way that the progress bar can be displayed with progress. I would advise using an indicator (
AjaxIndicatorAppender).Hope this helps.