Validation messages aren't cleared on success.
----------------------------------------------
Key: WICKET-2019
URL: https://issues.apache.org/jira/browse/WICKET-2019
Project: Wicket
Issue Type: Bug
Components: wicket
Affects Versions: 1.4-RC1
Reporter: Maarten Billemont
When triggering validation messages on a form component, they aren't cleared
anymore when afterward we fix our validation problem.
The following code demonstrates this issue by making a form with a single text
field that is set as required. First, we submit the form without filling in the
field. We expect that to cause an error. Which it does. Then, we set a value
in the field, and submit again. We expect that to pass validation. It does
not, however.
Instead, we get this exception:
junit.framework.AssertionFailedError: expect no error message, but contains
Field 'field' is required.
at junit.framework.Assert.fail(Assert.java:47)
at junit.framework.Assert.assertTrue(Assert.java:20)
at
org.apache.wicket.util.tester.WicketTester.assertNoErrorMessage(WicketTester.java:493)
at
test.spike.net.link.safeonline.TinyTests.wicketTest(TinyTests.java:93)
Code:
package test.spike;
import org.apache.wicket.Page;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.protocol.http.WebApplication;
import org.apache.wicket.util.tester.FormTester;
import org.apache.wicket.util.tester.WicketTester;
import org.junit.Test;
public class TinyTests {
public static class MyApp extends WebApplication {
@Override
public Class<? extends Page> getHomePage() {
return MyPage.class;
}
}
public static class MyPage extends WebPage {
public MyPage() {
add(new MyForm("form"));
}
class MyForm extends Form<String> {
private static final long serialVersionUID = 1L;
public MyForm(String id) {
super(id);
TextField<String> f = new TextField<String>("field");
f.setRequired(true);
add(f);
}
}
}
@Test
public void wicketTest() {
WicketTester wicket = new WicketTester(new MyApp());
wicket.processRequestCycle();
FormTester form = wicket.newFormTester("form");
form.submit();
wicket.assertErrorMessages(new String[] { "Field 'field' is required."
});
form = wicket.newFormTester("form");
form.setValue("field", "foo");
form.submit();
wicket.assertNoErrorMessage(); // <- Exception line.
}
}
<html>
<body>
<form wicket:id="form">
<input wicket:id="field" />
<input type="submit" />
</form>
</body>
</html>
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.