如何轻松链接Wicket的AjaxFormComponentUpdatingBehavior,以便可以从单个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
}
});
答案 0 :(得分:5)
这将在Wicket 6.0中得到支持。 但这不是一个好习惯,因为这样你将有2个请求逐个执行。我建议有一个做A和B的行为。