Author: thrantal
Date: Sun Sep 28 20:30:01 2008
New Revision: 699973

URL: http://svn.apache.org/viewvc?rev=699973&view=rev
Log:
WICKET-1582: Allowed surpassing the existing RequestCycle reuse in 
executeAjaxEvent() as a more cleaner workaround for the problem. See 
http://www.nabble.com/WICKET-1582-blocked-by-WICKET-254-td19521561.html#a19521561
 for discussion.

Modified:
    
wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java
    
wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/util/tester/MockPageWithFormAndCheckGroup.java
    
wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/util/tester/WicketTesterTest.java

Modified: 
wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java
URL: 
http://svn.apache.org/viewvc/wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java?rev=699973&r1=699972&r2=699973&view=diff
==============================================================================
--- 
wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java
 (original)
+++ 
wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java
 Sun Sep 28 20:30:01 2008
@@ -1128,19 +1128,8 @@
                failMessage = "No AjaxEventBehavior found on component: " + 
component.getId() +
                        " which matches the event: " + event;
                notNull(failMessage, ajaxEventBehavior);
+               WebRequestCycle requestCycle = resolveRequestCycle();
 
-               // initialize the request only if needed to allow the user to 
pass
-               // request parameters, see
-               // WICKET-254
-               WebRequestCycle requestCycle;
-               if (RequestCycle.get() == null)
-               {
-                       requestCycle = setupRequestAndResponse(true);
-               }
-               else
-               {
-                       requestCycle = (WebRequestCycle)RequestCycle.get();
-               }
                // when the requestcycle is not created via 
setupRequestAndResponse(true), it can happen
                // that the request is not an ajax request -> we have to set 
the header manually
                if (!requestCycle.getWebRequest().isAjax())
@@ -1165,6 +1154,23 @@
                processRequestCycle(requestCycle);
        }
 
+       protected WebRequestCycle resolveRequestCycle()
+       {
+               // initialize the request only if needed to allow the user to 
pass
+               // request parameters, see
+               // WICKET-254
+               WebRequestCycle requestCycle;
+               if (RequestCycle.get() == null)
+               {
+                       requestCycle = setupRequestAndResponse(true);
+               }
+               else
+               {
+                       requestCycle = (WebRequestCycle)RequestCycle.get();
+               }
+               return requestCycle;
+       }
+
        /**
         * Retrieves a <code>TagTester</code> based on a 
<code>wicket:id</code>. If more
         * <code>Component</code>s exist with the same <code>wicket:id</code> 
in the markup, only

Modified: 
wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/util/tester/MockPageWithFormAndCheckGroup.java
URL: 
http://svn.apache.org/viewvc/wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/util/tester/MockPageWithFormAndCheckGroup.java?rev=699973&r1=699972&r2=699973&view=diff
==============================================================================
--- 
wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/util/tester/MockPageWithFormAndCheckGroup.java
 (original)
+++ 
wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/util/tester/MockPageWithFormAndCheckGroup.java
 Sun Sep 28 20:30:01 2008
@@ -61,6 +61,7 @@
 
                        protected void onSubmit(AjaxRequestTarget target, Form 
form)
                        {
+                               target.addComponent(this);
                        }
                });
        }

Modified: 
wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/util/tester/WicketTesterTest.java
URL: 
http://svn.apache.org/viewvc/wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/util/tester/WicketTesterTest.java?rev=699973&r1=699972&r2=699973&view=diff
==============================================================================
--- 
wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/util/tester/WicketTesterTest.java
 (original)
+++ 
wicket/branches/wicket-1.3.x/jdk-1.4/wicket/src/test/java/org/apache/wicket/util/tester/WicketTesterTest.java
 Sun Sep 28 20:30:01 2008
@@ -20,11 +20,8 @@
 
 import junit.framework.TestCase;
 
-import org.apache.wicket.Component;
-import org.apache.wicket.MockPageWithLink;
-import org.apache.wicket.MockPageWithOneComponent;
-import org.apache.wicket.Page;
-import org.apache.wicket.Session;
+import org.apache.wicket.*;
+import org.apache.wicket.protocol.http.WebRequestCycle;
 import org.apache.wicket.ajax.AjaxEventBehavior;
 import org.apache.wicket.ajax.AjaxRequestTarget;
 import org.apache.wicket.ajax.markup.html.AjaxLink;
@@ -461,6 +458,19 @@
                tester.clickLink("submitLink");
        }
 
+       public void 
testTesterCanBeOverridenToNotReuseExistingRequestCycleInExecuteAjaxEvent()
+       {
+               tester = new WicketTester(new MyMockApplication()) {
+                       protected WebRequestCycle resolveRequestCycle()
+                       {
+                               return setupRequestAndResponse(true);
+                       }
+               };
+               tester.startPage(MockPageWithFormAndCheckGroup.class);
+               tester.executeAjaxEvent("submitLink", "onclick");
+               tester.assertComponentOnAjaxResponse("submitLink");
+       }
+
        /**
         * Test that the executeAjaxEvent "submits" the form if the event is a 
AjaxFormSubmitBehavior.
         */


Reply via email to