Author: jcompagner
Date: Sun Apr  6 14:07:21 2008
New Revision: 645309

URL: http://svn.apache.org/viewvc?rev=645309&view=rev
Log:
WICKET-1476
moved read/write to the lowest class (Component) so that circular references to 
pages even if they are in the metadata or child components on markupcontainer.

Added:
    
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/protocol/http/FirstPage.html
    
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/protocol/http/FirstPage.java
    
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/protocol/http/SecondPage.html
    
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/protocol/http/SecondPage.java
    
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/protocol/http/firstpage_result.html
    
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/protocol/http/firstpage_result2.html
    
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/protocol/http/secondpage_result.html
Modified:
    wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Component.java
    wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Page.java
    
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/protocol/http/FilePageStoreTest.java

Modified: 
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Component.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Component.java?rev=645309&r1=645308&r2=645309&view=diff
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Component.java 
(original)
+++ wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Component.java 
Sun Apr  6 14:07:21 2008
@@ -16,6 +16,7 @@
  */
 package org.apache.wicket;
 
+import java.io.IOException;
 import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -4194,5 +4195,30 @@
        public final boolean determineVisibility()
        {
                return isVisible() && isRenderAllowed() && 
isVisibilityAllowed();
+       }
+
+
+       private void writeObject(java.io.ObjectOutputStream s) throws 
IOException
+       {
+               if (this instanceof Page)
+               {
+                       ((Page)this).writePageObject(s);
+               }
+               else
+               {
+                       s.defaultWriteObject();
+               }
+       }
+
+       private void readObject(java.io.ObjectInputStream s) throws 
IOException, ClassNotFoundException
+       {
+               if (this instanceof Page)
+               {
+                       ((Page)this).readPageObject(s);
+               }
+               else
+               {
+                       s.defaultReadObject();
+               }
        }
 }

Modified: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Page.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Page.java?rev=645309&r1=645308&r2=645309&view=diff
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Page.java 
(original)
+++ wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Page.java Sun 
Apr  6 14:07:21 2008
@@ -791,15 +791,14 @@
                                stateless = (Boolean)returnValue;
                        }
 
-                       // TODO (matej_k): The stateless hint semantics has 
been changed, this warning doesn't work anymore. but we don't really have
-                       // alternative to this 
+                       // TODO (matej_k): The stateless hint semantics has 
been changed, this warning doesn't
+                       // work anymore. but we don't really have
+                       // alternative to this
                        /*
-                       if (!stateless.booleanValue() && getStatelessHint())
-                       {
-                               log.warn("Page '" + this + "' is not stateless 
because of '" + returnArray[0] +
-                                       "' but the stateless hint is set to 
true!");
-                       }
-                       */
+                        * if (!stateless.booleanValue() && getStatelessHint()) 
{ log.warn("Page '" + this + "'
+                        * is not stateless because of '" + returnArray[0] + "' 
but the stateless hint is set to
+                        * true!"); }
+                        */
                }
 
                return stateless.booleanValue();
@@ -1275,7 +1274,7 @@
        {
        }
 
-       private void readObject(java.io.ObjectInputStream s) throws 
IOException, ClassNotFoundException
+       void readPageObject(java.io.ObjectInputStream s) throws IOException, 
ClassNotFoundException
        {
                int id = s.readShort();
                String name = (String)s.readObject();
@@ -1306,7 +1305,7 @@
                }
        }
 
-       private void writeObject(java.io.ObjectOutputStream s) throws 
IOException
+       void writePageObject(java.io.ObjectOutputStream s) throws IOException
        {
                s.writeShort(numericId);
                s.writeObject(pageMapName);

Modified: 
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/protocol/http/FilePageStoreTest.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/protocol/http/FilePageStoreTest.java?rev=645309&r1=645308&r2=645309&view=diff
==============================================================================
--- 
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/protocol/http/FilePageStoreTest.java
 (original)
+++ 
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/protocol/http/FilePageStoreTest.java
 Sun Apr  6 14:07:21 2008
@@ -20,14 +20,29 @@
 
 import org.apache.wicket.Session;
 import org.apache.wicket.WicketTestCase;
+import org.apache.wicket.protocol.http.pagestore.DiskPageStore;
+import org.apache.wicket.resource.DummyApplication;
+import org.apache.wicket.session.ISessionStore;
 import org.apache.wicket.util.io.PageA;
 import org.apache.wicket.util.io.PageB;
+import org.apache.wicket.util.tester.WicketTester;
 
 /**
  * @author jcompagner
  */
 public class FilePageStoreTest extends WicketTestCase
 {
+       protected void setUp() throws Exception
+       {
+               tester = new WicketTester(new DummyApplication()
+               {
+                       protected ISessionStore newSessionStore()
+                       {
+                               return new SecondLevelCacheSessionStore(this, 
new DiskPageStore());
+                       }
+               });
+       }
+
        /**
         * @throws Exception
         */
@@ -49,5 +64,19 @@
                Assert.assertEquals(a, a2);
 
                Assert.assertSame(a2, a2.getB().getA());
+       }
+
+       /**
+        * @throws Exception
+        */
+       public void testCircular() throws Exception
+       {
+               executeTest(FirstPage.class, "firstpage_result.html");
+               FirstPage page = (FirstPage)tester.getLastRenderedPage();
+               executedListener(SecondPage.class, page.get("link"), 
"secondpage_result.html");
+
+               executeTest(FirstPage.class, "firstpage_result2.html");
+
+               executedListener(SecondPage.class, page.get("link"), 
"secondpage_result.html");
        }
 }

