Wicket 1.4 => 6.7替换AjaxButton:getAjaxCallDecorator

Kat*_*nes 3 wicket wicket-1.6

我被要求升级我们现有的一个应用程序,我在确定如何更新我们的一些类时遇到了一些麻烦.

我们有自己的CustomAjaxButtonextends AjaxButton,其中getAjaxCallDecorator被覆盖,所以我们可以返回自定义decorateOnSuccessScript等.

我找到了https://cwiki.apache.org/confluence/display/WICKET/Wicket+Ajax#WicketAjax-oawajax.IAjaxCallDecoratorisreplacedwitho.awajax.attributes.IAjaxCallListener.该页面确实解释了原因,但我不确定如何将此与新AjaxButton实现相结合,因为getAjaxCallDecorator已删除.

旧版本的代码段:

@Override
    protected IAjaxCallDecorator getAjaxCallDecorator() {
        return new IAjaxCallDecorator()
        {
         private static final long serialVersionUID = 6L;
...
         public CharSequence decorateScript(CharSequence script)
         {
          return script + " document.getElementById('inputBlocker').style.display='none';";
         }
        };
    }
Run Code Online (Sandbox Code Playgroud)

我不得不承认我在Wicket有一个很新的,我经验丰富的同事正在度假.任何帮助\建议非常感谢.

Rob*_*roj 6

试试这种方法:

add(new AjaxLink("btn"){

    @Override
    protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
        super.updateAjaxAttributes(attributes); 
        attributes.getAjaxCallListeners().add(new AjaxCallListener(){

            @Override
            public CharSequence getSuccessHandler(Component component) {
                return " document.getElementById('inputBlocker').style.display='none';";
            }

        });
    }

});
Run Code Online (Sandbox Code Playgroud)

在AjaxCallListener中,您可以覆盖所需的任何处理程序.如果需要,可以将脚本执行更改为完整的处理程序