0

I have a org.apache.wicket.markup.html.panel.FeedbackPanel in my panelA class. The feedback panel is instantiated in a panelA constructor with one message to display -> feedbackPanel.info("displayFirstTime"). I am navigating to a new page and later to the previous panelA with a command

target.getPage().get(BasePage.CONTENT_PANEL_ID).replaceWith(panelA);

but the message "displayFirstTime" won't be displayed on the feedback panel again.

I have made it with overriding a panel onBeforeRender method

@Override
public void onBeforeRender() {      
    super.onBeforeRender();
    if (again_displayCondition) {
       this.info("displayFirstTime");
    }
}

but it's not a clean solution.

Is it possible or how to make it, that when moving to a panelA page for the 2nd time the feedback message will be also displayed ?

PrzemyslawP
  • 190
  • 1
  • 13

1 Answers1

2

Wicket uses application.getApplicationSettings().getFeedbackMessageCleanupFilter() to delete the feedback messages at the end of the request cycle.

By default it will delete all already rendered messages.

You can setup a custom cleanup filter that may leave some of the messages, e.g. if they implement some interface. For example:

component.info(new DoNotDeleteMe("The actual message here."));

and your filter will have to check:

@Override
public boolean accept(FeedbackMessage message)
{
    if (message.getMessage() instanceOf DoNotDeleteMe) {
      return false;
    }

    return message.isRendered();
}

Make sure you implement DoNotDeleteMe#toString() so that it renders properly. Or you will have to use a custom FeedbackPanel too.

DoNotDeleteMe must implement java.io.Serializable!

martin-g
  • 17,243
  • 2
  • 23
  • 35