[
https://issues.apache.org/jira/browse/WICKET-4575?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13295657#comment-13295657
]
Carl-Eric Menzel commented on WICKET-4575:
------------------------------------------
Both this and WICKET-1894 present valid use cases, so I think we need to
support both. Ideally, each submit button should be able to choose whether it
wants to run before or after Form#onSubmit.
In 6.0 this should be easy - I'm going to give IFormSubmitter an additional
method #getSubmitOrder to return an enum value, either BEFORE_FORM or
AFTER_FORM. The existing buttons can default to return BEFORE_FORM as 1.5 is
doing now. Form#delegateSubmit can then simply switch the order around
depending on this value.
This would be an API break for 1.5 though. What are good options to add this
anyway? We could give 1.5 an additional Interface IOrderedFormSubmitter extends
IFormSubmitter, and have all default implementations like AjaxFallbackButton
etc implement it. In 6.0 it could be dropped again.
Opinions?
> 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
> Assignee: Carl-Eric Menzel
>
> 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