Uploaded image for project: 'Wicket'
  1. Wicket
  2. WICKET-1397

AjaxSubmitLink doesn't always find enclosing form properly


    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.3.0-final
    • Fix Version/s: 1.3.2
    • Component/s: None
    • Labels:


      If the AjaxSubmitLink constructor that doesn't take in a form is called, it calls the constructor that does take in a form with null for the form. This seems correct, and it passes the form argument into the constructor of the AjaxFormSubmitBehavior as also seems correct. AjaxFormSubmitBehavior has a private getForm() method that, if the form is null, sensibly searches through the component hierarchy to find a form that contains the component. This is also good.

      The bit that seems wrong is that the overridden onSubmit(AjaxRequestTarget) and onError(AjaxRequestTarget) methods in AjaxSubmitLink's version of AjaxFormSubmitBehavior call AjaxSubmitLink's onSubmit and onError with the form argument that was originally passed into the constructor. This means that if you originally called the one-argument constructor for AjaxSubmitLink, the onSubmit and onError methods will be called with a null form, rather than the actual form that was submitted.

      As far as I can see, an easy fix for this would be to make getForm() in AjaxFormSubmitBehavior protected rather than private, and then to call getForm() in the overridden onSubmit and onError in AjaxSubmitLink's version of AjaxFormSubmitBehavior. That way the AjaxSubmitLink's onSubmit and onError would always be called with the actual form that was submitted.




            • Assignee:
              david.shepherdson David Shepherdson
            • Votes:
              0 Vote for this issue
              0 Start watching this issue


              • Created: