gpt4 book ai didi

button - 在 Wicket 中单击后如何设置按钮启用 = 假?

转载 作者:行者123 更新时间:2023-12-04 10:51:44 25 4
gpt4 key购买 nike

我想要的是:

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

  • 这是我的按钮代码:
    @Override
    protected void onInitialize() {
    add(createOkLink());
    }

    private IndicatingAjaxLink<Void> createOkLink() {
    final IndicatingAjaxLink<Void> ret = new IndicatingAjaxLink<Void>("okLink") {
    private static final long serialVersionUID = 1L;
    @Override
    public void onClick(AjaxRequestTarget target) {
    //when I click on it, this button (link) should not be enabled while the rest of the methods are not finished.
    method1(); //about 2-5 seconds running time
    method2(); //about 2-5 seconds running time
    method3(); //about 2-5 seconds running time
    feedback.success("success");
    target.add(feedback);
    //after every method has finished, the button should be clickable againg
    }
    };
    ret.setOutputMarkupId(true);
    return ret;
    }

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

    我正在使用 Wicket 6。

    最佳答案

        final Form<?> form = new Form<>("form");
    form.setOutputMarkupId(true).setOutputMarkupPlaceholderTag(true);
    add(form
    .add(new FeedbackPanel("feedback"))
    .add(new AjaxButton("button") {
    @Override
    protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
    info(System.currentTimeMillis());
    target.add(form);
    try {
    TimeUnit.SECONDS.sleep(1);
    } catch (InterruptedException e) {
    e.printStackTrace();
    }
    }
    @Override
    protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
    super.updateAjaxAttributes(attributes);
    attributes.getAjaxCallListeners().add(new AjaxCallListener()
    .onBefore("$('#" + getMarkupId() + "').prop('disabled',true);")
    .onComplete("$('#" + getMarkupId() + "').prop('disabled',false);"));
    }
    }));

    关于button - 在 Wicket 中单击后如何设置按钮启用 = 假?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22017244/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com