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

Juh*_*älä 1 ajax wicket event-handling javascript-events

如何轻松链接WicketAjaxFormComponentUpdatingBehavior,以便可以从单个Javascript事件触发多个行为.我正在使用Wicket 1.4.

例如,当onblur事件发生时,我喜欢触发这两种行为.我只关心触发onUpdate()方法.如果我这样做,似乎只触发了一个行为.实现这一目标的一种方法是让一个行为同时执行AB操作,但我正在寻找更具创造性的东西.

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
   }
});
Run Code Online (Sandbox Code Playgroud)

mar*_*n-g 5

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