ok here is my first pass. i cannot reproduce the problem, so i am kinda flying blind here - all i know for sure is that it compiles

it seems to me that as soon as you change the page the browser dumps the old _javascript_, in my case looks like it also dumps any running ajax requests. i tried both ie and ffox.

i added a self upating counter that keeps updating every 1 sec and a link to go to another page, havent been able to catch the right timing i guess

anyways, i am attaching the patch, let me know if it works for you and we can take it from here

-Igor



On 5/23/06, Igor Vaynberg <[EMAIL PROTECTED]> wrote:
i got up extra early to take care of this, so by the end of the day

-igor


On 5/23/06, Ari Suutari < [EMAIL PROTECTED]> wrote:
This is so great !

    TIA,

            Ari S.

----- Original Message -----
From: "Johan Compagner" < [EMAIL PROTECTED]>
To: < wicket-user@lists.sourceforge.net>
Sent: Tuesday, May 23, 2006 11:37 AM
Subject: Re: [Wicket-user] pagemap problem with late arriving ajax request


We will fix it in the 1.2 branch.

I am currently a bit full of work for at least 2 days. So i can only look at
it by the end of this week.

johan


On 5/23/06, Ari Suutari <[EMAIL PROTECTED] > wrote:
>
> Hi,
>
> >best thing todo currently is to have that -1 check in the pagemap and
> make
> >your own version of wicket 1.2
>
>     We already decided to put my modified version to production and
>     if there are no side effects from my change we can keep it for some
> time.
>
> >in trunk (2.0) this is already fixed in the default setting because we
> >refactored the pagemap
> >and have now a different default pagemap and httpsessionstore.
>
>     You mean that if I would use 2.0 from trunk the problem would go
>     away ? If so, would it be possible to back-port the new pagemap
>     to 1.2 branch ? Not as default, but something that I could turn on
> from
>     application settings ?
>
>     Another point: when 1.2 is released, someone else might also
>     hit this problem so it might be necessary to implement some kind
>     of fix anyway (at least for us, some pages were almost unusable
>     because of this as other pages worked quite ok - it seems that YMMV).
>
>         Ari S.
>
> On 5/23/06, Ari Suutari < [EMAIL PROTECTED] > wrote:
> >
> > Hi,
> >
> > It is very important for us to get this fixed, preferably for 1.2.
> > If any wicket committer is willing to help us, we will pay
> > for the work (please contact me directly by e-mail for this).
> >
> >     Ari S.
> >
> > ----- Original Message -----
> > From: "Igor Vaynberg" < [EMAIL PROTECTED]>
> > To: < wicket-user@lists.sourceforge.net>
> > Sent: Monday, May 22, 2006 6:21 PM
> > Subject: Re: [Wicket-user] pagemap problem with late arriving ajax
> request
> >
> >
> > problem is, not every ajax behavior uses version -1. i guess we need to
> > have
> > the ability to tag a request as process-only-if-page-is-active
> >
> > -Igor
> >
> >
> > On 5/22/06, Ari Suutari <[EMAIL PROTECTED] > wrote:
> > >
> > > If I modify the PageMap.java like this:
> > >
> > > final Page get(final int id, int versionNumber)
> > > {
> > >     final IPageMapEntry entry =
> > > (IPageMapEntry)session.getAttribute(attributeForId(id));
> > >     if (entry != null)
> > >     {
> > >              if (versionNumber == -1) {
> > >                 Access a = peekAccess();
> > >                 if (a.getId() != id)
> > >                     return null;
> > >      }
> > >
> > > So this kludgery piece of the code checks that if request is coming
> from
> > > ajax
> > > (ie. versionNumber == -1) and the topmost page is not the one being
> > > requested
> > > -> return null.
> > >
> > > After adding this it looks like I cannot reproduce the problem any
> more.
> > >
> > >     Ari S.
> > >
> > > ----- Original Message -----
> > > From: "Johan Compagner" < [EMAIL PROTECTED]>
> > > To: < wicket-user@lists.sourceforge.net>
> > > Sent: Monday, May 22, 2006 2:37 PM
> > > Subject: Re: [Wicket-user] pagemap problem with late arriving ajax
> > request
> > >
> > >
> > > So what request comes first?
> > > The ajax request should always do -1 (so latest release)
> > > So if the request from the new page did come first then the ajax
> request
> > > shouild work on that new page.
> > > If the ajax request did come a bit earlier then there shouldn't be a
> > > problem
> > > at all because
> > > the last reqest will be the normal link click for a new page.
> > >
> > > johan
> > >
> > >
> > > On 5/22/06, Ari Suutari < [EMAIL PROTECTED]> wrote:
> > > >
> > > > I cannot figure out any workaround myself.
> UnversionedBehaviorListener
> > > > seems to use -1 as
> > > > page version number, would it make any sense to try to alter PageMap
> > so
> > > > that
> > > > if version is -1 the page stack is not cleared ?
> > > >
> > > >     Ari S.
> > > >
> > > > ----- Original Message -----
> > > > From: "Matej Knopp" <[EMAIL PROTECTED]>
> > > > To: < wicket-user@lists.sourceforge.net >
> > > > Sent: Monday, May 22, 2006 11:44 AM
> > > > Subject: Re: [Wicket-user] pagemap problem with late arriving ajax
> > > request
> > > >
> > > >
> > > > >I guess this is because in 1.2 pagemap behaves like stack. Johan?
> > > > >
> > > > > -Matej
> > > > >
> > > > > Ari Suutari wrote:
> > > > >> Hi,
> > > > >>
> > > > >> I'm having a problem with wicket's ajax stuff where an ajax
> request
> > > > >> fired by previous page hits the web server after user has clicked
> a
> > > > link
> > > > >> which has already transferred him to next page.
> > > > >>
> > > > >> This might be a problem in my application, but I'm seeking for
> > ideas
> > > > >> to solve this.
> > > > >>
> > > > >>> From web server's access log:
> > > > >>
> > > > >> First there are some normal ajax requests arriving from browser:
> > > > >>
> > > > >> 192.168.5.102 - - [22/May/2006:07:46:43 +0000] "GET
> > > > >>
> > > >
> > >
> >
> /wicket?wicket:interface=:0:uiPanel:viewPanel:normalView:panels:0:panel:listTableSpan:-1:IUnversionedBehaviorListener&wicket:behaviorId=0&random=
> > >
> > > > 0.35930677427195573
> > > > >> HTTP/1.1" 200 824
> > > > >> 192.168.5.102 - - [22/May/2006:07:46:43 +0000] "GET
> > > > >>
> > > >
> > >
> >
> /wicket?wicket:interface=:0:uiPanel:viewPanel:normalView:panels:0:panel:listTableSpan:-1:IUnversionedBehaviorListener&wicket:behaviorId=0&random=
> > >
> > > > 0.11935459751117722
> > > > >> HTTP/1.1" 200 824
> > > > >>
> > > > >> Here, user clicks a link which transfers application to help
> page,
> > it
> > > > is displayed ok.
> > > > >>
> > > > >> 192.168.5.102 - - [22/May/2006:07:46:43 +0000] "GET
> > > >
> /wicket?wicket:interface=:0:uiPanel:topPanel:showHelp:34:ILinkListener
> > > > >> HTTP/1.1" 302 -
> > > > >> 192.168.5.102 - - [22/May/2006:07:46:43 +0000] "GET
> > > > /wicket?wicket:interface=:34:: HTTP/1.1" 200 3191
> > > > >>
> > > > >> Now, for some reason a ajax request arrives from previous page,
> > which
> > >
> > > > causes to pagemap stack to be
> > > > >> popped so the page user's browser is on is removed from page map.
> > > > >>
> > > > >> 192.168.5.102 - - [22/May/2006:07:46:43 +0000] "GET
> > > > >>
> > > >
> > >
> >
> /wicket?wicket:interface=:0:uiPanel:viewPanel:normalView:panels:0:panel:listTableSpan:-1:IUnversionedBehaviorListener&wicket:behaviorId=0&random=
> > > > 0.2873453536331084
> > > > >> HTTP/1.1" 200 824
> > > > >>
> > > > >> Now, user presses a link on the page but gets 'page expired'
> > message,
> > > > because the page
> > > > >> is no longer in pagemap.
> > > > >>
> > > > >> 192.168.5.102 - - [22/May/2006:07:46:44 +0000] "GET
> > > > /wicket?wicket:interface=:34:back::ILinkListener HTTP/1.1" 404 651
> > > > >>
> > > > >> Any ideas what I could do to fix this ? The ajax requests are
> fired
> > > > asynchronously by a system which is very
> > > > >> similar to AjaxSelfUpdatingTimerBehaviour stuff.
> > > > >>
> > > > >>    Ari S.
> > > > >>
> > > > >>
> > > > >>
> > > > >> -------------------------------------------------------
> > > > >> Using Tomcat but need to do more? Need to support web services,
> > > > security?
> > > > >> Get stuff done quickly with pre-integrated technology to make
> your
> > > job
> > > > easier
> > > > >> Download IBM WebSphere Application Server v.1.0.1 based on Apache
> > > > Geronimo
> > > > >>
> > > >
> > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
> > >
> > > > >> _______________________________________________
> > > > >> Wicket-user mailing list
> > > > >> Wicket-user@lists.sourceforge.net
> > > > >> https://lists.sourceforge.net/lists/listinfo/wicket-user
> > > > >>
> > > > >
> > > > >
> > > > >
> > > > > -------------------------------------------------------
> > > > > Using Tomcat but need to do more? Need to support web services,
> > > > security?
> > > > > Get stuff done quickly with pre-integrated technology to make your
> > job
> > > > easier
> > > > > Download IBM WebSphere Application Server v.1.0.1 based on Apache
> > > > Geronimo
> > > > >
> > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
> > >
> > > > > _______________________________________________
> > > > > Wicket-user mailing list
> > > > > Wicket-user@lists.sourceforge.net
> > > > > https://lists.sourceforge.net/lists/listinfo/wicket-user
> > > > >
> > > >
> > > >
> > > >
> > > > -------------------------------------------------------
> > > > Using Tomcat but need to do more? Need to support web services,
> > > security?
> > > > Get stuff done quickly with pre-integrated technology to make your
> job
> > > > easier
> > > > Download IBM WebSphere Application Server v.1.0.1 based on Apache
> > > Geronimo
> > > >
> > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
> > > > _______________________________________________
> > > > Wicket-user mailing list
> > > > Wicket-user@lists.sourceforge.net
> > > > https://lists.sourceforge.net/lists/listinfo/wicket-user
> > > >
> > >
> > >
> > >
> > > -------------------------------------------------------
> > > Using Tomcat but need to do more? Need to support web services,
> > security?
> > > Get stuff done quickly with pre-integrated technology to make your job
> > > easier
> > > Download IBM WebSphere Application Server v.1.0.1 based on Apache
> > Geronimo
> > >
> > >
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
> > > _______________________________________________
> > > Wicket-user mailing list
> > > Wicket-user@lists.sourceforge.net
> > > https://lists.sourceforge.net/lists/listinfo/wicket-user
> > >
> >
> >
> >
> > -------------------------------------------------------
> > Using Tomcat but need to do more? Need to support web services,
> security?
> > Get stuff done quickly with pre-integrated technology to make your job
> > easier
> > Download IBM WebSphere Application Server v.1.0.1 based on Apache
> Geronimo
> > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
> > _______________________________________________
> > Wicket-user mailing list
> > Wicket-user@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/wicket-user
> >
>
>
>
> -------------------------------------------------------
> Using Tomcat but need to do more? Need to support web services, security?
> Get stuff done quickly with pre-integrated technology to make your job
> easier
> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
> _______________________________________________
> Wicket-user mailing list
> Wicket-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/wicket-user
>



-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


Index: D:/ws/wicket_1_2/src/java/wicket/ajax/AbstractAjaxTimerBehavior.java
===================================================================
--- D:/ws/wicket_1_2/src/java/wicket/ajax/AbstractAjaxTimerBehavior.java        
(revision 5776)
+++ D:/ws/wicket_1_2/src/java/wicket/ajax/AbstractAjaxTimerBehavior.java        
(working copy)
@@ -80,7 +80,7 @@
         */
        protected final String getJsTimeoutCall(final Duration updateInterval)
        {
-               return "setTimeout(function() { " + getCallbackScript(false) + 
" }, "
+               return "setTimeout(function() { " + getCallbackScript(false, 
true) + " }, "
                                + updateInterval.getMilliseconds() + ");";
        }
 
Index: D:/ws/wicket_1_2/src/java/wicket/ajax/AbstractDefaultAjaxBehavior.java
===================================================================
--- D:/ws/wicket_1_2/src/java/wicket/ajax/AbstractDefaultAjaxBehavior.java      
(revision 5776)
+++ D:/ws/wicket_1_2/src/java/wicket/ajax/AbstractDefaultAjaxBehavior.java      
(working copy)
@@ -110,7 +110,7 @@
         */
        protected CharSequence getCallbackScript()
        {
-               return getCallbackScript(true);
+               return getCallbackScript(true, false);
        }
 
        /**
@@ -120,11 +120,15 @@
         *            if true the url will be encoded to execute on the current 
page
         *            version, otherwise url will be encoded to execute on the
         *            latest page version
+        * @param onlyTargetActivePage
+        *            if true the callback to this behavior will be ignore if 
the
+        *            page is not the last one the user accessed
+        * 
         */
-       protected CharSequence getCallbackScript(boolean recordPageVersion)
+       protected CharSequence getCallbackScript(boolean recordPageVersion, 
boolean onlyTargetActivePage)
        {
-               return getCallbackScript("wicketAjaxGet('" + 
getCallbackUrl(recordPageVersion) + "'", null,
-                               null);
+               return getCallbackScript("wicketAjaxGet('"
+                               + getCallbackUrl(recordPageVersion, 
onlyTargetActivePage) + "'", null, null);
        }
 
        /**
@@ -281,7 +285,8 @@
                        throw new IllegalArgumentException("throttleDelay 
cannot be null");
                }
 
-               return new AppendingStringBuffer("wicketThrottler.throttle( 
'").append(throttleId).append("', ").append(
-                               throttleDelay.getMilliseconds()).append(", 
function() { ").append(script).append("});");
+               return new AppendingStringBuffer("wicketThrottler.throttle( 
'").append(throttleId).append(
+                               "', 
").append(throttleDelay.getMilliseconds()).append(", function() { ").append(
+                               script).append("});");
        }
 }
Index: D:/ws/wicket_1_2/src/java/wicket/behavior/AbstractAjaxBehavior.java
===================================================================
--- D:/ws/wicket_1_2/src/java/wicket/behavior/AbstractAjaxBehavior.java 
(revision 5776)
+++ D:/ws/wicket_1_2/src/java/wicket/behavior/AbstractAjaxBehavior.java 
(working copy)
@@ -1,6 +1,7 @@
 /*
- * $Id$
- * $Revision$ $Date$
+ * $Id: AbstractAjaxBehavior.java 5440 2006-04-17 12:07:07 -0700 (Mon, 17 Apr
+ * 2006) jdonnerstag $ $Revision$ $Date: 2006-04-17 12:07:07 -0700 (Mon,
+ * 17 Apr 2006) $
  * 
  * 
==============================================================================
  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
@@ -92,7 +93,7 @@
         */
        public CharSequence getCallbackUrl()
        {
-               return getCallbackUrl(true);
+               return getCallbackUrl(true, false);
        }
 
        /**
@@ -102,10 +103,14 @@
         *            if true the url will be encoded to execute on the current 
page
         *            version, otherwise url will be encoded to execute on the
         *            latest page version
+        * @param onlyTargetActivePage
+        *            if true the callback to this behavior will be ignore if 
the
+        *            page is not the last one the user accessed
         * 
         * @return the url that references this handler
         */
-       public final CharSequence getCallbackUrl(final boolean 
recordPageVersion)
+       public final CharSequence getCallbackUrl(final boolean 
recordPageVersion,
+                       final boolean onlyTargetActivePage)
        {
                if (getComponent() == null)
                {
@@ -136,11 +141,21 @@
                        rli = IUnversionedBehaviorListener.INTERFACE;
                }
 
-               // TODO Post 1.2: URL encoding strategies are not applied 
-               // And you can not simply call getResponse().encodeUrl() as the 
URL might
+               // TODO Post 1.2: URL encoding strategies are not applied
+               // And you can not simply call getResponse().encodeUrl() as the 
URL
+               // might
                // already be encoded.
-               return new 
AppendingStringBuffer(getComponent().urlFor(rli)).append('&').append(
-                               
WebRequestCodingStrategy.BEHAVIOR_ID_PARAMETER_NAME).append('=').append(index);
+               AppendingStringBuffer url = new 
AppendingStringBuffer(getComponent().urlFor(rli)).append(
+                               
'&').append(WebRequestCodingStrategy.BEHAVIOR_ID_PARAMETER_NAME).append('=')
+                               .append(index);
+
+               if (onlyTargetActivePage)
+               {
+                       
url.append("&").append(WebRequestCodingStrategy.IGNORE_IF_NOT_ACTIVE_PARAMETER_NAME)
+                                       .append("=true");
+               }
+
+               return url;
        }
 
        /**
Index: 
D:/ws/wicket_1_2/src/java/wicket/protocol/http/request/WebRequestCodingStrategy.java
===================================================================
--- 
D:/ws/wicket_1_2/src/java/wicket/protocol/http/request/WebRequestCodingStrategy.java
        (revision 5776)
+++ 
D:/ws/wicket_1_2/src/java/wicket/protocol/http/request/WebRequestCodingStrategy.java
        (working copy)
@@ -77,6 +77,14 @@
        /** Pagemap parameter constant */
        public static final String PAGEMAP = NAME_SPACE + "pageMapName";
 
+       /**
+        * Parameter name that tells decode to ignore this request if the
+        * page+version encoded in the url is not on top of the stack. The 
value of
+        * this parameter is not important, it simply has to be present to 
enable
+        * the behavior
+        */
+       public static final String IGNORE_IF_NOT_ACTIVE_PARAMETER_NAME = 
NAME_SPACE + "ignoreIfNotActive";
+
        /** Comparator implementation that sorts longest strings first */
        private static final Comparator lengthComparator = new Comparator()
        {
@@ -148,6 +156,10 @@
                addBookmarkablePageParameters(request, parameters);
                addResourceParameters(request, parameters);
                
parameters.setBehaviorId(request.getParameter(BEHAVIOR_ID_PARAMETER_NAME));
+               if 
(request.getParameter(IGNORE_IF_NOT_ACTIVE_PARAMETER_NAME)!=null) {
+                       parameters.setOnlyProcessIfPathActive(true);
+               }
+               
                Map map = request.getParameterMap();
                Iterator iterator = map.keySet().iterator();
                while (iterator.hasNext())
@@ -345,7 +357,8 @@
                        final String[] components = 
Strings.split(requestString, Component.PATH_SEPARATOR);
                        if (components.length != 2)
                        {
-                               throw new WicketRuntimeException("Invalid 
bookmarkablePage parameter: " + requestString + ", expected: 
'pageMapName:pageClassName'");
+                               throw new WicketRuntimeException("Invalid 
bookmarkablePage parameter: "
+                                               + requestString + ", expected: 
'pageMapName:pageClassName'");
                        }
 
                        // Extract any pagemap name
@@ -756,7 +769,8 @@
                                String path = request.getServletPath();
                                if (path != null && !path.equals(""))
                                {
-                                       if(!buffer.endsWith("/") && 
!path.startsWith("/")) buffer.append("/");
+                                       if (!buffer.endsWith("/") && 
!path.startsWith("/"))
+                                               buffer.append("/");
                                        buffer.append(path);
                                }
                        }
Index: D:/ws/wicket_1_2/src/java/wicket/request/RequestParameters.java
===================================================================
--- D:/ws/wicket_1_2/src/java/wicket/request/RequestParameters.java     
(revision 5776)
+++ D:/ws/wicket_1_2/src/java/wicket/request/RequestParameters.java     
(working copy)
@@ -1,6 +1,7 @@
 /*
- * $Id$
- * $Revision$ $Date$
+ * $Id: RequestParameters.java 4507 2006-02-16 14:51:20 -0800 (Thu, 16 Feb 
2006)
+ * jonathanlocke $ $Revision$ $Date: 2006-02-16 14:51:20 -0800 (Thu, 16
+ * Feb 2006) $
  * 
  * 
==============================================================================
  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
@@ -53,6 +54,12 @@
        /** any version number; 0 for no version. */
        private int versionNumber;
 
+       /**
+        * tells wicket this request should only be processed if the page + 
version
+        * specified are pointing to the last page the user accessed
+        */
+       private boolean onlyProcessIfPathActive = false;
+
        /** any callable interface name (e.g. [EMAIL PROTECTED] 
ILinkListener}). */
        private String interfaceName;
 
@@ -303,6 +310,32 @@
                this.behaviorId = behaviorId;
        }
 
+
+       /**
+        * Gets the only-process-if-path-active flag
+        * 
+        * @see #onlyProcessIfPathActive
+        * 
+        * @return the only-process-if-path-active flag
+        */
+       public boolean isOnlyProcessIfPathActive()
+       {
+               return onlyProcessIfPathActive;
+       }
+
+       /**
+        * Sets the only-process-if-path-active flag
+        * 
+        * @param onlyProcessIfPathActive
+        * 
+        * @see #onlyProcessIfPathActive
+        * 
+        */
+       public void setOnlyProcessIfPathActive(boolean onlyProcessIfPathActive)
+       {
+               this.onlyProcessIfPathActive = onlyProcessIfPathActive;
+       }
+
        /**
         * @see java.lang.Object#toString()
         */
@@ -330,6 +363,8 @@
                {
                        b.append(" resourceKey=").append(getResourceKey());
                }
+               b.append(" 
onlyProcessIfPathActive=").append(isOnlyProcessIfPathActive());
+               
                b.append("]");
                return b.toString();
        }
Index: 
D:/ws/wicket_1_2/src/java/wicket/request/compound/DefaultRequestTargetResolverStrategy.java
===================================================================
--- 
D:/ws/wicket_1_2/src/java/wicket/request/compound/DefaultRequestTargetResolverStrategy.java
 (revision 5776)
+++ 
D:/ws/wicket_1_2/src/java/wicket/request/compound/DefaultRequestTargetResolverStrategy.java
 (working copy)
@@ -28,6 +28,7 @@
 import wicket.IRedirectListener;
 import wicket.IRequestTarget;
 import wicket.Page;
+import wicket.PageMap;
 import wicket.PageParameters;
 import wicket.RequestCycle;
 import wicket.RequestListenerInterface;
@@ -33,6 +34,7 @@
 import wicket.RequestListenerInterface;
 import wicket.Session;
 import wicket.WicketRuntimeException;
+import wicket.PageMap.Access;
 import wicket.authorization.UnauthorizedActionException;
 import wicket.markup.MarkupException;
 import wicket.markup.html.INewBrowserWindowListener;
@@ -40,6 +42,7 @@
 import wicket.protocol.http.request.WebExternalResourceRequestTarget;
 import wicket.request.IRequestCodingStrategy;
 import wicket.request.RequestParameters;
+import wicket.request.target.basic.EmptyRequestTarget;
 import wicket.request.target.component.BookmarkablePageRequestTarget;
 import wicket.request.target.component.ExpiredPageClassRequestTarget;
 import wicket.request.target.component.PageRequestTarget;
@@ -89,7 +92,62 @@
                final String path = requestParameters.getPath();
                if (requestParameters.getComponentPath() != null)
                {
-                       return resolveRenderedPage(requestCycle, 
requestParameters);
+                       // we need to check if this request has been flagged as
+                       // process-only-if-path-is-active and if so make sure 
this condition
+                       // is met
+
+                       // marks whether or not we will be processing this 
request
+                       boolean processRequest = true;
+
+                       if (requestParameters.isOnlyProcessIfPathActive())
+                       {
+                               // this request has indeed been flagged as
+                               // process-only-if-path-is-active
+
+                               Session session = Session.get();
+                               PageMap pageMap = 
session.pageMapForName(requestParameters.getPageMapName(), false);
+                               if (pageMap == null)
+                               {
+                                       // requested pagemap no longer exists - 
ignore this request
+                                       processRequest = false;
+                               }
+                               else
+                               {
+                                       if (pageMap.getAccessStack().size() > 0)
+                                       {
+                                               final Access access = 
(Access)pageMap.getAccessStack().peek();
+
+                                               final int pageId = 
Integer.parseInt(Strings.firstPathComponent(
+                                                               
requestParameters.getComponentPath(), Component.PATH_SEPARATOR));
+
+                                               if (pageId != access.getId())
+                                               {
+                                                       // the page is no 
longer the active page
+                                                       // - ignore this request
+                                                       processRequest = false;
+                                               }
+                                               else
+                                               {
+                                                       final int version = 
requestParameters.getVersionNumber();
+                                                       if (version != 
Page.LATEST_VERSION && version != access.getVersion())
+                                                       {
+                                                               // version is 
no longer the active version -
+                                                               // ignore this 
request
+                                                               processRequest 
= false;
+                                                       }
+                                               }
+                                       }
+                               }
+                       }
+
+                       if (processRequest)
+                       {
+                               return resolveRenderedPage(requestCycle, 
requestParameters);
+                       }
+                       else
+                       {
+                               return EmptyRequestTarget.getInstance();
+                       }
                }
                // see whether this request points to a bookmarkable page
                else if (requestParameters.getBookmarkablePageClass() != null)

Reply via email to