You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Maarten Billemont (JIRA)" <ji...@apache.org> on 2009/01/13 21:51:05 UTC
[jira] Commented: (WICKET-2019) Validation messages aren't cleared
on success.
[ https://issues.apache.org/jira/browse/WICKET-2019?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12663470#action_12663470 ]
Maarten Billemont commented on WICKET-2019:
-------------------------------------------
The reason I made this test case was because it was failing in our live system.
So yes, this issue also occurs in live systems (Wicket + JBoss AS). Am I supposed to do a Session.get().clearFeedbackMessages() in onBeforeRender?
If so, that can probably be improved; the wicket user shouldn't have to implement this behaviour himself - that's something the Wicket framework should take care of, imho.
> 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
> Assignee: Juergen Donnerstag
> Fix For: 1.4-RC2
>
>
> 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.