gpt4 book ai didi

java - Wicket 6.18 AjaxEventBehavior ("onkeypress") 当 getPrecondition 返回 false 时

转载 作者:行者123 更新时间:2023-11-28 07:19:27 24 4
gpt4 key购买 nike

我正在尝试将 AjaxEventBehavior("onkeypress") 添加到 TextField,我正在这样做

TextField<String> input = new TextField<String>("input");
input.setOutputMarkupId(true);
input.add(new AjaxEventBehavior("onkeypress") {

@Override
protected void onEvent(AjaxRequestTarget target) {
Panel.this.info("hello!");
}

@Override
protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
super.updateAjaxAttributes(attributes);

attributes.getAjaxCallListeners().add(new AjaxCallListener(){
public CharSequence getPrecondition(Component component) {
return "if (Wicket.Event.keyCode(attrs.event) == 13) " +
" { return true; } " +
"else { return false; }";
}
});
}
});

当我在输入中按 Enter (keyCode==13) 时,我的反馈面板显示“你好!”但是当我按下另一个键时没有任何反应,Wicket Ajax 调试得到信息:“Ajax 请求因前提条件检查而停止”我的 ajaxIndicator 启动并且永远不会停止。

我有一个 application.js 与此

Wicket.Event.subscribe('/ajax/call/before',showBusysign);
Wicket.Event.subscribe('/ajax/call/success',hideBusysign);
Wicket.Event.subscribe('/ajax/call/failure',hideBusysign);
}

function hideBusysign() {
document.getElementById('busyIndicator').style.display = 'none';
hideMask();
}

function showBusysign() {
document.getElementById('busyIndicator').src = 'img/busy.gif'
document.getElementById('busyIndicator').style.display = 'inline';
}

hideBusysign 永远不会被调用,我尝试了这个但不起作用!

@Override
public CharSequence getFailureHandler(Component component) {
return "document.getElementById('busyIndicator').style.display = 'none'; " +
" hideMask();";

这是实现 EnterKeypressEvent 的正确方法吗?

谢谢,最诚挚的问候。

最佳答案

您应该使用'/ajax/call/beforeSend 而不是'/ajax/call/beforebeforeSend 仅当所有先决条件都满足时才执行。

关于java - Wicket 6.18 AjaxEventBehavior ("onkeypress") 当 getPrecondition 返回 false 时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30469650/

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