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 2007/04/07 21:13:10 UTC

svn commit: r526472 - in /incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/wicket: Component.java model/AbstractPropertyModel.java model/CompoundPropertyModel.java

Author: jcompagner
Date: Sat Apr  7 12:13:09 2007
New Revision: 526472

URL: http://svn.apache.org/viewvc?view=rev&rev=526472
Log:
component initModel will not call getModel on the parent, but will directly use the field
(so that not all kinds of inbetween models are created)
if model is an iwrapmodel and the wrapped modes is an inherited one then the model will be cleared on detach
Compound.getTarget() removed. Compound will not unwrap in getObject() anymore
AbstractPropertyModel will unwrap until all models are processed

Modified:
    incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/wicket/Component.java
    incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/wicket/model/AbstractPropertyModel.java
    incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/wicket/model/CompoundPropertyModel.java

Modified: incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/wicket/Component.java
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/wicket/Component.java?view=diff&rev=526472&r1=526471&r2=526472
==============================================================================
--- incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/wicket/Component.java (original)
+++ incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/wicket/Component.java Sat Apr  7 12:13:09 2007
@@ -2562,7 +2562,9 @@
 		for (Component current = getParent(); current != null; current = current.getParent())
 		{
 			// Get model
-			IModel model = current.getModel();
+			// Dont call the getModel() that could initialize many inbetween completely useless models. 
+			//IModel model = current.getModel();
+			IModel model = current.model;
 
 			if (model instanceof IWrapModel)
 			{
@@ -2767,6 +2769,15 @@
 		// always detach children because components can be attached
 		// independently of their parents
 		detachChildren();
+		
+		// reset the model to null when the current model is a IWrapModel and
+		// the model that created it/wrapped in it is a IComponentInheritedModel
+		// The model will be created next time.
+		if (model instanceof IWrapModel && 
+				((IWrapModel)model).getWrappedModel() instanceof IComponentInheritedModel)
+		{
+			model = null;
+		}
 	}
 
 

Modified: incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/wicket/model/AbstractPropertyModel.java
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/wicket/model/AbstractPropertyModel.java?view=diff&rev=526472&r1=526471&r2=526472
==============================================================================
--- incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/wicket/model/AbstractPropertyModel.java (original)
+++ incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/wicket/model/AbstractPropertyModel.java Sat Apr  7 12:13:09 2007
@@ -54,11 +54,12 @@
 
 	protected Object getTarget()
 	{
-		if (target instanceof IModel)
+		Object object = target;
+		while (object instanceof IModel)
 		{
-			return ((IModel)target).getObject();
+			object = ((IModel)object).getObject();
 		}
-		return target;
+		return object;
 	}
 
 	/**
@@ -116,6 +117,8 @@
 		final String expression = propertyExpression();
 		if (Strings.isEmpty(expression))
 		{
+			// TODO check, really do this?
+			// why not just set the target to the object?
 			if (target instanceof IModel)
 			{
 				((IModel)target).setObject(object);

Modified: incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/wicket/model/CompoundPropertyModel.java
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/wicket/model/CompoundPropertyModel.java?view=diff&rev=526472&r1=526471&r2=526472
==============================================================================
--- incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/wicket/model/CompoundPropertyModel.java (original)
+++ incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/wicket/model/CompoundPropertyModel.java Sat Apr  7 12:13:09 2007
@@ -38,12 +38,12 @@
 	/**
 	 * Constructor
 	 * 
-	 * @param model
+	 * @param object
 	 *            The model object, which may or may not implement IModel
 	 */
-	public CompoundPropertyModel(final Object model)
+	public CompoundPropertyModel(final Object object)
 	{
-		target = model;
+		this.target = object;
 	}
 
 	/**
@@ -51,22 +51,6 @@
 	 */
 	public Object getObject()
 	{
-		if (target instanceof IModel)
-		{
-			return ((IModel)target).getObject();
-		}
-		return target;
-	}
-
-	/**
-	 * TODO shouldn't this method be removed?
-	 * and getObject should just return target?
-	 * now it is a bit strange. setObject assigns target
-	 * but getObject doesn't return directly the target...
-	 * @return
-	 */
-	public Object getTarget()
-	{
 		return target;
 	}
 
@@ -131,9 +115,7 @@
 	 * @author ivaynberg
 	 */
 	private class AttachedCompoundPropertyModel extends AbstractPropertyModel
-			implements
-				IWrapModel,
-				IComponentInheritedModel
+			implements  IWrapModel
 	{
 		private static final long serialVersionUID = 1L;
 
@@ -166,14 +148,6 @@
 		{
 			return CompoundPropertyModel.this;
 		}
-
-		/**
-		 * @see wicket.model.IComponentInheritedModel#wrapOnInheritance(wicket.Component)
-		 */
-		public IWrapModel wrapOnInheritance(Component component)
-		{
-			return new AttachedCompoundPropertyModel(component);
-		};
 
 		/**
 		 * @see wicket.model.AbstractPropertyModel#detach()