You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by iv...@apache.org on 2010/11/16 19:01:08 UTC

svn commit: r1035715 - /wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/model/AbstractPropertyModel.java

Author: ivaynberg
Date: Tue Nov 16 18:01:08 2010
New Revision: 1035715

URL: http://svn.apache.org/viewvc?rev=1035715&view=rev
Log:
warn when referencing session directly in models

Modified:
    wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/model/AbstractPropertyModel.java

Modified: wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/model/AbstractPropertyModel.java
URL: http://svn.apache.org/viewvc/wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/model/AbstractPropertyModel.java?rev=1035715&r1=1035714&r2=1035715&view=diff
==============================================================================
--- wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/model/AbstractPropertyModel.java (original)
+++ wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/model/AbstractPropertyModel.java Tue Nov 16 18:01:08 2010
@@ -26,6 +26,8 @@ import org.apache.wicket.WicketRuntimeEx
 import org.apache.wicket.util.lang.PropertyResolver;
 import org.apache.wicket.util.lang.PropertyResolverConverter;
 import org.apache.wicket.util.string.Strings;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * Serves as a base class for different kinds of property models. By default, this class uses
@@ -50,6 +52,8 @@ public abstract class AbstractPropertyMo
 		IObjectClassAwareModel<T>,
 		IPropertyReflectionAwareModel
 {
+	private static final Logger logger = LoggerFactory.getLogger(AbstractPropertyModel.class);
+
 	/**
 	 * 
 	 */
@@ -70,6 +74,14 @@ public abstract class AbstractPropertyMo
 			throw new IllegalArgumentException("Parameter modelObject cannot be null");
 		}
 
+		if (modelObject instanceof Session)
+		{
+			logger.warn("It is not a good idea to reference the Session instance "
+				+ "in models directly as it may lead to serialization problems. "
+				+ "If you need to access a property of the session via the model use the "
+				+ "page instance as the model object and 'session.attribute' as the path.");
+		}
+
 		target = modelObject;
 	}