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

AjaxFormSubmitBehavior throws an NullPointerException when getForm() is overridden

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.4-RC4
    • 1.4-RC6
    • None
    • None

    Description

      I have an AjaxFormSubmitBehavior where I don't pass the form parameter in the constructor, but have overridden the getForm() method to find the related form. (The form is not parent of the button this behavior is attached to, so can not be found by the behavior itself).

      When I "click" on the button attached, the form is submitted nicely, but after the onSubmit call I get this exception:

      java.lang.NullPointerException

      at org.apache.wicket.ajax.form.AjaxFormSubmitBehavior.onEvent(AjaxFormSubmitBehavior.java:142)
      at org.apache.wicket.ajax.AjaxEventBehavior.respond(AjaxEventBehavior.java:166)
      at org.apache.wicket.ajax.AbstractDefaultAjaxBehavior.onRequest(AbstractDefaultAjaxBehavior.java:299)
      at org.apache.wicket.request.target.component.listener.BehaviorRequestTarget.processEvents(BehaviorRequestTarget.java:113)
      at org.apache.wicket.request.AbstractRequestCycleProcessor.processEvents(AbstractRequestCycleProcessor.java:92)
      at org.apache.wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:1240)
      at org.apache.wicket.RequestCycle.step(RequestCycle.java:1319)

      Having a look at the source it seems there is a but at this line in AjaxFormSubmitBehavior:

      @Override
      protected void onEvent(AjaxRequestTarget target)

      { ... if (form.findParent(Page.class) != null) ... }

      I think that should be :
      ... getForm().findParent(Page.class)

      unless, there is a good reason not to be so?

      Btw; I am using wicket version 1.4rc4.

      Attachments

        Activity

          People

            ivaynberg Igor Vaynberg
            zluspai@freemail.hu Zoltan Luspai
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: