You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by jc...@apache.org on 2006/11/10 22:47:49 UTC

svn commit: r473516 - in /incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket: behavior/ markup/html/form/ markup/html/image/ markup/html/image/resource/ markup/html/link/ protocol/http/

Author: jcompagner
Date: Fri Nov 10 13:47:47 2006
New Revision: 473516

URL: http://svn.apache.org/viewvc?view=rev&rev=473516
Log:
stateless support

Added:
    incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/markup/html/form/StatelessForm.java
    incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/markup/html/link/StatelessLink.java
    incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/protocol/http/FilePageStore.java
    incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/protocol/http/SecondLevelCacheSessionStore.java
Modified:
    incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/behavior/AbstractAjaxBehavior.java
    incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/behavior/AbstractBehavior.java
    incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/behavior/IBehavior.java
    incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/markup/html/form/CheckBox.java
    incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/markup/html/form/CheckGroup.java
    incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/markup/html/form/DropDownChoice.java
    incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/markup/html/form/Form.java
    incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/markup/html/form/ImageButton.java
    incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/markup/html/form/RadioChoice.java
    incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/markup/html/form/RadioGroup.java
    incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/markup/html/image/Image.java
    incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/markup/html/image/resource/LocalizedImageResource.java
    incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/markup/html/link/BookmarkablePageLink.java
    incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/markup/html/link/Link.java
    incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/protocol/http/AbstractHttpSessionStore.java
    incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/protocol/http/HttpSessionStore.java

Modified: incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/behavior/AbstractAjaxBehavior.java
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/behavior/AbstractAjaxBehavior.java?view=diff&rev=473516&r1=473515&r2=473516
==============================================================================
--- incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/behavior/AbstractAjaxBehavior.java (original)
+++ incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/behavior/AbstractAjaxBehavior.java Fri Nov 10 13:47:47 2006
@@ -311,4 +311,12 @@
 	protected void onRenderHeadInitContribution(final Response response)
 	{
 	}
+	
+	/**
+	 * @see wicket.behavior.AbstractBehavior#getStatelessHint()
+	 */
+	public boolean getStatelessHint()
+	{
+		return false;
+	}
 }

Modified: incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/behavior/AbstractBehavior.java
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/behavior/AbstractBehavior.java?view=diff&rev=473516&r1=473515&r2=473516
==============================================================================
--- incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/behavior/AbstractBehavior.java (original)
+++ incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/behavior/AbstractBehavior.java Fri Nov 10 13:47:47 2006
@@ -112,4 +112,12 @@
 	public void cleanup()
 	{
 	}
+	
+	/**
+	 * @see wicket.behavior.IBehavior#getStatelessHint()
+	 */
+	public boolean getStatelessHint()
+	{
+		return true;
+	}
 }

Modified: incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/behavior/IBehavior.java
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/behavior/IBehavior.java?view=diff&rev=473516&r1=473515&r2=473516
==============================================================================
--- incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/behavior/IBehavior.java (original)
+++ incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/behavior/IBehavior.java Fri Nov 10 13:47:47 2006
@@ -105,4 +105,12 @@
 	 *            the unexpected exception
 	 */
 	void exception(Component component, RuntimeException exception);
+	
+	/**
+	 * This method returns false if the behaviour generates a callback url (for
+	 * example ajax behaviours)
+	 * 
+	 * @return boolean true or false.
+	 */
+	boolean getStatelessHint();
 }

Modified: incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/markup/html/form/CheckBox.java
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/markup/html/form/CheckBox.java?view=diff&rev=473516&r1=473515&r2=473516
==============================================================================
--- incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/markup/html/form/CheckBox.java (original)
+++ incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/markup/html/form/CheckBox.java Fri Nov 10 13:47:47 2006
@@ -112,6 +112,18 @@
 	}
 
 	/**
+	 * @see wicket.MarkupContainer#getStatelessHint()
+	 */
+	protected boolean getStatelessHint()
+	{
+		if (wantOnSelectionChangedNotifications())
+		{
+			return false;
+		}
+		return super.getStatelessHint();
+	}
+	
+	/**
 	 * Processes the component tag.
 	 * 
 	 * @param tag

Modified: incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/markup/html/form/CheckGroup.java
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/markup/html/form/CheckGroup.java?view=diff&rev=473516&r1=473515&r2=473516
==============================================================================
--- incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/markup/html/form/CheckGroup.java (original)
+++ incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/markup/html/form/CheckGroup.java Fri Nov 10 13:47:47 2006
@@ -209,5 +209,17 @@
 	{
 		return false;
 	}
+	
+	/**
+	 * @see wicket.MarkupContainer#getStatelessHint()
+	 */
+	protected boolean getStatelessHint()
+	{
+		if (wantOnSelectionChangedNotifications())
+		{
+			return false;
+		}
+		return super.getStatelessHint();
+	}
 
 }

Modified: incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/markup/html/form/DropDownChoice.java
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/markup/html/form/DropDownChoice.java?view=diff&rev=473516&r1=473515&r2=473516
==============================================================================
--- incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/markup/html/form/DropDownChoice.java (original)
+++ incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/markup/html/form/DropDownChoice.java Fri Nov 10 13:47:47 2006
@@ -220,4 +220,16 @@
 	{
 		return false;
 	}
+	
+	/**
+	 * @see wicket.MarkupContainer#getStatelessHint()
+	 */
+	protected boolean getStatelessHint()
+	{
+		if (wantOnSelectionChangedNotifications())
+		{
+			return false;
+		}
+		return super.getStatelessHint();
+	}
 }

Modified: incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/markup/html/form/Form.java
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/markup/html/form/Form.java?view=diff&rev=473516&r1=473515&r2=473516
==============================================================================
--- incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/markup/html/form/Form.java (original)
+++ incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/markup/html/form/Form.java Fri Nov 10 13:47:47 2006
@@ -213,6 +213,11 @@
 		super(id, model);
 	}
 
+	protected boolean getStatelessHint()
+	{
+		return false;
+	}
+	
 	/**
 	 * Gets the default button. If set (not null), a hidden submit button will
 	 * be rendered right after the form tag, so that when users press enter in a
@@ -314,6 +319,11 @@
 					}
 				}
 			}
+		}
+		// If multi part did fail check if an error is registered and call onError
+		else if(hasError())
+		{
+			onError();
 		}
 	}
 

Modified: incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/markup/html/form/ImageButton.java
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/markup/html/form/ImageButton.java?view=diff&rev=473516&r1=473515&r2=473516
==============================================================================
--- incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/markup/html/form/ImageButton.java (original)
+++ incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/markup/html/form/ImageButton.java Fri Nov 10 13:47:47 2006
@@ -113,4 +113,12 @@
 		super.onComponentTag(tag);
 		localizedImageResource.setSrcAttribute(tag);
 	}
+	
+	/**
+	 * @see wicket.markup.html.form.Button#getStatelessHint()
+	 */
+	protected boolean getStatelessHint()
+	{
+		return localizedImageResource.isStateless();
+	}
 }

Modified: incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/markup/html/form/RadioChoice.java
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/markup/html/form/RadioChoice.java?view=diff&rev=473516&r1=473515&r2=473516
==============================================================================
--- incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/markup/html/form/RadioChoice.java (original)
+++ incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/markup/html/form/RadioChoice.java Fri Nov 10 13:47:47 2006
@@ -337,6 +337,18 @@
 	}
 
 	/**
+	 * @see wicket.MarkupContainer#getStatelessHint()
+	 */
+	protected boolean getStatelessHint()
+	{
+		if (wantOnSelectionChangedNotifications())
+		{
+			return false;
+		}
+		return super.getStatelessHint();
+	}
+	
+	/**
 	 * @return Prefix to use before choice
 	 */
 	public final String getPrefix()

Modified: incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/markup/html/form/RadioGroup.java
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/markup/html/form/RadioGroup.java?view=diff&rev=473516&r1=473515&r2=473516
==============================================================================
--- incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/markup/html/form/RadioGroup.java (original)
+++ incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/markup/html/form/RadioGroup.java Fri Nov 10 13:47:47 2006
@@ -70,6 +70,19 @@
 	{
 		return false;
 	}
+	
+	/**
+	 * @see wicket.MarkupContainer#getStatelessHint()
+	 */
+	protected boolean getStatelessHint()
+	{
+		if (wantOnSelectionChangedNotifications())
+		{
+			return false;
+		}
+		return super.getStatelessHint();
+	}
+
 
 	/**
 	 * @see wicket.markup.html.form.FormComponent#convertValue(String[])

Added: incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/markup/html/form/StatelessForm.java
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/markup/html/form/StatelessForm.java?view=auto&rev=473516
==============================================================================
--- incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/markup/html/form/StatelessForm.java (added)
+++ incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/markup/html/form/StatelessForm.java Fri Nov 10 13:47:47 2006
@@ -0,0 +1,63 @@
+/*
+ * $Id: org.eclipse.jdt.ui.prefs 5004 2006-03-17 20:47:08 -0800 (Fri, 17 Mar 2006) eelco12 $
+ * $Revision: 5004 $
+ * $Date: 2006-03-17 20:47:08 -0800 (Fri, 17 Mar 2006) $
+ * 
+ * ==============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package wicket.markup.html.form;
+
+import wicket.model.IModel;
+
+/**
+ * This StatelessForm is the same as a normal form but with the statelesshint default to true.
+ * The form can be newly constructed when the onSubmit of its form or its buttons is called.
+ * So you can't depend on state within the page. The only state you can depend on is what 
+ * was submitted from the browser.  So the model of the form or the formcomponents are updated
+ * with the submit values.
+ * 
+ *            
+ * @author jcompagner
+ */
+public class StatelessForm extends Form
+{
+	private static final long serialVersionUID = 1L;
+
+	/**
+	 * Construct.
+	 * @param parent
+	 * @param id
+	 */
+	public StatelessForm(String id)
+	{
+		super(id);
+	}
+
+	/**
+	 * Construct.
+	 * @param parent
+	 * @param id
+	 * @param model
+	 */
+	public StatelessForm(String id, IModel model)
+	{
+		super(id, model);
+	}
+
+	
+	protected boolean getStatelessHint()
+	{
+		return true;
+	}
+}

Modified: incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/markup/html/image/Image.java
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/markup/html/image/Image.java?view=diff&rev=473516&r1=473515&r2=473516
==============================================================================
--- incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/markup/html/image/Image.java (original)
+++ incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/markup/html/image/Image.java Fri Nov 10 13:47:47 2006
@@ -226,6 +226,14 @@
 	}
 
 	/**
+	 * @see wicket.Component#getStatelessHint()
+	 */
+	protected boolean getStatelessHint()
+	{
+		return getImageResource() == null && localizedImageResource.isStateless();
+	}
+	
+	/**
 	 * @see wicket.Component#onComponentTagBody(MarkupStream, ComponentTag)
 	 */
 	protected void onComponentTagBody(final MarkupStream markupStream, final ComponentTag openTag)

Modified: incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/markup/html/image/resource/LocalizedImageResource.java
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/markup/html/image/resource/LocalizedImageResource.java?view=diff&rev=473516&r1=473515&r2=473516
==============================================================================
--- incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/markup/html/image/resource/LocalizedImageResource.java (original)
+++ incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/markup/html/image/resource/LocalizedImageResource.java Fri Nov 10 13:47:47 2006
@@ -211,6 +211,15 @@
 	{
 		setResourceReference(resourceReference, null);
 	}
+	
+	/**
+	 * @return If it is stateless (if resource is null)
+	 */
+	public final boolean isStateless()
+	{
+		return this.resource == null;
+	}
+	
 	/**
 	 * @param resourceReference
 	 *            The resource to set.

Modified: incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/markup/html/link/BookmarkablePageLink.java
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/markup/html/link/BookmarkablePageLink.java?view=diff&rev=473516&r1=473515&r2=473516
==============================================================================
--- incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/markup/html/link/BookmarkablePageLink.java (original)
+++ incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/markup/html/link/BookmarkablePageLink.java Fri Nov 10 13:47:47 2006
@@ -120,6 +120,11 @@
 		return page.getClass() == pageClass;
 	}
 
+	protected boolean getStatelessHint()
+	{
+		return true;
+	}
+	
 	/**
 	 * THIS METHOD IS NOT USED! Bookmarkable links do not have a click handler.
 	 * It is here to satisfy the interface only, as bookmarkable links will be
@@ -140,9 +145,9 @@
 	 */
 	public final BookmarkablePageLink setPageMap(final PageMap pageMap)
 	{
-		this.pageMapName = pageMap.getName();
 		if (pageMap != null)
 		{
+			this.pageMapName = pageMap.getName();
 			add(new AttributeModifier("target", false, new Model(pageMapName)));
 		}
 		return this;

Modified: incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/markup/html/link/Link.java
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/markup/html/link/Link.java?view=diff&rev=473516&r1=473515&r2=473516
==============================================================================
--- incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/markup/html/link/Link.java (original)
+++ incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/markup/html/link/Link.java Fri Nov 10 13:47:47 2006
@@ -224,6 +224,11 @@
 		}
 		return super.isEnabled();
 	}
+	
+	protected boolean getStatelessHint()
+	{
+		return false;
+	}
 
 	/**
 	 * Called when a link is clicked.

Added: incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/markup/html/link/StatelessLink.java
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/markup/html/link/StatelessLink.java?view=auto&rev=473516
==============================================================================
--- incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/markup/html/link/StatelessLink.java (added)
+++ incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/markup/html/link/StatelessLink.java Fri Nov 10 13:47:47 2006
@@ -0,0 +1,51 @@
+/*
+ * $Id: org.eclipse.jdt.ui.prefs 5004 2006-03-17 20:47:08 -0800 (Fri, 17 Mar 2006) eelco12 $
+ * $Revision: 5004 $
+ * $Date: 2006-03-17 20:47:08 -0800 (Fri, 17 Mar 2006) $
+ * 
+ * ==============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package wicket.markup.html.link;
+
+
+/**
+ * This link is stateless that means that the url to this link could generate
+ * a new page before the link onClick is called. Because of this you can't depend
+ * on model data in the onClick method.
+ * 
+ * This Link component is the same as a normal link with the statelesshint to true.
+ * 
+ * @author jcompagner
+ */
+public abstract class StatelessLink extends Link
+{
+	private static final long serialVersionUID = 1L;
+
+	/**
+	 * Construct.
+	 * @param parent
+	 * @param id
+	 */
+	public StatelessLink(String id)
+	{
+		super(id);
+	}
+	
+	
+
+	protected boolean getStatelessHint()
+	{
+		return true;
+	}
+}

Modified: incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/protocol/http/AbstractHttpSessionStore.java
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/protocol/http/AbstractHttpSessionStore.java?view=diff&rev=473516&r1=473515&r2=473516
==============================================================================
--- incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/protocol/http/AbstractHttpSessionStore.java (original)
+++ incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/protocol/http/AbstractHttpSessionStore.java Fri Nov 10 13:47:47 2006
@@ -137,12 +137,25 @@
 	}
 
 	/**
-	 * @see wicket.session.ISessionStore#getSessionId(wicket.Request)
+	 * @see wicket.session.ISessionStore#getSessionId(wicket.Request, boolean)
 	 */
-	public final String getSessionId(Request request)
+	public final String getSessionId(Request request, boolean create)
 	{
+		String id = null;
 		WebRequest webRequest = toWebRequest(request);
-		return getHttpSession(webRequest).getId();
+		HttpSession httpSession = webRequest.getHttpServletRequest().getSession(false);
+		if(httpSession != null)
+		{
+			id = httpSession.getId();
+		}
+		else if(create)
+		{
+			httpSession = webRequest.getHttpServletRequest().getSession(true);
+			id = httpSession.getId();
+			IRequestLogger logger = Application.get().getRequestLogger();
+			if(logger != null) logger.sessionCreated(id);
+		}
+		return id;
 	}
 
 	/**
@@ -179,8 +192,13 @@
 	 */
 	public Session lookup(Request request)
 	{
-		WebRequest webRequest = toWebRequest(request);
-		return (Session)getAttribute(webRequest, Session.SESSION_ATTRIBUTE_NAME);
+		String sessionId = getSessionId(request, false);
+		if (sessionId != null)
+		{
+			WebRequest webRequest = toWebRequest(request);
+			return (Session)getAttribute(webRequest, Session.SESSION_ATTRIBUTE_NAME);
+		}
+		return null;
 	}
 
 	/**
@@ -220,9 +238,7 @@
 	 */
 	protected final HttpSession getHttpSession(WebRequest request)
 	{
-		// FIXME post 1.2 allow for session-less operation
-		HttpSession httpSession = request.getHttpServletRequest().getSession(true);
-		return httpSession;
+		return request.getHttpServletRequest().getSession(false);
 	}
 
 	/**
@@ -249,6 +265,24 @@
 	 *            The session id of the session that was invalidated.
 	 */
 	protected void onUnbind(String sessionId)
+	{
+	}
+
+	/**
+	 * Noop implementation. Clients can override this method.
+	 * 
+	 * @see wicket.session.ISessionStore#onBeginRequest(wicket.Request)
+	 */
+	public void onBeginRequest(Request request)
+	{
+	}
+
+	/**
+	 * Noop implementation. Clients can override this method.
+	 * 
+	 * @see wicket.session.ISessionStore#onEndRequest(wicket.Request)
+	 */
+	public void onEndRequest(Request request)
 	{
 	}
 }

