Uploaded image for project: 'Wicket'
  1. Wicket
  2. WICKET-2016

FormTester (BaseWicketTester.executeAjaxEvent[component,event]) submits also buttons that are hidden (isVisible=false) resulting in exception

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.4-RC1
    • 1.4-RC2
    • wicket
    • None

    Description

      FormTester (BaseWicketTester.executeAjaxEvent[component,event]) submits also buttons that are hidden (isVisible=false) resulting in exception.

      I am trying to ajax-click the visible button, but the formTester arranges even the hidden button to be submitted.. the form processing assumes the hidden button is now the submitting button.. and it is hidden, so an exception is thrown:

      org.apache.wicket.WicketRuntimeException: Submit Button hiddenButton (path=form:hiddenButton) is not visible
      at org.apache.wicket.markup.html.form.Form$2.component(Form.java:604)
      at org.apache.wicket.MarkupContainer.visitChildren(MarkupContainer.java:859)
      at org.apache.wicket.MarkupContainer.visitChildren(MarkupContainer.java:874)
      at org.apache.wicket.markup.html.form.Form.findSubmittingButton(Form.java:588)
      at org.apache.wicket.markup.html.form.Form.onFormSubmitted(Form.java:852)
      at org.apache.wicket.ajax.form.AjaxFormSubmitBehavior.onEvent(AjaxFormSubmitBehavior.java:132)
      at org.apache.wicket.ajax.AjaxEventBehavior.respond(AjaxEventBehavior.java:166)
      at org.apache.wicket.ajax.AbstractDefaultAjaxBehavior.onRequest(AbstractDefaultAjaxBehavior.java:299)
      at org.apache.wicket.util.tester.BaseWicketTester.executeAjaxEvent(BaseWicketTester.java:1170)
      at org.apache.wicket.util.tester.BaseWicketTester.executeAjaxEvent(BaseWicketTester.java:1080)
      at com.mycompany.TestHomePage.testAjaxSubmitWhileAnotherButtonIsNotVisible(TestHomePage.java:33)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at junit.framework.TestCase.runTest(TestCase.java:164)
      at junit.framework.TestCase.runBare(TestCase.java:130)
      at junit.framework.TestResult$1.protect(TestResult.java:106)
      at junit.framework.TestResult.runProtected(TestResult.java:124)
      at junit.framework.TestResult.run(TestResult.java:109)
      at junit.framework.TestCase.run(TestCase.java:120)
      at junit.framework.TestSuite.runTest(TestSuite.java:230)
      at junit.framework.TestSuite.run(TestSuite.java:225)
      at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
      at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)

      I would assume this is an easy fix to the BaseWicketTester.executeAjaxEvent[component,event]) method where it visits the form components...

      An invasive workaround: Just set your hidden button temporarily visible (from within your wickettest) while executing the ajax event

      Attachments

        1. Wicket-Quickstart.zip
          34 kB
          Martin Terra

        Activity

          People

            jdonnerstag Juegen Donnerstag
            mmakundi Martin Terra
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 2h
                2h
                Remaining:
                Remaining Estimate - 2h
                2h
                Logged:
                Time Spent - Not Specified
                Not Specified