将 Wicket 中的 AjaxFormComponentUpdatingBehaviors 链接到单个 Javascript 事件
如何轻松链接 Wicket 的 AjaxFormComponentUpdatingBehaviors,这样几个行为可以由单个 Javascript 事件触发。我正在使用Wicket 1.4。
例如,当 onblur 事件发生时,我喜欢触发这两种行为。我只关心触发 onUpdate()
方法。如果我这样做,似乎只会触发一种行为。实现此目的的一种方法是使用一个行为来执行 A 和 B 操作,但我正在寻找更可组合的东西。
field.add(new AjaxFormComponentUpdatingBehavior("onblur") {
protected void onUpdate(AjaxRequestTarget target) {
// do thing A here
getComponent(); // behaviors need a reference to field they are attached to
}
});
field.add(new AjaxFormComponentUpdatingBehavior("onblur") {
protected void onUpdate(AjaxRequestTarget target) {
// do thing B here
}
});
How to easily chain Wicket's AjaxFormComponentUpdatingBehaviors, so that several behaviors can be triggered from single Javascript event. I am using Wicket 1.4.
For example, when onblur
event happens, I like these two behaviors to trigger. I am just concerned with triggering onUpdate()
method. If I do this, it seems that only one behavior gets triggered. One way to achieve this is to have a single behavior that does both the A and B operations, but I am looking for something more composeable.
field.add(new AjaxFormComponentUpdatingBehavior("onblur") {
protected void onUpdate(AjaxRequestTarget target) {
// do thing A here
getComponent(); // behaviors need a reference to field they are attached to
}
});
field.add(new AjaxFormComponentUpdatingBehavior("onblur") {
protected void onUpdate(AjaxRequestTarget target) {
// do thing B here
}
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Wicket 6.0 将支持此功能。
但这不是一个好的做法,因为这样您将有 2 个请求被一一执行。我建议采取一种同时满足 A 和 B 的行为。
This will be supported in Wicket 6.0.
But it is not a good practice because this way you will have 2 requests which are executed one by one. I recommend to have one behavior which does A and B.