You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Juergen Donnerstag (JIRA)" <ji...@apache.org> on 2009/09/26 13:05:16 UTC

[jira] Resolved: (WICKET-2398) AjaxFormSubmitBehavior cannot be applied to Form

     [ https://issues.apache.org/jira/browse/WICKET-2398?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Juergen Donnerstag resolved WICKET-2398.
----------------------------------------

       Resolution: Fixed
    Fix Version/s: 1.5-M1
         Assignee: Juergen Donnerstag

fixed

> AjaxFormSubmitBehavior cannot be applied to Form
> ------------------------------------------------
>
>                 Key: WICKET-2398
>                 URL: https://issues.apache.org/jira/browse/WICKET-2398
>             Project: Wicket
>          Issue Type: Improvement
>          Components: wicket
>    Affects Versions: 1.4.0
>            Reporter: John Patterson
>            Assignee: Juergen Donnerstag
>            Priority: Minor
>             Fix For: 1.5-M1
>
>
> I need to apply the above behavior directly to a Form rather than to one of its children.  This is so I can listen to the "onsubmit" event of the form itself rather than attach it to a button.
> This patch allows you to do this
> Index: AjaxFormSubmitBehavior.java
> ===================================================================
> --- AjaxFormSubmitBehavior.java	(revision 797714)
> +++ AjaxFormSubmitBehavior.java	(working copy)
> @@ -86,13 +86,20 @@
>  		{
>  			// try to find form in the hierarchy of owning component
>  			Component component = getComponent();
> -			__form = component.findParent(Form.class);
> -			if (__form == null)
> +			if (component instanceof Form)
> +			{
> +				__form = (Form<?>)component;
> +			}
> +			else
>  			{
> -				throw new IllegalStateException(
> -					"form was not specified in the constructor and cannot "
> -						+ "be found in the hierarchy of the component this behavior "
> -						+ "is attached to");
> +				__form = component.findParent(Form.class);
> +				if (__form == null)
> +				{
> +					throw new IllegalStateException(
> +						"form was not specified in the constructor and cannot "
> +							+ "be found in the hierarchy of the component this behavior "
> +							+ "is attached to");
> +				}
>  			}
>  		}
>  		return __form;

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