我已經被要求在Web應用程序中將Wicket版本從1.5.9升級到6.14.0。 我發現升級(行爲)裝飾器聽衆很有問題。將Wicket Decorator升級爲Listener從1.5.x升級到6.x
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,作爲一個noob的種類特別是最新版本。 :)