Author: jcompagner
Date: Sat Oct  4 14:44:29 2008
New Revision: 701717

URL: http://svn.apache.org/viewvc?rev=701717&view=rev
Log:
from 1.3: when the request is an ajax request and the processRequest == false 
(onlyActivePage should be processed) then a page expired shouldnt be thrown, 
just a empty ajax request target should be set

Modified:
    
wicket/trunk/wicket/src/main/java/org/apache/wicket/protocol/http/WebRequestCycleProcessor.java

Modified: 
wicket/trunk/wicket/src/main/java/org/apache/wicket/protocol/http/WebRequestCycleProcessor.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/protocol/http/WebRequestCycleProcessor.java?rev=701717&r1=701716&r2=701717&view=diff
==============================================================================
--- 
wicket/trunk/wicket/src/main/java/org/apache/wicket/protocol/http/WebRequestCycleProcessor.java
 (original)
+++ 
wicket/trunk/wicket/src/main/java/org/apache/wicket/protocol/http/WebRequestCycleProcessor.java
 Sat Oct  4 14:44:29 2008
@@ -24,6 +24,7 @@
 import org.apache.wicket.IPageMap;
 import org.apache.wicket.IRequestTarget;
 import org.apache.wicket.Page;
+import org.apache.wicket.Request;
 import org.apache.wicket.RequestCycle;
 import org.apache.wicket.Session;
 import org.apache.wicket.AccessStackPageMap.Access;
@@ -58,10 +59,10 @@
         *      org.apache.wicket.request.RequestParameters)
         */
        public IRequestTarget resolve(final RequestCycle requestCycle,
-                       final RequestParameters requestParameters)
+               final RequestParameters requestParameters)
        {
                IRequestCodingStrategy requestCodingStrategy = 
requestCycle.getProcessor()
-                               .getRequestCodingStrategy();
+                       .getRequestCodingStrategy();
 
                final String path = requestParameters.getPath();
                IRequestTarget target = null;
@@ -88,7 +89,7 @@
 
                                        Session session = Session.get();
                                        IPageMap pageMap = 
session.pageMapForName(requestParameters.getPageMapName(),
-                                                       false);
+                                               false);
                                        if (pageMap == null)
                                        {
                                                // requested pagemap no longer 
exists - ignore this
@@ -101,11 +102,10 @@
                                                if 
(accessStackPageMap.getAccessStack().size() > 0)
                                                {
                                                        final Access access = 
(Access)accessStackPageMap.getAccessStack()
-                                                                       .peek();
+                                                               .peek();
 
-                                                       final int pageId = 
Integer
-                                                                       
.parseInt(Strings.firstPathComponent(requestParameters
-                                                                               
        .getComponentPath(), Component.PATH_SEPARATOR));
+                                                       final int pageId = 
Integer.parseInt(Strings.firstPathComponent(
+                                                               
requestParameters.getComponentPath(), Component.PATH_SEPARATOR));
 
                                                        if (pageId != 
access.getId())
                                                        {
@@ -117,7 +117,7 @@
                                                        {
                                                                final int 
version = requestParameters.getVersionNumber();
                                                                if (version != 
Page.LATEST_VERSION &&
-                                                                               
version != access.getVersion())
+                                                                       version 
!= access.getVersion())
                                                                {
                                                                        // 
version is no longer the active version -
                                                                        // 
ignore this request
@@ -145,7 +145,16 @@
                        }
                        else
                        {
-                               throw new PageExpiredException("Request cannot 
be processed");
+                               Request request = requestCycle.getRequest();
+                               if (request instanceof WebRequest && 
((WebRequest)request).isAjax())
+                               {
+                                       // if processRequest is false in an 
ajax request just have an empty ajax target
+                                       target = 
EmptyAjaxRequestTarget.getInstance();
+                               }
+                               else
+                               {
+                                       throw new PageExpiredException("Request 
cannot be processed");
+                               }
                        }
                }
                // See whether this request points to a shared resource
@@ -179,10 +188,10 @@
                                // If the target is still null and there was a 
component path
                                // then the Page could not be located in the 
session
                                throw new PageExpiredException(
-                                               "Cannot find the rendered page 
in session [pagemap=" +
-                                                               
requestParameters.getPageMapName() + ",componentPath=" +
-                                                               
requestParameters.getComponentPath() + ",versionNumber=" +
-                                                               
requestParameters.getVersionNumber() + "]");
+                                       "Cannot find the rendered page in 
session [pagemap=" +
+                                               
requestParameters.getPageMapName() + ",componentPath=" +
+                                               
requestParameters.getComponentPath() + ",versionNumber=" +
+                                               
requestParameters.getVersionNumber() + "]");
                        }
                }
                else
@@ -190,28 +199,25 @@
                        // a target was found, but not by looking up a mount. 
check whether
                        // this is allowed
                        if 
(Application.get().getSecuritySettings().getEnforceMounts() &&
-                                       
requestCodingStrategy.pathForTarget(target) != null)
+                               requestCodingStrategy.pathForTarget(target) != 
null)
                        {
                                String msg = "Direct access not allowed for 
mounted targets";
                                // the target was mounted, but we got here via 
another path
                                // : deny the request
                                log.error(msg + " [request=" + 
requestCycle.getRequest() + ",target=" + target +
-                                               ",session=" + Session.get() + 
"]");
+                                       ",session=" + Session.get() + "]");
                                throw new 
AbortWithWebErrorCodeException(HttpServletResponse.SC_FORBIDDEN, msg);
                        }
                }
 
-               // (WICKET-1356) in case no target was found, return null here. 
RequestCycle will deal with it
-               // possible letting wicket filter to pass the request down the 
filter chain             
+               // (WICKET-1356) in case no target was found, return null here. 
RequestCycle will deal with
+               // it
+               // possible letting wicket filter to pass the request down the 
filter chain
                /*
-               if (target == null)
-               {
-                       // if we get here, we have no recognized Wicket target, 
and thus
-                       // regard this as a external (non-wicket) resource 
request on
-                       // this server
-                       return resolveExternalResource(requestCycle);
-               }
-               */
+                * if (target == null) { // if we get here, we have no 
recognized Wicket target, and thus //
+                * regard this as a external (non-wicket) resource request on 
// this server return
+                * resolveExternalResource(requestCycle); }
+                */
 
                return target;
        }


Reply via email to