Avoid duplicating feedback that are already displayed through a ComponentFeedbackMessageFilter

215 Views Asked by At

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.

1

There are 1 best solutions below

0
On

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.