0

In my form, there is one feedback panel for general feedback messages, and two form input fields, each with its own feedback panel for validation feedback messages. However, when a form input fails to validate, the feedback message appears both in the panel for the field feedback message, and in the panel for general messages. This is not what I want, because the feedback messages are duplicated:

Wicket form validation feedback

HTML:

<h2>The Form</h2>
<form wicket:id="loginForm">
    <div wicket:id="allFeedback"></div>

    <div wicket:id="usernameFeedback"></div>
    <p>Username: <input wicket:id="username" type="text"/></p>

    <div wicket:id="passwordFeedback"></div>
    <p>Password: <input wicket:id="password" type="password"/><p>

    <input type="submit" name="Login" value="Login"/>
</form>

Java:

TextField usernameField = new TextField("username", Model.of(""));
usernameField.setRequired(true);
add(usernameField);

PasswordTextField passwordField = new PasswordTextField("password", Model.of(""));
add(passwordField);

add(new FeedbackPanel("allFeedback"));
add(new FeedbackPanel("usernameFeedback",
                      new ComponentFeedbackMessageFilter(usernameField)));
add(new FeedbackPanel("passwordFeedback",
                      new ComponentFeedbackMessageFilter(passwordField)));

Is there a way to prevent the duplication? I do not want the field-specific feedback messages to be duplicated in the general feedback panel.

Flux
  • 9,805
  • 5
  • 46
  • 92
  • See: https://jeremythomerson.com/2011/01/04/catching-all-feedback-messages-that-arent-rendered-by-other-feedback-panels/ – Flux Mar 02 '20 at 11:22

1 Answers1

0

check user guide to learn how to implement a custom feedback message filter. This might be useful for the general feedback panel to discard messages from usernameField and passwordField.

Andrea Del Bene
  • 2,521
  • 1
  • 15
  • 20