Form with ajaxsubmitbutton won't submit after error
---------------------------------------------------

                 Key: WICKET-645
                 URL: https://issues.apache.org/jira/browse/WICKET-645
             Project: Wicket
          Issue Type: Bug
          Components: wicket
    Affects Versions: 1.3.0-beta1
            Reporter: Marieke Vandamme


Posted on the mailing list :
Hello, 

I'm using the Apache Wicket incubating 1.3 and updated my existing application. 
One of my forms wasn't working anymore. I isolated my problem in the code 
below. 
I'm using a form with an AjaxSubmitButton. On my form, one of my components is 
required. 
When user doesn't fill in field and presses the ajaxsubmitbutton, he gets an 
alert telling hem to fill in the required field. 
When user then fills in field and presses submitbutton again, the onError is 
again called instead of the onsubmit. 

Is this a bug (or is it already reported)? 
Thanks in advance. 

------------------------------------------------------------------------------------------------------------------------------
 

public class TestPage extends WebPage { 
  public TestPage() { 
    Form frm = new TestForm("form"); 
    frm.add(new TestSubmitButton("button", frm)); 
    frm.add(new RequiredTextField("name", new PropertyModel(frm, "name"))); 
    add(frm); 
  } 
  
  public class TestForm extends Form { 
    private String name = null; 
    public TestForm(String id){ 
      super(id); 
    } 
    public void setName(String name){ 
      name = name; 
    } 
    public String getName(){ 
      return name; 
    } 
  } 
  
  public class TestSubmitButton extends AjaxSubmitButton { 
    public TestSubmitButton(String id, Form form) { 
      super(id, form); 
    } 

    protected void onSubmit(AjaxRequestTarget ajaxRequestTarget, Form form){ 
      System.out.println("Form submitted"); 
    } 

    protected void onError(final AjaxRequestTarget target, Form form) { 
      target.appendJavascript("alert('Fill in all fields.');"); 
    } 
  } 
}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to