Question

I have an application using FeedbackPanel to show the user the results of posting forms.

On calling Component#info(String) on pages which are stateless, Wicket does appear to be putting that string into the FeedbackMessages session. However later on, FeedbackPanel tries to find the messages and doesn't seem to be able to find any at all, even though they still appear to be in the session when I view all this in a debugger.

Also, when this occurs, WicketTester swears that the message is being displayed, making WicketTester essentially useless for testing feedback messages (I now have a TODO on my list to replace usage of that with assertions on the markup itself.)

Was it helpful?

Solution 2

Answering my question with my own solution. In our StatelessWebSession, override an additional method:

private static final IFeedbackMessageFilter renderedMessagesForComponents =
    new IFeedbackMessageFilter()
    {
        @Override
        public boolean accept(FeedbackMessage message)
        {
            return message.getReporter() != null && message.isRendered();
        }
    };

@Override
protected void cleanupComponentFeedbackMessages()
{
    // deliberately not calling the method in the superclass because it
    // clears all messages for components.
    getFeedbackMessages().clear(renderedMessagesForComponents);
}

This way it only clears rendered messages for components instead of all messages for components.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top