Added: incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/protocol/http/FilePageStore.java
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/protocol/http/FilePageStore.java?view=auto&rev=473516
==============================================================================
--- incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/protocol/http/FilePageStore.java (added)
+++ incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/protocol/http/FilePageStore.java Fri Nov 10 13:47:47 2006
@@ -0,0 +1,203 @@
+/*
+ * $Id: org.eclipse.jdt.ui.prefs 5004 2006-03-17 20:47:08 -0800 (Fri, 17 Mar
+ * 2006) eelco12 $ $Revision: 5004 $ $Date: 2006-03-17 20:47:08 -0800 (Fri, 17
+ * Mar 2006) $
+ * 
+ * ==============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package wicket.protocol.http;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import wicket.Application;
+import wicket.Page;
+import wicket.protocol.http.SecondLevelCacheSessionStore.IPageStore;
+import wicket.util.lang.Objects;
+
+/**
+ * @author jcompagner
+ */
+public class FilePageStore implements IPageStore
+{
+	/** log. */
+	protected static Log log = LogFactory.getLog(FilePageStore.class);
+
+	private File workDir;
+
+	/**
+	 * Construct.
+	 */
+	public FilePageStore()
+	{
+		workDir = (File)((WebApplication)Application.get()).getServletContext().getAttribute(
+				"javax.servlet.context.tempdir");
+	}
+
+	/**
+	 * @see wicket.protocol.http.SecondLevelCacheSessionStore.IPageStore#getPage(java.lang.String,
+	 *      int, int)
+	 */
+	public Page getPage(String sessionId, int id, int versionNumber)
+	{
+		File sessionDir = new File(workDir, sessionId);
+		if (sessionDir.exists())
+		{
+			File pageFile = getPageFile(id, versionNumber, sessionDir);
+			if (pageFile.exists())
+			{
+				FileInputStream fis = null;
+				try
+				{
+					byte[] pageData = null;
+					fis = new FileInputStream(pageFile);
+					int length = (int)pageFile.length();
+					ByteBuffer bb = ByteBuffer.allocate(length);
+					fis.getChannel().read(bb);
+					if (bb.hasArray())
+					{
+						pageData = bb.array();
+					}
+					else
+					{
+						pageData = new byte[length];
+						bb.get(pageData);
+					}
+
+					Page page = (Page)Objects.byteArrayToObject(pageData);
+					return page.getVersion(versionNumber);
+				}
+				catch (Exception e)
+				{
+					log.debug("Error loading page " + id + " with version " + versionNumber
+							+ " for the sessionid " + sessionId + " from disc", e);
+				}
+				finally
+				{
+					try
+					{
+						if (fis != null)
+						{
+							fis.close();
+						}
+					}
+					catch (IOException ex)
+					{
+						// ignore
+					}
+				}
+			}
+		}
+		return null;
+	}
+
+	/**
+	 * @param id
+	 * @param versionNumber
+	 * @param sessionDir
+	 * @return The file pointing to the page
+	 */
+	private File getPageFile(int id, int versionNumber, File sessionDir)
+	{
+		return new File(sessionDir, Application.get().getApplicationKey() + "-page-" + id
+				+ "-version-" + versionNumber);
+	}
+
+	/**
+	 * @see wicket.protocol.http.SecondLevelCacheSessionStore.IPageStore#removePage(java.lang.String,
+	 *      wicket.Page)
+	 */
+	public void removePage(String sessionId, Page page)
+	{
+		File sessionDir = new File(workDir, sessionId);
+		if (sessionDir.exists())
+		{
+			File pageFile = getPageFile(page.getNumericId(), page.getCurrentVersionNumber(),
+					sessionDir);
+			if (pageFile.exists())
+			{
+				pageFile.delete();
+			}
+		}
+	}
+
+	/**
+	 * @see wicket.protocol.http.SecondLevelCacheSessionStore.IPageStore#storePage(java.lang.String,
+	 *      wicket.Page)
+	 */
+	public void storePage(String sessionId, Page page)
+	{
+		File sessionDir = new File(workDir, sessionId);
+		sessionDir.mkdirs();
+		File pageFile = getPageFile(page.getNumericId(), page.getCurrentVersionNumber(), sessionDir);
+		// TODO check can this be called everytime at this place? Putting should
+		// be called after the rendering so it should be ok.
+		page.internalDetach();
+		byte[] bytes = Objects.objectToByteArray(page);
+		FileOutputStream fos = null;
+		try
+		{
+			fos = new FileOutputStream(pageFile);
+			ByteBuffer bb = ByteBuffer.wrap(bytes);
+			fos.getChannel().write(bb);
+		}
+		catch (Exception e)
+		{
+			log.debug("Error saving page " + page.getId() + " with version "
+					+ page.getCurrentVersionNumber() + " for the sessionid " + sessionId
+					+ " from disc", e);
+		}
+		finally
+		{
+			try
+			{
+				if (fos != null)
+				{
+					fos.close();
+				}
+			}
+			catch (IOException ex)
+			{
+				// ignore
+			}
+		}
+
+	}
+
+	/**
+	 * @see wicket.protocol.http.SecondLevelCacheSessionStore.IPageStore#unbind(java.lang.String)
+	 */
+	public void unbind(String sessionId)
+	{
+		File sessionDir = new File(workDir, sessionId);
+		if (sessionDir.exists())
+		{
+			File[] files = sessionDir.listFiles();
+			if (files != null)
+			{
+				for (int i = 0; i < files.length; i++)
+				{
+					files[i].delete();
+				}
+			}
+			sessionDir.delete();
+		}
+	}
+}

Modified: incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/protocol/http/HttpSessionStore.java
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/protocol/http/HttpSessionStore.java?view=diff&rev=473516&r1=473515&r2=473516
==============================================================================
--- incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/protocol/http/HttpSessionStore.java (original)
+++ incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/protocol/http/HttpSessionStore.java Fri Nov 10 13:47:47 2006
@@ -26,8 +26,12 @@
 
 import javax.servlet.http.HttpSession;
 
+import wicket.AccessStackPageMap;
 import wicket.Application;
+import wicket.Page;
+import wicket.PageMap;
 import wicket.Request;
+import wicket.Session;
 import wicket.WicketRuntimeException;
 import wicket.util.lang.Bytes;
 
@@ -50,6 +54,10 @@
 		// session replication
 		if (Application.get().getDebugSettings().getSerializeSessionAttributes())
 		{
+			if (value instanceof Page)
+			{
+				((Page)value).internalDetach();
+			}
 			String valueTypeName = (value != null ? value.getClass().getName() : "null");
 			try
 			{
@@ -70,7 +78,7 @@
 		HttpSession httpSession = getHttpSession(webRequest);
 		if (httpSession != null)
 		{
-			RequestLogger logger = application.getRequestLogger();
+			IRequestLogger logger = application.getRequestLogger();
 			String attributeName = getSessionAttributePrefix(webRequest) + name;
 			if (logger != null)
 			{
@@ -89,7 +97,8 @@
 	}
 
 	/**
-	 * @see wicket.session.ISessionStore#getAttribute(wicket.Request, java.lang.String)
+	 * @see wicket.session.ISessionStore#getAttribute(wicket.Request,
+	 *      java.lang.String)
 	 */
 	public Object getAttribute(Request request, String name)
 	{
@@ -112,7 +121,7 @@
 		if (httpSession != null)
 		{
 			String attributeName = getSessionAttributePrefix(webRequest) + name;
-			RequestLogger logger = application.getRequestLogger();
+			IRequestLogger logger = application.getRequestLogger();
 			if (logger != null)
 			{
 				Object value = httpSession.getAttribute(attributeName);
@@ -161,5 +170,14 @@
 	private String getSessionAttributePrefix(final WebRequest request)
 	{
 		return application.getSessionAttributePrefix(request);
+	}
+
+	/**
+	 * @see wicket.session.ISessionStore#createPageMap(java.lang.String,
+	 *      wicket.Session)
+	 */
+	public PageMap createPageMap(String name, Session session)
+	{
+		return new AccessStackPageMap(name, session);
 	}
 }

Added: incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/protocol/http/SecondLevelCacheSessionStore.java
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/protocol/http/SecondLevelCacheSessionStore.java?view=auto&rev=473516
==============================================================================
--- incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/protocol/http/SecondLevelCacheSessionStore.java (added)
+++ incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/protocol/http/SecondLevelCacheSessionStore.java Fri Nov 10 13:47:47 2006
@@ -0,0 +1,250 @@
+/*
+ * $Id: org.eclipse.jdt.ui.prefs 5004 2006-03-17 20:47:08 -0800 (Fri, 17 Mar
+ * 2006) eelco12 $ $Revision: 5004 $ $Date: 2006-03-17 20:47:08 -0800 (Fri, 17
+ * Mar 2006) $
+ * 
+ * ==============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package wicket.protocol.http;
+
+import java.lang.ref.SoftReference;
+import java.util.Map;
+import wicket.util.concurrent.ConcurrentHashMap;
+
+import wicket.Application;
+import wicket.Page;
+import wicket.PageMap;
+import wicket.Request;
+import wicket.Session;
+import wicket.session.pagemap.IPageMapEntry;
+
+/**
+ * FIXME document me!
+ * 
+ * @author jcompagner
+ */
+public class SecondLevelCacheSessionStore extends HttpSessionStore
+{
+	private static final class SecondLevelCachePageMap extends PageMap
+	{
+		private static final long serialVersionUID = 1L;
+
+		Page lastPage = null;
+
+		/**
+		 * Construct.
+		 * 
+		 * @param name
+		 * @param session
+		 */
+		private SecondLevelCachePageMap(String name, Session session)
+		{
+			super(name, session);
+		}
+
+		protected void removeEntry(IPageMapEntry entry)
+		{
+			String sessionId = getSession().getId();
+			if (sessionId != null)
+			{
+				getStore().removePage(sessionId, entry.getPage());
+			}
+		}
+
+		protected void put(Page page)
+		{
+			if (!page.isPageStateless())
+			{
+				String sessionId = getSession().getId();
+				if (sessionId != null)
+				{
+					if (lastPage != page)
+					{
+						lastPage = page;
+						dirty();
+					}
+					getStore().storePage(sessionId, page);
+				}
+			}
+		}
+
+		protected Page get(int id, int versionNumber)
+		{
+			if (lastPage != null && lastPage.getNumericId() == id)
+			{
+				Page page = lastPage.getVersion(versionNumber);
+				if (page != null)
+				{
+					return page;
+				}
+			}
+			String sessionId = getSession().getId();
+			if (sessionId != null)
+			{
+				return getStore().getPage(sessionId, id, versionNumber);
+			}
+			return null;
+		}
+
+		private IPageStore getStore()
+		{
+			return ((SecondLevelCacheSessionStore)Application.get().getSessionStore()).getStore();
+		}
+	}
+
+	/**
+	 * FIXME document me!
+	 */
+	public interface IPageStore
+	{
+
+		/**
+		 * @param sessionId
+		 * @param page
+		 */
+		void storePage(String sessionId, Page page);
+
+		/**
+		 * @param sessionId
+		 * @param id
+		 * @param versionNumber
+		 * @return The page
+		 */
+		Page getPage(String sessionId, int id, int versionNumber);
+
+		/**
+		 * @param sessionId
+		 * @param page
+		 */
+		void removePage(String sessionId, Page page);
+
+		/**
+		 * @param sessionId
+		 */
+		void unbind(String sessionId);
+
+	}
+
+	private final IPageStore cachingStore;
+
+	/**
+	 * Construct.
+	 * 
+	 * @param pageStore
+	 */
+	public SecondLevelCacheSessionStore(final IPageStore pageStore)
+	{
+		this.cachingStore = new IPageStore()
+		{
+			Map sessionMap = new ConcurrentHashMap();
+
+			public void unbind(String sessionId)
+			{
+				sessionMap.remove(sessionId);
+				pageStore.unbind(sessionId);
+			}
+
+			public void removePage(String sessionId, Page page)
+			{
+				SoftReference sr = (SoftReference)sessionMap.get(sessionId);
+				if (sr != null)
+				{
+					Map map = (Map)sr.get();
+					if (map != null)
+					{
+						map.remove(page.getId());
+					}
+				}
+				pageStore.removePage(sessionId, page);
+			}
+
+			public Page getPage(String sessionId, int id, int versionNumber)
+			{
+				SoftReference sr = (SoftReference)sessionMap.get(sessionId);
+				if (sr != null)
+				{
+					Map map = (Map)sr.get();
+					if (map != null)
+					{
+						SoftReference sr2 = (SoftReference)map.get(Integer.toString(id));
+						if (sr2 != null)
+						{
+							Page page = (Page)sr2.get();
+							if (page != null)
+							{
+								page = page.getVersion(versionNumber);
+							}
+							if (page != null)
+							{
+								return page;
+							}
+						}
+					}
+				}
+				return pageStore.getPage(sessionId, id, versionNumber);
+			}
+
+			public void storePage(String sessionId, Page page)
+			{
+				Map pageMap = null;
+				SoftReference sr = (SoftReference)sessionMap.get(sessionId);
+				if (sr == null || (pageMap = (Map)sr.get()) == null)
+				{
+					pageMap = new ConcurrentHashMap();
+					sessionMap.put(sessionId, new SoftReference(pageMap));
+				}
+				pageMap.put(page.getId(), new SoftReference(page));
+				pageStore.storePage(sessionId, page);
+			}
+		};
+	}
+
+	/**
+	 * @see wicket.session.ISessionStore#setAttribute(wicket.Request,
+	 *      java.lang.String, java.lang.Object)
+	 */
+	public final void setAttribute(Request request, String name, Object value)
+	{
+		// ignore all pages, they are stored through the pagemap
+		if (!(value instanceof Page))
+		{
+			super.setAttribute(request, name, value);
+		}
+	}
+
+	/**
+	 * @see wicket.protocol.http.AbstractHttpSessionStore#onUnbind(java.lang.String)
+	 */
+	protected void onUnbind(String sessionId)
+	{
+		getStore().unbind(sessionId);
+	}
+
+	/**
+	 * @return The store to use
+	 */
+	public IPageStore getStore()
+	{
+		return cachingStore;
+	}
+
+	/**
+	 * @see wicket.protocol.http.HttpSessionStore#createPageMap(java.lang.String,
+	 *      wicket.Session)
+	 */
+	public PageMap createPageMap(String name, Session session)
+	{
+		return new SecondLevelCachePageMap(name, session);
+	}
+}