Angie Benck
Angie Benck

Reputation: 21

Wicket Validation 'hangs' after first submit

I have a form with validation on some fields (required fields). Whenever I submit the form with missing values i get according error messages in a FeedbackPanel. When I enter the missing information and submit the form again, the error messages do not change; the form is not submitted.

It seems like the validation is a one-time thing in my environment and once I submit a form I am stuck with the results from the initial submit.

Any explanations for this? Suggestions?? Help???

I am using Wicket-1.5.7 (just upgraded to make sure it's not an already fixed bug) and Tomcat v6.0 ... also EclipseLink as JPA provider and H2 as DB - just for the sake of completeness.

The following simple example exhibits the described problems:

JAVA:

public class TestPage extends WebPage {

    public TestPage() {
        final MyModel myModel = new MyModel();
        final Form<MyModel> form = new Form<MyModel>("form", new CompoundPropertyModel<MyModel>(myModel));
        add(form);

        add(new FeedbackPanel("feedback"));

        final TextField<String> textField = new TextField<String>("name");
        textField.setRequired(true);
        form.add(textField);
        form.add(new Button("submit"));
    }

    public class MyModel implements Serializable {

        public String name;

    }

}

HTML:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>

<div wicket:id="feedback"></div>

<form wicket:id="form">
<input type="text" id="name" wicket:id="name" />
<input type="submit" wicket:id="submit" />
</form>

</body>
</html>

Upvotes: 2

Views: 277

Answers (1)

Nicktar
Nicktar

Reputation: 5575

Just threw your code at my Wicket 1.5.7 and it worked just fine. Judging from the described Behaviour, you're using Ajax to submit your form and didn't add the FeedbackPanel to the AjaxRequestTarget in onSuccess.

Upvotes: 2

Related Questions