Added: 
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/protocol/http/FirstPage.html
URL: 
http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/protocol/http/FirstPage.html?rev=645309&view=auto
==============================================================================
--- 
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/protocol/http/FirstPage.html
 (added)
+++ 
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/protocol/http/FirstPage.html
 Sun Apr  6 14:07:21 2008
@@ -0,0 +1,10 @@
+<html xmlns:wicket>
+    <head>
+        <title>Wicket Quickstart Archetype Homepage</title>
+    </head>
+    <body>
+       first page<br/>
+       <a wicket:id="link">link to second page</a>
+    </body>
+</html>
+

Added: 
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/protocol/http/FirstPage.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/protocol/http/FirstPage.java?rev=645309&view=auto
==============================================================================
--- 
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/protocol/http/FirstPage.java
 (added)
+++ 
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/protocol/http/FirstPage.java
 Sun Apr  6 14:07:21 2008
@@ -0,0 +1,31 @@
+package org.apache.wicket.protocol.http;
+
+import org.apache.wicket.Page;
+import org.apache.wicket.markup.html.WebPage;
+import org.apache.wicket.markup.html.link.IPageLink;
+import org.apache.wicket.markup.html.link.PageLink;
+
+public class FirstPage extends WebPage
+{
+
+       public FirstPage()
+       {
+               add(new PageLink("link", new IPageLink()
+               {
+
+                       private static final long serialVersionUID = 1L;
+
+                       SecondPage page = new SecondPage(FirstPage.this);
+
+                       public Page getPage()
+                       {
+                               return page;
+                       }
+
+                       public Class getPageIdentity()
+                       {
+                               return SecondPage.class;
+                       }
+               }));
+       }
+}

Added: 
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/protocol/http/SecondPage.html
URL: 
http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/protocol/http/SecondPage.html?rev=645309&view=auto
==============================================================================
--- 
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/protocol/http/SecondPage.html
 (added)
+++ 
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/protocol/http/SecondPage.html
 Sun Apr  6 14:07:21 2008
@@ -0,0 +1,7 @@
+<html>
+
+<body>
+       second page<br/>
+       <a wicket:id="link">link to first page</a>
+</body>
+</html>
\ No newline at end of file

Added: 
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/protocol/http/SecondPage.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/protocol/http/SecondPage.java?rev=645309&view=auto
==============================================================================
--- 
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/protocol/http/SecondPage.java
 (added)
+++ 
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/protocol/http/SecondPage.java
 Sun Apr  6 14:07:21 2008
@@ -0,0 +1,29 @@
+package org.apache.wicket.protocol.http;
+
+import org.apache.wicket.Page;
+import org.apache.wicket.markup.html.WebPage;
+import org.apache.wicket.markup.html.link.IPageLink;
+import org.apache.wicket.markup.html.link.PageLink;
+
+public class SecondPage extends WebPage
+{
+
+       public SecondPage(final FirstPage page)
+       {
+               add(new PageLink("link", new IPageLink()
+               {
+
+                       private static final long serialVersionUID = 1L;
+
+                       public Page getPage()
+                       {
+                               return page;
+                       }
+
+                       public Class getPageIdentity()
+                       {
+                               return FirstPage.class;
+                       }
+               }));
+       }
+}

Added: 
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/protocol/http/firstpage_result.html
URL: 
http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/protocol/http/firstpage_result.html?rev=645309&view=auto
==============================================================================
--- 
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/protocol/http/firstpage_result.html
 (added)
+++ 
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/protocol/http/firstpage_result.html
 Sun Apr  6 14:07:21 2008
@@ -0,0 +1,10 @@
+<html xmlns:wicket>
+    <head>
+        <title>Wicket Quickstart Archetype Homepage</title>
+    </head>
+    <body>
+       first page<br/>
+       <a href="?wicket:interface=:0:link::ILinkListener::" 
wicket:id="link">link to second page</a>
+    </body>
+</html>
+

Added: 
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/protocol/http/firstpage_result2.html
URL: 
http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/protocol/http/firstpage_result2.html?rev=645309&view=auto
==============================================================================
--- 
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/protocol/http/firstpage_result2.html
 (added)
+++ 
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/protocol/http/firstpage_result2.html
 Sun Apr  6 14:07:21 2008
@@ -0,0 +1,10 @@
+<html xmlns:wicket>
+    <head>
+        <title>Wicket Quickstart Archetype Homepage</title>
+    </head>
+    <body>
+       first page<br/>
+       <a href="?wicket:interface=:2:link::ILinkListener::" 
wicket:id="link">link to second page</a>
+    </body>
+</html>
+

Added: 
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/protocol/http/secondpage_result.html
URL: 
http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/protocol/http/secondpage_result.html?rev=645309&view=auto
==============================================================================
--- 
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/protocol/http/secondpage_result.html
 (added)
+++ 
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/protocol/http/secondpage_result.html
 Sun Apr  6 14:07:21 2008
@@ -0,0 +1,7 @@
+<html>
+
+<body>
+       second page<br/>
+       <a href="?wicket:interface=:1:link::ILinkListener::" 
wicket:id="link">link to first page</a>
+</body>
+</html>
\ No newline at end of file


Reply via email to