I think I've found a bug in FormTester.  Or maybe just a limitation.  When 
submitting a form you have no way of specifying the button that was actually 
clicked.  All buttons are marked as pressed, so the form visitor just finds the 
first one and marks it as the sender.  My suggestion is that FormTester 
shouldn't add a marker string to buttons, and a new submit(buttonName) method 
should be created.  I'd submit a formal patch, but I've never used 'patch' and 
the long weekend starts in an hour :)

  Here's the changes I'm proposing:
        FormTester(final String path, final Form workingForm, final 
WicketTester wicketTester, boolean fillBlankString)
        {
                this.path = path;
                this.workingForm = workingForm;
                this.wicketTester = wicketTester;
                this.wicketTester.setupRequestAndResponse();

                if (fillBlankString)
                {
                        workingForm.visitFormComponents(new 
FormComponent.IVisitor()
                        {
                                public void formComponent(FormComponent 
formComponent)
                                {
                                        if (formComponent.isEnabled() && 
!(formComponent instanceof Button)) { // JUST ADDED THE SECOND PART 
                                                
setValue(formComponent.getInputName(), "");
                                        }
                                }
                        });
                }
        }

   And the new submit method (keep the old one!):
        public void submit(String submitButtonPath) {
                checkClosed();
                try {
                        
wicketTester.getServletRequest().setParameter(submitButtonPath, "marker");
                        
wicketTester.getServletRequest().setRequestToComponent(workingForm);
                        wicketTester.processRequestCycle();
                } finally {
                        closed = true;
                }
        }

  Seems to have worked for my test cases.


    []s Gus

   


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid0944&bid$1720&dat1642
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to