Author: jdonnerstag
Date: Wed Oct 7 18:26:19 2009
New Revision: 822823
URL: http://svn.apache.org/viewvc?rev=822823&view=rev
Log:
fixed: Inconsistent resource path using <wicket:link> and HeaderContributor
after second request
Issue: WICKET-2507
Added:
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/resolver/HomePage_1.html
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/resolver/HomePage_1.java
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/resolver/HomePage_2.html
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/resolver/HomePage_2.java
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/resolver/TestHomePage.java
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/resolver/main.css
Modified:
wicket/trunk/wicket/src/main/java/org/apache/wicket/ResourceReference.java
Modified:
wicket/trunk/wicket/src/main/java/org/apache/wicket/ResourceReference.java
URL:
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/ResourceReference.java?rev=822823&r1=822822&r2=822823&view=diff
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/ResourceReference.java
(original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/ResourceReference.java
Wed Oct 7 18:26:19 2009
@@ -142,6 +142,10 @@
SharedResources sharedResources =
application.getSharedResources();
// Try to get resource from Application repository
resource = sharedResources.get(getScope(), name,
locale, style, variation, true);
+ if ((resource != null) && (resource instanceof
PackageResource))
+ {
+ locale =
((PackageResource)resource).getLocale();
+ }
// Not available yet?
if (resource == null)
Added:
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/resolver/HomePage_1.html
URL:
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/resolver/HomePage_1.html?rev=822823&view=auto
==============================================================================
---
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/resolver/HomePage_1.html
(added)
+++
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/resolver/HomePage_1.html
Wed Oct 7 18:26:19 2009
@@ -0,0 +1,14 @@
+<html
xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.3-strict.dtd" >
+ <head>
+ <title>Wicket Quickstart Archetype Homepage</title>
+ <wicket:link>
+ <link href="main.css" rel="stylesheet" type="text/css"
media="screen, projection"/>
+ </wicket:link>
+ </head>
+ <body>
+ <strong>Wicket Quickstart Archetype Homepage</strong>
+ <br/><br/>
+ <span wicket:id="message">message will be here</span>
+ </body>
+</html>
+
Added:
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/resolver/HomePage_1.java
URL:
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/resolver/HomePage_1.java?rev=822823&view=auto
==============================================================================
---
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/resolver/HomePage_1.java
(added)
+++
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/resolver/HomePage_1.java
Wed Oct 7 18:26:19 2009
@@ -0,0 +1,44 @@
+/*
+ * 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.markup.resolver;
+
+import org.apache.wicket.PageParameters;
+import org.apache.wicket.markup.html.WebPage;
+import org.apache.wicket.markup.html.basic.Label;
+
+/**
+ * Homepage
+ */
+public class HomePage_1 extends WebPage
+{
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Constructor that is invoked when page is invoked without a session.
+ *
+ * @param parameters
+ * Page parameters
+ */
+ public HomePage_1(final PageParameters parameters)
+ {
+
+ // Add the simplest type of label
+ add(new Label("message",
+ "If you see this message wicket is properly configured
and running"));
+ }
+}
Added:
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/resolver/HomePage_2.html
URL:
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/resolver/HomePage_2.html?rev=822823&view=auto
==============================================================================
---
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/resolver/HomePage_2.html
(added)
+++
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/resolver/HomePage_2.html
Wed Oct 7 18:26:19 2009
@@ -0,0 +1,14 @@
+<html
xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.3-strict.dtd" >
+ <head>
+ <title>Wicket Quickstart Archetype Homepage</title>
+ <wicket:link>
+ <link href="main.css" rel="stylesheet" type="text/css"
media="screen, projection"/>
+ </wicket:link>
+ </head>
+ <body>
+ <strong>Wicket Quickstart Archetype Homepage</strong>
+ <br/><br/>
+ <span wicket:id="message">message will be here</span>
+ </body>
+</html>
+
Added:
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/resolver/HomePage_2.java
URL:
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/resolver/HomePage_2.java?rev=822823&view=auto
==============================================================================
---
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/resolver/HomePage_2.java
(added)
+++
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/resolver/HomePage_2.java
Wed Oct 7 18:26:19 2009
@@ -0,0 +1,47 @@
+/*
+ * 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.markup.resolver;
+
+import org.apache.wicket.PageParameters;
+import org.apache.wicket.markup.html.CSSPackageResource;
+import org.apache.wicket.markup.html.WebPage;
+import org.apache.wicket.markup.html.basic.Label;
+
+/**
+ * Homepage
+ */
+public class HomePage_2 extends WebPage
+{
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Constructor that is invoked when page is invoked without a session.
+ *
+ * @param parameters
+ * Page parameters
+ */
+ public HomePage_2(final PageParameters parameters)
+ {
+
+ // Add the simplest type of label
+ add(new Label("message",
+ "If you see this message wicket is properly configured
and running"));
+
+ add(CSSPackageResource.getHeaderContribution(HomePage_2.class,
"main.css"));
+ }
+}
Added:
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/resolver/TestHomePage.java
URL:
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/resolver/TestHomePage.java?rev=822823&view=auto
==============================================================================
---
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/resolver/TestHomePage.java
(added)
+++
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/resolver/TestHomePage.java
Wed Oct 7 18:26:19 2009
@@ -0,0 +1,80 @@
+/*
+ * 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.markup.resolver;
+
+import junit.framework.TestCase;
+
+import org.apache.wicket.util.tester.WicketTester;
+
+/**
+ * Simple test using the WicketTester
+ */
+public class TestHomePage extends TestCase
+{
+ private WicketTester tester;
+
+ @Override
+ public void setUp()
+ {
+ tester = new WicketTester();
+ }
+
+ /**
+ *
+ */
+ public void testRenderMyPage_1()
+ {
+ // start and render the test page
+ tester.startPage(HomePage_1.class);
+
+ // assert rendered page class
+ tester.assertRenderedPage(HomePage_1.class);
+
+ // assert rendered label component
+ tester.assertLabel("message",
+ "If you see this message wicket is properly configured
and running");
+
+ String href =
"href=\"resources/org.apache.wicket.markup.resolver.HomePage_1/main.css\"";
+
+ String doc = tester.getServletResponse().getDocument();
+ tester.assertContains(href);
+
+ // When rendered the 2nd time, the result should be same. The
href must not contain the
+ // locale
+ tester.startPage(HomePage_1.class);
+ tester.assertContains(href);
+ }
+
+ /**
+ *
+ */
+ public void testRenderMyPage_2()
+ {
+ // start and render the test page
+ tester.startPage(HomePage_2.class);
+
+ String href =
"href=\"resources/org.apache.wicket.markup.resolver.HomePage_2/main.css\"";
+
+ String doc = tester.getServletResponse().getDocument();
+ tester.assertContains(href);
+
+ // When rendered the 2nd time, the result should be same. The
href must not contain the
+ // locale
+ tester.startPage(HomePage_2.class);
+ tester.assertContains(href);
+ }
+}
Added:
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/resolver/main.css
URL:
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/resolver/main.css?rev=822823&view=auto
==============================================================================
---
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/resolver/main.css
(added)
+++
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/resolver/main.css
Wed Oct 7 18:26:19 2009
@@ -0,0 +1,3 @@
+body {
+ background-color: green;
+}
\ No newline at end of file