There might be a bug with executeAjaxEvent in WicketTester: everytime I use
it to fire off an ajax event in a form, page redirection goes nuts.  For
example, the following test code:

        Public class MyTestCase extends TestCase {
        final MyWicketTester tester = new MyWicketTester(application);
        ...
        ...
        ...
        public void testHomePage() {
        tester.startPage(HomePage.class);
        
        FormTester form = tester.newFormTester("inputForm");
        form.setValue("text1", "Testing text");
        tester.executeAjaxEvent("inputForm:text1", "onchange");
        form.submit();
        
[0]    tester.assertRenderedPage(OtherPage.class);
         }

will fail at [0] with "expected OtherPage.class but got HomePage.class". 
If, on the other hand, I remove the executeAjaxEvent call, everything works
fine.  The page code looks like this:
        private class HomePage extends WebPage
        
        public HomePage()  {
                 add(new InputForm("inputForm"));
        }
        ...            
        ...
        ...
        private class InputForm extends Form {
        ...
        ...
        ...
        text1 = new TextField("text1", new PropertyModel(this, string1));
        text1.add(new OnChangeAjaxBehavior() {

                @Override
                protected void onUpdate(final AjaxRequestTarget target) {
                        System.out.println("Text1 onChangeAjaxBehavior fired");
                        
                        string2 = string1;
                        target.addComponent(text2);
                }
        });
        add(text1);
        
        text2 = new TextField("text2", new PropertyModel(this, string2));
        text2.setOutputMarkupId(true);
        add(text2);
        ...
        ...
        ...
        public final void onSubmit()
        {
                setResponsePage(OtherPage.class);
        }
        ...
        ...
        ...

I've checked for validation errors, errors in my code, tried using behaviors
instead, tried firing the ajax event off multiple times, all to no avail. 
Is executeAjaxEvent broken?  

Luke

-- 
View this message in context: 
http://www.nabble.com/Wicket-tester%3A-executeAjaxEvent-broken--tp14828557p14828557.html
Sent from the Wicket - Dev mailing list archive at Nabble.com.

Reply via email to