Author: ate
Date: Fri Sep 21 06:34:52 2007
New Revision: 578101

URL: http://svn.apache.org/viewvc?rev=578101&view=rev
Log:
WICKET-926: New Wicket Portlet support: Support for detached/popup pages
- cleaner implementation, using better naming and shortened coding but no 
functional or technical changes
See: https://issues.apache.org/jira/browse/WICKET-926#action_12529418

Modified:
    
wicket/branches/wicket-1.3.0-beta3-portlet-support/jdk-1.4/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/ModalWindow.java
    
wicket/branches/wicket-1.3.0-beta3-portlet-support/jdk-1.4/wicket/src/main/java/org/apache/wicket/RequestCycle.java
    
wicket/branches/wicket-1.3.0-beta3-portlet-support/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/link/Link.java
    
wicket/branches/wicket-1.3.0-beta3-portlet-support/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/PortletRequestContext.java

Modified: 
wicket/branches/wicket-1.3.0-beta3-portlet-support/jdk-1.4/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/ModalWindow.java
URL: 
http://svn.apache.org/viewvc/wicket/branches/wicket-1.3.0-beta3-portlet-support/jdk-1.4/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/ModalWindow.java?rev=578101&r1=578100&r2=578101&view=diff
==============================================================================
--- 
wicket/branches/wicket-1.3.0-beta3-portlet-support/jdk-1.4/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/ModalWindow.java
 (original)
+++ 
wicket/branches/wicket-1.3.0-beta3-portlet-support/jdk-1.4/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/ModalWindow.java
 Fri Sep 21 06:34:52 2007
