【问题标题】:Wicket: How to change the visibility of a ProgressBar component for two times during the Ajax responseWicket:如何在 Ajax 响应期间两次更改 ProgressBar 组件的可见性
【发布时间】:2011-08-27 15:23:46
【问题描述】:

在我的表单中,我有一个来自 Wiquery 项目 (http://code.google.com/p/wiquery/) 的 ProgessBar 组件,并且 ProgressBar 的可见性在开始时设置为 false。

我在表单上也有 AjaxButton,我需要在他的 onSubmit() 方法中做一些事情:

  1. 首先,我需要显示 ProgressBar 的值设置为 0(设置为 true)。
  2. 其次,我需要对页面进行注释,这需要几秒钟的时间。
  3. 最后,我需要在注解过程中将 ProgressBar 从值 0 更新为值 100,并且我需要在注解过程结束时隐藏 ProgressBar 组件。

下面是我需要改进的代码。我也尝试过使用 UploadProgressBar 组件,但是这里不需要“上传开始...”的消息。有没有办法更改此消息?

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);

【问题讨论】:

    标签: jquery ajax wicket


    【解决方案1】:

    您遇到的问题是onSubmit 方法将在返回客户端之前运行,此时您将进度条设置为100

    我不认为进度条是你想要的,没有任何步骤可以说这是 x% 完成。它要么完整,要么不完整,因此进度条无法显示进度。我建议使用指标 (AjaxIndicatorAppender)。

    希望这会有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-10-14
      • 2017-08-04
      • 1970-01-01
      • 1970-01-01
      • 2021-06-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多