[ 
https://issues.apache.org/jira/browse/WICKET-2150?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Dave Schoorl updated WICKET-2150:
---------------------------------

    Attachment: wizard-patch-revised-1.3.x.txt

Yes, but I need to override the Wizard's newForm methods like this:

        /**
         * Create a new form. Clients can override this method to provide a 
custom {...@link Form}.
         * 
         * @param id
         *            The id to be used to construct the component
         * @return a new form
         */
        protected Form newForm(String id)
        {
                return new Form(id)
                {
                        private static final long serialVersionUID = 1L;

                        protected void delegateSubmit(IFormSubmittingComponent 
submittingComponent)
                        {
                                /*
                                 * In the standard submit flow, the onSubmit of 
the Form is called after the
                                 * onSubmit of the submittingComponent. For the 
Wizard, this must be reversed.
                                 */

                                Form formToProcess = this;
                                if (submittingComponent != null)
                                {
                                        // use the form which the 
submittingComponent has submitted for further
                                        // processing
                                        formToProcess = 
submittingComponent.getForm();
                                }

                                // call onSubmit on the submitted form
                                formToProcess.onSubmit();

                                // call onSubmit on nested forms
                                formToProcess.visitChildren(Form.class, new 
IVisitor()
                                {
                                        public Object component(Component 
component)
                                        {
                                                Form form = (Form)component;
                                                if (form.isEnabled() && 
form.isEnableAllowed() &&
                                                        
form.isVisibleInHierarchy())
                                                {
                                                        form.onSubmit();
                                                        return 
IVisitor.CONTINUE_TRAVERSAL;
                                                }
                                                return 
IVisitor.CONTINUE_TRAVERSAL_BUT_DONT_GO_DEEPER;
                                        }
                                });

                                // reverse standard flow: execute the 
submittingComponent#onSubmit
                                // after the Form#onSubmit()
                                submittingComponent.onSubmit();
                        }
                };
        }


In order for this to work, I need Form.onSubmit() to be public. If this is not 
adjusted in the Wizard, than the Wizard is not working properly. See my 
attached patch 'wizard-patch-revised-1.3.x.txt' with the necessary changes 
(haven't run it in my application yet).

> Wizard executes onSubmit() of wrong nested form
> -----------------------------------------------
>
>                 Key: WICKET-2150
>                 URL: https://issues.apache.org/jira/browse/WICKET-2150
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket-extensions
>    Affects Versions: 1.3.5, 1.4-RC2
>            Reporter: Dave Schoorl
>             Fix For: 1.3.6, 1.4-RC3
>
>         Attachments: wizard-onsubmit.zip, wizard-patch-1.3.x.txt, 
> wizard-patch-1.4.x.txt, wizard-patch-revised-1.3.x.txt
>
>
> When you have a wizard and the steps in the wizard contain nested forms, the 
> onSubmit() of the next - instead of the current - step's nested form is 
> executed. This is caused by the fact that during the advancing of step A to 
> step B, first the view of A is replaced with the view of B on the wizard's 
> form, and after that, the form's (and nested form's) onSubmit() is called, 
> incorrectly calling the onSubmit() of view B.
> The swapping of the view should happen after the wizard's form (and nested 
> forms) onSubmit() has been called.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to