【问题标题】:Chaining AjaxFormComponentUpdatingBehaviors in Wicket to single Javascript event将 Wicket 中的 AjaxFormComponentUpdatingBehavior 链接到单个 Javascript 事件
【发布时间】:2012-02-10 12:43:55
【问题描述】:

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

【问题讨论】:

  • 在最坏的情况下,您可以创建一个通用的复合更新行为类,该类接受其他行为的列表/数组并调用所有这些行为。
  • @biziclop:我希望有现成的东西。

标签: javascript ajax event-handling dom-events wicket


【解决方案1】:

Wicket 6.0 将支持此功能。 但这不是一个好习惯,因为这样您将有 2 个请求一个一个地执行。我建议采用一种行为,即 A 和 B。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-09-16
    • 1970-01-01
    • 2014-11-03
    • 2020-06-28
    • 1970-01-01
    相关资源
    最近更新 更多