You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by alex shubert <al...@gmail.com> on 2010/11/30 14:28:47 UTC

AjaxButton + Form

Hello!

May someone explain me, why AjaxButton must call his parent form
onSubmittion? It surely did becouse of
	@Override
	protected void onEvent(AjaxRequestTarget target)
	{
		getForm().getRootForm().onFormSubmitted();
 ...


Why to submit form if it's Ajax request?

The real example: I have a filterForm with some fileds where entered
data can be malformed and as so may not be used in filtering. So, I
mistyped something in filter fileds alredy forget about that and
pressing "add" button.
But as FilterForm uses onSubmission user receives error message that
does not  related with his latest activity.
May be there are any way to say AjaxButton not to call form validation
at least? Or the right way is to put such buttons in separate form?
But what if this is "delete current line" button?

-- 
Best regards
Alex

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: AjaxButton + Form

Posted by alex shubert <al...@gmail.com>.
Sure. Just add a Form and AjaxButton and see.
I replaced Button with Link as assembly of object to be ready before
button handler called sounds reasonable for me.

On 1 December 2010 17:46, Andrea Del Bene <ad...@ciseonweb.it> wrote:
> That sounds strange. AjaxButton implements  IFormSubmittingComponent
> interface,  hence it should first invoke its onsubmit method and then parent
> form's onSubmit (as described in Form class JavaDoc).
>
> Is your AjaxButton inside form's hierarchy?
>>
>> It is
>> public final void onFormSubmitted()
>>
>> No, Form#onSubmit is not called at all. After successful execution of
>> internal submission trace proceed to
>> AjaxButton#onSubmit(AjaxRequestTarget target, Form<?>  form)
>>
>>
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>



-- 
Best regards
Alex

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: AjaxButton + Form

Posted by Andrea Del Bene <ad...@ciseonweb.it>.
That sounds strange. AjaxButton implements  IFormSubmittingComponent 
interface,  hence it should first invoke its onsubmit method and then 
parent form's onSubmit (as described in Form class JavaDoc).

Is your AjaxButton inside form's hierarchy?
> It is
> public final void onFormSubmitted()
>
> No, Form#onSubmit is not called at all. After successful execution of
> internal submission trace proceed to
> AjaxButton#onSubmit(AjaxRequestTarget target, Form<?>  form)
>
>
>
>    


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: AjaxButton + Form

Posted by alex shubert <al...@gmail.com>.
It is
public final void onFormSubmitted()

No, Form#onSubmit is not called at all. After successful execution of
internal submission trace proceed to
AjaxButton#onSubmit(AjaxRequestTarget target, Form<?> form)



-- 
Best regards
Alex

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: AjaxButton + Form

Posted by andrea del bene <an...@libero.it>.
Well, Form#onSubmit is called only if form's validation step went fine. 
Maybe some of your fields' validator is preventing form submission.
BTW, where is onSubmission method? Is a Wicket standard method? I can't 
find it in Wicket classes.

> Thanks for your response.
> Looks like I misunderstand the very purpose of the component.
>
> But anyway, this is NOT submission. I mean, if you trace the call to
> the end, you'll find that no call of overridden Form#onSubmit happens.
> only Form#onSubmission called.
> That's why I stay confused. Although it is good to know that Model
> object is validated and assembled on AJAX call arrival...
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: AjaxButton + Form

Posted by alex shubert <al...@gmail.com>.
Thanks for your response.
Looks like I misunderstand the very purpose of the component.

But anyway, this is NOT submission. I mean, if you trace the call to
the end, you'll find that no call of overridden Form#onSubmit happens.
only Form#onSubmission called.
That's why I stay confused. Although it is good to know that Model
object is validated and assembled on AJAX call arrival...


-- 
Best regards
Alex

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: AjaxButton + Form

Posted by Andrea Del Bene <ad...@ciseonweb.it>.
Hi Alex,

AjaxButton was build for submitting form via Ajax and that's why it has 
an AjaxFormSubmitBehavior attached. You could substitute it with 
AjaxLink component if you want to avoid form submitting.


> Hello!
>
> May someone explain me, why AjaxButton must call his parent form
> onSubmittion? It surely did becouse of
> 	@Override
> 	protected void onEvent(AjaxRequestTarget target)
> 	{
> 		getForm().getRootForm().onFormSubmitted();
>   ...
>
>
> Why to submit form if it's Ajax request?
>
> The real example: I have a filterForm with some fileds where entered
> data can be malformed and as so may not be used in filtering. So, I
> mistyped something in filter fileds alredy forget about that and
> pressing "add" button.
> But as FilterForm uses onSubmission user receives error message that
> does not  related with his latest activity.
> May be there are any way to say AjaxButton not to call form validation
> at least? Or the right way is to put such buttons in separate form?
> But what if this is "delete current line" button?
>
>    


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org