On reading some material, it explains that when a Button is within a Form,
the Buttons onSubmit should be called before the Forms onSubmit. (if not
configured otherwise). Which makes perfect sense.

However; when I add "AjaxButton" to the Form, and have it within the Form. I
see the order of calling reversed by default implementation. 

As I interrogated, it is how the code is written in AjaxFormSubmitBehavior". 
Notice: getForm().getRootForm().onFormSubmitted() called before
onSubmit(target); -- See code pasted from that class below. being a pure
Ajax call the form is never actually submitted to it allows it to carry on
to the onSubmit(target);.

The question is, why is there a reverse in the concept?

Is it because "target" is loosely associated with Any target and we dont
care if it belongs to the form and hence is a third grade citizen? (hence
comes after the main forms onSumit()) ? ; that makes sense imo thinking
aloud.

(since method is not final I dont think this will ever be an issue but I
just want to confirm the thought process)


        /**
         * 
         * @see
org.apache.wicket.ajax.AjaxEventBehavior#onEvent(org.apache.wicket.ajax.AjaxRequestTarget)
         */
        @Override
        protected void onEvent(AjaxRequestTarget target)
        {
                getForm().getRootForm().onFormSubmitted();
                if (!getForm().isSubmitted())
                { // only process the form submission if the form was actually 
submitted
-> needs to be
                        // enabled and visible
                        return;
                }
                if (!getForm().hasError())
                {
                        onSubmit(target);
                }
                if (getForm().findParent(Page.class) != null)
                {
                        /*
                         * there can be cases when a form is replaced with 
another component in
the onsubmit()
                         * handler of this behavior. in that case form no 
longer has a page and
so calling
                         * .hasError on it will cause an exception, thus the 
check above.
                         */
                        if (getForm().hasError())
                        {
                                onError(target);
                        }
                }
        }


Thanks
-- 
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/onSubmit-sequence-call-with-AjaxFormSubmitBehavior-tp3061241p3061241.html
Sent from the Users forum mailing list archive at Nabble.com.

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

Reply via email to