Author: jcompagner
Date: Tue Feb 12 07:15:59 2008
New Revision: 620825

URL: http://svn.apache.org/viewvc?rev=620825&view=rev
Log:
fix for WICKET-1340, getStatelessHint a bit more relaxed

Added:
    
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/stateless/ImageStatelessTest.java
Modified:
    
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/image/Image.java

Modified: 
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/image/Image.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/image/Image.java?rev=620825&r1=620824&r2=620825&view=diff
==============================================================================
--- 
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/image/Image.java
 (original)
+++ 
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/image/Image.java
 Tue Feb 12 07:15:59 2008
@@ -32,9 +32,9 @@
  * An Image component displays a localizable image resource.
  * <p>
  * For details of how Images load, generate and manage images, see [EMAIL 
PROTECTED] LocalizedImageResource}.
- *
+ * 
  * @see NonCachingImage
- *
+ * 
  * @author Jonathan Locke
  */
 public class Image extends WebComponent implements IResourceListener
@@ -48,7 +48,7 @@
         * This constructor can be used if you have a img tag that has a src 
that points to a
         * PackageResource (which will be created and bind to the shared 
resources) Or if you have a
         * value attribute in your tag for which the image factory can make an 
image.
-        *
+        * 
         * @see org.apache.wicket.Component#Component(String)
         */
        public Image(final String id)
@@ -59,13 +59,13 @@
        /**
         * Constructs an image from an image resourcereference. That resource 
reference will bind its
         * resource to the current SharedResources.
-        *
+        * 
         * If you are using non sticky session clustering and the resource 
reference is pointing to a
         * Resource that isn't guaranteed to be on every server, for example a 
dynamic image or
         * resources that aren't added with a IInitializer at application 
startup. Then if only that
         * resource is requested from another server, without the rendering of 
the page, the image won't
         * be there and will result in a broken link.
-        *
+        * 
         * @param id
         *            See Component
         * @param resourceReference
@@ -79,13 +79,13 @@
        /**
         * Constructs an image from an image resourcereference. That resource 
reference will bind its
         * resource to the current SharedResources.
-        *
+        * 
         * If you are using non sticky session clustering and the resource 
reference is pointing to a
         * Resource that isn't guaranteed to be on every server, for example a 
dynamic image or
         * resources that aren't added with a IInitializer at application 
startup. Then if only that
         * resource is requested from another server, without the rendering of 
the page, the image won't
         * be there and will result in a broken link.
-        *
+        * 
         * @param id
         *            See Component
         * @param resourceReference
@@ -102,14 +102,14 @@
 
        /**
         * Constructs an image directly from an image resource.
-        *
+        * 
         * This one doesn't have the 'non sticky session clustering' problem 
that the ResourceReference
         * constructor has. But this will result in a non 'stable' url and the 
url will have request
         * parameters.
-        *
+        * 
         * @param id
         *            See Component
-        *
+        * 
         * @param imageResource
         *            The image resource
         */
@@ -241,7 +241,8 @@
         */
        protected boolean getStatelessHint()
        {
-               return getImageResource() == null && 
localizedImageResource.isStateless();
+               return (getImageResource() == null || getImageResource() == 
localizedImageResource.getResource()) &&
+                       localizedImageResource.isStateless();
        }
 
        /**

Added: 
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/stateless/ImageStatelessTest.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/stateless/ImageStatelessTest.java?rev=620825&view=auto
==============================================================================
--- 
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/stateless/ImageStatelessTest.java
 (added)
+++ 
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/stateless/ImageStatelessTest.java
 Tue Feb 12 07:15:59 2008
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.wicket.stateless;
+
+import org.apache.wicket.ResourceReference;
+import org.apache.wicket.WicketTestCase;
+import org.apache.wicket.markup.html.image.Image;
+import org.apache.wicket.resource.ByteArrayResource;
+
+/**
+ * @author jcompagner
+ */
+public class ImageStatelessTest extends WicketTestCase
+{
+       /**
+        * 
+        */
+       public void testResourceReference()
+       {
+               final Image i = new Image("test", new 
ResourceReference("test"));
+               tester.startComponent(i);
+               assertTrue("image with resource reference should be stateless", 
i.isStateless());
+       }
+
+       /**
+        * 
+        */
+       public void testEmpty()
+       {
+               final Image i = new Image("test");
+               tester.startComponent(i);
+               assertTrue("image with resource reference should be statefull", 
!i.isStateless());
+       }
+
+       /**
+        * 
+        */
+       public void testResource()
+       {
+               final Image i = new Image("test", new 
ByteArrayResource("text/text", new byte[0]));
+               tester.startComponent(i);
+               assertTrue("image with resource reference should be statefull", 
!i.isStateless());
+       }
+}


Reply via email to