How to get all FeedbackMessages from components inside specific form?

214 views Asked by At

Wicket 6 no longer keeps feedback messages in session. Now they are attached to components, which I think is great move but I approach an issue connected with that. I used to remove all feedback messages that were related to the specific form like this :

Session.get().getFeedbackMessages().clear(new ContainerFeedbackMessageFilter(panelForm));

Unfortunetly right now I can't clear it like this:

panelForm.getFeedbackMessages().clear();

For obvious reasons - they are attached to components inside form. So is there a way to get those feedback messages by only accesing (in my case) panelForm or my only way to go is to call getFeedbackMessages() on all of my components (panelForm.component1, panelForm.component2 etc)?

2

There are 2 answers

0
mefi On BEST ANSWER

use FeedbackCollector as in example:

new FeedbackMessagesModel(this) {    
            @Override
            protected List<FeedbackMessage> collectMessages(Component panel, IFeedbackMessageFilter filter) {
                return new FeedbackCollector(YourComponent.this.getParent()) {
                    @Override
                    protected boolean shouldRecurseInto(Component component) {
                        return true; // your citeria here
                    }
                }.setIncludeSession(false).collect(filter);
            }
        };
2
martin-g On

Yes. You should use FeedbackCollector. Collect the messages and mark them as rendered.