我被要求在网络应用程序中将检票口版本从 1.5.9 升级到 6.14.0。我发现将(行为)装饰器升级为监听器非常有问题。
o.a.w.ajax.IAjaxCallDecorator is replaced with o.a.w.ajax.attributes.IAjaxCallListener.
我已经成功创建了一个 POC,我几乎可以正确地升级所需的部件。
在 1.5.9 中,元素脚本可以这样装饰(在低级别,还涉及其他更改,但到此为止)
public class MyBehavior extends AjaxFormComponentUpdatingBehavior {
@Override
// (removed in upgrade to 6.14.0)
protected IAjaxCallDecorator getAjaxCallDecorator() {
return new SmallDecorator();
}
private class SmallDecorator extends AjaxCallDecorator {
public SmallDecorator() {}
@Override
public CharSequence decorateScript(Component component, CharSequence script) {
return "alert('decorated onblur');" + script;
}
}
}
在 6.14.0 中也是这样(据我理解正确)
public class OnBlurBehavior extends AjaxFormComponentUpdatingBehavior {
@Override
protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
super.updateAjaxAttributes(attributes);
attributes.getAjaxCallListeners().add(new
GenericListenerImpl("alert('Listener onblur')"));
}
private class GenericListenerImpl extends AjaxCallListener {
private String decoratorScript = null;
public GenericListenerImpl(String decoratorScript) {
this.decoratorScript = decoratorScript;
}
@Override
public CharSequence getPrecondition(Component component) {
return this.decoratorScript;
}
}
}
现在这基本工作了,但是当我想在 1.5.9 版本中编辑或包装“脚本”时,我该如何在 6.14.0 版本中完成呢?
事实证明,这对我来说是非常有问题的,因为我已经(很长)长时间没有使用 Wicket 了,而最新版本的菜鸟尤其如此。:)