@@ -927,7 +927,7 @@
                        {
                                throw new WicketRuntimeException("Error 
creating page for modal dialog.");
                        }
-                       RequestCycle.get().setNextUrlForNewWindow();
+                       RequestCycle.get().setUrlForNewWindowEncoding();
                        buffer.append("settings.src=\"" + 
RequestCycle.get().urlFor(page) + "\";\n");
 
                        if (getPageMapName() != null)

Modified: 
wicket/branches/wicket-1.3.0-beta3-portlet-support/jdk-1.4/wicket/src/main/java/org/apache/wicket/RequestCycle.java
URL: 
http://svn.apache.org/viewvc/wicket/branches/wicket-1.3.0-beta3-portlet-support/jdk-1.4/wicket/src/main/java/org/apache/wicket/RequestCycle.java?rev=578101&r1=578100&r2=578101&view=diff
==============================================================================
--- 
wicket/branches/wicket-1.3.0-beta3-portlet-support/jdk-1.4/wicket/src/main/java/org/apache/wicket/RequestCycle.java
 (original)
+++ 
wicket/branches/wicket-1.3.0-beta3-portlet-support/jdk-1.4/wicket/src/main/java/org/apache/wicket/RequestCycle.java
 Fri Sep 21 06:34:52 2007
@@ -26,7 +26,6 @@
 import org.apache.wicket.protocol.http.servlet.ServletWebRequest;
 import org.apache.wicket.request.AbstractRequestCycleProcessor;
 import org.apache.wicket.request.ClientInfo;
-import org.apache.wicket.request.IRequestCodingStrategy;
 import org.apache.wicket.request.IRequestCycleProcessor;
 import org.apache.wicket.request.RequestParameters;
 import 
org.apache.wicket.request.target.component.BookmarkableListenerInterfaceRequestTarget;
@@ -269,11 +268,11 @@
        protected Response response;
        
        /**
-        * Boolean if the next urlFor call is intended for a new window 
(ModalWindow, popup, tab).
+        * Boolean if the next to be encoded url is targetting a new window 
(ModalWindow, popup, tab).
         * This temporary flag is specifically needed for portlet-support as 
then such a page needs a special target (Resource) url.
         * After each urlFor call, this flag is reset to false.
         */
-       private transient boolean nextUrlForNewWindow;
+       private transient boolean urlForNewWindowEncoding;
 
        /**
         * Constructor. This instance will be set as the current one for this
@@ -694,26 +693,34 @@
        }
 
        /**
-        * @return true if the page is intended to be displayed in a new window 
(ModalWindow, popup, tab).
+        * @return true if the next to be encoded url is targetting a new 
window (ModalWindow, popup, tab).
         */
-       public final boolean isNextUrlForNewWindow()
+       public final boolean isUrlForNewWindowEncoding()
        {
-               return nextUrlForNewWindow;
+               return urlForNewWindowEncoding;
        }
        
        /**
-        * Indicate if the next urlFor call is intended for a new window 
(ModalWindow, popup, tab).
+        * Indicate if the next to be encoded url is targetting a new window 
(ModalWindow, popup, tab).
         * This temporary flag is specifically needed for portlet-support as 
then such a page needs a special target (Resource) url.
         * After each urlFor call, this flag is reset to false.
         */
-       public final void setNextUrlForNewWindow()
+       public final void setUrlForNewWindowEncoding()
        {
-               nextUrlForNewWindow = true;
+               urlForNewWindowEncoding = true;
        }
        
-       private final CharSequence resetNextUrlForNewWindow(CharSequence url)
+       /**
+        * Returns an encoded URL that references the given request target and 
clears the nextUrlForNewWindow flag.
+        * 
+        * @param requestTarget
+        *            the request target to reference
+        * @return a URL that references the given request target
+        */
+       private final CharSequence encodeUrlFor(final IRequestTarget 
requestTarget)
        {
-               nextUrlForNewWindow = false;
+               CharSequence url = 
getProcessor().getRequestCodingStrategy().encode(this, requestTarget);
+               urlForNewWindowEncoding = false;
                return url;
        }
        
@@ -774,9 +781,7 @@
 
                final IRequestTarget target = new 
BehaviorRequestTarget(component.getPage(), component,
                                listener, params);
-               final IRequestCodingStrategy requestCodingStrategy = 
getProcessor()
-                               .getRequestCodingStrategy();
-               return 
resetNextUrlForNewWindow(requestCodingStrategy.encode(this, target));
+               return encodeUrlFor(target);
        }
 
        /**
@@ -817,9 +822,7 @@
                        // Get the listener interface name
                        target = new ListenerInterfaceRequestTarget(page, 
component, listener);
                }
-               final IRequestCodingStrategy requestCodingStrategy = 
getProcessor()
-                               .getRequestCodingStrategy();
-               return 
resetNextUrlForNewWindow(requestCodingStrategy.encode(this, target));
+               return encodeUrlFor(target);
        }
 
        /**
@@ -843,9 +846,7 @@
                final IRequestTarget target = new 
BookmarkablePageRequestTarget(pageMap == null
                                ? PageMap.DEFAULT_NAME
                                : pageMap.getName(), pageClass, parameters);
-               final IRequestCodingStrategy requestCodingStrategy = 
getProcessor()
-                               .getRequestCodingStrategy();
-               return 
resetNextUrlForNewWindow(requestCodingStrategy.encode(this, target));
+               return encodeUrlFor(target);
        }
 
        /**
@@ -857,8 +858,7 @@
         */
        public final CharSequence urlFor(final IRequestTarget requestTarget)
        {
-               IRequestCodingStrategy requestCodingStrategy = 
getProcessor().getRequestCodingStrategy();
-               return 
resetNextUrlForNewWindow(requestCodingStrategy.encode(this, requestTarget));
+               return encodeUrlFor(requestTarget);
        }
 
        /**
@@ -875,7 +875,7 @@
        {
                IRequestTarget target = new PageRequestTarget(page);
                getSession().touch(((IPageRequestTarget)target).getPage());
-               return urlFor(target);
+               return encodeUrlFor(target);
        }
 
        /**
@@ -906,9 +906,7 @@
                RequestParameters requestParameters = new RequestParameters();
                
requestParameters.setResourceKey(resourceReference.getSharedResourceKey());
                requestParameters.setParameters(parameters);
-               CharSequence url = 
getProcessor().getRequestCodingStrategy().encode(this,
-                               new 
SharedResourceRequestTarget(requestParameters));
-               return resetNextUrlForNewWindow(url);
+               return encodeUrlFor(new 
SharedResourceRequestTarget(requestParameters));
        }
 
        /**

Modified: 
wicket/branches/wicket-1.3.0-beta3-portlet-support/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/link/Link.java
URL: 
http://svn.apache.org/viewvc/wicket/branches/wicket-1.3.0-beta3-portlet-support/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/link/Link.java?rev=578101&r1=578100&r2=578101&view=diff
==============================================================================
--- 
wicket/branches/wicket-1.3.0-beta3-portlet-support/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/link/Link.java
 (original)
+++ 
wicket/branches/wicket-1.3.0-beta3-portlet-support/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/link/Link.java
 Fri Sep 21 06:34:52 2007
@@ -404,7 +404,7 @@
 
                if (popupSettings != null)
                {
-                       RequestCycle.get().setNextUrlForNewWindow();
+                       RequestCycle.get().setUrlForNewWindowEncoding();
                }
                // Set href to link to this link's linkClicked method
                CharSequence url = getURL();

Modified: 
wicket/branches/wicket-1.3.0-beta3-portlet-support/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/PortletRequestContext.java
URL: 
http://svn.apache.org/viewvc/wicket/branches/wicket-1.3.0-beta3-portlet-support/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/PortletRequestContext.java?rev=578101&r1=578100&r2=578101&view=diff
==============================================================================
--- 
wicket/branches/wicket-1.3.0-beta3-portlet-support/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/PortletRequestContext.java
 (original)
+++ 
wicket/branches/wicket-1.3.0-beta3-portlet-support/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/PortletRequestContext.java
 Fri Sep 21 06:34:52 2007
@@ -113,7 +113,7 @@
     
     public CharSequence encodeActionURL(CharSequence path, boolean 
forceActionURL)
     {
-        if ((!forceActionURL && resourceRequest) || 
RequestCycle.get().isNextUrlForNewWindow())
+        if ((!forceActionURL && resourceRequest) || 
RequestCycle.get().isUrlForNewWindowEncoding())
                {
                        return encodeResourceURL(path);
                }
@@ -152,7 +152,7 @@
     
     public CharSequence encodeRenderURL(CharSequence path, boolean 
forceRenderURL)
     {
-        if ((!forceRenderURL && resourceRequest) || 
RequestCycle.get().isNextUrlForNewWindow())
+        if ((!forceRenderURL && resourceRequest) || 
RequestCycle.get().isUrlForNewWindowEncoding())
                {
                        return encodeResourceURL(path);
                }


Reply via email to