将Wicket中的AjaxFormComponentUpdatingBehaviors链接到单个Javascript事件

时间:2012-02-10 12:43:55

标签: ajax javascript-events event-handling wicket

如何轻松链接WicketAjaxFormComponentUpdatingBehavior,以便可以从单个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
   }
});

1 个答案:

答案 0 :(得分:5)

这将在Wicket 6.0中得到支持。 但这不是一个好习惯,因为这样你将有2个请求逐个执行。我建议有一个做A和B的行为。