【发布时间】:2012-02-10 12:43:55
【问题描述】:
如何轻松链接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
}
});
【问题讨论】:
-
在最坏的情况下,您可以创建一个通用的复合更新行为类,该类接受其他行为的列表/数组并调用所有这些行为。
-
@biziclop:我希望有现成的东西。
标签: javascript ajax event-handling dom-events wicket