AjaxLink updateAjaxAttributes-AjaxCallListener GetPremission
我在从Wicket 1.5迁移到6.6的过程中结巴了 早期的AjaxLink允许重写getAjaxCallDecorator()方法,并使用preDecorateScript(CharSequence脚本)包装脚本AjaxLink updateAjaxAttributes-AjaxCallListener GetPremission,ajax,wicket,hyperlink,wicket-6,Ajax,Wicket,Hyperlink,Wicket 6,我在从Wicket 1.5迁移到6.6的过程中结巴了 早期的AjaxLink允许重写getAjaxCallDecorator()方法,并使用preDecorateScript(CharSequence脚本)包装脚本 现在推荐的方法是使用AjaxCallListener和GetPremission(组件)方法。但是如何使用组件参数包装源脚本?不知道我是否理解正确。我们这样做: public class MyAjaxCallListener implements IAjaxCallListener{
现在推荐的方法是使用AjaxCallListener和GetPremission(组件)方法。但是如何使用组件参数包装源脚本?不知道我是否理解正确。我们这样做:
public class MyAjaxCallListener implements IAjaxCallListener{
@Override
public CharSequence getBeforeHandler(Component component) {
return null;
}
@Override
public CharSequence getPrecondition(Component component) {
return YOUR_SCRIPT;
}
// ... not needed overrides can return null
}
然后通过行为将其添加到AjaxLink
ajaxLink.add(new AjaxEventBehavior("onclick") {
@Override
protected void onSubmit(AjaxRequestTarget target) {
//do stuff
}
@Override
protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
super.updateAjaxAttributes(attributes);
attributes.getAjaxCallListeners().add(new MyAjaxCallListener());
}
});
我不知道我是否理解正确。我们这样做:
public class MyAjaxCallListener implements IAjaxCallListener{
@Override
public CharSequence getBeforeHandler(Component component) {
return null;
}
@Override
public CharSequence getPrecondition(Component component) {
return YOUR_SCRIPT;
}
// ... not needed overrides can return null
}
然后通过行为将其添加到AjaxLink
ajaxLink.add(new AjaxEventBehavior("onclick") {
@Override
protected void onSubmit(AjaxRequestTarget target) {
//do stuff
}
@Override
protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
super.updateAjaxAttributes(attributes);
attributes.getAjaxCallListeners().add(new MyAjaxCallListener());
}
});
看起来不错。问题是早期的CharSequence脚本是一个方法参数,我能够包装它(例如在脚本中添加或替换某些内容)。脚本因上下文而异。现在方法参数是Component,我不能添加或替换somting,我必须返回完整的脚本。我没有这样做,所以我的答案只是部分地满足了你的需要,似乎很好。问题是早期的CharSequence脚本是一个方法参数,我能够包装它(例如在脚本中添加或替换某些内容)。脚本因上下文而异。现在方法参数是Component,我不能添加或替换somting,我必须返回完整的脚本。我没有这样做,所以我的答案只是部分地满足了你的需要,我想我已经明白了。相反,在Wicket 6中包装脚本可以分为两个阶段:ajax调用之前(例如使用getBeforeHandler())和ajax调用之后(getCompleteHandler()),我想我已经解决了。相反,在Wicket 6中包装脚本可以分为两个阶段:在ajax调用之前(例如使用getBeforeHandler())和在ajax调用之后(getCompleteHandler())