You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by zoltan luspai <zl...@gmail.com> on 2009/06/17 16:40:21 UTC
AjaxFormSubmitBehavior throws an NullPointerException when the
getForm() is overridden
Hi,
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.
Cheers
Zoltan
Re: AjaxFormSubmitBehavior throws an NullPointerException when the
getForm() is overridden
Posted by Erik van Oosten <e....@grons.nl>.
Please file an issue in Jira, preferably with a quickstart to
demonstrate the problem. A patch would be even better of course.
Regards,
Erik.
zoltan luspai wrote:
> Hi,
>
>
> 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.
>
>
> Cheers
>
> Zoltan
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org