Author: jcompagner
Date: Sat Nov 3 12:35:11 2007
New Revision: 591665
URL: http://svn.apache.org/viewvc?rev=591665&view=rev
Log:
fix for WICKET-1075 and || was meant to be a && but because of this bug we did
hide another bug that was also not really shown because the unit test covering
that was wrong.
Modified:
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/image/resource/LocalizedImageResource.java
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/image/ImageTest.java
Modified:
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/image/resource/LocalizedImageResource.java
URL:
http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/image/resource/LocalizedImageResource.java?rev=591665&r1=591664&r2=591665&view=diff
==============================================================================
---
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/image/resource/LocalizedImageResource.java
(original)
+++
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/image/resource/LocalizedImageResource.java
Sat Nov 3 12:35:11 2007
@@ -199,8 +199,11 @@
*/
public final void setResource(final Resource resource)
{
- resourceKind = Boolean.TRUE;
- this.resource = resource;
+ if (this.resource != resource)
+ {
+ resourceKind = Boolean.TRUE;
+ this.resource = resource;
+ }
}
/**
@@ -227,10 +230,13 @@
* The resource parameters for the shared resource
*/
public final void setResourceReference(final ResourceReference
resourceReference,
- final ValueMap resourceParameters)
+ final ValueMap resourceParameters)
{
- resourceKind = Boolean.FALSE;
- this.resourceReference = resourceReference;
+ if (resourceReference != this.resourceReference)
+ {
+ resourceKind = Boolean.FALSE;
+ this.resourceReference = resourceReference;
+ }
this.resourceParameters = resourceParameters;
bind();
}
@@ -247,9 +253,9 @@
// resource, then we need to reload the resource in the new
locale
Locale l = component.getLocale();
String s = component.getStyle();
- if (resourceKind == null ||
- (!Objects.equal(locale, component.getLocale())
|| !Objects.equal(style, component
- .getStyle())))
+ if (resourceKind == null &&
+ (!Objects.equal(locale, component.getLocale()) ||
!Objects.equal(style, component
+ .getStyle())))
{
// Get new component locale and style
locale = component.getLocale();
@@ -323,7 +329,7 @@
// Set the SRC attribute to point to the component or shared
resource
tag.put("src",
RequestCycle.get().getOriginalResponse().encodeURL(
- Strings.replaceAll(url, "&", "&")));
+ Strings.replaceAll(url, "&", "&")));
}
/**
@@ -336,16 +342,16 @@
* Thrown if factory cannot be found
*/
private IResourceFactory getResourceFactory(final Application
application,
- final String factoryName)
+ final String factoryName)
{
final IResourceFactory factory =
application.getResourceSettings().getResourceFactory(
- factoryName);
+ factoryName);
// Found factory?
if (factory == null)
{
throw new WicketRuntimeException("Could not find image
resource factory named " +
- factoryName);
+ factoryName);
}
return factory;
}
@@ -364,8 +370,8 @@
if ((path.indexOf("..") != -1) || (path.indexOf("./") != -1) ||
(path.indexOf("/.") != -1))
{
throw new WicketRuntimeException(
- "The 'src' attribute must not contain
any of the following strings: '..', './', '/.': path=" +
- path);
+ "The 'src' attribute must not contain any of
the following strings: '..', './', '/.': path=" +
+ path);
}
MarkupContainer parent =
component.findParentWithAssociatedMarkup();
@@ -384,7 +390,7 @@
protected Resource newResource()
{
PackageResource pr =
PackageResource.get(getScope(), getName(),
-
LocalizedImageResource.this.locale, style);
+ LocalizedImageResource.this.locale,
style);
locale = pr.getLocale();
return pr;
}
@@ -410,7 +416,7 @@
{
final String imageReferenceName =
valueParser.getImageReferenceName();
final String specification =
Strings.replaceHtmlEscapeNumber(valueParser
- .getSpecification());
+ .getSpecification());
final String factoryName = valueParser.getFactoryName();
final Application application =
component.getApplication();
@@ -419,14 +425,14 @@
{
// Is resource already available via the
application?
if
(application.getSharedResources().get(Application.class, imageReferenceName,
- locale, style, true) == null)
+ locale, style, true) == null)
{
// Resource not available yet, so
create it with factory and
// share via Application
final Resource imageResource =
getResourceFactory(application, factoryName)
-
.newResource(specification, locale, style);
+ .newResource(specification,
locale, style);
application.getSharedResources().add(Application.class, imageReferenceName,
- locale, style,
imageResource);
+ locale, style, imageResource);
}
// Create resource reference
@@ -437,15 +443,15 @@
else
{
resource = getResourceFactory(application,
factoryName).newResource(specification,
- locale, style);
+ locale, style);
}
}
else
{
throw new WicketRuntimeException(
- "Could not generate image for value
attribute '" +
- value +
- "'. Was expecting a
value attribute of the form
\"[resourceFactoryName]:[resourceReferenceName]?:[factorySpecification]\".");
+ "Could not generate image for value attribute
'" +
+ value +
+ "'. Was expecting a value attribute of
the form
\"[resourceFactoryName]:[resourceReferenceName]?:[factorySpecification]\".");
}
}
Modified:
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/image/ImageTest.java
URL:
http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/image/ImageTest.java?rev=591665&r1=591664&r2=591665&view=diff
==============================================================================
---
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/image/ImageTest.java
(original)
+++
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/image/ImageTest.java
Sat Nov 3 12:35:11 2007
@@ -42,33 +42,27 @@
tester.startPage(Home.class);
tester.clickLink("goCanadian");
- tester.startPage(Home.class);
tester
-
.assertContains("src=\"resources/org.apache.wicket.markup.html.image.Home/Beer_en_CA.gif\"");
+
.assertContains("src=\"resources/org.apache.wicket.markup.html.image.Home/Beer_en_CA.gif\"");
tester.clickLink("goChinese");
- tester.startPage(Home.class);
tester
-
.assertContains("src=\"resources/org.apache.wicket.markup.html.image.Home/Beer_zh_CN.gif\"");
+
.assertContains("src=\"resources/org.apache.wicket.markup.html.image.Home/Beer_zh_CN.gif\"");
tester.clickLink("goDanish");
- tester.startPage(Home.class);
tester
-
.assertContains("src=\"resources/org.apache.wicket.markup.html.image.Home/Beer_da_DK.gif\"");
+
.assertContains("src=\"resources/org.apache.wicket.markup.html.image.Home/Beer_da_DK.gif\"");
tester.clickLink("goDutch");
- tester.startPage(Home.class);
tester
-
.assertContains("src=\"resources/org.apache.wicket.markup.html.image.Home/Beer_nl_NL.gif\"");
+
.assertContains("src=\"resources/org.apache.wicket.markup.html.image.Home/Beer_nl_NL.gif\"");
tester.clickLink("goGerman");
- tester.startPage(Home.class);
tester
-
.assertContains("src=\"resources/org.apache.wicket.markup.html.image.Home/Beer_de_DE.gif\"");
+
.assertContains("src=\"resources/org.apache.wicket.markup.html.image.Home/Beer_de_DE.gif\"");
tester.clickLink("goUS");
- tester.startPage(Home.class);
tester
-
.assertContains("src=\"resources/org.apache.wicket.markup.html.image.Home/Beer_en_US.gif\"");
+
.assertContains("src=\"resources/org.apache.wicket.markup.html.image.Home/Beer.gif\"");
}
}