[
https://issues.apache.org/jira/browse/WICKET-4575?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13288077#comment-13288077
]
Martin Grigorov commented on WICKET-4575:
-----------------------------------------
The change in the order is caused by WICKET-1894.
> AjaxButton / AjaxFormSubmitBehavior behaviour in wicket 1.5
> -----------------------------------------------------------
>
> Key: WICKET-4575
> URL: https://issues.apache.org/jira/browse/WICKET-4575
> Project: Wicket
> Issue Type: Bug
> Components: wicket
> Affects Versions: 1.5.0
> Reporter: James McIntosh
>
> I've just been going through an upgrade form wicket 1.4 to 1.5 and noticed a
> big change in the AjaxFormSubmitBehavior.onEvent(AjaxRequestTarget).
> In 1.4 the code would submit the From.onSubmit() first and then fire the
> AjaxFormSubmitBehavior.onSubmit() event, now this behaviour is reversed to
> process the AjaxFormSubmitBehavior first.
> I have lots of examples of requiring the AjaxButton to perform "on after
> submit" ajax events, e.g. Ajax Wizard navigation, closing modals after form
> submit. These ajax events change the component heirachy so that the form is
> no longer present, thus never gets submitted e.g. Next button. I have no
> particular cases where I would want the AjaxButton onSubmit called before the
> form submit, I'm wondering if there are many at all.
> I'm not sure of the implications of changing the AjaxFormSubmitBehavior logic
> for other components which use it so I will make a suggestion to modify the
> AjaxFormSubmitBehaviour's onEvent and onSubmit in the AjaxButton to emulate
> the original behaviour:
> new AjaxFormSubmitBehavior(form, "onclick") {
> boolean formSubmited;
> protected void onEvent(AjaxRequestTarget target) {
> formSubmited = false;
> super.onEvent(target);
> if (formSubmited) {
> LegacyAjaxButton.this.onSubmit(target,
> LegacyAjaxButton.this.getForm());
> }
> }
>
> protected void onSubmit(AjaxRequestTarget target) {
> formSubmited = true;
> LegacyAjaxButton.this.onBeforeSubmit(target,
> LegacyAjaxButton.this.getForm());
> }
>
> ...
>
> }
> and add an onBeforeSubmit method to the AjaxButton.
> protected void onBeforeSubmit(AjaxRequestTarget target, Form<?> form) {
>
> }
> The other possible solution would be to change the IFormSubmitter to have
> both an onAfterSubmit() and call it in Form.delegateSubmit().
> Just as a side note, I've noticed some other chatter on mailing lists around
> this (see below) so thought I would raise it.
> AjaxWizard issue:
> http://www.mail-archive.com/[email protected]/msg71273.html
> AjaxButton issue:
> http://comments.gmane.org/gmane.comp.java.wicket.user/96947
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira