如何在wicket 6.x或7.x中使用受保护的IFeedbackMessageFilter [] getFilters()

时间:2017-06-23 09:19:11

标签: wicket wicket-1.5 wicket-6 wicket-1.6 wicket-7

我正在尝试将以下代码从wicket-1.4.9转换为wicket-6.x / 7.x,但未获得解决方案。请帮忙,因为我是Apache Wicket的新手

@Override
protected IFeedbackMessageFilter[] getFilters() {
    final List<IFeedbackMessageFilter> filters = new ArrayList<IFeedbackMessageFilter>();
    getPage().visitChildren(FeedbackPanel.class, new IVisitor<FeedbackPanel>() {

        @Override
        public Object component(FeedbackPanel component) {
            if (pageFeedback.equals(component)) {
                return CONTINUE_TRAVERSAL_BUT_DONT_GO_DEEPER;
            }
            filters.add(component.getFilter());
            return CONTINUE_TRAVERSAL;
        }
    });

    return filters.toArray(new IFeedbackMessageFilter[filters.size()]);
} 

1 个答案:

答案 0 :(得分:0)

应该是这样的:

@Override
protected IFeedbackMessageFilter[] getFilters() {
    final List<IFeedbackMessageFilter> filters = new ArrayList<IFeedbackMessageFilter>();

    getPage().visitChildren(FeedbackPanel.class, new IVisitor<FeedbackPanel, Void>() {

        @Override
        public void component(FeedbackPanel component, IVisit<Void> visit) {
            if (pageFeedback.equals(component)) {
                visit.dontGoDeeper();
                return;
            }
            filters.add(component.getFilter());
        }
    });

    return filters.toArray(new IFeedbackMessageFilter[filters.size()]);

}