You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by mg...@apache.org on 2011/06/07 11:35:33 UTC

svn commit: r1132923 - /wicket/trunk/wicket-core/src/main/java/org/apache/wicket/markup/html/image/Image.java

Author: mgrigorov
Date: Tue Jun  7 09:35:33 2011
New Revision: 1132923

URL: http://svn.apache.org/viewvc?rev=1132923&view=rev
Log:
WICKET-3757 Image always noncaching when included in ajax request. However, sometimes caching image is desirable.

Add #shouldAddAntiCacheParameter() which by default adds the parameter for Ajax requests.
The user can override it and chnage the check with his own.


Modified:
    wicket/trunk/wicket-core/src/main/java/org/apache/wicket/markup/html/image/Image.java

Modified: wicket/trunk/wicket-core/src/main/java/org/apache/wicket/markup/html/image/Image.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/main/java/org/apache/wicket/markup/html/image/Image.java?rev=1132923&r1=1132922&r2=1132923&view=diff
==============================================================================
--- wicket/trunk/wicket-core/src/main/java/org/apache/wicket/markup/html/image/Image.java (original)
+++ wicket/trunk/wicket-core/src/main/java/org/apache/wicket/markup/html/image/Image.java Tue Jun  7 09:35:33 2011
@@ -239,13 +239,27 @@ public class Image extends WebComponent 
 		}
 		localizedImageResource.setSrcAttribute(tag);
 
-		if (AjaxRequestTarget.get() != null)
+		if (shouldAddAntiCacheParameter())
 		{
 			addAntiCacheParameter(tag);
 		}
 	}
 
 	/**
+	 * Adding an image to {@link AjaxRequestTarget} most of the times mean that the image has
+	 * changes and must be re-rendered.
+	 * <p>
+	 * With this method the user may change this default behavior for some of her images.
+	 * </p>
+	 * 
+	 * @return {@code true} to add the anti cache request parameter, {@code false} - otherwise
+	 */
+	protected boolean shouldAddAntiCacheParameter()
+	{
+		return AjaxRequestTarget.get() != null;
+	}
+
+	/**
 	 * Adds random noise to the url every request to prevent the browser from caching the image.
 	 * 
 	 * @param tag