You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Marieke Vandamme (JIRA)" <ji...@apache.org> on 2007/06/14 08:01:49 UTC

[jira] Created: (WICKET-645) Form with ajaxsubmitbutton won't submit after error

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.


[jira] Commented: (WICKET-645) Form with ajaxsubmitbutton won't submit after error

Posted by "Marieke Vandamme (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-645?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12506069 ] 

Marieke Vandamme commented on WICKET-645:
-----------------------------------------

Hello,

I found my workaround for this.
I need to add the Feedbackpanel to my form and append it to my target when the ajax onError method is called.
In the Feedbackpanel following code is important :
           final FeedbackMessage message = (FeedbackMessage)listItem.getModelObject();
           message.markRendered();
When the feedbackmessages aren't rendered, they are never cleared in the cleanupFeedbackMessages() from the session.

I want to handle the error messages myself, so I added the feedbackpanel, but added style="display:none" to it. In 1.2.6 I could handle the error messages without adding the feedbackpanel.

> 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.