如何在Wicket中单击它后设置按钮enabled = false?

前端之家收集整理的这篇文章主要介绍了如何在Wicket中单击它后设置按钮enabled = false?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我想要的是:

>如果我点击一个按钮,它应该不启用(不可点击)
在其他方法(点击)完成之前,只有AFTER
方法的结束.

这是我的按钮代码

  1. @Override
  2. protected void onInitialize() {
  3. add(createOkLink());
  4. }
  5.  
  6. private IndicatingAjaxLink<Void> createOkLink() {
  7. final IndicatingAjaxLink<Void> ret = new IndicatingAjaxLink<Void>("okLink") {
  8. private static final long serialVersionUID = 1L;
  9. @Override
  10. public void onClick(AjaxRequestTarget target) {
  11. //when I click on it,this button (link) should not be enabled while the rest of the methods are not finished.
  12. method1(); //about 2-5 seconds running time
  13. method2(); //about 2-5 seconds running time
  14. method3(); //about 2-5 seconds running time
  15. Feedback.success("success");
  16. target.add(Feedback);
  17. //after every method has finished,the button should be clickable againg
  18. }
  19. };
  20. ret.setOutputMarkupId(true);
  21. return ret;
  22. }

我希望有一个人可以帮助我!

我正在使用Wicket 6.

  1. final Form<?> form = new Form<>("form");
  2. form.setOutputMarkupId(true).setOutputMarkupPlaceholderTag(true);
  3. add(form
  4. .add(new FeedbackPanel("Feedback"))
  5. .add(new AjaxButton("button") {
  6. @Override
  7. protected void onSubmit(AjaxRequestTarget target,Form<?> form) {
  8. info(System.currentTimeMillis());
  9. target.add(form);
  10. try {
  11. TimeUnit.SECONDS.sleep(1);
  12. } catch (InterruptedException e) {
  13. e.printStackTrace();
  14. }
  15. }
  16. @Override
  17. protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
  18. super.updateAjaxAttributes(attributes);
  19. attributes.getAjaxCallListeners().add(new AjaxCallListener()
  20. .onBefore("$('#" + getMarkupId() + "').prop('disabled',true);")
  21. .onComplete("$('#" + getMarkupId() + "').prop('disabled',false);"));
  22. }
  23. }));

猜你在找的Ajax相关文章