[
https://issues.apache.org/jira/browse/WICKET-4575?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13396801#comment-13396801
]
Carl-Eric Menzel commented on WICKET-4575:
------------------------------------------
I have an implementation for both 6.0 and 1.5.
In 1.5 I have deprecated onSubmit and added onSubmitBeforeForm and
onSubmitAfterForm in an extension interface.
In 6.0 I have moved onSubmit to onSubmitBeforeForm and added onSubmitAfterForm.
It works, the two methods seem intuitive, so that is nice. The implementation
is as simple as I could get it. Still, after talking with martin-g I didn't
push it out to the main branches directly, but set up two sandbox branches
instead so others can have a look. See sandbox/formsubmit-beforeafter-1.5 and
sandbox/formsubmit-beforeafter-6.0.
It's ready to be merged, I'd just like some more comments.
> 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, 6.0.0-beta2
> Reporter: James McIntosh
> Assignee: Carl-Eric Menzel
> Fix For: 6.0.0-RC1
>
>
> 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