开发者

Wicket: How to change the visibility of a ProgressBar component for two times during the Ajax response

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:

  1. Firstly, I need to show ProgressBar which value is set to 0 (set visible to true).
  2. Secondly, I need to perform the annotation of a page, that will take a few seconds.
  3. 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 onSubmit method will get run before returning to the client, by this time you will have set the progress bar to 100.

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