id
stringlengths 33
40
| content
stringlengths 662
61.5k
| max_stars_repo_path
stringlengths 85
97
|
---|---|---|
bugs-dot-jar_data_WICKET-4483_53442bb4 | ---
BugID: WICKET-4483
Summary: 'Component#setDefaultModel() should call #modelChanging()'
Description: |-
Component#setDefaultModel() should call #modelChanging() as #setDefaultModelObject() does.
It worked by chance so far because addStateChange() is called.
http://markmail.org/thread/uxl6uufusggqbb6s
diff --git a/wicket-core/src/main/java/org/apache/wicket/Component.java b/wicket-core/src/main/java/org/apache/wicket/Component.java
index fb56254..342f107 100644
--- a/wicket-core/src/main/java/org/apache/wicket/Component.java
+++ b/wicket-core/src/main/java/org/apache/wicket/Component.java
@@ -2985,15 +2985,11 @@ public abstract class Component
// Change model
if (wrappedModel != model)
{
- if (wrappedModel != null)
- {
- addStateChange();
- }
-
+ modelChanging();
setModelImpl(wrap(model));
+ modelChanged();
}
- modelChanged();
return this;
}
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-4483_53442bb4.diff |
bugs-dot-jar_data_WICKET-5728_3cc3fe95 | ---
BugID: WICKET-5728
Summary: Component queuing breaks with html tags that don't require close tag.
Description: Component queuing try to skip to close tag also for those tags that don't
have one. This leads to a EmptyStackException (see ArrayListStack#peek).
diff --git a/wicket-core/src/main/java/org/apache/wicket/MarkupContainer.java b/wicket-core/src/main/java/org/apache/wicket/MarkupContainer.java
index 0a3cab4..3eef517 100644
--- a/wicket-core/src/main/java/org/apache/wicket/MarkupContainer.java
+++ b/wicket-core/src/main/java/org/apache/wicket/MarkupContainer.java
@@ -1369,7 +1369,7 @@ public abstract class MarkupContainer extends Component implements Iterable<Comp
{
page.componentRemoved(component);
}
-
+
component.detach();
component.internalOnRemove();
@@ -2096,7 +2096,7 @@ public abstract class MarkupContainer extends Component implements Iterable<Comp
{
// could not dequeue, or does not contain children
- if (tag.isOpen())
+ if (tag.isOpen() && !tag.hasNoCloseTag())
{
dequeue.skipToCloseTag();
}
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5728_3cc3fe95.diff |
bugs-dot-jar_data_WICKET-4509_b672cb2d | ---
BugID: WICKET-4509
Summary: Spaces in path cause ModifcationWatcher to fail
Description: |-
The ModificationWatcher isn't able to reload resource files if there's a space in the path.
The problem is that Files#getLocalFileFromUrl(String) receives an URL encoded String in which spaces are encoded to %20. They are never decoded and passed to File(). The fix is not to use the external representation of an URL but the file representation.
diff --git a/wicket-util/src/main/java/org/apache/wicket/util/file/Files.java b/wicket-util/src/main/java/org/apache/wicket/util/file/Files.java
index 3b5b97c..f9d2579 100644
--- a/wicket-util/src/main/java/org/apache/wicket/util/file/Files.java
+++ b/wicket-util/src/main/java/org/apache/wicket/util/file/Files.java
@@ -23,7 +23,9 @@ import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
import java.net.URL;
+import java.net.URLDecoder;
import org.apache.wicket.util.io.IOUtils;
import org.apache.wicket.util.io.Streams;
@@ -363,7 +365,16 @@ public class Files
*/
public static File getLocalFileFromUrl(URL url)
{
- return getLocalFileFromUrl(Args.notNull(url, "url").toExternalForm());
+ final URL location = Args.notNull(url, "url");
+
+ try
+ {
+ return getLocalFileFromUrl(URLDecoder.decode(location.toExternalForm(), "UTF-8"));
+ }
+ catch (UnsupportedEncodingException ex)
+ {
+ return null;
+ }
}
/**
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-4509_b672cb2d.diff |
bugs-dot-jar_data_WICKET-3713_e1168a57 | ---
BugID: WICKET-3713
Summary: g/apache/wicket/protocol/http/request/UserAgent matches method is not correct
Description: |-
In the UserAgent Enum matches method, the loop over detectionStrings is at most executed once:
for (List<String> detectionGroup : detectionStrings)
{
for (String detectionString : detectionGroup)
{
if (!userAgent.contains(detectionString))
{
return false;
}
}
return true;
}
It returns true after only processing the first element in the detectionStrings list.
It never looks at any of the other elements of the list.
diff --git a/wicket-core/src/main/java/org/apache/wicket/protocol/http/request/UserAgent.java b/wicket-core/src/main/java/org/apache/wicket/protocol/http/request/UserAgent.java
index 4c663d3..b6c028a 100644
--- a/wicket-core/src/main/java/org/apache/wicket/protocol/http/request/UserAgent.java
+++ b/wicket-core/src/main/java/org/apache/wicket/protocol/http/request/UserAgent.java
@@ -96,15 +96,19 @@ enum UserAgent {
for (List<String> detectionGroup : detectionStrings)
{
+ boolean groupPassed = true;
for (String detectionString : detectionGroup)
{
if (!userAgent.contains(detectionString))
{
- return false;
+ groupPassed = false;
+ break;
}
}
-
- return true;
+ if (groupPassed)
+ {
+ return true;
+ }
}
return false;
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-3713_e1168a57.diff |
bugs-dot-jar_data_WICKET-3174_0cf14725 | ---
BugID: WICKET-3174
Summary: SmartLinkLabel failing to process email with +
Description: |+
Using SmartLinkLabel with an email address that includes a "+" generates a link only on the right-most part of the address.
Example:
- [email protected]
Will generate a link like:
- my+<a href="mailto:[email protected]">[email protected]@pappin.ca</a>
THe addition of the "+" char is a valid email address format.
diff --git a/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/basic/DefaultLinkParser.java b/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/basic/DefaultLinkParser.java
index 2c95610..ff824a1 100644
--- a/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/basic/DefaultLinkParser.java
+++ b/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/basic/DefaultLinkParser.java
@@ -29,7 +29,7 @@ import org.apache.wicket.util.string.AppendingStringBuffer;
public class DefaultLinkParser extends LinkParser
{
/** Email address pattern */
- private static final String emailPattern = "[\\w\\.-]+@[\\w\\.-]+";
+ private static final String emailPattern = "[\\w\\.-\\\\+]+@[\\w\\.-]+";
/** URL pattern */
private static final String urlPattern = "([a-zA-Z]+://[\\w\\.\\-\\:\\/~]+)[\\w\\.:\\-/?&=%]*";
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-3174_0cf14725.diff |
bugs-dot-jar_data_WICKET-4877_6470c3f7 | ---
BugID: WICKET-4877
Summary: encodeUrl fails parsing jsessionid when using root context
Description: "We are using Selenium 2.26.0 to test our Wicket application, using Jetty
6.1.25 (also tried 7.0.0.pre5) and Firefox 12 as client browser.\n\nWith Wicket
1.5.8 everything worked fine but updating to 1.5.9 the following error occurs on
first request:\n\njava.lang.NumberFormatException: For input string: \"56704;jsessionid=t3j8z4tsuazh1jfbcnjr8ryg\"\n\tat
java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)\n\tat
java.lang.Integer.parseInt(Integer.java:458)\n\tat java.lang.Integer.parseInt(Integer.java:499)\n\tat
org.apache.wicket.request.Url.parse(Url.java:195)\n\tat org.apache.wicket.request.Url.parse(Url.java:121)\n\tat
org.apache.wicket.protocol.http.servlet.ServletWebResponse.encodeURL(ServletWebResponse.java:194)\n\tat
org.apache.wicket.protocol.http.HeaderBufferingWebResponse.encodeURL(HeaderBufferingWebResponse.java:161)\n\tat
org.apache.wicket.request.cycle.RequestCycle.renderUrl(RequestCycle.java:524)\n\tat
org.apache.wicket.request.cycle.RequestCycle.urlFor(RequestCycle.java:492)\n\tat
org.apache.wicket.request.cycle.RequestCycle.urlFor(RequestCycle.java:477)\n\tat
org.apache.wicket.Component.urlFor(Component.java:3319)\n\tat org.apache.wicket.markup.html.link.BookmarkablePageLink.getURL(BookmarkablePageLink.java:209)\n\tat
org.apache.wicket.markup.html.link.Link.onComponentTag(Link.java:361)\n\tat org.apache.wicket.Component.internalRenderComponent(Component.java:2530)\n\tat
org.apache.wicket.MarkupContainer.onRender(MarkupContainer.java:1530)\n\tat org.apache.wicket.Component.internalRender(Component.java:2389)\n\tat
org.apache.wicket.Component.render(Component.java:2317)\n\tat org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java:1428)\n\tat
org.apache.wicket.MarkupContainer.renderAll(MarkupContainer.java:1592)\n\tat org.apache.wicket.Page.onRender(Page.java:907)\n\tat
org.apache.wicket.markup.html.WebPage.onRender(WebPage.java:140)\n\tat org.apache.wicket.Component.internalRender(Component.java:2389)\n\tat
org.apache.wicket.Component.render(Component.java:2317)\n\tat org.apache.wicket.Page.renderPage(Page.java:1035)\n\tat
org.apache.wicket.request.handler.render.WebPageRenderer.renderPage(WebPageRenderer.java:118)\n\tat
org.apache.wicket.request.handler.render.WebPageRenderer.respond(WebPageRenderer.java:246)\n\tat
org.apache.wicket.request.handler.RenderPageRequestHandler.respond(RenderPageRequestHandler.java:167)\n\tat
org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:784)\n\tat
org.apache.wicket.request.RequestHandlerStack.execute(RequestHandlerStack.java:64)\n\tat
org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:304)\n\tat
org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:313)\n\tat
org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:313)\n\tat
org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:313)\n\tat
org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:313)\n\tat
org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:313)\n\tat
org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:313)\n\tat
org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:313)\n\tat
org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:313)\n\tat
org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:313)\n\tat
org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:313)\n\tat
org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:227)\n\tat
org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:283)\n\tat
org.apache.wicket.protocol.http.WicketFilter.processRequest(WicketFilter.java:188)\n\tat
org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:244)\n\nUsing
debugger, the encodeUrl method has variables \n\nfullUrl = http://localhost:56704\nencodedFullUrl
= http://localhost:56704;jsessionid=8kxeo3reannw1qjtxgkju8yiu\n\nbefore the exception
occurs. I believe this is related to https://issues.apache.org/jira/browse/WICKET-4645.\n"
diff --git a/wicket-request/src/main/java/org/apache/wicket/request/Url.java b/wicket-request/src/main/java/org/apache/wicket/request/Url.java
index 9fb454c..191ebbe 100755
--- a/wicket-request/src/main/java/org/apache/wicket/request/Url.java
+++ b/wicket-request/src/main/java/org/apache/wicket/request/Url.java
@@ -232,8 +232,11 @@ public class Url implements Serializable
final String afterProto = absoluteUrl.substring(protocolAt + 3);
final String hostAndPort;
- final int relativeAt = afterProto.indexOf('/');
-
+ int relativeAt = afterProto.indexOf('/');
+ if (relativeAt == -1)
+ {
+ relativeAt = afterProto.indexOf(';');
+ }
if (relativeAt == -1)
{
relativeUrl = "";
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-4877_6470c3f7.diff |
bugs-dot-jar_data_WICKET-3514_2b6da516 | ---
BugID: WICKET-3514
Summary: SimpleTree example not working with CryptoMapper
Description: "Adding the following lines to WicketExampleApplication.java causes the
SimpleTree example to break. There are no expand icons anymore and there is no way
to expand the tree. Even the expand link will not work.\n\nAdd to WicketExampleApplication.java
\n\nIRequestMapper cryptoMapper = new CryptoMapper(getRootRequestMapper(), this);\nsetRootRequestMapper(cryptoMapper);\n\n\nComment
out in WicketExampleApplication.java \n\n//getSecuritySettings().setCryptFactory(new
ClassCryptFactory(NoCrypt.class, ISecuritySettings.DEFAULT_ENCRYPTION_KEY));\n\nWithout
the CryptoMapper everythings works fine.\n\n\n"
diff --git a/wicket-core/src/main/java/org/apache/wicket/request/mapper/CryptoMapper.java b/wicket-core/src/main/java/org/apache/wicket/request/mapper/CryptoMapper.java
index 4e632f8..bc2b297 100755
--- a/wicket-core/src/main/java/org/apache/wicket/request/mapper/CryptoMapper.java
+++ b/wicket-core/src/main/java/org/apache/wicket/request/mapper/CryptoMapper.java
@@ -125,10 +125,6 @@ public class CryptoMapper implements IRequestMapper
encryptedUrl.getSegments().add(encryptedUrlString);
int numberOfSegments = url.getSegments().size();
- if (numberOfSegments == 0 && !url.getQueryParameters().isEmpty())
- {
- numberOfSegments = 1;
- }
char[] encryptedChars = encryptedUrlString.toCharArray();
int hash = 0;
for (int segNo = 0; segNo < numberOfSegments; segNo++)
@@ -157,7 +153,7 @@ public class CryptoMapper implements IRequestMapper
}
List<String> segments = encryptedUrl.getSegments();
- if (segments.size() < 2)
+ if (segments.size() < 1)
{
return null;
}
@@ -175,11 +171,6 @@ public class CryptoMapper implements IRequestMapper
Url originalUrl = Url.parse(decryptedUrl, request.getCharset());
int originalNumberOfSegments = originalUrl.getSegments().size();
- if (originalNumberOfSegments == 0 &&
- originalUrl.getQueryParameters().isEmpty() == false)
- {
- originalNumberOfSegments = 1;
- }
int numberOfSegments = encryptedUrl.getSegments().size();
char[] encryptedChars = encryptedUrlString.toCharArray();
@@ -207,6 +198,12 @@ public class CryptoMapper implements IRequestMapper
}
else
{
+ // append new segments from browser
+ while (segNo < numberOfSegments)
+ {
+ url.getSegments().add(encryptedUrl.getSegments().get(segNo));
+ segNo++;
+ }
break;
}
}
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-3514_2b6da516.diff |
bugs-dot-jar_data_WICKET-4260_925cae5c | ---
BugID: WICKET-4260
Summary: UrlRenderer renders invalid relative URLs if first segment contains colon
Description: |
Seen on Wicket 1.5.3.
If a relative url of a link starts with a path segment containing a colon then the whole uri will be regarded as absolute uri, so typically browsers will complain that there is no handle for the protocol foo in foo:bar/dee/per.
See also the attached quickstart. The start page contains three links, one relative with colon, one absolute and one to a mounted page without colon for comparison.
The application also has a static switch to add an extended urlrenderer, prepending "./" if needed. This fix is merely a quick shot and there might be better alternatives.
diff --git a/wicket-core/src/main/java/org/apache/wicket/protocol/http/servlet/ServletWebResponse.java b/wicket-core/src/main/java/org/apache/wicket/protocol/http/servlet/ServletWebResponse.java
index 27b52b1..2296e34 100644
--- a/wicket-core/src/main/java/org/apache/wicket/protocol/http/servlet/ServletWebResponse.java
+++ b/wicket-core/src/main/java/org/apache/wicket/protocol/http/servlet/ServletWebResponse.java
@@ -227,6 +227,14 @@ public class ServletWebResponse extends WebResponse
}
else
{
+ if (url.startsWith("./"))
+ {
+ /*
+ * WICKET-4260 Tomcat does not canonalize urls, which leads to problems with IE
+ * when url is relative and starts with a dot
+ */
+ url = url.substring(2);
+ }
httpServletResponse.sendRedirect(url);
}
}
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-4260_925cae5c.diff |
bugs-dot-jar_data_WICKET-5570_57d8f051 | ---
BugID: WICKET-5570
Summary: Rescheduling the same ajax timer behavior causes memory leak in the browser
Description: 'AbstractAjaxTimerBehavior uses JavaScript setTimeout() function to do
its job. It has a #stop() method that clears the timeout but if the timeout is re-scheduled
without being cleared a memory leak is observed in the browser.'
diff --git a/wicket-core/src/main/java/org/apache/wicket/ajax/AbstractAjaxTimerBehavior.java b/wicket-core/src/main/java/org/apache/wicket/ajax/AbstractAjaxTimerBehavior.java
index 39c3cc6..5ecf56e 100644
--- a/wicket-core/src/main/java/org/apache/wicket/ajax/AbstractAjaxTimerBehavior.java
+++ b/wicket-core/src/main/java/org/apache/wicket/ajax/AbstractAjaxTimerBehavior.java
@@ -18,9 +18,7 @@ package org.apache.wicket.ajax;
import org.apache.wicket.Component;
import org.apache.wicket.Page;
-import org.apache.wicket.core.util.string.JavaScriptUtils;
import org.apache.wicket.markup.head.IHeaderResponse;
-import org.apache.wicket.markup.head.JavaScriptHeaderItem;
import org.apache.wicket.markup.head.OnLoadHeaderItem;
import org.apache.wicket.util.time.Duration;
@@ -36,7 +34,6 @@ public abstract class AbstractAjaxTimerBehavior extends AbstractDefaultAjaxBehav
{
private static final long serialVersionUID = 1L;
- private static final String WICKET_TIMERS_ID = AbstractAjaxTimerBehavior.class.getSimpleName() + "-timers";
/** The update interval */
private Duration updateInterval;
@@ -88,10 +85,6 @@ public abstract class AbstractAjaxTimerBehavior extends AbstractDefaultAjaxBehav
{
super.renderHead(component, response);
- response.render(JavaScriptHeaderItem.forScript(
- "if (typeof(Wicket.TimerHandles) === 'undefined') {Wicket.TimerHandles = {}}",
- WICKET_TIMERS_ID));
-
if (component.getRequestCycle().find(AjaxRequestTarget.class) == null)
{
// complete page is rendered, so timeout has to be rendered again
@@ -112,22 +105,12 @@ public abstract class AbstractAjaxTimerBehavior extends AbstractDefaultAjaxBehav
protected final String getJsTimeoutCall(final Duration updateInterval)
{
CharSequence js = getCallbackScript();
- js = JavaScriptUtils.escapeQuotes(js);
- String timeoutHandle = getTimeoutHandle();
- // this might look strange, but it is necessary for IE not to leak :(
- return timeoutHandle+" = setTimeout('" + js + "', " +
- updateInterval.getMilliseconds() + ')';
+ return String.format("Wicket.Timer.set('%s', function(){%s}, %d);",
+ getComponent().getMarkupId(), js, updateInterval.getMilliseconds());
}
/**
- * @return the name of the handle that is used to stop any scheduled timer
- */
- private String getTimeoutHandle() {
- return "Wicket.TimerHandles['"+getComponent().getMarkupId() + "']";
- }
-
- /**
*
* @see org.apache.wicket.ajax.AbstractDefaultAjaxBehavior#respond(AjaxRequestTarget)
*/
@@ -218,9 +201,7 @@ public abstract class AbstractAjaxTimerBehavior extends AbstractDefaultAjaxBehav
{
hasTimeout = false;
- String timeoutHandle = getTimeoutHandle();
- headerResponse.render(OnLoadHeaderItem.forScript("clearTimeout(" + timeoutHandle
- + "); delete " + timeoutHandle + ";"));
+ headerResponse.render(OnLoadHeaderItem.forScript("Wicket.Timer.clear('" + getComponent().getMarkupId() + "');"));
}
}
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5570_57d8f051.diff |
bugs-dot-jar_data_WICKET-5359_61122bab | ---
BugID: WICKET-5359
Summary: org.apache.wicket.util.string.StringValue#equals broken
Description: |
The #equals implementation for org.apache.wicket.util.string.StringValue is broken. The following throws an exception instead of just printing 'false':
StringValue val = StringValue.valueOf("bla", Locale.FRANCE);
StringValue val2 = StringValue.valueOf("bla", Locale.CANADA);
System.out.println(val.equals(val2));
This part of #equals
Objects.isEqual(locale, stringValue.locale)
should probably be replaced with something like
(locale == stringValue.locale || (locale != null && locale.equals(stringValue.locale))
-> Objects.isEqual is not suitable to determine equality of Locale
diff --git a/wicket-util/src/main/java/org/apache/wicket/util/string/StringValue.java b/wicket-util/src/main/java/org/apache/wicket/util/string/StringValue.java
index fa5bbbd..2887f95 100755
--- a/wicket-util/src/main/java/org/apache/wicket/util/string/StringValue.java
+++ b/wicket-util/src/main/java/org/apache/wicket/util/string/StringValue.java
@@ -318,56 +318,56 @@ public class StringValue implements IClusterable
if (type == String.class)
{
- return (T) toString();
+ return (T)toString();
}
if ((type == Integer.TYPE) || (type == Integer.class))
{
- return (T) toInteger();
+ return (T)toInteger();
}
if ((type == Long.TYPE) || (type == Long.class))
{
- return (T) toLongObject();
+ return (T)toLongObject();
}
if ((type == Boolean.TYPE) || (type == Boolean.class))
{
- return (T) toBooleanObject();
+ return (T)toBooleanObject();
}
if ((type == Double.TYPE) || (type == Double.class))
{
- return (T) toDoubleObject();
+ return (T)toDoubleObject();
}
if ((type == Character.TYPE) || (type == Character.class))
{
- return (T) toCharacter();
+ return (T)toCharacter();
}
if (type == Time.class)
{
- return (T) toTime();
+ return (T)toTime();
}
if (type == Duration.class)
{
- return (T) toDuration();
+ return (T)toDuration();
}
if (type.isEnum())
{
- return (T) toEnum((Class) type);
+ return (T)toEnum((Class)type);
}
- throw new StringValueConversionException("Cannot convert '" + toString() + "'to type " +
- type);
+ throw new StringValueConversionException("Cannot convert '" + toString() + "'to type "
+ + type);
}
/**
* Converts this StringValue to a given type or {@code null} if the value is empty.
- *
+ *
* @param type
* The type to convert to
* @return The converted value
@@ -377,7 +377,7 @@ public class StringValue implements IClusterable
{
return Strings.isEmpty(text) ? null : to(type);
}
-
+
/**
* Convert this text to a boolean.
*
@@ -394,8 +394,9 @@ public class StringValue implements IClusterable
*
* @param defaultValue
* the default value
- * @return the converted text as a boolean or the default value if text is empty or inconvertible
- * @see Strings#isTrue(String)
+ * @return the converted text as a boolean or the default value if text is empty or
+ * inconvertible
+ * @see Strings#isTrue(String)
*/
public final boolean toBoolean(final boolean defaultValue)
{
@@ -410,7 +411,8 @@ public class StringValue implements IClusterable
if (LOG.isDebugEnabled())
{
LOG.debug(String.format(
- "An error occurred while converting '%s' to a boolean: %s", text, x.getMessage()), x);
+ "An error occurred while converting '%s' to a boolean: %s", text,
+ x.getMessage()), x);
}
}
}
@@ -444,7 +446,8 @@ public class StringValue implements IClusterable
*
* @param defaultValue
* the default value
- * @return the converted text as a primitive char or the default value if text is not a single character
+ * @return the converted text as a primitive char or the default value if text is not a single
+ * character
*/
public final char toChar(final char defaultValue)
{
@@ -459,7 +462,8 @@ public class StringValue implements IClusterable
if (LOG.isDebugEnabled())
{
LOG.debug(String.format(
- "An error occurred while converting '%s' to a character: %s", text, x.getMessage()), x);
+ "An error occurred while converting '%s' to a character: %s", text,
+ x.getMessage()), x);
}
}
}
@@ -491,8 +495,8 @@ public class StringValue implements IClusterable
}
catch (ParseException e)
{
- throw new StringValueConversionException("Unable to convert '" + text +
- "' to a double value", e);
+ throw new StringValueConversionException("Unable to convert '" + text
+ + "' to a double value", e);
}
}
@@ -516,7 +520,8 @@ public class StringValue implements IClusterable
if (LOG.isDebugEnabled())
{
LOG.debug(String.format(
- "An error occurred while converting '%s' to a double: %s", text, x.getMessage()), x);
+ "An error occurred while converting '%s' to a double: %s", text,
+ x.getMessage()), x);
}
}
}
@@ -539,7 +544,7 @@ public class StringValue implements IClusterable
*
* @return Converted text
* @throws StringValueConversionException
- * @see Duration#valueOf(String, java.util.Locale)
+ * @see Duration#valueOf(String, java.util.Locale)
*/
public final Duration toDuration() throws StringValueConversionException
{
@@ -551,8 +556,9 @@ public class StringValue implements IClusterable
*
* @param defaultValue
* the default value
- * @return the converted text as a duration or the default value if text is empty or inconvertible
- * @see Duration#valueOf(String, java.util.Locale)
+ * @return the converted text as a duration or the default value if text is empty or
+ * inconvertible
+ * @see Duration#valueOf(String, java.util.Locale)
*/
public final Duration toDuration(final Duration defaultValue)
{
@@ -567,7 +573,8 @@ public class StringValue implements IClusterable
if (LOG.isDebugEnabled())
{
LOG.debug(String.format(
- "An error occurred while converting '%s' to a Duration: %s", text, x.getMessage()), x);
+ "An error occurred while converting '%s' to a Duration: %s", text,
+ x.getMessage()), x);
}
}
}
@@ -588,8 +595,8 @@ public class StringValue implements IClusterable
}
catch (NumberFormatException e)
{
- throw new StringValueConversionException("Unable to convert '" + text +
- "' to an int value", e);
+ throw new StringValueConversionException("Unable to convert '" + text
+ + "' to an int value", e);
}
}
@@ -613,7 +620,8 @@ public class StringValue implements IClusterable
if (LOG.isDebugEnabled())
{
LOG.debug(String.format(
- "An error occurred while converting '%s' to an integer: %s", text, x.getMessage()), x);
+ "An error occurred while converting '%s' to an integer: %s", text,
+ x.getMessage()), x);
}
}
}
@@ -634,8 +642,8 @@ public class StringValue implements IClusterable
}
catch (NumberFormatException e)
{
- throw new StringValueConversionException("Unable to convert '" + text +
- "' to an Integer value", e);
+ throw new StringValueConversionException("Unable to convert '" + text
+ + "' to an Integer value", e);
}
}
@@ -653,8 +661,8 @@ public class StringValue implements IClusterable
}
catch (NumberFormatException e)
{
- throw new StringValueConversionException("Unable to convert '" + text +
- "' to a long value", e);
+ throw new StringValueConversionException("Unable to convert '" + text
+ + "' to a long value", e);
}
}
@@ -663,7 +671,8 @@ public class StringValue implements IClusterable
*
* @param defaultValue
* the default value
- * @return the converted text as a long integer or the default value if text is empty or inconvertible
+ * @return the converted text as a long integer or the default value if text is empty or
+ * inconvertible
*/
public final long toLong(final long defaultValue)
{
@@ -678,7 +687,8 @@ public class StringValue implements IClusterable
if (LOG.isDebugEnabled())
{
LOG.debug(String.format(
- "An error occurred while converting '%s' to a long: %s", text, x.getMessage()), x);
+ "An error occurred while converting '%s' to a long: %s", text,
+ x.getMessage()), x);
}
}
}
@@ -699,8 +709,8 @@ public class StringValue implements IClusterable
}
catch (NumberFormatException e)
{
- throw new StringValueConversionException("Unable to convert '" + text +
- "' to a Long value", e);
+ throw new StringValueConversionException("Unable to convert '" + text
+ + "' to a Long value", e);
}
}
@@ -826,8 +836,8 @@ public class StringValue implements IClusterable
}
catch (ParseException e)
{
- throw new StringValueConversionException("Unable to convert '" + text +
- "' to a Time value", e);
+ throw new StringValueConversionException("Unable to convert '" + text
+ + "' to a Time value", e);
}
}
@@ -851,7 +861,8 @@ public class StringValue implements IClusterable
if (LOG.isDebugEnabled())
{
LOG.debug(String.format(
- "An error occurred while converting '%s' to a Time: %s", text, x.getMessage()), x);
+ "An error occurred while converting '%s' to a Time: %s", text,
+ x.getMessage()), x);
}
}
}
@@ -860,7 +871,7 @@ public class StringValue implements IClusterable
/**
* Convert this text to an enum.
- *
+ *
* @param eClass
* enum type
* @return The value as an enum
@@ -874,7 +885,7 @@ public class StringValue implements IClusterable
/**
* Convert this text to an enum.
- *
+ *
* @param defaultValue
* This will be returned if there is an error converting the value
* @return The value as an enum
@@ -887,7 +898,7 @@ public class StringValue implements IClusterable
/**
* Convert this text to an enum.
- *
+ *
* @param eClass
* enum type
* @param defaultValue
@@ -916,10 +927,10 @@ public class StringValue implements IClusterable
/**
* Convert to enum, returning null if text is null or empty.
- *
+ *
* @param eClass
* enum type
- *
+ *
* @return converted
* @throws StringValueConversionException
*/
@@ -968,8 +979,7 @@ public class StringValue implements IClusterable
if (obj instanceof StringValue)
{
StringValue stringValue = (StringValue)obj;
- return Objects.isEqual(text, stringValue.text) &&
- Objects.isEqual(locale, stringValue.locale);
+ return Objects.isEqual(text, stringValue.text) && locale.equals(stringValue.locale);
}
else
{
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5359_61122bab.diff |
bugs-dot-jar_data_WICKET-5898_b00920f3 | ---
BugID: WICKET-5898
Summary: StackOverflowError after form submit with a validation error
Description: "I was not able to find a cause or make a small quickstart, but it has
something to do with a form validation, my workaround was to setDefaultFormProcessing(false)
or not use required TextFields.\n\nIt can be reproduced on https://github.com/krasa/DevSupportApp/tree/stackOverflow
\n1) run StartVojtitkoDummy\n2) go to http://localhost:8765/wicket/bookmarkable/krasa.release.frontend.TokenizationPage\n3)
click on \"Generate Release json\" button \n- instead of SOE, it should give a validation
error, probably even on fields which I would not want to validate, but that's just
because I've made the page badly... \n\n \n{code}\njava.lang.StackOverflowError:
null\n...\n\tat org.apache.wicket.Component.getMarkup(Component.java:755)\n\tat
org.apache.wicket.markup.html.panel.DefaultMarkupSourcingStrategy.getMarkup(DefaultMarkupSourcingStrategy.java:81)\n\tat
org.apache.wicket.MarkupContainer.getMarkup(MarkupContainer.java:453)\n\tat org.apache.wicket.markup.html.panel.AbstractMarkupSourcingStrategy$1.component(AbstractMarkupSourcingStrategy.java:74)\n\tat
org.apache.wicket.markup.html.panel.AbstractMarkupSourcingStrategy$1.component(AbstractMarkupSourcingStrategy.java:66)\n\tat
org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:144)\n\tat org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:123)\n\tat
org.apache.wicket.MarkupContainer.visitChildren(MarkupContainer.java:862)\n\tat
org.apache.wicket.markup.html.panel.AbstractMarkupSourcingStrategy.searchMarkupInTransparentResolvers(AbstractMarkupSourcingStrategy.java:65)\n\tat
org.apache.wicket.markup.html.panel.DefaultMarkupSourcingStrategy.getMarkup(DefaultMarkupSourcingStrategy.java:99)\n\tat
org.apache.wicket.MarkupContainer.getMarkup(MarkupContainer.java:453)\n\tat org.apache.wicket.Component.getMarkup(Component.java:755)\n\tat
org.apache.wicket.markup.html.panel.DefaultMarkupSourcingStrategy.getMarkup(DefaultMarkupSourcingStrategy.java:81)\n\tat
org.apache.wicket.MarkupContainer.getMarkup(MarkupContainer.java:453)\n\tat org.apache.wicket.markup.html.panel.AbstractMarkupSourcingStrategy$1.component(AbstractMarkupSourcingStrategy.java:74)\n\tat
org.apache.wicket.markup.html.panel.AbstractMarkupSourcingStrategy$1.component(AbstractMarkupSourcingStrategy.java:66)\n\tat
org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:144)\n\tat org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:123)\n\tat
org.apache.wicket.MarkupContainer.visitChildren(MarkupContainer.java:862)\n\tat
org.apache.wicket.markup.html.panel.AbstractMarkupSourcingStrategy.searchMarkupInTransparentResolvers(AbstractMarkupSourcingStrategy.java:65)\n\tat
org.apache.wicket.markup.html.panel.DefaultMarkupSourcingStrategy.getMarkup(DefaultMarkupSourcingStrategy.java:99)\n\tat
org.apache.wicket.MarkupContainer.getMarkup(MarkupContainer.java:453)\n\tat org.apache.wicket.Component.getMarkup(Component.java:755)\n\tat
org.apache.wicket.markup.html.panel.DefaultMarkupSourcingStrategy.getMarkup(DefaultMarkupSourcingStrategy.java:81)\n\tat
org.apache.wicket.MarkupContainer.getMarkup(MarkupContainer.java:453)\n\tat org.apache.wicket.markup.html.panel.AbstractMarkupSourcingStrategy$1.component(AbstractMarkupSourcingStrategy.java:74)\n\tat
org.apache.wicket.markup.html.panel.AbstractMarkupSourcingStrategy$1.component(AbstractMarkupSourcingStrategy.java:66)\n\tat
org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:144)\n\tat org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:123)\n\tat
org.apache.wicket.MarkupContainer.visitChildren(MarkupContainer.java:862)\n\tat
org.apache.wicket.markup.html.panel.AbstractMarkupSourcingStrategy.searchMarkupInTransparentResolvers(AbstractMarkupSourcingStrategy.java:65)\n\tat
org.apache.wicket.markup.html.panel.DefaultMarkupSourcingStrategy.getMarkup(DefaultMarkupSourcingStrategy.java:99)\n\tat
org.apache.wicket.MarkupContainer.getMarkup(MarkupContainer.java:453)\n\tat org.apache.wicket.Component.getMarkup(Component.java:755)\n\tat
org.apache.wicket.markup.html.panel.DefaultMarkupSourcingStrategy.getMarkup(DefaultMarkupSourcingStrategy.java:81)\n\tat
org.apache.wicket.MarkupContainer.getMarkup(MarkupContainer.java:453)\n\tat org.apache.wicket.markup.html.panel.AbstractMarkupSourcingStrategy$1.component(AbstractMarkupSourcingStrategy.java:74)\n\tat
org.apache.wicket.markup.html.panel.AbstractMarkupSourcingStrategy$1.component(AbstractMarkupSourcingStrategy.java:66)\n\tat
org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:144)\n\tat org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:123)\n\tat
org.apache.wicket.MarkupContainer.visitChildren(MarkupContainer.java:862)\n\tat
org.apache.wicket.markup.html.panel.AbstractMarkupSourcingStrategy.searchMarkupInTransparentResolvers(AbstractMarkupSourcingStrategy.java:65)\n\tat
org.apache.wicket.markup.html.panel.DefaultMarkupSourcingStrategy.getMarkup(DefaultMarkupSourcingStrategy.java:99)\n\tat
org.apache.wicket.MarkupContainer.getMarkup(MarkupContainer.java:453)\n\tat org.apache.wicket.Component.getMarkup(Component.java:755)\n\tat
org.apache.wicket.markup.html.panel.DefaultMarkupSourcingStrategy.getMarkup(DefaultMarkupSourcingStrategy.java:81)\n\tat
org.apache.wicket.MarkupContainer.getMarkup(MarkupContainer.java:453)\n\tat org.apache.wicket.markup.html.panel.AbstractMarkupSourcingStrategy$1.component(AbstractMarkupSourcingStrategy.java:74)\n\tat
org.apache.wicket.markup.html.panel.AbstractMarkupSourcingStrategy$1.component(AbstractMarkupSourcingStrategy.java:66)\n\tat
org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:144)\n\tat org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:123)\n\tat
org.apache.wicket.MarkupContainer.visitChildren(MarkupContainer.java:862)\n\tat
org.apache.wicket.markup.html.panel.AbstractMarkupSourcingStrategy.searchMarkupInTransparentResolvers(AbstractMarkupSourcingStrategy.java:65)\n\tat
org.apache.wicket.markup.html.panel.DefaultMarkupSourcingStrategy.getMarkup(DefaultMarkupSourcingStrategy.java:99)\n\tat
org.apache.wicket.MarkupContainer.getMarkup(MarkupContainer.java:453)\n\tat org.apache.wicket.Component.getMarkup(Component.java:755)\n\tat
org.apache.wicket.markup.html.panel.DefaultMarkupSourcingStrategy.getMarkup(DefaultMarkupSourcingStrategy.java:81)\n\tat
org.apache.wicket.MarkupContainer.getMarkup(MarkupContainer.java:453)\n\tat org.apache.wicket.markup.html.panel.AbstractMarkupSourcingStrategy$1.component(AbstractMarkupSourcingStrategy.java:74)\n\tat
org.apache.wicket.markup.html.panel.AbstractMarkupSourcingStrategy$1.component(AbstractMarkupSourcingStrategy.java:66)\n\tat
org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:144)\n\tat org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:123)\n\tat
org.apache.wicket.MarkupContainer.visitChildren(MarkupContainer.java:862)\n\tat
org.apache.wicket.markup.html.panel.AbstractMarkupSourcingStrategy.searchMarkupInTransparentResolvers(AbstractMarkupSourcingStrategy.java:65)\n\tat
org.apache.wicket.markup.html.panel.DefaultMarkupSourcingStrategy.getMarkup(DefaultMarkupSourcingStrategy.java:99)\n\tat
org.apache.wicket.MarkupContainer.getMarkup(MarkupContainer.java:453)\n\tat org.apache.wicket.Component.getMarkup(Component.java:755)\n\tat
org.apache.wicket.markup.html.panel.DefaultMarkupSourcingStrategy.getMarkup(DefaultMarkupSourcingStrategy.java:81)\n\tat
org.apache.wicket.MarkupContainer.getMarkup(MarkupContainer.java:453)\n\tat org.apache.wicket.markup.html.panel.AbstractMarkupSourcingStrategy$1.component(AbstractMarkupSourcingStrategy.java:74)\n\tat
org.apache.wicket.markup.html.panel.AbstractMarkupSourcingStrategy$1.component(AbstractMarkupSourcingStrategy.java:66)\n\tat
org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:144)\n\tat org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:123)\n\tat
org.apache.wicket.MarkupContainer.visitChildren(MarkupContainer.java:862)\n\tat
org.apache.wicket.markup.html.panel.AbstractMarkupSourcingStrategy.searchMarkupInTransparentResolvers(AbstractMarkupSourcingStrategy.java:65)\n\tat
org.apache.wicket.markup.html.panel.DefaultMarkupSourcingStrategy.getMarkup(DefaultMarkupSourcingStrategy.java:99)\n\tat
org.apache.wicket.MarkupContainer.getMarkup(MarkupContainer.java:453)\n\tat org.apache.wicket.Component.getMarkup(Component.java:755)\n\tat
org.apache.wicket.markup.html.panel.DefaultMarkupSourcingStrategy.getMarkup(DefaultMarkupSourcingStrategy.java:81)\n\tat
org.apache.wicket.MarkupContainer.getMarkup(MarkupContainer.java:453)\n\tat org.apache.wicket.markup.html.panel.AbstractMarkupSourcingStrategy$1.component(AbstractMarkupSourcingStrategy.java:74)\n\tat
org.apache.wicket.markup.html.panel.AbstractMarkupSourcingStrategy$1.component(AbstractMarkupSourcingStrategy.java:66)\n\tat
org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:144)\n\tat org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:123)\n\tat
org.apache.wicket.MarkupContainer.visitChildren(MarkupContainer.java:862)\n\tat
org.apache.wicket.markup.html.panel.AbstractMarkupSourcingStrategy.searchMarkupInTransparentResolvers(AbstractMarkupSourcingStrategy.java:65)\n\tat
org.apache.wicket.markup.html.panel.DefaultMarkupSourcingStrategy.getMarkup(DefaultMarkupSourcingStrategy.java:99)\n\tat
org.apache.wicket.MarkupContainer.getMarkup(MarkupContainer.java:453)\n\tat org.apache.wicket.Component.getMarkup(Component.java:755)\n\tat
org.apache.wicket.markup.html.panel.DefaultMarkupSourcingStrategy.getMarkup(DefaultMarkupSourcingStrategy.java:81)\n\tat
org.apache.wicket.MarkupContainer.getMarkup(MarkupContainer.java:453)\n\tat org.apache.wicket.markup.html.panel.AbstractMarkupSourcingStrategy$1.component(AbstractMarkupSourcingStrategy.java:74)\n\tat
org.apache.wicket.markup.html.panel.AbstractMarkupSourcingStrategy$1.component(AbstractMarkupSourcingStrategy.java:66)\n\tat
org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:144)\n\tat org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:162)\n\tat
org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:162)\n\tat org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:162)\n\tat
org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:123)\n\tat org.apache.wicket.MarkupContainer.visitChildren(MarkupContainer.java:862)\n\tat
org.apache.wicket.markup.html.panel.AbstractMarkupSourcingStrategy.searchMarkupInTransparentResolvers(AbstractMarkupSourcingStrategy.java:65)\n\tat
org.apache.wicket.markup.html.panel.DefaultMarkupSourcingStrategy.getMarkup(DefaultMarkupSourcingStrategy.java:99)\n\tat
org.apache.wicket.MarkupContainer.getMarkup(MarkupContainer.java:453)\n\tat org.apache.wicket.Component.getMarkup(Component.java:755)\n\tat
org.apache.wicket.Component.internalRender(Component.java:2344)\n\tat org.apache.wicket.Component.render(Component.java:2307)\n\tat
org.apache.wicket.ajax.XmlAjaxResponse.writeComponent(XmlAjaxResponse.java:128)\n\tat
org.apache.wicket.ajax.AbstractAjaxResponse.writeComponents(AbstractAjaxResponse.java:218)\n\tat
org.apache.wicket.ajax.AbstractAjaxResponse.writeTo(AbstractAjaxResponse.java:150)\n\tat
org.apache.wicket.ajax.AjaxRequestHandler.respond(AjaxRequestHandler.java:359)\n\tat
org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:865)\n\tat
org.apache.wicket.request.RequestHandlerStack.execute(RequestHandlerStack.java:64)\n\tat
org.apache.wicket.request.RequestHandlerStack.execute(RequestHandlerStack.java:97)\n\tat
org.apache.wicket.request.cycle.RequestCycle.execute(RequestCycle.java:265)\n\tat
org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:222)\n\tat
org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:293)\n\tat
org.apache.wicket.protocol.ws.AbstractUpgradeFilter.processRequestCycle(AbstractUpgradeFilter.java:59)\n\tat
org.apache.wicket.protocol.http.WicketFilter.processRequest(WicketFilter.java:203)\n\tat
org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:284)\n\tat
org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652)\n\tat
org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:585)\n\tat
org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)\n\tat
org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:577)\n\tat
org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:223)\n\tat
org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1125)\n\tat
org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)\n\tat
org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)\n\tat
org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1059)\n\tat
org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)\n\tat
org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)\n\tat
org.eclipse.jetty.server.Server.handle(Server.java:497)\n\tat org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:310)\n\tat
org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:248)\n\tat
org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:540)\n\tat
org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:620)\n\tat
org.eclipse.jetty.util.thread.QueuedThreadPool$3.ru\n{code}"
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/panel/DefaultMarkupSourcingStrategy.java b/wicket-core/src/main/java/org/apache/wicket/markup/html/panel/DefaultMarkupSourcingStrategy.java
index 6ba5b61..f1749af 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/html/panel/DefaultMarkupSourcingStrategy.java
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/panel/DefaultMarkupSourcingStrategy.java
@@ -21,6 +21,7 @@ import org.apache.wicket.MarkupContainer;
import org.apache.wicket.markup.ComponentTag;
import org.apache.wicket.markup.IMarkupFragment;
import org.apache.wicket.markup.MarkupStream;
+import org.apache.wicket.markup.resolver.IComponentResolver;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -95,8 +96,11 @@ public final class DefaultMarkupSourcingStrategy extends AbstractMarkupSourcingS
{
return markup;
}
-
- markup = searchMarkupInTransparentResolvers(container, child);
+
+ if(!(child instanceof IComponentResolver))
+ {
+ markup = searchMarkupInTransparentResolvers(container, child);
+ }
return markup;
}
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5898_b00920f3.diff |
bugs-dot-jar_data_WICKET-2334_96330447 | ---
BugID: WICKET-2334
Summary: DebugBar throws an java.lang.ExceptionInInitializerError when Tomcat is restarted
Description: "I have just added the DebugBar to our base page, and since then when
Tomcat is restarted and session would be reloaded by this it throws this exception:\n\n1
\ ERROR org.apache.catalina.session.ManagerBase - Exception loading sessions
from persistent storage\njava.lang.ExceptionInInitializerError\n\tat sun.misc.Unsafe.ensureClassInitialized(Native
Method)\n\tat sun.reflect.UnsafeFieldAccessorFactory.newFieldAccessor(UnsafeFieldAccessorFactory.java:25)\n\tat
sun.reflect.ReflectionFactory.newFieldAccessor(ReflectionFactory.java:122)\n\tat
java.lang.reflect.Field.acquireFieldAccessor(Field.java:918)\n\tat java.lang.reflect.Field.getFieldAccessor(Field.java:899)\n\tat
java.lang.reflect.Field.getLong(Field.java:528)\n\tat java.io.ObjectStreamClass.getDeclaredSUID(ObjectStreamClass.java:1614)\n\tat
java.io.ObjectStreamClass.access$700(ObjectStreamClass.java:52)\n\tat java.io.ObjectStreamClass$2.run(ObjectStreamClass.java:425)\n\tat
java.security.AccessController.doPrivileged(Native Method)\n\tat java.io.ObjectStreamClass.<init>(ObjectStreamClass.java:413)\n\tat
java.io.ObjectStreamClass.lookup(ObjectStreamClass.java:310)\n\tat java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:547)\n\tat
java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1583)\n\tat java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1496)\n\tat
java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1583)\n\tat java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1496)\n\tat
java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1732)\n\tat
java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)\n\tat java.io.ObjectInputStream.readArray(ObjectInputStream.java:1667)\n\tat
java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1323)\n\tat java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1947)\n\tat
java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1871)\n\tat java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)\n\tat
java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)\n\tat java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1947)\n\tat
java.io.ObjectInputStream.defaultReadObject(ObjectInputStream.java:480)\n\tat org.apache.wicket.Component.readObject(Component.java:4469)\n\tat
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\n\tat sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)\n\tat
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)\n\tat
java.lang.reflect.Method.invoke(Method.java:597)\n\tat java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:974)\n\tat
java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1849)\n\tat java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)\n\tat
java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)\n\tat java.io.ObjectInputStream.readArray(ObjectInputStream.java:1667)\n\tat
java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1323)\n\tat java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1947)\n\tat
java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1871)\n\tat java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)\n\tat
java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)\n\tat java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)\n\tat
java.util.concurrent.CopyOnWriteArrayList.readObject(CopyOnWriteArrayList.java:845)\n\tat
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\n\tat sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)\n\tat
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)\n\tat
java.lang.reflect.Method.invoke(Method.java:597)\n\tat java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:974)\n\tat
java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1849)\n\tat java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)\n\tat
java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)\n\tat java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1947)\n\tat
java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1871)\n\tat java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)\n\tat
java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)\n\tat java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1947)\n\tat
java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1871)\n\tat java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)\n\tat
java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)\n\tat java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1947)\n\tat
java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1871)\n\tat java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)\n\tat
java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)\n\tat java.io.ObjectInputStream.readArray(ObjectInputStream.java:1667)\n\tat
java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1323)\n\tat java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1947)\n\tat
java.io.ObjectInputStream.defaultReadObject(ObjectInputStream.java:480)\n\tat org.apache.wicket.Page.readPageObject(Page.java:1349)\n\tat
org.apache.wicket.Component.readObject(Component.java:4465)\n\tat sun.reflect.NativeMethodAccessorImpl.invoke0(Native
Method)\n\tat sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)\n\tat
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)\n\tat
java.lang.reflect.Method.invoke(Method.java:597)\n\tat java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:974)\n\tat
java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1849)\n\tat java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)\n\tat
java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)\n\tat java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)\n\tat
org.apache.wicket.protocol.http.SecondLevelCacheSessionStore$SecondLevelCachePageMap.readObject(SecondLevelCacheSessionStore.java:412)\n\tat
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\n\tat sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)\n\tat
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)\n\tat
java.lang.reflect.Method.invoke(Method.java:597)\n\tat java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:974)\n\tat
java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1849)\n\tat java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)\n\tat
java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)\n\tat java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)\n\tat
org.apache.catalina.session.StandardSession.readObject(StandardSession.java:1407)\n\tat
org.apache.catalina.session.StandardSession.readObjectData(StandardSession.java:931)\n\tat
org.apache.catalina.session.StandardManager.doLoad(StandardManager.java:394)\n\tat
org.apache.catalina.session.StandardManager.load(StandardManager.java:321)\n\tat
org.apache.catalina.session.StandardManager.start(StandardManager.java:637)\n\tat
org.apache.catalina.core.ContainerBase.setManager(ContainerBase.java:432)\n\tat
org.apache.catalina.core.StandardContext.start(StandardContext.java:4160)\n\tat
org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)\n\tat org.apache.catalina.core.StandardHost.start(StandardHost.java:736)\n\tat
org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)\n\tat org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)\n\tat
org.apache.catalina.core.StandardService.start(StandardService.java:448)\n\tat org.apache.catalina.core.StandardServer.start(StandardServer.java:700)\n\tat
org.apache.catalina.startup.Catalina.start(Catalina.java:552)\n\tat sun.reflect.NativeMethodAccessorImpl.invoke0(Native
Method)\n\tat sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)\n\tat
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)\n\tat
java.lang.reflect.Method.invoke(Method.java:597)\n\tat org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:295)\n\tat
org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:433)\nCaused by: org.apache.wicket.WicketRuntimeException:
There is no application attached to current thread main\n\tat org.apache.wicket.Application.get(Application.java:178)\n\tat
org.apache.wicket.devutils.debugbar.DebugBar.getContributors(DebugBar.java:146)\n\tat
org.apache.wicket.devutils.debugbar.DebugBar.registerContributor(DebugBar.java:140)\n\tat
org.apache.wicket.devutils.debugbar.DebugBar.registerStandardContributors(DebugBar.java:152)\n\tat
org.apache.wicket.devutils.debugbar.DebugBar.<clinit>(DebugBar.java:65)\n\t... 109
more"
diff --git a/wicket-devutils/src/main/java/org/apache/wicket/devutils/debugbar/DebugBar.java b/wicket-devutils/src/main/java/org/apache/wicket/devutils/debugbar/DebugBar.java
index 88f1371..866340f 100644
--- a/wicket-devutils/src/main/java/org/apache/wicket/devutils/debugbar/DebugBar.java
+++ b/wicket-devutils/src/main/java/org/apache/wicket/devutils/debugbar/DebugBar.java
@@ -33,11 +33,10 @@ import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.model.AbstractReadOnlyModel;
/**
- * The debug bar is for use during development. It allows contributors to add
- * useful functions or data, making them readily accessible to the developer.<br />
+ * The debug bar is for use during development. It allows contributors to add useful functions or
+ * data, making them readily accessible to the developer.<br />
* <br />
- * To use it, simply add it to your base page so that all of your pages
- * automatically have it.<br />
+ * To use it, simply add it to your base page so that all of your pages automatically have it.<br />
*
* <br />
* <code>
@@ -49,108 +48,135 @@ import org.apache.wicket.model.AbstractReadOnlyModel;
* </code>
*
* <br />
- * You can also add your own information to the bar by creating a
- * {@link IDebugBarContributor} and registering it with the debug bar.
+ * You can also add your own information to the bar by creating a {@link IDebugBarContributor} and
+ * registering it with the debug bar.
*
* @author Jeremy Thomerson <[email protected]>
* @see IDebugBarContributor
*/
-public class DebugBar extends DevUtilsPanel {
-
- private static final MetaDataKey<List<IDebugBarContributor>> CONTRIBS_META_KEY = new MetaDataKey<List<IDebugBarContributor>>() {
- private static final long serialVersionUID = 1L;
- };
-
- static {
- registerStandardContributors();
- }
-
- private static final long serialVersionUID = 1L;
-
- public DebugBar(String id) {
- super(id);
- setMarkupId("wicketDebugBar");
- setOutputMarkupId(true);
- add(new AttributeModifier("class", true,
- new AbstractReadOnlyModel<String>() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public String getObject() {
- return "wicketDebugBar"
- + (DebugBar.this.hasErrorMessage() ? "Error"
- : "");
- }
-
- }));
- add(CSSPackageResource.getHeaderContribution(DebugBar.class,
- "wicket-debugbar.css"));
- add(JavascriptPackageResource.getHeaderContribution(DebugBar.class,
- "wicket-debugbar.js"));
- add(new Image("logo", new ResourceReference(DebugBar.class,
- "wicket.png")));
- add(new Image("removeImg", new ResourceReference(DebugBar.class,
- "remove.png")));
- List<IDebugBarContributor> contributors = getContributors();
- if (contributors.isEmpty()) {
- // we do this so that if you have multiple applications running in
- // the same container,
- // each ends up registering its' own contributors (wicket-examples
- // for example)
- registerStandardContributors();
- contributors = getContributors();
- }
- add(new ListView<IDebugBarContributor>("contributors", contributors) {
- private static final long serialVersionUID = 1L;
-
- @Override
- protected void populateItem(ListItem<IDebugBarContributor> item) {
- IDebugBarContributor contrib = item.getModelObject();
- Component comp = contrib.createComponent("contrib", DebugBar.this);
- if (comp == null) {
- // some contributors only add information to the debug bar
- // and don't actually create a contributed component
- item.setVisibilityAllowed(false);
- } else {
- item.add(comp);
- }
- }
- });
- }
-
- @Override
- public boolean isVisible() {
- return getApplication().getDebugSettings()
- .isDevelopmentUtilitiesEnabled();
- }
-
- /**
- * Register your own custom contributor that will be part of the debug bar.
- * You must have the context of an application for this thread at the time
- * of calling this method.
- *
- * @param contrib
- * custom contributor - can not be null
- */
- public static void registerContributor(IDebugBarContributor contrib) {
- if (contrib == null) {
- throw new IllegalArgumentException("contrib can not be null");
- }
-
- List<IDebugBarContributor> contributors = getContributors();
- contributors.add(contrib);
- Application.get().setMetaData(CONTRIBS_META_KEY, contributors);
- }
-
- private static List<IDebugBarContributor> getContributors() {
- List<IDebugBarContributor> list = Application.get().getMetaData(
- CONTRIBS_META_KEY);
- return list == null ? new ArrayList<IDebugBarContributor>() : list;
- }
-
- private static void registerStandardContributors() {
- registerContributor(VersionDebugContributor.DEBUG_BAR_CONTRIB);
- registerContributor(InspectorDebugPanel.DEBUG_BAR_CONTRIB);
- registerContributor(SessionSizeDebugPanel.DEBUG_BAR_CONTRIB);
- }
+public class DebugBar extends DevUtilsPanel
+{
+
+ private static final MetaDataKey<List<IDebugBarContributor>> CONTRIBS_META_KEY = new MetaDataKey<List<IDebugBarContributor>>()
+ {
+ private static final long serialVersionUID = 1L;
+ };
+
+ private static final long serialVersionUID = 1L;
+
+ public DebugBar(String id)
+ {
+ super(id);
+ setMarkupId("wicketDebugBar");
+ setOutputMarkupId(true);
+ add(new AttributeModifier("class", true, new AbstractReadOnlyModel<String>()
+ {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public String getObject()
+ {
+ return "wicketDebugBar" + (DebugBar.this.hasErrorMessage() ? "Error" : "");
+ }
+
+ }));
+ add(CSSPackageResource.getHeaderContribution(DebugBar.class, "wicket-debugbar.css"));
+ add(JavascriptPackageResource.getHeaderContribution(DebugBar.class, "wicket-debugbar.js"));
+ add(new Image("logo", new ResourceReference(DebugBar.class, "wicket.png")));
+ add(new Image("removeImg", new ResourceReference(DebugBar.class, "remove.png")));
+ List<IDebugBarContributor> contributors = getContributors();
+
+ // no longer necessary, registered from DebugBarInitializer
+ // if (contributors.isEmpty())
+ // {
+ // we do this so that if you have multiple applications running in
+ // the same container,
+ // each ends up registering its' own contributors (wicket-examples
+ // for example)
+ // registerStandardContributors(Application.get());
+ // contributors = getContributors();
+ // }
+ add(new ListView<IDebugBarContributor>("contributors", contributors)
+ {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ protected void populateItem(ListItem<IDebugBarContributor> item)
+ {
+ IDebugBarContributor contrib = item.getModelObject();
+ Component comp = contrib.createComponent("contrib", DebugBar.this);
+ if (comp == null)
+ {
+ // some contributors only add information to the debug bar
+ // and don't actually create a contributed component
+ item.setVisibilityAllowed(false);
+ }
+ else
+ {
+ item.add(comp);
+ }
+ }
+ });
+ }
+
+ @Override
+ public boolean isVisible()
+ {
+ return getApplication().getDebugSettings().isDevelopmentUtilitiesEnabled();
+ }
+
+ /**
+ * Register your own custom contributor that will be part of the debug bar. You must have the
+ * context of an application for this thread at the time of calling this method.
+ *
+ * @param application
+ * @param contrib
+ * custom contributor - can not be null
+ */
+ public static void registerContributor(IDebugBarContributor contrib)
+ {
+ registerContributor(contrib, Application.get());
+ }
+
+ /**
+ * Register your own custom contributor that will be part of the debug bar. You must have the
+ * context of an application for this thread at the time of calling this method.
+ *
+ * @param application
+ * @param contrib
+ * custom contributor - can not be null
+ */
+ public static void registerContributor(IDebugBarContributor contrib, Application application)
+ {
+ if (contrib == null)
+ {
+ throw new IllegalArgumentException("contrib can not be null");
+ }
+
+ List<IDebugBarContributor> contributors = getContributors(application);
+ contributors.add(contrib);
+ application.setMetaData(CONTRIBS_META_KEY, contributors);
+ }
+
+ private static List<IDebugBarContributor> getContributors()
+ {
+ return getContributors(Application.get());
+ }
+
+ private static List<IDebugBarContributor> getContributors(Application application)
+ {
+ List<IDebugBarContributor> list = application.getMetaData(CONTRIBS_META_KEY);
+ return list == null ? new ArrayList<IDebugBarContributor>() : list;
+ }
+
+
+ /**
+ * Called from {@link DebugBarInitializer}
+ */
+ static void registerStandardContributors(Application application)
+ {
+ registerContributor(VersionDebugContributor.DEBUG_BAR_CONTRIB, application);
+ registerContributor(InspectorDebugPanel.DEBUG_BAR_CONTRIB, application);
+ registerContributor(SessionSizeDebugPanel.DEBUG_BAR_CONTRIB, application);
+ }
}
diff --git a/wicket-devutils/src/main/java/org/apache/wicket/devutils/debugbar/DebugBarInitializer.java b/wicket-devutils/src/main/java/org/apache/wicket/devutils/debugbar/DebugBarInitializer.java
new file mode 100644
index 0000000..d32ea7c
--- /dev/null
+++ b/wicket-devutils/src/main/java/org/apache/wicket/devutils/debugbar/DebugBarInitializer.java
@@ -0,0 +1,30 @@
+package org.apache.wicket.devutils.debugbar;
+
+import org.apache.wicket.Application;
+import org.apache.wicket.IInitializer;
+
+/**
+ * Debug bar module initializer
+ *
+ * @author igor.vaynberg
+ *
+ */
+public class DebugBarInitializer implements IInitializer
+{
+
+ /** {@inheritDoc} */
+ public void init(Application application)
+ {
+ // register standard debug contributors
+ DebugBar.registerContributor(VersionDebugContributor.DEBUG_BAR_CONTRIB, application);
+ DebugBar.registerContributor(InspectorDebugPanel.DEBUG_BAR_CONTRIB, application);
+ DebugBar.registerContributor(SessionSizeDebugPanel.DEBUG_BAR_CONTRIB, application);
+ }
+
+ @Override
+ public String toString()
+ {
+ return "DevUtils DebugBar Initializer";
+ }
+
+}
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-2334_96330447.diff |
bugs-dot-jar_data_WICKET-1718_bb7f9cf5 | ---
BugID: WICKET-1718
Summary: WebPage#onAfterRender erroneously reports missing header
Description: "In WebPage#onAfterRender() there's a check wether a header was missing
on a page and header contributions would be lost.\n\nIn the following case this
check erroneously barks:\n- page A was requested\n- in A's onBeforeRender() a RestartResponseAtInterceptPageException
to page B is thrown\n- page A's onAfterRender() is invoked in a finally block\n-
processing continues with page B\n\nPage A's onAfterRender() complains about the
missing header, althought his page was never completely rendered.\n\nIMHO there's
a check missing in WebPage#onAfterRender():\n\n \tif (getRequestCycle().getResponsePage()
== this) {\n\t\t.....\n\t}\n\nOr is Page A not allowed to throw RestartResponseAtInterceptPageException
in onBeforeRender() at all?"
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/WebPage.java b/wicket-core/src/main/java/org/apache/wicket/markup/html/WebPage.java
index 903d7c4..5c7d6bb 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/html/WebPage.java
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/WebPage.java
@@ -26,11 +26,9 @@ import org.apache.wicket.markup.parser.filter.HtmlHeaderSectionHandler;
import org.apache.wicket.markup.renderStrategy.AbstractHeaderRenderStrategy;
import org.apache.wicket.model.IModel;
import org.apache.wicket.protocol.http.WebApplication;
-import org.apache.wicket.request.IRequestHandler;
import org.apache.wicket.request.Request;
import org.apache.wicket.request.Response;
import org.apache.wicket.request.cycle.RequestCycle;
-import org.apache.wicket.core.request.handler.IPageRequestHandler;
import org.apache.wicket.request.http.WebRequest;
import org.apache.wicket.request.http.WebResponse;
import org.apache.wicket.request.mapper.parameter.PageParameters;
@@ -216,7 +214,10 @@ public class WebPage extends Page
// only in development mode validate the headers
if (getApplication().usesDevelopmentConfig())
{
- validateHeaders();
+ // check headers only when page was completely rendered
+ if (wasRendered(this)) {
+ validateHeaders();
+ }
}
super.onAfterRender();
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-1718_bb7f9cf5.diff |
bugs-dot-jar_data_WICKET-5165_0d4d1df7 | ---
BugID: WICKET-5165
Summary: Session should be bound when adding messages to it
Description: |-
When using the Sessions info(), error() and success() methods, and the session is temporary, the messages can be dropped silently. This happens when on stateless pages and a redirect happens in the same request during which a session message is added.
The fix for this could be to make sure the session is bound and call Session#bind() automatically when a session message is added.
Email thread:
http://wicket-users.markmail.org/thread/zd72s4gwnlp5d7ch
diff --git a/wicket-core/src/main/java/org/apache/wicket/request/handler/render/WebPageRenderer.java b/wicket-core/src/main/java/org/apache/wicket/request/handler/render/WebPageRenderer.java
index e25142c..c3899ec 100644
--- a/wicket-core/src/main/java/org/apache/wicket/request/handler/render/WebPageRenderer.java
+++ b/wicket-core/src/main/java/org/apache/wicket/request/handler/render/WebPageRenderer.java
@@ -16,9 +16,14 @@
*/
package org.apache.wicket.request.handler.render;
+import java.util.List;
+
import org.apache.wicket.Application;
+import org.apache.wicket.Session;
import org.apache.wicket.core.request.handler.RenderPageRequestHandler;
import org.apache.wicket.core.request.handler.RenderPageRequestHandler.RedirectPolicy;
+import org.apache.wicket.feedback.FeedbackCollector;
+import org.apache.wicket.feedback.FeedbackMessage;
import org.apache.wicket.protocol.http.BufferedWebResponse;
import org.apache.wicket.protocol.http.WebApplication;
import org.apache.wicket.request.IRequestHandler;
@@ -145,11 +150,28 @@ public class WebPageRenderer extends PageRenderer
*/
protected void redirectTo(Url url, RequestCycle requestCycle)
{
+ bindSessionIfNeeded();
+
WebResponse response = (WebResponse)requestCycle.getResponse();
String relativeUrl = requestCycle.getUrlRenderer().renderUrl(url);
response.sendRedirect(relativeUrl);
}
+ /**
+ * Bind the session if there are feedback messages pending.
+ * https://issues.apache.org/jira/browse/WICKET-5165
+ */
+ private void bindSessionIfNeeded()
+ {
+ // check for session feedback messages only
+ FeedbackCollector collector = new FeedbackCollector();
+ List<FeedbackMessage> feedbackMessages = collector.collect();
+ if (feedbackMessages.size() > 0)
+ {
+ Session.get().bind();
+ }
+ }
+
/*
* TODO: simplify the code below. See WICKET-3347
*/
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5165_0d4d1df7.diff |
bugs-dot-jar_data_WICKET-4259_1f128536 | ---
BugID: WICKET-4259
Summary: Using an IValidator on an AjaxEditableLabel causes ClassCastException
Description: "AjaxEditableLabel<Integer> label = new AjaxEditableLabel<Integer>(\"label\",
new PropertyModel<Integer>(this, \"value\"));\nform.add(label);\nlabel.setRequired(true);\nlabel.add(new
RangeValidator<Integer>(1, 10));\n\nUsing a RangeValidator<Integer> on an AjaxEditableLabel<Integer>
\ causes an ClassCastException after editing the label. \n\njava.lang.ClassCastException:
java.lang.Integer cannot be cast to java.lang.String\n\nThis can be avoided by setting
the type explicit on the AjaxEditableLabel.\n\nlabel.setType(Integer.class);\n\nBut
this wasn't necessary in Wicket 1.4.19. In this version all works fine without setting
the type explicit.\n\nI found out, that AbstractTextComponent.resolveType() is not
able to get the type of the DefaultModel of the AjaxEditableLabel in Wicket 1.5.3.\n\nI
will attach two QuickStarts to demonstrate the bug. One with wicket 1.4.19 and the
other with Wicket 1.5.3\n\n"
diff --git a/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/AjaxEditableLabel.java b/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/AjaxEditableLabel.java
index 15dc1c1..ee3006e 100644
--- a/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/AjaxEditableLabel.java
+++ b/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/AjaxEditableLabel.java
@@ -30,6 +30,7 @@ import org.apache.wicket.markup.html.form.FormComponent;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.IModel;
+import org.apache.wicket.model.IObjectClassAwareModel;
import org.apache.wicket.request.cycle.RequestCycle;
import org.apache.wicket.util.convert.IConverter;
import org.apache.wicket.util.string.JavaScriptUtils;
@@ -391,7 +392,7 @@ public class AjaxEditableLabel<T> extends Panel
{
if (editor == null)
{
- initLabelAndEditor(getDelegatingParentModel());
+ initLabelAndEditor(new WrapperModel());
}
return editor;
}
@@ -405,7 +406,7 @@ public class AjaxEditableLabel<T> extends Panel
{
if (label == null)
{
- initLabelAndEditor(getDelegatingParentModel());
+ initLabelAndEditor(new WrapperModel());
}
return label;
}
@@ -420,7 +421,7 @@ public class AjaxEditableLabel<T> extends Panel
// lazily add label and editor
if (editor == null)
{
- initLabelAndEditor(getDelegatingParentModel());
+ initLabelAndEditor(new WrapperModel());
}
// obsolete with WICKET-1919
// label.setEnabled(isEnabledInHierarchy());
@@ -510,35 +511,41 @@ public class AjaxEditableLabel<T> extends Panel
}
/**
- * get a model that accesses the parent model lazily. this is required since we eventually
- * request the parents model before the component is added to the parent.
- *
- * @return model
+ * Model that accesses the parent model lazily. this is required since we eventually request the
+ * parents model before the component is added to the parent.
*/
- private IModel<T> getDelegatingParentModel()
+ private class WrapperModel implements IModel<T>, IObjectClassAwareModel<T>
{
- return new IModel<T>()
+
+ public T getObject()
{
- private static final long serialVersionUID = 1L;
+ return getParentModel().getObject();
+ }
- public T getObject()
- {
- return getParentModel().getObject();
- }
+ public void setObject(final T object)
+ {
+ getParentModel().setObject(object);
+ }
+
+ public void detach()
+ {
+ getParentModel().detach();
+
+ }
- public void setObject(final T object)
+ public Class<T> getObjectClass()
+ {
+ if (getParentModel() instanceof IObjectClassAwareModel)
{
- getParentModel().setObject(object);
+ return ((IObjectClassAwareModel)getParentModel()).getObjectClass();
}
-
- public void detach()
+ else
{
- getParentModel().detach();
+ return null;
}
- };
+ }
}
-
/**
* @return Gets the parent model in case no explicit model was specified.
*/
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-4259_1f128536.diff |
bugs-dot-jar_data_WICKET-5418_e350f19e | ---
BugID: WICKET-5418
Summary: PropertyValidator ignoring groups with the @NotNull annotation only
Description: 'When using groups in your JSR303 compliant classes, Wicket does not
honor the groups for the @NotNull annotation. '
diff --git a/wicket-experimental/wicket-bean-validation/src/main/java/org/apache/wicket/bean/validation/PropertyValidator.java b/wicket-experimental/wicket-bean-validation/src/main/java/org/apache/wicket/bean/validation/PropertyValidator.java
index 032a818..e8e6376 100644
--- a/wicket-experimental/wicket-bean-validation/src/main/java/org/apache/wicket/bean/validation/PropertyValidator.java
+++ b/wicket-experimental/wicket-bean-validation/src/main/java/org/apache/wicket/bean/validation/PropertyValidator.java
@@ -1,6 +1,10 @@
package org.apache.wicket.bean.validation;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
import java.util.Iterator;
+import java.util.List;
import java.util.Set;
import javax.validation.ConstraintViolation;
@@ -62,8 +66,8 @@ public class PropertyValidator<T> extends Behavior implements IValidator<T>
private final IModel<Class<?>[]> groups_;
/**
- * A flag that indicates whether {@linkplain #setComponentRequiredFlag()}
- * has been called for this behavior.
+ * A flag that indicates whether {@linkplain #setComponentRequiredFlag()} has been called for
+ * this behavior.
*/
private boolean requiredFlagSet;
@@ -132,8 +136,10 @@ public class PropertyValidator<T> extends Behavior implements IValidator<T>
" can only be added to FormComponents");
}
- // TODO add a validation key that appends the type so we can have different messages for
- // @Size on String vs Collection - done but need to add a key for each superclass/interface
+ // TODO add a validation key that appends the type so we can have
+ // different messages for
+ // @Size on String vs Collection - done but need to add a key for each
+ // superclass/interface
this.component = (FormComponent<T>)component;
}
@@ -144,10 +150,15 @@ public class PropertyValidator<T> extends Behavior implements IValidator<T>
super.onConfigure(component);
if (requiredFlagSet == false)
{
- // "Required" flag is calculated upon component's model property, so we must ensure,
- // that model object is accessible (i.e. component is already added in a page).
+ // "Required" flag is calculated upon component's model property, so
+ // we must ensure,
+ // that model object is accessible (i.e. component is already added
+ // in a page).
requiredFlagSet = true;
- setComponentRequiredFlag();
+ if (isRequired())
+ {
+ this.component.setRequired(true);
+ }
}
}
@@ -161,27 +172,57 @@ public class PropertyValidator<T> extends Behavior implements IValidator<T>
}
}
- /**
- * Marks the form component required if necessary
- */
- private void setComponentRequiredFlag()
+ private List<NotNull> findNotNullConstraints()
{
BeanValidationContext config = BeanValidationConfiguration.get();
Validator validator = config.getValidator();
Property property = getProperty();
- // if the property has a NotNull constraint mark the form component required
+ List<NotNull> constraints = new ArrayList<NotNull>();
Iterator<ConstraintDescriptor<?>> it = new ConstraintIterator(validator, property);
+
while (it.hasNext())
{
ConstraintDescriptor<?> desc = it.next();
if (desc.getAnnotation().annotationType().equals(NotNull.class))
{
- component.setRequired(true);
- break;
+ constraints.add((NotNull)desc.getAnnotation());
+ }
+ }
+
+ return constraints;
+ }
+
+ boolean isRequired()
+ {
+ List<NotNull> constraints = findNotNullConstraints();
+
+ if (constraints.isEmpty())
+ {
+ return false;
+ }
+
+ HashSet<Class<?>> validatorGroups = new HashSet<Class<?>>();
+ validatorGroups.addAll(Arrays.asList(getGroups()));
+
+ for (NotNull constraint : constraints)
+ {
+ if (constraint.groups().length == 0 && validatorGroups.isEmpty())
+ {
+ return true;
+ }
+
+ for (Class<?> constraintGroup : constraint.groups())
+ {
+ if (validatorGroups.contains(constraintGroup))
+ {
+ return true;
+ }
}
}
+
+ return false;
}
@Override
@@ -194,7 +235,8 @@ public class PropertyValidator<T> extends Behavior implements IValidator<T>
Validator validator = config.getValidator();
Property property = getProperty();
- // find any tag modifiers that apply to the constraints of the property being validated
+ // find any tag modifiers that apply to the constraints of the property
+ // being validated
// and allow them to modify the component tag
Iterator<ConstraintDescriptor<?>> it = new ConstraintIterator(validator, property,
diff --git a/wicket-experimental/wicket-bean-validation/src/main/java/org/apache/wicket/bean/validation/SessionLocaleInterpolator.java b/wicket-experimental/wicket-bean-validation/src/main/java/org/apache/wicket/bean/validation/SessionLocaleInterpolator.java
index 00aa506..f8927e2 100644
--- a/wicket-experimental/wicket-bean-validation/src/main/java/org/apache/wicket/bean/validation/SessionLocaleInterpolator.java
+++ b/wicket-experimental/wicket-bean-validation/src/main/java/org/apache/wicket/bean/validation/SessionLocaleInterpolator.java
@@ -20,7 +20,7 @@ public class SessionLocaleInterpolator implements MessageInterpolator
* Constructor
*
* @param delegate
- * the MessageInterpolator to delegate to
+ * the MessageInterpolator to delegate to
*/
public SessionLocaleInterpolator(MessageInterpolator delegate)
{
@@ -28,7 +28,8 @@ public class SessionLocaleInterpolator implements MessageInterpolator
this.delegate = delegate;
}
- public String interpolate(final String messageTemplate, final MessageInterpolator.Context context)
+ public String interpolate(final String messageTemplate,
+ final MessageInterpolator.Context context)
{
final Locale locale = getLocale();
if (locale != null)
@@ -41,7 +42,8 @@ public class SessionLocaleInterpolator implements MessageInterpolator
}
}
- public String interpolate(final String message, final MessageInterpolator.Context context, final Locale locale)
+ public String interpolate(final String message, final MessageInterpolator.Context context,
+ final Locale locale)
{
return delegate.interpolate(message, context, locale);
}
diff --git a/wicket-experimental/wicket-bean-validation/src/main/java/org/apache/wicket/bean/validation/SizeTagModifier.java b/wicket-experimental/wicket-bean-validation/src/main/java/org/apache/wicket/bean/validation/SizeTagModifier.java
index 4124974..1795dc4 100644
--- a/wicket-experimental/wicket-bean-validation/src/main/java/org/apache/wicket/bean/validation/SizeTagModifier.java
+++ b/wicket-experimental/wicket-bean-validation/src/main/java/org/apache/wicket/bean/validation/SizeTagModifier.java
@@ -6,8 +6,8 @@ import org.apache.wicket.markup.ComponentTag;
import org.apache.wicket.markup.html.form.FormComponent;
/**
- * A tag modifier that adds the {@code maxlength} attribute to the {@code input} tag with the max value
- * from the {@link Size} constraint annotation.
+ * A tag modifier that adds the {@code maxlength} attribute to the {@code input} tag with the max
+ * value from the {@link Size} constraint annotation.
*
* @author igor
*
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5418_e350f19e.diff |
bugs-dot-jar_data_WICKET-4686_89184b79 | ---
BugID: WICKET-4686
Summary: MountMapper does not support correctly parameter placeholders
Description: "Package mounting doesn't support parameter placeholders. The problem
seems to be inside MountMapper which should wrap PackageMapper and take care of
substituting placeholders with their actual value. \nMore precisely this class doesn't
read parameter values from PageParameters and it's not very clear to me how it tries
to read these values.\nDoes anybody have some hints about this class?"
diff --git a/wicket-core/src/main/java/org/apache/wicket/core/request/handler/PageProvider.java b/wicket-core/src/main/java/org/apache/wicket/core/request/handler/PageProvider.java
index 0be5d76..2c015a4 100644
--- a/wicket-core/src/main/java/org/apache/wicket/core/request/handler/PageProvider.java
+++ b/wicket-core/src/main/java/org/apache/wicket/core/request/handler/PageProvider.java
@@ -259,12 +259,6 @@ public class PageProvider implements IPageProvider
if (pageId != null)
{
page = getStoredPage(pageId);
-
- if (page == null)
- {
- // WICKET-4594 - ignore the parsed parameters for stateful pages
- pageParameters = null;
- }
}
if (page == null)
diff --git a/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/AbstractBookmarkableMapper.java b/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/AbstractBookmarkableMapper.java
index 1569468..8a30578 100644
--- a/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/AbstractBookmarkableMapper.java
+++ b/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/AbstractBookmarkableMapper.java
@@ -271,11 +271,11 @@ public abstract class AbstractBookmarkableMapper extends AbstractComponentMapper
if (listenerInterface != null)
{
-// if (pageInfo.getPageId() != null)
-// {
-// // WICKET-4594 - ignore the parsed parameters for stateful pages
-// pageParameters = null;
-// }
+ if (pageInfo.getPageId() != null)
+ {
+ // WICKET-4594 - ignore the parsed parameters for stateful pages
+ pageParameters = null;
+ }
PageAndComponentProvider provider = new PageAndComponentProvider(pageInfo.getPageId(),
pageClass, pageParameters, renderCount, componentInfo.getComponentPath());
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-4686_89184b79.diff |
bugs-dot-jar_data_WICKET-5056_56169634 | ---
BugID: WICKET-5056
Summary: Page mount with an optional named parameter overtakes a mount with more specific
path
Description: |-
See the discussion in http://markmail.org/thread/sgpiku27ah2tmcim
Having:
mountPage("/all/sindex",Page1.class);
mountPage("/all/#{exp}", Page2.class);
Request to /all/sindex will be handled by Page2.
Compatibility score for optional parameters should be lower than mandatory parameters which should be lower than exact value.
diff --git a/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/MountedMapper.java b/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/MountedMapper.java
index ae742d6..12f8985 100644
--- a/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/MountedMapper.java
+++ b/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/MountedMapper.java
@@ -495,7 +495,15 @@ public class MountedMapper extends AbstractBookmarkableMapper
{
if (urlStartsWith(request.getUrl(), mountSegments))
{
- return mountSegments.length;
+ /* see WICKET-5056 - alter score with pathSegment type */
+ int countOptional = 0;
+ int fixedSegments = 0;
+ for (MountPathSegment pathSegment : pathSegments)
+ {
+ fixedSegments += pathSegment.getFixedPartSize();
+ countOptional += pathSegment.getOptionalParameters();
+ }
+ return mountSegments.length - countOptional + fixedSegments;
}
else
{
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5056_56169634.diff |
bugs-dot-jar_data_WICKET-4251_53bcb78d | ---
BugID: WICKET-4251
Summary: Multipart Form and AjaxSubmitLink will result in invalid redirect after user
session expires
Description: "Hi,\n\nI have hit an issue similar to this one:\n\nhttps://issues.apache.org/jira/browse/WICKET-3141\n\nI
do not receive any errors from Wicket itself to help clarify, so I will try to explain
using an example.\n\nThe example below with which I could recreate the issue uses
the default SignInPanel (in my LoginPage.clas) and AuthenticatedWebSession to authenticate
the user and store the session:\n\n\tprotected Class<? extends WebPage> getSignInPageClass()\n\t{\n\t\treturn
LoginPage.class;\n\t}\n\nIf the authentiation is succesfull then the user is redirect
back to the test page:\n\n\t\t\tprotected void onSignInSucceeded() {\n\t\t\t\tsetResponsePage(Test.class);\n\t\t\t}\n\nSo
far so good. However if I use a form with setMultiPart(true) in combination with
an AjaxSubmitLink as shown in the following piece of code:\n\nimport org.apache.wicket.ajax.AjaxRequestTarget;\nimport
org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink;\nimport org.apache.wicket.authroles.authorization.strategies.role.annotations.AuthorizeInstantiation;\nimport
org.apache.wicket.markup.html.WebPage;\nimport org.apache.wicket.markup.html.form.Form;\n\n@AuthorizeInstantiation(\"USER\")\npublic
class Test extends WebPage {\n\n\tpublic Test()\n\t{\n\t\tsuper();\n\t\t\n\t\tfinal
Form testForm = \n\t\t\t\tnew Form(\"testForm\");\n\t\n\t\ttestForm.setMultiPart(true);\n\t\t\n\t\ttestForm.add(new
AjaxSubmitLink(\"testButton\", testForm) {\n\t\t\t\n\t\t\t@Override\n\t\t\tprotected
void onSubmit(AjaxRequestTarget target, Form form) {\n\t\t\t\tsuper.onSubmit();\n\t\t\t};\n\t\t\t\n\t\t\t@Override\n\t\t\tprotected
void onError(AjaxRequestTarget target, Form form) {\n\t\t\t\t\n\t\t\t};\n\t\t});\n\t\t\t\t\n\t\tadd(testForm);\n\t}\n}\n\nAnd
have selected the option \"Remember credentials\" in the SignInPanel, clicking on
the testButton AFTER the session has expired will result in:\n\nhttp://localhost:8080/PaladinWicket/?3-1.IBehaviorListener.0-testForm-testButton&wicket-ajax=true&wicket-ajax-baseurl=.\n\nwhich
displays this in the browser:\n\nThis XML file does not appear to have any style
information associated with it. The document tree is shown below.\n<ajax-response>\n<redirect>\n<![CDATA[
.?1 ]]>\n</redirect>\n</ajax-response>"
diff --git a/wicket-core/src/main/java/org/apache/wicket/RestartResponseAtInterceptPageException.java b/wicket-core/src/main/java/org/apache/wicket/RestartResponseAtInterceptPageException.java
index 69fe186..6c425c0 100644
--- a/wicket-core/src/main/java/org/apache/wicket/RestartResponseAtInterceptPageException.java
+++ b/wicket-core/src/main/java/org/apache/wicket/RestartResponseAtInterceptPageException.java
@@ -19,6 +19,7 @@ package org.apache.wicket;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -27,11 +28,13 @@ import org.apache.wicket.request.IRequestMapper;
import org.apache.wicket.request.IWritableRequestParameters;
import org.apache.wicket.request.Request;
import org.apache.wicket.request.Url;
+import org.apache.wicket.request.Url.QueryParameter;
import org.apache.wicket.request.cycle.RequestCycle;
import org.apache.wicket.request.flow.ResetResponseException;
import org.apache.wicket.request.handler.PageProvider;
import org.apache.wicket.request.handler.RenderPageRequestHandler;
import org.apache.wicket.request.handler.RenderPageRequestHandler.RedirectPolicy;
+import org.apache.wicket.request.http.WebRequest;
import org.apache.wicket.request.http.handler.RedirectRequestHandler;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.apache.wicket.util.string.StringValue;
@@ -110,9 +113,27 @@ public class RestartResponseAtInterceptPageException extends ResetResponseExcept
InterceptData data = new InterceptData();
Request request = RequestCycle.get().getRequest();
data.originalUrl = request.getOriginalUrl();
+ Iterator<QueryParameter> itor = data.originalUrl.getQueryParameters().iterator();
+ while (itor.hasNext())
+ {
+ QueryParameter parameter = itor.next();
+ String parameterName = parameter.getName();
+ if (WebRequest.PARAM_AJAX.equals(parameterName) ||
+ WebRequest.PARAM_AJAX_BASE_URL.equals(parameterName) ||
+ WebRequest.PARAM_AJAX_REQUEST_ANTI_CACHE.equals(parameterName))
+ {
+ itor.remove();
+ }
+ }
+
data.postParameters = new HashMap<String, List<StringValue>>();
for (String s : request.getPostParameters().getParameterNames())
{
+ if (WebRequest.PARAM_AJAX.equals(s) || WebRequest.PARAM_AJAX_BASE_URL.equals(s) ||
+ WebRequest.PARAM_AJAX_REQUEST_ANTI_CACHE.equals(s))
+ {
+ continue;
+ }
data.postParameters.put(s, new ArrayList<StringValue>(request.getPostParameters()
.getParameterValues(s)));
}
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-4251_53bcb78d.diff |
bugs-dot-jar_data_WICKET-5689_2ac29d30 | ---
BugID: WICKET-5689
Summary: Nested Redirects and REDIRECT_TO_BUFFER
Description: "When the render strategy is REDIRECT_TO_BUFFER, redirects cannot be
nested. After the second redirect, Wicket renders the buffered first page in preference
to the second page. The relevant code is in WebPageRenderer.respond:\n\n{noformat}\n\t\tif
(bufferedResponse != null)\n\t\t{\n\t\t\tlogger.warn(\"The Buffered response should
be handled by BufferedResponseRequestHandler\");\n\t\t\t// if there is saved response
for this URL render it\n\t\t\tbufferedResponse.writeTo((WebResponse)requestCycle.getResponse());\n\t\t}\n{noformat}\n\nThe
attached quickstart demonstrates the issue. Simply navigate to the home page. The
observed behavior is that Page1 is displayed, but I expect Page2 to be displayed.\n\nI
can work around the issue by calling WebApplication.getAndRemoveBufferedResponse()
to clear the render buffer, but I am uneasy with this solution since it seems like
I am playing with Wicket internals; albeit the function is public. "
diff --git a/wicket-core/src/main/java/org/apache/wicket/protocol/http/WebApplication.java b/wicket-core/src/main/java/org/apache/wicket/protocol/http/WebApplication.java
index 52d41ca..0ff49bc 100644
--- a/wicket-core/src/main/java/org/apache/wicket/protocol/http/WebApplication.java
+++ b/wicket-core/src/main/java/org/apache/wicket/protocol/http/WebApplication.java
@@ -876,10 +876,12 @@ public abstract class WebApplication extends Application
}
/**
- *
- * @param sessionId
+ * Retrieves a stored buffered response for a given sessionId and url.
+ *
* @param url
- * @return buffered response
+ * The url used as a key
+ * @return the stored buffered response. {@code null} if there is no stored response for the given url
+ * @see org.apache.wicket.settings.IRequestCycleSettings.RenderStrategy#REDIRECT_TO_BUFFER
*/
public BufferedWebResponse getAndRemoveBufferedResponse(String sessionId, Url url)
{
diff --git a/wicket-core/src/main/java/org/apache/wicket/request/handler/render/WebPageRenderer.java b/wicket-core/src/main/java/org/apache/wicket/request/handler/render/WebPageRenderer.java
index aee0104..00a8ea2 100644
--- a/wicket-core/src/main/java/org/apache/wicket/request/handler/render/WebPageRenderer.java
+++ b/wicket-core/src/main/java/org/apache/wicket/request/handler/render/WebPageRenderer.java
@@ -86,12 +86,7 @@ public class WebPageRenderer extends PageRenderer
WebApplication.get().storeBufferedResponse(getSessionId(), url, response);
}
-
- protected BufferedWebResponse getAndRemoveBufferedResponse(Url url)
- {
- return WebApplication.get().getAndRemoveBufferedResponse(getSessionId(), url);
- }
-
+
/**
* Renders page to a {@link BufferedWebResponse}. All URLs in page will be rendered relative to
* <code>targetUrl</code>
@@ -195,17 +190,7 @@ public class WebPageRenderer extends PageRenderer
// 3 rendering strategies and two kind of requests (ajax and normal)
//
- // try to get an already rendered buffered response for current URL
- BufferedWebResponse bufferedResponse = getAndRemoveBufferedResponse(currentUrl);
-
- if (bufferedResponse != null)
- {
- logger
- .warn("The Buffered response should be handled by BufferedResponseRequestHandler");
- // if there is saved response for this URL render it
- bufferedResponse.writeTo((WebResponse)requestCycle.getResponse());
- }
- else if (shouldRenderPageAndWriteResponse(requestCycle, currentUrl, targetUrl))
+ if (shouldRenderPageAndWriteResponse(requestCycle, currentUrl, targetUrl))
{
BufferedWebResponse response = renderPage(currentUrl, requestCycle);
if (response != null)
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5689_2ac29d30.diff |
bugs-dot-jar_data_WICKET-3076_d3dc9a50 | ---
BugID: WICKET-3076
Summary: UrlUtils.isRelative returns false if URL parameter contains an absolute URL
Description: "I have a page that gets a return path for a back link as a parameter.
A link to this page looks like this:\n\n./mypage?return=http://example.com\n\nIn
WebRequestCodingStrategy.encode, this URL is returned by pathForTarget.\nThen it
is checked whether this URL is relative using UrlUtils.isRelative. The URL is apparently
relative, but UrlUtils.isRelative returns false, since the check contains:\n\n(url.indexOf(\"://\")
< 0\n\nthis is false for the above example. Thus, an incorrect path is returned
by WebRequestCodingStrategy.encode (relative path resolution does not take place).\n\nA
fix for the problem would be to check for \n\n!(url.startsWith(\"http://\") || url.startsWith(\"https://\"))\n\nOr,
if other protocols should also be supported, a regular expression like \"^[^/?]*://\"
should work. \n"
diff --git a/wicket/src/main/java/org/apache/wicket/util/string/UrlUtils.java b/wicket/src/main/java/org/apache/wicket/util/string/UrlUtils.java
index c18852d..6f1e8d7 100644
--- a/wicket/src/main/java/org/apache/wicket/util/string/UrlUtils.java
+++ b/wicket/src/main/java/org/apache/wicket/util/string/UrlUtils.java
@@ -39,9 +39,10 @@ public class UrlUtils
* @param url
* @return <code>true</code> if url is relative, <code>false</code> otherwise
*/
- public static boolean isRelative(String url)
+ public static boolean isRelative(final String url)
{
- if ((url != null) && (url.startsWith("/") == false) && (url.indexOf("://") < 0) &&
+ // the regex means "doesn't start with 'scheme://'"
+ if ((url != null) && (url.startsWith("/") == false) && (!url.matches("^\\w+\\:\\/\\/.*")) &&
!(url.startsWith("#")))
{
return true;
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-3076_d3dc9a50.diff |
bugs-dot-jar_data_WICKET-4309_b4274415 | ---
BugID: WICKET-4309
Summary: StringValueConversionException for correct situation
Description: |-
StringValue.toOptionalLong() produces org.apache.wicket.util.string.StringValueConversionException if empty string was passed.
Let me suggest, that this behavior should be changes for all toOptionalXXX methods except getOptionalString method.
The problem in inner code:
The problem in following code:
public final Long toOptionalLong() throws StringValueConversionException
{
return (text == null) ? null : toLongObject();
}
Should be something like this:
The problem in following code:
public final Long toOptionalLong() throws StringValueConversionException
{
return Strings.isEmpty() ? null : toLongObject();
}
But there is another problem: what to do if incorrect param was passed - for example "abc" for parameter of Long type?
diff --git a/wicket-util/src/main/java/org/apache/wicket/util/string/StringValue.java b/wicket-util/src/main/java/org/apache/wicket/util/string/StringValue.java
index de5206c..fa5ba54 100755
--- a/wicket-util/src/main/java/org/apache/wicket/util/string/StringValue.java
+++ b/wicket-util/src/main/java/org/apache/wicket/util/string/StringValue.java
@@ -592,69 +592,69 @@ public class StringValue implements IClusterable
}
/**
- * Convert to object types, returning null if text is null.
+ * Convert to object types, returning null if text is null or empty.
*
* @return converted
* @throws StringValueConversionException
*/
public final Boolean toOptionalBoolean() throws StringValueConversionException
{
- return (text == null) ? null : toBooleanObject();
+ return Strings.isEmpty(text) ? null : toBooleanObject();
}
/**
- * Convert to object types, returning null if text is null.
+ * Convert to object types, returning null if text is null or empty.
*
* @return converted
* @throws StringValueConversionException
*/
public final Character toOptionalCharacter() throws StringValueConversionException
{
- return (text == null) ? null : toCharacter();
+ return Strings.isEmpty(text) ? null : toCharacter();
}
/**
- * Convert to object types, returning null if text is null.
+ * Convert to object types, returning null if text is null or empty.
*
* @return converted
* @throws StringValueConversionException
*/
public final Double toOptionalDouble() throws StringValueConversionException
{
- return (text == null) ? null : toDoubleObject();
+ return Strings.isEmpty(text) ? null : toDoubleObject();
}
/**
- * Convert to object types, returning null if text is null.
+ * Convert to object types, returning null if text is null or empty.
*
* @return converted
* @throws StringValueConversionException
*/
public final Duration toOptionalDuration() throws StringValueConversionException
{
- return (text == null) ? null : toDuration();
+ return Strings.isEmpty(text) ? null : toDuration();
}
/**
- * Convert to object types, returning null if text is null.
+ * Convert to object types, returning null if text is null or empty.
*
* @return converted
* @throws StringValueConversionException
*/
public final Integer toOptionalInteger() throws StringValueConversionException
{
- return (text == null) ? null : toInteger();
+ return Strings.isEmpty(text) ? null : toInteger();
}
/**
- * Convert to object types, returning null if text is null.
+ * Convert to object types, returning null if text is null or empty.
*
* @return converted
* @throws StringValueConversionException
*/
public final Long toOptionalLong() throws StringValueConversionException
{
- return (text == null) ? null : toLongObject();
+ return Strings.isEmpty(text) ? null : toLongObject();
}
/**
@@ -668,14 +668,14 @@ public class StringValue implements IClusterable
}
/**
- * Convert to object types, returning null if text is null.
+ * Convert to object types, returning null if text is null or empty.
*
* @return converted
* @throws StringValueConversionException
*/
public final Time toOptionalTime() throws StringValueConversionException
{
- return (text == null) ? null : toTime();
+ return Strings.isEmpty(text) ? null : toTime();
}
/**
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-4309_b4274415.diff |
bugs-dot-jar_data_WICKET-5960_03663750 | ---
BugID: WICKET-5960
Summary: Page header isn't rendered for pages where URL has changed during render
Description: "Due to the changes in WICKET-5309, a page is re-rendered when any of
the URL segments is modified during the request:\n\nFrom WebPageRenderer.java:\n\n{code}\n\t//
the url might have changed after page has been rendered (e.g. the\n\t// stateless
flag might have changed because stateful components\n\t// were added)\n\tfinal Url
afterRenderUrl = requestCycle\n\t\t.mapUrlFor(getRenderPageRequestHandler());\n\n\tif
(beforeRenderUrl.getSegments().equals(afterRenderUrl.getSegments()) == false)\n\t{\n\t\t//
the amount of segments is different - generated relative URLs\n\t\t// will not work,
we need to rerender the page. This can happen\n\t\t// with IRequestHandlers that
produce different URLs with\n\t\t// different amount of segments for stateless and
stateful pages\n\t\tresponse = renderPage(afterRenderUrl, requestCycle);\n\t}\n\n\tif
(currentUrl.equals(afterRenderUrl))\n{code}\n\nThe re-render causes the <head> section
to be empty because it was already rendered in the first try."
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/internal/HtmlHeaderContainer.java b/wicket-core/src/main/java/org/apache/wicket/markup/html/internal/HtmlHeaderContainer.java
index 1ce6809..e906560 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/html/internal/HtmlHeaderContainer.java
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/internal/HtmlHeaderContainer.java
@@ -314,9 +314,8 @@ public class HtmlHeaderContainer extends TransparentWebMarkupContainer
}
@Override
- protected void onDetach()
- {
- super.onDetach();
+ protected void onAfterRender() {
+ super.onAfterRender();
renderedComponentsPerScope = null;
headerResponse = null;
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5960_03663750.diff |
bugs-dot-jar_data_WICKET-4016_f1c9cef2 | ---
BugID: WICKET-4016
Summary: MarkupContainer.toString(true) fails with MarkupNotFoundException if the
call is made in the component constructor
Description: org.apache.wicket.MarkupContainer.toString(boolean) uses "if (getMarkup()
!= null)" to decide whether to write something for the markup but since recently
Component#getMarkup() throws MarkupNotFoundException when there is no markup and
doesn't return null.
diff --git a/wicket-core/src/main/java/org/apache/wicket/Component.java b/wicket-core/src/main/java/org/apache/wicket/Component.java
index 13b32cb..5f0a97d 100644
--- a/wicket-core/src/main/java/org/apache/wicket/Component.java
+++ b/wicket-core/src/main/java/org/apache/wicket/Component.java
@@ -3207,23 +3207,22 @@ public abstract class Component
{
try
{
+ final StringBuilder buffer = new StringBuilder();
+ buffer.append("[Component id = ").append(getId());
+
if (detailed)
{
final Page page = findPage();
if (page == null)
{
- return new StringBuilder("[Component id = ").append(getId())
- .append(", page = <No Page>, path = ")
+ buffer.append(", page = <No Page>, path = ")
.append(getPath())
.append('.')
- .append(Classes.simpleName(getClass()))
- .append(']')
- .toString();
+ .append(Classes.simpleName(getClass()));
}
else
{
- return new StringBuilder("[Component id = ").append(getId())
- .append(", page = ")
+ buffer.append(", page = ")
.append(getPage().getClass().getName())
.append(", path = ")
.append(getPath())
@@ -3232,15 +3231,18 @@ public abstract class Component
.append(", isVisible = ")
.append((determineVisibility()))
.append(", isVersioned = ")
- .append(isVersioned())
- .append(']')
- .toString();
+ .append(isVersioned());
+ }
+
+ if (markup != null)
+ {
+ buffer.append(", markup = ").append(new MarkupStream(getMarkup()).toString());
}
}
- else
- {
- return "[Component id = " + getId() + ']';
- }
+
+ buffer.append(']');
+
+ return buffer.toString();
}
catch (Exception e)
{
diff --git a/wicket-core/src/main/java/org/apache/wicket/MarkupContainer.java b/wicket-core/src/main/java/org/apache/wicket/MarkupContainer.java
index 056d483..f992264 100644
--- a/wicket-core/src/main/java/org/apache/wicket/MarkupContainer.java
+++ b/wicket-core/src/main/java/org/apache/wicket/MarkupContainer.java
@@ -860,32 +860,26 @@ public abstract class MarkupContainer extends Component implements Iterable<Comp
public String toString(final boolean detailed)
{
final StringBuilder buffer = new StringBuilder();
- buffer.append("[").append(this.getClass().getSimpleName()).append(" ");
+ buffer.append('[').append(this.getClass().getSimpleName()).append(' ');
buffer.append(super.toString(detailed));
- if (detailed)
+ if (detailed && children_size() != 0)
{
- if (getMarkup() != null)
- {
- buffer.append(", markup = ").append(new MarkupStream(getMarkup()).toString());
- }
- if (children_size() != 0)
- {
- buffer.append(", children = ");
+ buffer.append(", children = ");
- // Loop through child components
- final int size = children_size();
- for (int i = 0; i < size; i++)
+ // Loop through child components
+ final int size = children_size();
+ for (int i = 0; i < size; i++)
+ {
+ // Get next child
+ final Component child = children_get(i);
+ if (i != 0)
{
- // Get next child
- final Component child = children_get(i);
- if (i != 0)
- {
- buffer.append(' ');
- }
- buffer.append(child.toString());
+ buffer.append(' ');
}
+ buffer.append(child.toString());
}
+
}
buffer.append(']');
return buffer.toString();
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-4016_f1c9cef2.diff |
bugs-dot-jar_data_WICKET-2281_6e0b40bc | ---
BugID: WICKET-2281
Summary: MockHttpServletRequest is broken when used with CryptedUrlWebRequestCodingStrategy
Description: "Upgraded to 1.3.6. One of my test cases started to fail with \norg.apache.wicket.WicketRuntimeException:
Internal error parsing wicket:interface = ?x=GR7uTj8e-D8FE0tmM9vvYcwdiASd9OJ5GgveAhSNaig\n
\ \nI tracked down the issue to MockHttpServletRequest .setRequestToComponent()\nIn
line 1253 it check for url starting with 6*. However, in CryptedUrlWebRequestCodingStrategy
following encryption is employed:\n\n198:\t\t\t\t\tqueryString = shortenUrl(queryString).toString();\n199:\n200:\t\t\t\t\t//
encrypt the query string\n201:\t\t\t\t\tString encryptedQueryString = urlCrypt.encryptUrlSafe(queryString);\n\n\nshortenUrl
will replace 'wicket:interface=' with '6*' but then it gets immediately encrypted,
consequently MockHttpServletRequest will never recognize it correctly.\n\n"
diff --git a/wicket/src/main/java/org/apache/wicket/protocol/http/MockHttpServletRequest.java b/wicket/src/main/java/org/apache/wicket/protocol/http/MockHttpServletRequest.java
index 7b240c6..b998156 100644
--- a/wicket/src/main/java/org/apache/wicket/protocol/http/MockHttpServletRequest.java
+++ b/wicket/src/main/java/org/apache/wicket/protocol/http/MockHttpServletRequest.java
@@ -1255,37 +1255,38 @@ public class MockHttpServletRequest implements HttpServletRequest
.get(clazz);
String auto = component.getRequestCycle().urlFor(component, rli).toString();
- int idx = auto.indexOf(WebRequestCodingStrategy.INTERFACE_PARAMETER_NAME);
- if (idx >= 0)
+
+ // check for crypted strategy
+ if (auto.startsWith("?x="))
{
- auto = auto.substring(idx +
- WebRequestCodingStrategy.INTERFACE_PARAMETER_NAME.length() + 1);
+ auto = auto.substring(3);
+ parameters.put("x", auto);
+ parameters.remove(WebRequestCodingStrategy.INTERFACE_PARAMETER_NAME);
}
else
{
- // additional check for crypted strategy
- idx = auto.indexOf("x=6*");
+ int idx = auto.indexOf(WebRequestCodingStrategy.INTERFACE_PARAMETER_NAME);
if (idx >= 0)
{
- auto = auto.substring(idx + 4);
+ auto = auto.substring(idx +
+ WebRequestCodingStrategy.INTERFACE_PARAMETER_NAME.length() + 1);
}
+ else
+ {
+ idx = auto.indexOf("&");
+ if (idx >= 0)
+ {
+ auto = auto.substring(0, idx);
+ }
+ }
+ parameters.put(WebRequestCodingStrategy.INTERFACE_PARAMETER_NAME, auto);
}
-
- idx = auto.indexOf("&");
- if (idx >= 0)
- {
- auto = auto.substring(0, idx);
- }
-
- parameters.put(WebRequestCodingStrategy.INTERFACE_PARAMETER_NAME, auto);
-
}
catch (Exception e)
{
// noop
}
-
if (component.isStateless() && component.getPage().isBookmarkable())
{
parameters.put(WebRequestCodingStrategy.BOOKMARKABLE_PAGE_PARAMETER_NAME,
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-2281_6e0b40bc.diff |
bugs-dot-jar_data_WICKET-5085_581c7306 | ---
BugID: WICKET-5085
Summary: InlineEnclosure are piling up on each render
Description: "InlineEnclosureHandler#resolve() uses an auto-incremented id for its
resolved InlineEnclosure, \n\nOn the next render, a new instance will be resolved,
since the id of the already resolved InlineEnclosure does not match the id in the
markup.\n\nBut InlineEnclosures are not removed after render as other auto-components,
thus all instances pile up in the owning container of the markup.\n"
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/internal/InlineEnclosure.java b/wicket-core/src/main/java/org/apache/wicket/markup/html/internal/InlineEnclosure.java
index 6ce1edc..3e4d230 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/html/internal/InlineEnclosure.java
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/internal/InlineEnclosure.java
@@ -19,7 +19,6 @@ package org.apache.wicket.markup.html.internal;
import org.apache.wicket.Page;
import org.apache.wicket.markup.ComponentTag;
import org.apache.wicket.markup.IMarkupFragment;
-import org.apache.wicket.markup.Markup;
import org.apache.wicket.markup.MarkupParser;
import org.apache.wicket.markup.MarkupResourceStream;
import org.apache.wicket.markup.parser.filter.InlineEnclosureHandler;
@@ -47,8 +46,6 @@ public class InlineEnclosure extends Enclosure
private static final Logger log = LoggerFactory.getLogger(InlineEnclosure.class);
- private String enclosureMarkupAsString;
-
/**
* Construct.
*
@@ -59,8 +56,6 @@ public class InlineEnclosure extends Enclosure
{
super(id, childId);
- enclosureMarkupAsString = null;
-
// ensure that the Enclosure is ready for ajax updates
setOutputMarkupPlaceholderTag(true);
setMarkupId(getId());
@@ -88,34 +83,6 @@ public class InlineEnclosure extends Enclosure
}
/**
- * {@link InlineEnclosure}s keep their own cache of their markup because Component#markup is
- * detached and later during Ajax request it is hard to re-lookup {@link InlineEnclosure}'s
- * markup from its parent.
- *
- * @see org.apache.wicket.Component#getMarkup()
- */
- @Override
- public IMarkupFragment getMarkup()
- {
- IMarkupFragment enclosureMarkup = null;
- if (enclosureMarkupAsString == null)
- {
- IMarkupFragment markup = super.getMarkup();
- if (markup != null && markup != Markup.NO_MARKUP)
- {
- enclosureMarkup = markup;
- enclosureMarkupAsString = markup.toString(true);
- }
- }
- else
- {
- enclosureMarkup = Markup.of(enclosureMarkupAsString, getWicketNamespace());
- }
-
- return enclosureMarkup;
- }
-
- /**
* @return the markup namespace for Wicket elements and attributes.
*/
private String getWicketNamespace()
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/parser/filter/InlineEnclosureHandler.java b/wicket-core/src/main/java/org/apache/wicket/markup/parser/filter/InlineEnclosureHandler.java
index 7e9ea8e..507339b 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/parser/filter/InlineEnclosureHandler.java
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/parser/filter/InlineEnclosureHandler.java
@@ -65,6 +65,12 @@ public final class InlineEnclosureHandler extends AbstractMarkupFilter
private Stack<ComponentTag> enclosures;
/**
+ * InlinceEnclosures are not removed after render as other auto-components,
+ * thus they have to have a stable id.
+ */
+ private int counter;
+
+ /**
* Construct.
*/
public InlineEnclosureHandler()
@@ -107,7 +113,8 @@ public final class InlineEnclosureHandler extends AbstractMarkupFilter
{
if (Strings.isEmpty(htmlId))
{
- String id = getWicketNamespace() + "_" + INLINE_ENCLOSURE_ID_PREFIX;
+ String id = getWicketNamespace() + "_" + INLINE_ENCLOSURE_ID_PREFIX +
+ (counter++);
tag.setId(id);
}
else
@@ -198,10 +205,7 @@ public final class InlineEnclosureHandler extends AbstractMarkupFilter
if (Strings.isEmpty(inlineEnclosureChildId) == false)
{
String id = tag.getId();
- if (id.startsWith(getWicketNamespace(markupStream)))
- {
- id = id + container.getPage().getAutoIndex();
- }
+
// Yes, we handled the tag
return new InlineEnclosure(id, inlineEnclosureChildId);
}
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5085_581c7306.diff |
bugs-dot-jar_data_WICKET-5102_d110e307 | ---
BugID: WICKET-5102
Summary: 'wicket-bean-validation: Bean validation PropertyValidator only works with
direct field access'
Description: |-
There's a substring indexing bug in the wicket-bean-validation module in org.apache.wicket.bean.validation.DefaultPropertyResolver that causes it to only work with direct field access and fail when field is missing and getter method should be used.
The problem is on this line:
String name = getter.getName().substring(3, 1).toLowerCase() + getter.getName().substring(4);
Which should be:
String name = getter.getName().substring(3, 4).toLowerCase() + getter.getName().substring(4);
(or simply a single character access)
diff --git a/wicket-experimental/wicket-bean-validation/src/main/java/org/apache/wicket/bean/validation/DefaultPropertyResolver.java b/wicket-experimental/wicket-bean-validation/src/main/java/org/apache/wicket/bean/validation/DefaultPropertyResolver.java
index 64caf18..91eb1a3 100644
--- a/wicket-experimental/wicket-bean-validation/src/main/java/org/apache/wicket/bean/validation/DefaultPropertyResolver.java
+++ b/wicket-experimental/wicket-bean-validation/src/main/java/org/apache/wicket/bean/validation/DefaultPropertyResolver.java
@@ -6,6 +6,7 @@ import java.lang.reflect.Method;
import org.apache.wicket.markup.html.form.FormComponent;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.IPropertyReflectionAwareModel;
+import org.apache.wicket.model.IWrapModel;
import org.apache.wicket.model.PropertyModel;
/**
@@ -23,8 +24,21 @@ public class DefaultPropertyResolver implements IPropertyResolver
{
IModel<?> model = component.getModel();
- if (!(model instanceof IPropertyReflectionAwareModel))
+ while (true)
{
+ if (model == null)
+ {
+ return null;
+ }
+ if (model instanceof IPropertyReflectionAwareModel)
+ {
+ break;
+ }
+ if (model instanceof IWrapModel<?>)
+ {
+ model = ((IWrapModel<?>)model).getWrappedModel();
+ continue;
+ }
return null;
}
@@ -35,11 +49,11 @@ public class DefaultPropertyResolver implements IPropertyResolver
{
return new Property(field.getDeclaringClass(), field.getName());
}
-
+
Method getter = delegate.getPropertyGetter();
if (getter != null)
{
- String name = getter.getName().substring(3, 1).toLowerCase() +
+ String name = getter.getName().substring(3, 4).toLowerCase() +
getter.getName().substring(4);
return new Property(getter.getDeclaringClass(), name);
}
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5102_d110e307.diff |
bugs-dot-jar_data_WICKET-5112_ed780cc7 | ---
BugID: WICKET-5112
Summary: Parantheses problem with UrlValidator
Description: |-
One of our users got an error message when trying to add a new URL:
'http://en.wikipedia.org/wiki/Genus_(mathematics)' is not a valid URL
I just created very quickly a junit test and it fails:
String[] schemes = {"http"};
UrlValidator urlValidator = new UrlValidator(schemes);
assertTrue(urlValidator.isValid("http://en.wikipedia.org/wiki/Genus_(mathematics)"));
diff --git a/wicket-core/src/main/java/org/apache/wicket/validation/validator/UrlValidator.java b/wicket-core/src/main/java/org/apache/wicket/validation/validator/UrlValidator.java
index a259c51..b7eee15 100644
--- a/wicket-core/src/main/java/org/apache/wicket/validation/validator/UrlValidator.java
+++ b/wicket-core/src/main/java/org/apache/wicket/validation/validator/UrlValidator.java
@@ -115,7 +115,7 @@ public class UrlValidator implements IValidator<String>
private static final int PARSE_AUTHORITY_PORT = 4;
private static final int PARSE_AUTHORITY_EXTRA = 5; // Should always be empty.
- private static final String PATH_PATTERN = "^(/[-\\w:@&?=+,.!/~*'%$_;]*)?$";
+ private static final String PATH_PATTERN = "^(/[-\\w:@&?=+,.!/~*'%$_;\\(\\)]*)?$";
private static final String QUERY_PATTERN = "^(.*)$";
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5112_ed780cc7.diff |
bugs-dot-jar_data_WICKET-4391_5d64196a | ---
BugID: WICKET-4391
Summary: XsltOutputTransformerContainer incorrectly claims markup type "xsl"
Description: |-
XsltOutputTransformerContainer return "xsl" from getMarkupType(), forcing is on all contained components.
If the components in org.apache.wicket.markup.outputTransformer.Page_1 are reordered (XsltOutputTransformerContainer coming first) the test fails because no markup for SimpleBorder can be found.
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/transformer/XsltOutputTransformerContainer.java b/wicket-core/src/main/java/org/apache/wicket/markup/transformer/XsltOutputTransformerContainer.java
index d09c100..4d1724b 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/transformer/XsltOutputTransformerContainer.java
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/transformer/XsltOutputTransformerContainer.java
@@ -19,7 +19,6 @@ package org.apache.wicket.markup.transformer;
import org.apache.wicket.AttributeModifier;
import org.apache.wicket.Component;
import org.apache.wicket.markup.MarkupResourceStream;
-import org.apache.wicket.markup.MarkupType;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
@@ -29,9 +28,8 @@ import org.apache.wicket.model.Model;
* with an associated markup and must have a filename equal to the component's id.
* <p>
* The containers tag will be the root element of the xml data applied for transformation to ensure
- * the xml data are well formed (single root element). In addition the attribute
- * <code>xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.3-strict.dtd</code> is added
- * to the root element to allow the XSL processor to handle the wicket namespace.
+ * the xml data are well formed (single root element). In addition the attribute <code>xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.3-strict.dtd</code>
+ * is added to the root element to allow the XSL processor to handle the wicket namespace.
* <p>
* Similar to this container, a <code>IBehavior</code> is available which does the same, but does
* not require an additional Container.
@@ -105,12 +103,6 @@ public class XsltOutputTransformerContainer extends AbstractOutputTransformerCon
}
@Override
- public MarkupType getMarkupType()
- {
- return new MarkupType("xsl", null);
- }
-
- @Override
public CharSequence transform(final Component component, final CharSequence output)
throws Exception
{
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-4391_5d64196a.diff |
bugs-dot-jar_data_WICKET-3719_5ad32df9 | ---
BugID: WICKET-3719
Summary: Component's markup cannot be found in Ajax requests if the parent is transparent
Description: "When TransparentWebMarkupContainer is used an inner markup container
cannot find its markup on Ajax updates.\nThe problem seems to be caused by the fact
that ComponentResolvers#resolve() is not executed and since there is transparent
container involved Markup.find(String) cannot find the markup for non-transparent
markup containers.\nI'll commit a disabled test case that shows the problem. "
diff --git a/wicket-core/src/main/java/org/apache/wicket/MarkupContainer.java b/wicket-core/src/main/java/org/apache/wicket/MarkupContainer.java
index bd62e47..77dd7e1 100644
--- a/wicket-core/src/main/java/org/apache/wicket/MarkupContainer.java
+++ b/wicket-core/src/main/java/org/apache/wicket/MarkupContainer.java
@@ -40,6 +40,7 @@ import org.apache.wicket.model.IComponentInheritedModel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.IWrapModel;
import org.apache.wicket.settings.IDebugSettings;
+import org.apache.wicket.util.lang.Args;
import org.apache.wicket.util.lang.Generics;
import org.apache.wicket.util.string.ComponentStrings;
import org.apache.wicket.util.string.Strings;
@@ -129,10 +130,7 @@ public abstract class MarkupContainer extends Component implements Iterable<Comp
{
for (Component child : childs)
{
- if (child == null)
- {
- throw new IllegalArgumentException("argument child may not be null");
- }
+ Args.notNull(child, "child");
MarkupContainer parent = getParent();
while (parent != null)
@@ -141,14 +139,17 @@ public abstract class MarkupContainer extends Component implements Iterable<Comp
{
String msg = "You can not add a component's parent as child to the component (loop): Component: " +
this.toString(false) + "; parent == child: " + parent.toString(false);
+
if (child instanceof Border.BorderBodyContainer)
{
msg += ". Please consider using Border.addToBorder(new " +
this.getClass().getSimpleName() + "(\"" + this.getId() +
"\", ...) instead of add(...)";
}
+
throw new WicketRuntimeException(msg);
}
+
parent = parent.getParent();
}
@@ -899,10 +900,7 @@ public abstract class MarkupContainer extends Component implements Iterable<Comp
private final void addedComponent(final Component child)
{
// Check for degenerate case
- if (child == this)
- {
- throw new IllegalArgumentException("Component can't be added to itself");
- }
+ Args.notNull(child, "child");
MarkupContainer parent = child.getParent();
if (parent != null)
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/Markup.java b/wicket-core/src/main/java/org/apache/wicket/markup/Markup.java
index 6bc5bd8..2d27638 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/Markup.java
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/Markup.java
@@ -25,7 +25,6 @@ import java.util.List;
import org.apache.wicket.util.lang.Args;
import org.apache.wicket.util.resource.ResourceStreamNotFoundException;
import org.apache.wicket.util.string.AppendingStringBuffer;
-import org.apache.wicket.util.string.Strings;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -187,10 +186,7 @@ public class Markup implements IMarkupFragment
public final IMarkupFragment find(final String id)
{
- if (Strings.isEmpty(id))
- {
- throw new IllegalArgumentException("Parameter 'id' must not be null or empty");
- }
+ Args.notEmpty(id, "id");
MarkupStream stream = new MarkupStream(this);
stream.setCurrentIndex(0);
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/panel/DefaultMarkupSourcingStrategy.java b/wicket-core/src/main/java/org/apache/wicket/markup/html/panel/DefaultMarkupSourcingStrategy.java
index e183553..9a4a1d3 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/html/panel/DefaultMarkupSourcingStrategy.java
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/panel/DefaultMarkupSourcingStrategy.java
@@ -23,6 +23,7 @@ import org.apache.wicket.markup.IMarkupFragment;
import org.apache.wicket.markup.MarkupStream;
import org.apache.wicket.markup.html.internal.HtmlHeaderContainer;
import org.apache.wicket.markup.html.list.AbstractItem;
+import org.apache.wicket.markup.resolver.IComponentResolver;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -95,6 +96,24 @@ public final class DefaultMarkupSourcingStrategy implements IMarkupSourcingStrat
return markup;
}
+ // If the child has not been directly added to the container, but via a
+ // TransparentWebMarkupContainer, than we are in trouble. In general Wicket iterates over
+ // the markup elements and searches for associated components, not the other way around.
+ // Because of TransparentWebMarkupContainer (or more generally resolvers), there is no
+ // "synchronous" search possible.
+ for (Component ch : container)
+ {
+ if ((ch != child) && (ch instanceof MarkupContainer) &&
+ (ch instanceof IComponentResolver))
+ {
+ markup = ((MarkupContainer)ch).getMarkup(child);
+ if (markup != null)
+ {
+ return markup;
+ }
+ }
+ }
+
// This is to make migration for Items from 1.4 to 1.5 more easy
if (Character.isDigit(child.getId().charAt(0)))
{
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-3719_5ad32df9.diff |
bugs-dot-jar_data_WICKET-4760_2f1ece4b | ---
BugID: WICKET-4760
Summary: JavaScriptStripper fails with single line comments
Description: |-
The valid input
x++ //
x++
gets transformed to
x++ x++
which is syntactically invalid. This breaks the unminified version of bootstrap 2.1.1.
The problem doesn't occur with multiline comments because the linebreaks are preserved there.
diff --git a/wicket-core/src/main/java/org/apache/wicket/core/util/string/JavaScriptStripper.java b/wicket-core/src/main/java/org/apache/wicket/core/util/string/JavaScriptStripper.java
index 79c6542..46988d6 100644
--- a/wicket-core/src/main/java/org/apache/wicket/core/util/string/JavaScriptStripper.java
+++ b/wicket-core/src/main/java/org/apache/wicket/core/util/string/JavaScriptStripper.java
@@ -173,6 +173,7 @@ public class JavaScriptStripper
if (c == '\n' || c == '\r')
{
state = REGULAR_TEXT;
+ result.append(c);
continue;
}
}
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-4760_2f1ece4b.diff |
bugs-dot-jar_data_WICKET-4610_b19a3d69 | ---
BugID: WICKET-4610
Summary: WicketTester.assertRedirectUrl always fails because it always thinks the
redirect was null
Description: |
I have a page which always redirects.
When I write a test for this page, tester.assertRedirectUrl(...) always fails with the assertion failure showing that the redirect URL was null.
The page does redirect when running the application for real and I have stepped through in the debugger when running the test and it goes all the way to the HttpServletResponse.sendRedirect call.
However, in the same debugging session, tester.getLastResponse().getRedirectLocation() == null
Cut-down example follows.
public class AlwaysRedirectPage extends WebPage
{
public AlwaysRedirectPage()
{
// redirects to another web server on the same computer
throw new RedirectToUrlException("http://localhost:4333/");
}
}
public class TestAlwaysRedirectPage
{
@Test
public void test()
{
WicketTester tester = new WicketTester();
tester.startPage(AlwaysRedirectPage.class);
tester.assertRedirectUrl("http://localhost:4333/");
}
}
diff --git a/wicket-core/src/main/java/org/apache/wicket/protocol/http/mock/MockHttpServletResponse.java b/wicket-core/src/main/java/org/apache/wicket/protocol/http/mock/MockHttpServletResponse.java
index 01581ef..af09060 100755
--- a/wicket-core/src/main/java/org/apache/wicket/protocol/http/mock/MockHttpServletResponse.java
+++ b/wicket-core/src/main/java/org/apache/wicket/protocol/http/mock/MockHttpServletResponse.java
@@ -604,6 +604,7 @@ public class MockHttpServletResponse implements HttpServletResponse, IMetaDataBu
public void sendRedirect(String location) throws IOException
{
redirectLocation = location;
+ status = HttpServletResponse.SC_FOUND;
}
/**
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-4610_b19a3d69.diff |
bugs-dot-jar_data_WICKET-3647_1b57b51c | ---
BugID: WICKET-3647
Summary: Component#getMarkupId() throws exceptions when not added to page yet
Description: |
When retrieving the markup ID for a component that has not yet been added to a page, Wicket currently throws an exception telling that the markup could not be found, or that the markup type (in case the component was added to a Panel) could not be determined. In 1.4, Wicket would generate a markup ID in these cases.
Proposed solution: to first see if a markup ID has been either generated or set (using setOutputMarkupId), and then returning that, or if no ID was yet available *and* the component has been added to a Page: use the ID from the markup, or if the component has not been added to a Page nor a markup ID: generate the ID.
diff --git a/wicket-core/src/main/java/org/apache/wicket/Component.java b/wicket-core/src/main/java/org/apache/wicket/Component.java
index 6644c24..e81ffa5 100644
--- a/wicket-core/src/main/java/org/apache/wicket/Component.java
+++ b/wicket-core/src/main/java/org/apache/wicket/Component.java
@@ -1499,18 +1499,20 @@ public abstract class Component
*/
public final Object getMarkupIdImpl()
{
- String id = getMarkupIdFromMarkup();
- if (id != null)
- {
- return id;
- }
-
if (generatedMarkupId != -1)
{
return generatedMarkupId;
}
- return getMetaData(MARKUP_ID_KEY);
+ String id = getMetaData(MARKUP_ID_KEY);
+
+ // if still no markup id is found, and the component has been attached to a page, try to
+ // retrieve the id from the markup file.
+ if (id == null && findPage() != null)
+ {
+ id = getMarkupIdFromMarkup();
+ }
+ return id;
}
/**
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-3647_1b57b51c.diff |
bugs-dot-jar_data_WICKET-4927_8c827e33 | ---
BugID: WICKET-4927
Summary: Header can not be set from IRequestCycleListener#onEndRequest()
Description: |-
Due to HeaderBufferingWebResponse a header can no longer be set from IRequestCycleListener#onEndRequest().
In 1.4.x this was possible because BufferedWebResponse just passed through all headers to HttpServletResponse.
diff --git a/wicket-core/src/main/java/org/apache/wicket/protocol/http/HeaderBufferingWebResponse.java b/wicket-core/src/main/java/org/apache/wicket/protocol/http/HeaderBufferingWebResponse.java
index 0ac0c2a..8771dca 100644
--- a/wicket-core/src/main/java/org/apache/wicket/protocol/http/HeaderBufferingWebResponse.java
+++ b/wicket-core/src/main/java/org/apache/wicket/protocol/http/HeaderBufferingWebResponse.java
@@ -24,135 +24,134 @@ import org.apache.wicket.util.lang.Args;
import org.apache.wicket.util.time.Time;
/**
- * Response that keeps headers in buffers but writes the content directly to the response.
+ * Response that keeps headers in buffers until the first content is written.
*
* This is necessary to get {@link #reset()} working without removing the JSESSIONID cookie. When
* {@link HttpServletResponse#reset()} is called it removes all cookies, including the JSESSIONID
- * cookie.
+ * cookie - see <a href="https://issues.apache.org/bugzilla/show_bug.cgi?id=26183">Bug 26183</a>.
*
- * Calling {@link #reset()} on this response only clears the buffered headers. If there is any
- * content written to response it throws {@link IllegalStateException}.
+ * Calling {@link #reset()} on this response clears the buffered meta data, if there is already any
+ * content written it throws {@link IllegalStateException}.
*
* @author Matej Knopp
*/
class HeaderBufferingWebResponse extends WebResponse implements IMetaDataBufferingWebResponse
{
private final WebResponse originalResponse;
+
+ /**
+ * Buffer of meta data.
+ */
private final BufferedWebResponse bufferedResponse;
public HeaderBufferingWebResponse(WebResponse originalResponse)
{
this.originalResponse = originalResponse;
+
bufferedResponse = new BufferedWebResponse(originalResponse);
}
- private boolean bufferedWritten = false;
+ private boolean buffering = true;
- private void writeBuffered()
+ private void stopBuffering()
{
- if (!bufferedWritten)
+ if (buffering)
{
bufferedResponse.writeTo(originalResponse);
- bufferedWritten = true;
+ buffering = false;
}
}
- private void checkHeader()
+ /**
+ * The response used for meta data.
+ *
+ * @return buffered response if nothing was written yet, the original response otherwise
+ */
+ private WebResponse getMetaResponse()
{
- if (bufferedWritten)
+ if (buffering)
+ {
+ return bufferedResponse;
+ }
+ else
{
- throw new IllegalStateException("Header was already written to response!");
+ return originalResponse;
}
}
@Override
public void addCookie(Cookie cookie)
{
- checkHeader();
- bufferedResponse.addCookie(cookie);
+ getMetaResponse().addCookie(cookie);
}
@Override
public void clearCookie(Cookie cookie)
{
- checkHeader();
- bufferedResponse.clearCookie(cookie);
+ getMetaResponse().clearCookie(cookie);
}
- private boolean flushed = false;
-
@Override
public void flush()
{
- if (!bufferedWritten)
- {
- bufferedResponse.writeTo(originalResponse);
- bufferedResponse.reset();
- }
+ stopBuffering();
+
originalResponse.flush();
- flushed = true;
}
@Override
public boolean isRedirect()
{
- return bufferedResponse.isRedirect();
+ return getMetaResponse().isRedirect();
}
@Override
public void sendError(int sc, String msg)
{
- checkHeader();
- bufferedResponse.sendError(sc, msg);
+ getMetaResponse().sendError(sc, msg);
}
@Override
public void sendRedirect(String url)
{
- checkHeader();
- bufferedResponse.sendRedirect(url);
+ getMetaResponse().sendRedirect(url);
}
@Override
public void setContentLength(long length)
{
- checkHeader();
- bufferedResponse.setContentLength(length);
+ getMetaResponse().setContentLength(length);
}
@Override
public void setContentType(String mimeType)
{
- checkHeader();
- bufferedResponse.setContentType(mimeType);
+ getMetaResponse().setContentType(mimeType);
}
@Override
public void setDateHeader(String name, Time date)
{
Args.notNull(date, "date");
- checkHeader();
- bufferedResponse.setDateHeader(name, date);
+ getMetaResponse().setDateHeader(name, date);
}
@Override
public void setHeader(String name, String value)
{
- checkHeader();
- bufferedResponse.setHeader(name, value);
+ getMetaResponse().setHeader(name, value);
}
@Override
public void addHeader(String name, String value)
{
- checkHeader();
- bufferedResponse.addHeader(name, value);
+ getMetaResponse().addHeader(name, value);
}
@Override
public void setStatus(int sc)
{
- bufferedResponse.setStatus(sc);
+ getMetaResponse().setStatus(sc);
}
@Override
@@ -170,14 +169,16 @@ class HeaderBufferingWebResponse extends WebResponse implements IMetaDataBufferi
@Override
public void write(CharSequence sequence)
{
- writeBuffered();
+ stopBuffering();
+
originalResponse.write(sequence);
}
@Override
public void write(byte[] array)
{
- writeBuffered();
+ stopBuffering();
+
originalResponse.write(array);
}
@@ -185,19 +186,24 @@ class HeaderBufferingWebResponse extends WebResponse implements IMetaDataBufferi
@Override
public void write(byte[] array, int offset, int length)
{
- writeBuffered();
+ stopBuffering();
+
originalResponse.write(array, offset, length);
}
@Override
public void reset()
{
- if (flushed)
+ if (buffering)
+ {
+ // still buffering so just reset the buffer of meta data
+ bufferedResponse.reset();
+ }
+ else
{
- throw new IllegalStateException("Response has already been flushed!");
+ // the original response is never reset (see class javadoc)
+ throw new IllegalStateException("Response is no longer buffering!");
}
- bufferedResponse.reset();
- bufferedWritten = false;
}
@Override
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-4927_8c827e33.diff |
bugs-dot-jar_data_WICKET-4839_8b294488 | ---
BugID: WICKET-4839
Summary: Date converters should use a new instance of DateFormat to be thread safe
Description: |-
Please consider the linked issue WICKET-4833.
I had to open a new issue because I cannot attach the quickstart project I've prepared to a closed issue.
diff --git a/wicket-core/src/main/java/org/apache/wicket/ConverterLocator.java b/wicket-core/src/main/java/org/apache/wicket/ConverterLocator.java
index 5e48a83..6c85808 100644
--- a/wicket-core/src/main/java/org/apache/wicket/ConverterLocator.java
+++ b/wicket-core/src/main/java/org/apache/wicket/ConverterLocator.java
@@ -189,33 +189,32 @@ public class ConverterLocator implements IConverterLocator
public final <C> IConverter<C> get(Class<C> c)
{
@SuppressWarnings("unchecked")
- final IConverter<C> converter;
+ IConverter<C> converter = (IConverter<C>)classToConverter.get(c.getName());
- // Date based converters work with thread unsafe DateFormats and
- // a new instance should be created for each usage
- if (Date.class.equals(c))
- {
- converter = (IConverter<C>) new DateConverter();
- }
- else if (java.sql.Date.class.equals(c))
- {
- converter = (IConverter<C>) new SqlDateConverter();
- }
- else if (java.sql.Time.class.equals(c))
- {
- converter = (IConverter<C>) new SqlTimeConverter();
- }
- else if (java.sql.Timestamp.class.equals(c))
- {
- converter = (IConverter<C>) new SqlTimestampConverter();
- }
- else if (Calendar.class.equals(c))
- {
- converter = (IConverter<C>) new CalendarConverter();
- }
- else
+ if (converter == null)
{
- converter = (IConverter<C>)classToConverter.get(c.getName());
+ // Date based converters work with thread unsafe DateFormats and
+ // a new instance should be created for each usage
+ if (Date.class.equals(c))
+ {
+ converter = (IConverter<C>) new DateConverter();
+ }
+ else if (java.sql.Date.class.equals(c))
+ {
+ converter = (IConverter<C>) new SqlDateConverter();
+ }
+ else if (java.sql.Time.class.equals(c))
+ {
+ converter = (IConverter<C>) new SqlTimeConverter();
+ }
+ else if (java.sql.Timestamp.class.equals(c))
+ {
+ converter = (IConverter<C>) new SqlTimestampConverter();
+ }
+ else if (Calendar.class.equals(c))
+ {
+ converter = (IConverter<C>) new CalendarConverter();
+ }
}
return converter;
}
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-4839_8b294488.diff |
bugs-dot-jar_data_WICKET-3620_1a2bc1bc | ---
BugID: WICKET-3620
Summary: IResponseFilter cannot change buffer contents
Description: Changes to the responseBuffer, passed to an IResponseFilter, are not
picked up, nor are newly created AppendingStringBuffer (return value of the method).
Both callers of the method invoke it with a copy of the buffer and ignore return
values (BufferedWebResponse line 145 and AjaxRequestTarget line 687).
diff --git a/wicket-core/src/main/java/org/apache/wicket/ajax/AjaxRequestTarget.java b/wicket-core/src/main/java/org/apache/wicket/ajax/AjaxRequestTarget.java
index 0c73aff..f6ff1ad 100644
--- a/wicket-core/src/main/java/org/apache/wicket/ajax/AjaxRequestTarget.java
+++ b/wicket-core/src/main/java/org/apache/wicket/ajax/AjaxRequestTarget.java
@@ -600,8 +600,8 @@ public class AjaxRequestTarget implements IPageRequestHandler
{
final StringResponse bodyResponse = new StringResponse();
contructResponseBody(bodyResponse, encoding);
- invokeResponseFilters(bodyResponse);
- response.write(bodyResponse.getBuffer());
+ CharSequence filteredResponse = invokeResponseFilters(bodyResponse);
+ response.write(filteredResponse);
}
finally
{
@@ -670,8 +670,9 @@ public class AjaxRequestTarget implements IPageRequestHandler
*
* @param contentResponse
* the Ajax {@link Response} body
+ * @return filtered response
*/
- private void invokeResponseFilters(final StringResponse contentResponse)
+ private AppendingStringBuffer invokeResponseFilters(final StringResponse contentResponse)
{
AppendingStringBuffer responseBuffer = new AppendingStringBuffer(
contentResponse.getBuffer());
@@ -684,9 +685,10 @@ public class AjaxRequestTarget implements IPageRequestHandler
{
for (IResponseFilter filter : responseFilters)
{
- filter.filter(responseBuffer);
+ responseBuffer = filter.filter(responseBuffer);
}
}
+ return responseBuffer;
}
/**
diff --git a/wicket-core/src/main/java/org/apache/wicket/protocol/http/BufferedWebResponse.java b/wicket-core/src/main/java/org/apache/wicket/protocol/http/BufferedWebResponse.java
index 83c0556..03e18f9 100644
--- a/wicket-core/src/main/java/org/apache/wicket/protocol/http/BufferedWebResponse.java
+++ b/wicket-core/src/main/java/org/apache/wicket/protocol/http/BufferedWebResponse.java
@@ -142,10 +142,10 @@ public class BufferedWebResponse extends WebResponse implements IMetaDataBufferi
{
for (IResponseFilter filter : responseFilters)
{
- filter.filter(responseBuffer);
+ responseBuffer = filter.filter(responseBuffer);
}
}
- response.write(builder);
+ response.write(responseBuffer);
}
@Override
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-3620_1a2bc1bc.diff |
bugs-dot-jar_data_WICKET-4105_64656c98 | ---
BugID: WICKET-4105
Summary: Using ajax to update a component that has an AbstractTransformerBehavior
attached throws a ClassCastException
Description: |
Using ajax to update a component that has an AbstractTransformerBehavior attached throws a ClassCastException:
java.lang.ClassCastException:
org.apache.wicket.ajax.AjaxRequestTarget$AjaxResponse cannot be cast
to org.apache.wicket.request.http.WebResponse
at org.apache.wicket.markup.transformer.AbstractTransformerBehavior.beforeRender(AbstractTransformerBehavior.java:68)
at org.apache.wicket.Component.notifyBehaviorsComponentBeforeRender(Component.java:3421)
at org.apache.wicket.Component.internalRender(Component.java:2344)
at org.apache.wicket.Component.render(Component.java:2273)
at org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java:1474)
at org.apache.wicket.MarkupContainer.renderAll(MarkupContainer.java:1638)
at org.apache.wicket.MarkupContainer.renderComponentTagBody(MarkupContainer.java:1613)
at org.apache.wicket.MarkupContainer.onComponentTagBody(MarkupContainer.java:1567)
at org.apache.wicket.markup.html.form.Form.onComponentTagBody(Form.java:1570)
at org.apache.wicket.markup.html.panel.DefaultMarkupSourcingStrategy.onComponentTagBody(DefaultMarkupSourcingStrategy.java:72)
at org.apache.wicket.Component.internalRenderComponent(Component.java:2515)
at org.apache.wicket.MarkupContainer.onRender(MarkupContainer.java:1576)
at org.apache.wicket.Component.internalRender(Component.java:2345)
at org.apache.wicket.Component.render(Component.java:2273)
at org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java:1474)
at org.apache.wicket.MarkupContainer.renderAll(MarkupContainer.java:1638)
at org.apache.wicket.MarkupContainer.renderComponentTagBody(MarkupContainer.java:1613)
at org.apache.wicket.MarkupContainer.renderAssociatedMarkup(MarkupContainer.java:735)
at org.apache.wicket.markup.html.panel.AssociatedMarkupSourcingStrategy.renderAssociatedMarkup(AssociatedMarkupSourcingStrategy.java:76)
at org.apache.wicket.markup.html.panel.PanelMarkupSourcingStrategy.onComponentTagBody(PanelMarkupSourcingStrategy.java:112)
at org.apache.wicket.Component.internalRenderComponent(Component.java:2515)
at org.apache.wicket.MarkupContainer.onRender(MarkupContainer.java:1576)
at org.apache.wicket.Component.internalRender(Component.java:2345)
at org.apache.wicket.Component.render(Component.java:2273)
at org.apache.wicket.ajax.AjaxRequestTarget.respondComponent(AjaxRequestTarget.java:982)
at org.apache.wicket.ajax.AjaxRequestTarget.respondComponents(AjaxRequestTarget.java:796)
at org.apache.wicket.ajax.AjaxRequestTarget.constructResponseBody(AjaxRequestTarget.java:676)
at org.apache.wicket.ajax.AjaxRequestTarget.respond(AjaxRequestTarget.java:637)
at org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:712)
at org.apache.wicket.request.RequestHandlerStack.execute(RequestHandlerStack.java:63)
at org.apache.wicket.request.RequestHandlerStack.execute(RequestHandlerStack.java:96)
at org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:208)
at org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:251)
at org.apache.wicket.protocol.http.WicketFilter.processRequest(WicketFilter.java:162)
at org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:218)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/transformer/AbstractTransformerBehavior.java b/wicket-core/src/main/java/org/apache/wicket/markup/transformer/AbstractTransformerBehavior.java
index be0490b..f752e10 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/transformer/AbstractTransformerBehavior.java
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/transformer/AbstractTransformerBehavior.java
@@ -20,12 +20,13 @@ import org.apache.wicket.Component;
import org.apache.wicket.WicketRuntimeException;
import org.apache.wicket.behavior.Behavior;
import org.apache.wicket.protocol.http.BufferedWebResponse;
+import org.apache.wicket.request.Response;
import org.apache.wicket.request.cycle.RequestCycle;
import org.apache.wicket.request.http.WebResponse;
/**
- * A IBehavior which can be added to any component. It allows to post-process (transform) the markup
- * generated by the component.
+ * A {@link Behavior} which can be added to any component. It allows to post-process (transform) the
+ * markup generated by the component.
*
* @see org.apache.wicket.markup.transformer.AbstractOutputTransformerContainer
*
@@ -35,20 +36,17 @@ public abstract class AbstractTransformerBehavior extends Behavior implements IT
{
private static final long serialVersionUID = 1L;
- private WebResponse webResponse;
-
/**
- * Construct.
+ * The request cycle's response before the transformation.
*/
- public AbstractTransformerBehavior()
- {
- }
+ private Response originalResponse;
/**
* Create a new response object which is used to store the markup generated by the child
* objects.
*
* @param originalResponse
+ * the original web response or {@code null} if it isn't a {@link WebResponse}
*
* @return Response object. Must not be null
*/
@@ -65,17 +63,14 @@ public abstract class AbstractTransformerBehavior extends Behavior implements IT
final RequestCycle requestCycle = RequestCycle.get();
// Temporarily replace the web response with a String response
- webResponse = (WebResponse)requestCycle.getResponse();
+ originalResponse = requestCycle.getResponse();
- // Create a new response object
- final BufferedWebResponse response = newResponse(webResponse);
- if (response == null)
- {
- throw new IllegalStateException("newResponse() must not return null");
- }
+ WebResponse origResponse = (WebResponse)((originalResponse instanceof WebResponse)
+ ? originalResponse : null);
+ BufferedWebResponse tempResponse = newResponse(origResponse);
- // and make it the current one
- requestCycle.setResponse(response);
+ // temporarily set StringResponse to collect the transformed output
+ requestCycle.setResponse(tempResponse);
}
@Override
@@ -85,28 +80,28 @@ public abstract class AbstractTransformerBehavior extends Behavior implements IT
try
{
- BufferedWebResponse response = (BufferedWebResponse)requestCycle.getResponse();
+ BufferedWebResponse tempResponse = (BufferedWebResponse)requestCycle.getResponse();
// Transform the data
- CharSequence output = transform(component, response.getText());
- response.setText(output);
- response.writeTo(webResponse);
+ CharSequence output = transform(component, tempResponse.getText());
+ originalResponse.write(output);
}
catch (Exception ex)
{
- throw new WicketRuntimeException("Error while transforming the output: " + this, ex);
+ throw new WicketRuntimeException("Error while transforming the output of component: " +
+ component, ex);
}
finally
{
// Restore the original response object
- requestCycle.setResponse(webResponse);
+ requestCycle.setResponse(originalResponse);
}
}
@Override
public void detach(Component component)
{
- webResponse = null;
+ originalResponse = null;
super.detach(component);
}
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-4105_64656c98.diff |
bugs-dot-jar_data_WICKET-4932_f20b2d70 | ---
BugID: WICKET-4932
Summary: Mounted page is not throwing ExpireException with setting setRecreateMountedPagesAfterExpiry(false)
Description: "We have a page that is both bookmarkable (and accessible with certain
page parameters) and has a second constructor taking an object. \nWhen ever the
session time-out we want to show a session expired page. But we get a exception
because Wicket is trying to rebuild the page with no page parameters. \nWe have
set the setting getPageSettings().setRecreateMountedPagesAfterExpiry(false); This
works when clicking on (ajax)links, but it's not working when using the back/forward
button in the browser (or javascript:history.go(-1)).\n\nI'll attache a quickstart."
diff --git a/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/AbstractBookmarkableMapper.java b/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/AbstractBookmarkableMapper.java
index 86c64a6..56e27d4 100644
--- a/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/AbstractBookmarkableMapper.java
+++ b/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/AbstractBookmarkableMapper.java
@@ -24,6 +24,8 @@ import org.apache.wicket.core.request.handler.ListenerInterfaceRequestHandler;
import org.apache.wicket.core.request.handler.PageAndComponentProvider;
import org.apache.wicket.core.request.handler.PageProvider;
import org.apache.wicket.core.request.handler.RenderPageRequestHandler;
+import org.apache.wicket.protocol.http.PageExpiredException;
+import org.apache.wicket.protocol.http.WebApplication;
import org.apache.wicket.request.IRequestHandler;
import org.apache.wicket.request.IRequestHandlerDelegate;
import org.apache.wicket.request.IRequestMapper;
@@ -41,7 +43,7 @@ import org.slf4j.LoggerFactory;
/**
* Abstract encoder for Bookmarkable, Hybrid and BookmarkableListenerInterface URLs.
- *
+ *
* @author Matej Knopp
*/
public abstract class AbstractBookmarkableMapper extends AbstractComponentMapper
@@ -50,7 +52,7 @@ public abstract class AbstractBookmarkableMapper extends AbstractComponentMapper
/**
* Represents information stored in URL.
- *
+ *
* @author Matej Knopp
*/
protected static final class UrlInfo
@@ -61,7 +63,7 @@ public abstract class AbstractBookmarkableMapper extends AbstractComponentMapper
/**
* Construct.
- *
+ *
* @param pageComponentInfo
* optional parameter providing the page instance and component information
* @param pageClass
@@ -82,7 +84,7 @@ public abstract class AbstractBookmarkableMapper extends AbstractComponentMapper
/**
* Cleans the original parameters from entries used by Wicket internals.
- *
+ *
* @param originalParameters
* the current request's non-modified parameters
* @return all parameters but Wicket internal ones
@@ -142,7 +144,7 @@ public abstract class AbstractBookmarkableMapper extends AbstractComponentMapper
/**
* Parse the given request to an {@link UrlInfo} instance.
- *
+ *
* @param request
* @return UrlInfo instance or <code>null</code> if this encoder can not handle the request
*/
@@ -151,7 +153,7 @@ public abstract class AbstractBookmarkableMapper extends AbstractComponentMapper
/**
* Builds URL for the given {@link UrlInfo} instance. The URL this method produces must be
* parseable by the {@link #parseRequest(Request)} method.
- *
+ *
* @param info
* @return Url result URL
*/
@@ -163,7 +165,7 @@ public abstract class AbstractBookmarkableMapper extends AbstractComponentMapper
* <p>
* For generic bookmarkable encoders this method should return <code>true</code>. For explicit
* (mounted) encoders this method should return <code>false</code>
- *
+ *
* @return <code>true</code> if hybrid URL requires page created bookmarkable,
* <code>false</code> otherwise.
*/
@@ -177,7 +179,7 @@ public abstract class AbstractBookmarkableMapper extends AbstractComponentMapper
/**
* Creates a {@code IRequestHandler} that processes a bookmarkable request.
- *
+ *
* @param pageClass
* @param pageParameters
* @return a {@code IRequestHandler} capable of processing the bookmarkable request.
@@ -194,7 +196,7 @@ public abstract class AbstractBookmarkableMapper extends AbstractComponentMapper
* Creates a {@code IRequestHandler} that processes a hybrid request. When the page identified
* by {@code pageInfo} was not available, the request should be treated as a bookmarkable
* request.
- *
+ *
* @param pageInfo
* @param pageClass
* @param pageParameters
@@ -208,12 +210,21 @@ public abstract class AbstractBookmarkableMapper extends AbstractComponentMapper
PageProvider provider = new PageProvider(pageInfo.getPageId(), pageClass, pageParameters,
renderCount);
provider.setPageSource(getContext());
- return new RenderPageRequestHandler(provider);
+ if (provider.isNewPageInstance() &&
+ !WebApplication.get().getPageSettings().getRecreateMountedPagesAfterExpiry())
+ {
+ throw new PageExpiredException(String.format("Bookmarkable page id '%d' has expired.",
+ pageInfo.getPageId()));
+ }
+ else
+ {
+ return new RenderPageRequestHandler(provider);
+ }
}
/**
* Creates a {@code IRequestHandler} that processes a listener request.
- *
+ *
* @param pageComponentInfo
* @param pageClass
* @param pageParameters
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-4932_f20b2d70.diff |
bugs-dot-jar_data_WICKET-4997_ee02c883 | ---
BugID: WICKET-4997
Summary: Mounted bookmarkable Page not recreated on Session Expiry
Description: "With the default true of org.apache.wicket.settings.IPageSettings#getRecreateMountedPagesAfterExpiry()
PageExpiryException is thrown when a Link on a page is clicked.\n\nI find it very
useful and in fact indispensible to rely on RecreateMountedPagesAfterExpiry especially
on logout links.\n\nBut it doesn't seem to work for me in 6.4.0. I think this is
because Link#getUrl() calls Component#utlFor() which requires a stateless page for
this to work:\n\n\t\tif (page.isPageStateless())\n\t\t{\n\t\t\thandler = new BookmarkableListenerInterfaceRequestHandler(provider,
listener);\n\t\t}\n\t\telse\n\t\t{\n\t\t\thandler = new ListenerInterfaceRequestHandler(provider,
listener);\n\t\t}\n\nWith a stateless page a url is:\n\nhttp://localhost:8080/wicket/HomePage?-1.ILinkListener-toolBar-signout\n\nWith
a non stateless but bookmarkable page a url is:\n\nhttp://localhost:8080/wicket/page?1-1.ILinkListener-toolBar-signout\n\nSo
I guess that a stateful page cannot be recovered because after session expiry Wicket
cannot find out what the page is. It is not coded in the URL.\n\nLooking at the
semantics of UrlFor(), I thought this might be a bug and I copied and changed the
code in my Link subclass from\n\n//\t\tif (page.isPageStateless()) {\nto:\n if
(page.isBookmarkable()) {\n\t\t\nIt works as expected but I don't know whether it
would break other things if implemented in Wicket.\n\nI guess I am not the only
one who needs recovery for bookmarkable pages in this way. Would it be possible
to change Wicket to fix this so it becomes possible?"
diff --git a/wicket-core/src/main/java/org/apache/wicket/Component.java b/wicket-core/src/main/java/org/apache/wicket/Component.java
index 0c56063..b78f8bf 100644
--- a/wicket-core/src/main/java/org/apache/wicket/Component.java
+++ b/wicket-core/src/main/java/org/apache/wicket/Component.java
@@ -3334,7 +3334,8 @@ public abstract class Component
Page page = getPage();
PageAndComponentProvider provider = new PageAndComponentProvider(page, this, parameters);
IRequestHandler handler;
- if (page.isBookmarkable())
+ if (getApplication().getPageSettings().getRecreateMountedPagesAfterExpiry() &&
+ ((page.isBookmarkable() && page.wasCreatedBookmarkable()) || page.isPageStateless()))
{
handler = new BookmarkableListenerInterfaceRequestHandler(provider, listener, id);
}
@@ -3377,7 +3378,8 @@ public abstract class Component
Page page = getPage();
PageAndComponentProvider provider = new PageAndComponentProvider(page, this, parameters);
IRequestHandler handler;
- if (page.isBookmarkable())
+ if (getApplication().getPageSettings().getRecreateMountedPagesAfterExpiry() &&
+ ((page.isBookmarkable() && page.wasCreatedBookmarkable()) || page.isPageStateless()))
{
handler = new BookmarkableListenerInterfaceRequestHandler(provider, listener);
}
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-4997_ee02c883.diff |
bugs-dot-jar_data_WICKET-3965_6051019b | ---
BugID: WICKET-3965
Summary: A (stateless) page immediately disappears after the first render
Description: |-
Using setResponsePage(new SomeStatelessNonBookmarkablePage(aParameter)) renders the page but trying to reload the page in the browser fails with PageExpiredException.
The reason is that the page is stateless and thus it is not saved in the page stores. Since it was scheduled for render with setResponsePage(Page) method its Url is created by PageInstanceMapper (i.e. something like: wicket/page?1). An attempt to refresh such page fails with "Page with id '1' is not found => PageExpiredException".
Igor suggested to call 'page.setStatelessHint(false)' for all pages passed to PageProvider(IRequestablePage) constructor, i.e. such pages must be stored.
This solved the problem but exposed few more problems:
- MockPageManager (used in WicketTester) until now always touched/stored pages, no matter their statelessness
- org.apache.wicket.markup.html.internal.EnclosureTest.testRender10() was wrong for some unknown reason. All expectations against EnclosurePageExpectedResult_10-2.html should not have the enclosure rendered because "input" component is invisible
diff --git a/wicket-core/src/main/java/org/apache/wicket/Component.java b/wicket-core/src/main/java/org/apache/wicket/Component.java
index 13ab5e1..a762035 100644
--- a/wicket-core/src/main/java/org/apache/wicket/Component.java
+++ b/wicket-core/src/main/java/org/apache/wicket/Component.java
@@ -3284,15 +3284,18 @@ public abstract class Component
public final CharSequence urlFor(final Behavior behaviour,
final RequestListenerInterface listener)
{
- PageAndComponentProvider provider = new PageAndComponentProvider(getPage(), this);
int id = getBehaviorId(behaviour);
+ Page page = getPage();
IRequestHandler handler;
- if (getPage().isPageStateless())
+ if (page.isPageStateless())
{
+ PageAndComponentProvider provider = new PageAndComponentProvider(page.getPageClass(),
+ page.getPageParameters(), getPageRelativePath());
handler = new BookmarkableListenerInterfaceRequestHandler(provider, listener, id);
}
else
{
+ PageAndComponentProvider provider = new PageAndComponentProvider(page, this);
handler = new ListenerInterfaceRequestHandler(provider, listener, id);
}
return getRequestCycle().urlFor(handler);
@@ -3324,14 +3327,17 @@ public abstract class Component
*/
public final CharSequence urlFor(final RequestListenerInterface listener)
{
- PageAndComponentProvider provider = new PageAndComponentProvider(getPage(), this);
+ Page page = getPage();
IRequestHandler handler;
- if (getPage().isPageStateless())
+ if (page.isPageStateless())
{
+ PageAndComponentProvider provider = new PageAndComponentProvider(page.getPageClass(),
+ page.getPageParameters(), getPageRelativePath());
handler = new BookmarkableListenerInterfaceRequestHandler(provider, listener);
}
else
{
+ PageAndComponentProvider provider = new PageAndComponentProvider(page, this);
handler = new ListenerInterfaceRequestHandler(provider, listener);
}
return getRequestCycle().urlFor(handler);
diff --git a/wicket-core/src/main/java/org/apache/wicket/mock/MockPageManager.java b/wicket-core/src/main/java/org/apache/wicket/mock/MockPageManager.java
index 3cf9213..cf18216 100644
--- a/wicket-core/src/main/java/org/apache/wicket/mock/MockPageManager.java
+++ b/wicket-core/src/main/java/org/apache/wicket/mock/MockPageManager.java
@@ -78,7 +78,10 @@ public class MockPageManager implements IPageManager
public void touchPage(IManageablePage page)
{
- pages.put(page.getPageId(), page);
+ if (page.isPageStateless() == false)
+ {
+ pages.put(page.getPageId(), page);
+ }
}
/**
diff --git a/wicket-core/src/main/java/org/apache/wicket/request/handler/PageProvider.java b/wicket-core/src/main/java/org/apache/wicket/request/handler/PageProvider.java
index 379b473..c9569a8 100644
--- a/wicket-core/src/main/java/org/apache/wicket/request/handler/PageProvider.java
+++ b/wicket-core/src/main/java/org/apache/wicket/request/handler/PageProvider.java
@@ -17,6 +17,7 @@
package org.apache.wicket.request.handler;
import org.apache.wicket.Application;
+import org.apache.wicket.Page;
import org.apache.wicket.Session;
import org.apache.wicket.page.IPageManager;
import org.apache.wicket.protocol.http.PageExpiredException;
@@ -148,6 +149,10 @@ public class PageProvider implements IPageProvider
Args.notNull(page, "page");
pageInstance = page;
+ if (pageInstance instanceof Page)
+ {
+ ((Page)pageInstance).setStatelessHint(false);
+ }
}
/**
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-3965_6051019b.diff |
bugs-dot-jar_data_WICKET-5751_bcea89fc | ---
BugID: WICKET-5751
Summary: NullPointerException in IntHashMap
Description: "I was looking through a tester's log file to track down a separate issue.
I came across a {{NullPointerException}} with {{IntHashMap}}, apparently when the
server was shutting down.\n\nSee also WICKET-5584, which also deals with a {{NullPointerException}}
with {{IntHashMap}}, and also seems to relate to a {{null}} {{modCount}} (judging
by the line number).\n\n{noformat}\nINFO (ExampleServer) [2014-11-06 00:49:24,979]
- com.example.server.ExampleServer.stopServer(ExampleServer.java:268): Stopping
server.\nINFO (ServerConnector) [2014-11-06 00:49:24,982] - org.eclipse.jetty.server.AbstractConnector.doStop(AbstractConnector.java:306):
Stopped ServerConnector@3b7d3a38{HTTP/1.1}{0.0.0.0:8099}\nINFO (Application) [2014-11-06
00:49:24,983] - org.apache.wicket.Application.destroyInitializers(Application.java:588):
[org.apache.wicket.protocol.http.WicketFilter-55b0dcab] destroy: Wicket core library
initializer\nINFO (Application) [2014-11-06 00:49:24,983] - org.apache.wicket.Application.destroyInitializers(Application.java:588):
[org.apache.wicket.protocol.http.WicketFilter-55b0dcab] destroy: Wicket extensions
initializer\nERROR (DiskDataStore) [2014-11-06 00:49:24,988] - org.apache.wicket.pageStore.DiskDataStore.saveIndex(DiskDataStore.java:282):
Couldn't write DiskDataStore index to file C:\\Windows\\SERVIC~2\\NETWOR~1\\AppData\\Local\\Temp\\org.apache.wicket.protocol.http.WicketFilter-55b0dcab-filestore\\DiskDataStoreIndex.\njava.lang.NullPointerException\n\tat
org.apache.wicket.util.collections.IntHashMap$HashIterator.<init>(IntHashMap.java:777)\n\tat
org.apache.wicket.util.collections.IntHashMap$EntryIterator.<init>(IntHashMap.java:871)\n\tat
org.apache.wicket.util.collections.IntHashMap$EntryIterator.<init>(IntHashMap.java:871)\n\tat
org.apache.wicket.util.collections.IntHashMap.newEntryIterator(IntHashMap.java:896)\n\tat
org.apache.wicket.util.collections.IntHashMap$EntrySet.iterator(IntHashMap.java:1055)\n\tat
org.apache.wicket.util.collections.IntHashMap.writeObject(IntHashMap.java:1128)\n\tat
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\n\tat sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\n\tat
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\n\tat
java.lang.reflect.Method.invoke(Method.java:483)\n\tat java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:988)\n\tat
java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1496)\n\tat java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1432)\n\tat
java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1178)\n\tat java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1548)\n\tat
java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1509)\n\tat java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1432)\n\tat
java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1178)\n\tat java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1548)\n\tat
java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1509)\n\tat java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1432)\n\tat
java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1178)\n\tat java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:348)\n\tat
java.util.HashMap.internalWriteEntries(HashMap.java:1777)\n\tat java.util.HashMap.writeObject(HashMap.java:1354)\n\tat
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\n\tat sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\n\tat
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\n\tat
java.lang.reflect.Method.invoke(Method.java:483)\n\tat java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:988)\n\tat
java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1496)\n\tat java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1432)\n\tat
java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1178)\n\tat java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:348)\n\tat
org.apache.wicket.pageStore.DiskDataStore.saveIndex(DiskDataStore.java:274)\n\tat
org.apache.wicket.pageStore.DiskDataStore.destroy(DiskDataStore.java:106)\n\tat
org.apache.wicket.pageStore.AsynchronousDataStore.destroy(AsynchronousDataStore.java:118)\n\tat
org.apache.wicket.pageStore.AbstractPageStore.destroy(AbstractPageStore.java:53)\n\tat
org.apache.wicket.pageStore.AbstractCachingPageStore.destroy(AbstractCachingPageStore.java:102)\n\tat
org.apache.wicket.page.PageStoreManager.destroy(PageStoreManager.java:437)\n\tat
org.apache.wicket.Application.internalDestroy(Application.java:659)\n\tat org.apache.wicket.protocol.http.WebApplication.internalDestroy(WebApplication.java:607)\n\tat
org.apache.wicket.protocol.http.WicketFilter.destroy(WicketFilter.java:605)\n\tat
org.eclipse.jetty.servlet.FilterHolder.destroyInstance(FilterHolder.java:173)\n\tat
org.eclipse.jetty.servlet.FilterHolder.doStop(FilterHolder.java:151)\n\tat org.eclipse.jetty.util.component.AbstractLifeCycle.stop(AbstractLifeCycle.java:89)\n\tat
org.eclipse.jetty.util.component.ContainerLifeCycle.stop(ContainerLifeCycle.java:143)\n\tat
org.eclipse.jetty.util.component.ContainerLifeCycle.doStop(ContainerLifeCycle.java:162)\n\tat
org.eclipse.jetty.server.handler.AbstractHandler.doStop(AbstractHandler.java:73)\n\tat
org.eclipse.jetty.servlet.ServletHandler.doStop(ServletHandler.java:230)\n\tat org.eclipse.jetty.util.component.AbstractLifeCycle.stop(AbstractLifeCycle.java:89)\n\tat
org.eclipse.jetty.util.component.ContainerLifeCycle.stop(ContainerLifeCycle.java:143)\n\tat
org.eclipse.jetty.util.component.ContainerLifeCycle.doStop(ContainerLifeCycle.java:162)\n\tat
org.eclipse.jetty.server.handler.AbstractHandler.doStop(AbstractHandler.java:73)\n\tat
org.eclipse.jetty.security.SecurityHandler.doStop(SecurityHandler.java:411)\n\tat
org.eclipse.jetty.security.ConstraintSecurityHandler.doStop(ConstraintSecurityHandler.java:457)\n\tat
org.eclipse.jetty.util.component.AbstractLifeCycle.stop(AbstractLifeCycle.java:89)\n\tat
org.eclipse.jetty.util.component.ContainerLifeCycle.stop(ContainerLifeCycle.java:143)\n\tat
org.eclipse.jetty.util.component.ContainerLifeCycle.doStop(ContainerLifeCycle.java:162)\n\tat
org.eclipse.jetty.server.handler.AbstractHandler.doStop(AbstractHandler.java:73)\n\tat
org.eclipse.jetty.server.session.SessionHandler.doStop(SessionHandler.java:127)\n\tat
org.eclipse.jetty.util.component.AbstractLifeCycle.stop(AbstractLifeCycle.java:89)\n\tat
org.eclipse.jetty.util.component.ContainerLifeCycle.stop(ContainerLifeCycle.java:143)\n\tat
org.eclipse.jetty.util.component.ContainerLifeCycle.doStop(ContainerLifeCycle.java:162)\n\tat
org.eclipse.jetty.server.handler.AbstractHandler.doStop(AbstractHandler.java:73)\n\tat
org.eclipse.jetty.server.handler.ContextHandler.doStop(ContextHandler.java:833)\n\tat
org.eclipse.jetty.servlet.ServletContextHandler.doStop(ServletContextHandler.java:215)\n\tat
org.eclipse.jetty.util.component.AbstractLifeCycle.stop(AbstractLifeCycle.java:89)\n\tat
org.eclipse.jetty.util.component.ContainerLifeCycle.stop(ContainerLifeCycle.java:143)\n\tat
org.eclipse.jetty.util.component.ContainerLifeCycle.doStop(ContainerLifeCycle.java:162)\n\tat
org.eclipse.jetty.server.handler.AbstractHandler.doStop(AbstractHandler.java:73)\n\tat
org.eclipse.jetty.server.Server.doStop(Server.java:456)\n\tat org.eclipse.jetty.util.component.AbstractLifeCycle.stop(AbstractLifeCycle.java:89)\n\tat
com.example.server.ExampleServer.stopServer(ExampleServer.java:269)\n\tat com.example.server.ExampleServer.stop(ExampleServer.java:279)\nINFO
\ (ContextHandler) [2014-11-06 00:49:24,990] - org.eclipse.jetty.server.handler.ContextHandler.doStop(ContextHandler.java:863):
Stopped o.e.j.s.ServletContextHandler@63f259c3{/,null,UNAVAILABLE}\n{noformat}"
diff --git a/wicket-util/src/main/java/org/apache/wicket/util/collections/IntHashMap.java b/wicket-util/src/main/java/org/apache/wicket/util/collections/IntHashMap.java
index 7b377fc..7a8d180 100644
--- a/wicket-util/src/main/java/org/apache/wicket/util/collections/IntHashMap.java
+++ b/wicket-util/src/main/java/org/apache/wicket/util/collections/IntHashMap.java
@@ -1145,6 +1145,8 @@ public class IntHashMap<V> implements Cloneable, Serializable
private void readObject(final java.io.ObjectInputStream s) throws IOException,
ClassNotFoundException
{
+ modCount = new AtomicInteger(0);
+
// Read in the threshold, loadfactor, and any hidden stuff
s.defaultReadObject();
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5751_bcea89fc.diff |
bugs-dot-jar_data_WICKET-4066_4d3d1f85 | ---
BugID: WICKET-4066
Summary: RestartResponseAtInterceptPageException.InterceptData is never cleared
Description: |-
RestartResponseAtInterceptPageException.InterceptData is supposed to be cleared after continueToOriginalDestination() is called. This is accomplished via RestartResponseAtInterceptPageException.MAPPER, which is registered in the SystemMapper.
However there seems to be a serious bug here. The MAPPER always returns a compatibilityScore of 0, and thus is never actually invoked. The InterceptData is thus never cleared. Furthermore, even if the MAPPER did return a Integer.MAX_VALUE score, it would still not be invoked in many scenarios, since other mappers in the SystemMapper are registered later and therefore have higher priority.
In practice, this can lead to very odd login behavior in Wicket applications (which is where RestartResponseAtInterceptPageException is typically used). For example, if the user clicks a "login" link they may end up on a totally unexpected page, due to stale InterceptData that is hanging around in the session.
I am attaching a quick start that demonstrates the problem, as well as a patch the fixes the compatibilityScore and moves the MAPPER to a higher priority in the SystemMapper.
diff --git a/wicket-core/src/main/java/org/apache/wicket/RestartResponseAtInterceptPageException.java b/wicket-core/src/main/java/org/apache/wicket/RestartResponseAtInterceptPageException.java
index 1a31878..98668ad 100644
--- a/wicket-core/src/main/java/org/apache/wicket/RestartResponseAtInterceptPageException.java
+++ b/wicket-core/src/main/java/org/apache/wicket/RestartResponseAtInterceptPageException.java
@@ -165,7 +165,7 @@ public class RestartResponseAtInterceptPageException extends ResetResponseExcept
{
public int getCompatibilityScore(Request request)
{
- return 0;
+ return matchedData(request) != null ? Integer.MAX_VALUE : 0;
}
public Url mapHandler(IRequestHandler requestHandler)
@@ -175,23 +175,30 @@ public class RestartResponseAtInterceptPageException extends ResetResponseExcept
public IRequestHandler mapRequest(Request request)
{
- InterceptData data = InterceptData.get();
+ InterceptData data = matchedData(request);
if (data != null)
{
- if (data.originalUrl.equals(request.getOriginalUrl()))
+ if (data.postParameters.isEmpty() == false &&
+ request.getPostParameters() instanceof IWritableRequestParameters)
{
- if (data.postParameters.isEmpty() == false &&
- request.getPostParameters() instanceof IWritableRequestParameters)
+ IWritableRequestParameters parameters = (IWritableRequestParameters)request.getPostParameters();
+ parameters.reset();
+ for (String s : data.postParameters.keySet())
{
- IWritableRequestParameters parameters = (IWritableRequestParameters)request.getPostParameters();
- parameters.reset();
- for (String s : data.postParameters.keySet())
- {
- parameters.setParameterValues(s, data.postParameters.get(s));
- }
+ parameters.setParameterValues(s, data.postParameters.get(s));
}
- InterceptData.clear();
}
+ InterceptData.clear();
+ }
+ return null;
+ }
+
+ private InterceptData matchedData(Request request)
+ {
+ InterceptData data = InterceptData.get();
+ if(data != null && data.originalUrl.equals(request.getOriginalUrl()))
+ {
+ return data;
}
return null;
}
diff --git a/wicket-core/src/main/java/org/apache/wicket/SystemMapper.java b/wicket-core/src/main/java/org/apache/wicket/SystemMapper.java
index e0eea63..7412737 100644
--- a/wicket-core/src/main/java/org/apache/wicket/SystemMapper.java
+++ b/wicket-core/src/main/java/org/apache/wicket/SystemMapper.java
@@ -46,12 +46,12 @@ public class SystemMapper extends CompoundRequestMapper
public SystemMapper(final Application application)
{
this.application = application;
- add(RestartResponseAtInterceptPageException.MAPPER);
add(new PageInstanceMapper());
add(new BookmarkableMapper());
add(new HomePageMapper(new HomePageProvider<Page>(application)));
add(new ResourceReferenceMapper(new PageParametersEncoder(),
new ParentFolderPlaceholderProvider(application), getResourceCachingStrategy()));
+ add(RestartResponseAtInterceptPageException.MAPPER);
add(new BufferedResponseMapper());
}
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-4066_4d3d1f85.diff |
bugs-dot-jar_data_WICKET-5686_8e794fc4 | ---
BugID: WICKET-5686
Summary: "@Inject should require the bean dependency instead of setting null"
Description: |-
When using {{@SpringBean}}, if the bean cannot be injected then Wicket will throw {{Exception}}.
However current behavior if when using {{@Inject}} inside component, the field will be left as null. This is inconsistent behavior with what CDI spec and how the "real" Spring does it.
Wicket should change its behavior so that {{@Inject}} is always required. If the dependency is optional the user can use {{@SpringBean(required=false)}} as always.
diff --git a/wicket-spring/src/main/java/org/apache/wicket/spring/injection/annot/AnnotProxyFieldValueFactory.java b/wicket-spring/src/main/java/org/apache/wicket/spring/injection/annot/AnnotProxyFieldValueFactory.java
index 6b7d071..54d11de 100644
--- a/wicket-spring/src/main/java/org/apache/wicket/spring/injection/annot/AnnotProxyFieldValueFactory.java
+++ b/wicket-spring/src/main/java/org/apache/wicket/spring/injection/annot/AnnotProxyFieldValueFactory.java
@@ -68,6 +68,7 @@ import org.springframework.context.support.AbstractApplicationContext;
* @see LazyInitProxyFactory
* @see SpringBean
* @see SpringBeanLocator
+ * @see javax.inject.Inject
*
* @author Igor Vaynberg (ivaynberg)
* @author Istvan Devai
@@ -123,7 +124,7 @@ public class AnnotProxyFieldValueFactory implements IFieldValueFactory
{
Named named = field.getAnnotation(Named.class);
name = named != null ? named.value() : "";
- required = false;
+ required = true;
}
String beanName = getBeanName(field, name, required);
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5686_8e794fc4.diff |
bugs-dot-jar_data_WICKET-4520_ccb8fc9e | ---
BugID: WICKET-4520
Summary: Inline enclosure doesn't work if wicket:message attribute is used on the
same tag
Description: "Markup like:\n\n <div wicket:enclosure=\"child\" wicket:message=\"title:something\">\n\t
\ <div>Inner div\n\t\t <span wicket:id=\"child\">Blah</span>\n\t </div>\n
\ </div>\n\ndoesn't work (Inner div is visible, no matter whether 'child'
is visible or not) because the auto component created for wicket:message breaks
somehow wicket:enclosure.\n"
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/parser/filter/InlineEnclosureHandler.java b/wicket-core/src/main/java/org/apache/wicket/markup/parser/filter/InlineEnclosureHandler.java
index 06a193a..e059657 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/parser/filter/InlineEnclosureHandler.java
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/parser/filter/InlineEnclosureHandler.java
@@ -176,11 +176,7 @@ public final class InlineEnclosureHandler extends AbstractMarkupFilter
String inlineEnclosureChildId = getInlineEnclosureAttribute(tag);
if (Strings.isEmpty(inlineEnclosureChildId) == false)
{
- String id = tag.getId();
- if (id.equals(INLINE_ENCLOSURE_ID_PREFIX))
- {
- id = id + container.getPage().getAutoIndex();
- }
+ String id = tag.getId() + container.getPage().getAutoIndex();
// Yes, we handled the tag
return new InlineEnclosure(id, inlineEnclosureChildId);
}
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-4520_ccb8fc9e.diff |
bugs-dot-jar_data_WICKET-4292_9cb617ae | ---
BugID: WICKET-4292
Summary: MockHttpServletResponse.addCookie(Cookie) adds duplicate cookies
Description: |-
org.apache.wicket.protocol.http.mock.MockHttpServletResponse.addCookie(Cookie) makes a bad check whether the cookie to be added is already in the list of cookies.
Since javax.servlet.http.Cookie doesn't implement #equals() "cookies.remove(cookie)" wont remove the previous cookie because the identity is different.
According to http://www.ietf.org/rfc/rfc2109.txt, p.4.3.3 :
If a user agent receives a Set-Cookie response header whose NAME is
the same as a pre-existing cookie, and whose Domain and Path
attribute values exactly (string) match those of a pre-existing
cookie, the new cookie supersedes the old. However, if the Set-
Cookie has a value for Max-Age of zero, the (old and new) cookie is
discarded. Otherwise cookies accumulate until they expire (resources
permitting), at which time they are discarded.
I.e. the equality is on the name, path and domain.
diff --git a/wicket-core/src/main/java/org/apache/wicket/protocol/http/mock/MockHttpServletResponse.java b/wicket-core/src/main/java/org/apache/wicket/protocol/http/mock/MockHttpServletResponse.java
index eb8262a..01581ef 100755
--- a/wicket-core/src/main/java/org/apache/wicket/protocol/http/mock/MockHttpServletResponse.java
+++ b/wicket-core/src/main/java/org/apache/wicket/protocol/http/mock/MockHttpServletResponse.java
@@ -27,6 +27,7 @@ import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.GregorianCalendar;
+import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Set;
@@ -102,7 +103,18 @@ public class MockHttpServletResponse implements HttpServletResponse, IMetaDataBu
public void addCookie(final Cookie cookie)
{
// remove any potential duplicates
- cookies.remove(cookie);
+ // see http://www.ietf.org/rfc/rfc2109.txt, p.4.3.3
+ Iterator<Cookie> iterator = cookies.iterator();
+ while (iterator.hasNext())
+ {
+ Cookie old = iterator.next();
+ if (cookie.getName().equals(old.getName()) &&
+ ((cookie.getPath() == null && old.getPath() == null) || (cookie.getPath().equals(old.getPath()))) &&
+ ((cookie.getDomain() == null && old.getDomain() == null) || (cookie.getDomain().equals(old.getDomain()))))
+ {
+ iterator.remove();
+ }
+ }
cookies.add(cookie);
}
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-4292_9cb617ae.diff |
bugs-dot-jar_data_WICKET-4338_9decad35 | ---
BugID: WICKET-4338
Summary: POST params ignored by IPageParametersEncoder#decodePageParameters()
Description: |
As per this conversation: http://apache-wicket.1842946.n4.nabble.com/how-to-get-https-port-number-in-Wicket-1-5-td4295139.html
it seems that POST params are not properly processed and made available as PageParameters. Can anyone say whether this is intended behavior or not? I will attach a Quickstart to demonstrate.
Martin's proposed fix is straightforward, but I am not comfortable enough with Wicket internals to say whether or not this would break something.
Thanks
diff --git a/wicket-request/src/main/java/org/apache/wicket/request/mapper/parameter/PageParametersEncoder.java b/wicket-request/src/main/java/org/apache/wicket/request/mapper/parameter/PageParametersEncoder.java
index 2312995..5687a71 100644
--- a/wicket-request/src/main/java/org/apache/wicket/request/mapper/parameter/PageParametersEncoder.java
+++ b/wicket-request/src/main/java/org/apache/wicket/request/mapper/parameter/PageParametersEncoder.java
@@ -16,9 +16,13 @@
*/
package org.apache.wicket.request.mapper.parameter;
+import java.util.List;
+
+import org.apache.wicket.request.IRequestParameters;
import org.apache.wicket.request.Request;
import org.apache.wicket.request.Url;
import org.apache.wicket.request.Url.QueryParameter;
+import org.apache.wicket.util.string.StringValue;
/**
* Simple encoder with direct indexed/named parameters mapping.
@@ -47,10 +51,15 @@ public class PageParametersEncoder implements IPageParametersEncoder
parameters.set(i, s);
++i;
}
-
- for (QueryParameter p : request.getUrl().getQueryParameters())
+
+ IRequestParameters requestParameters = request.getRequestParameters();
+ for (String paramName : requestParameters.getParameterNames())
{
- parameters.add(p.getName(), p.getValue());
+ List<StringValue> parameterValues = requestParameters.getParameterValues(paramName);
+ for (StringValue paramValue : parameterValues)
+ {
+ parameters.add(paramName, paramValue);
+ }
}
return parameters.isEmpty() ? null : parameters;
diff --git a/wicket-request/src/main/java/org/apache/wicket/request/mapper/parameter/UrlPathPageParametersEncoder.java b/wicket-request/src/main/java/org/apache/wicket/request/mapper/parameter/UrlPathPageParametersEncoder.java
index db3ea51..f31f5c1 100644
--- a/wicket-request/src/main/java/org/apache/wicket/request/mapper/parameter/UrlPathPageParametersEncoder.java
+++ b/wicket-request/src/main/java/org/apache/wicket/request/mapper/parameter/UrlPathPageParametersEncoder.java
@@ -25,9 +25,12 @@ import org.apache.wicket.util.string.Strings;
/**
+ * <p>
* Encodes page parameters into Url path fragments instead of the query string like the default
* {@link PageParametersEncoder}. The parameters are encoded in the following format:
* {@code /param1Name/param1Value/param2Name/param2Value}.
+ * </p>
+ * <strong>Note</strong>: Because of the nature of the encoder it doesn't support POST request parameters.
* <p>
* This used to be the default way of encoding page parameters in 1.4.x applications. Newer 1.5.x+
* applications use the query string, by default. This class facilitates backwards compatibility and
diff --git a/wicket-request/src/main/java/org/apache/wicket/request/parameter/CombinedRequestParametersAdapter.java b/wicket-request/src/main/java/org/apache/wicket/request/parameter/CombinedRequestParametersAdapter.java
index e895f3b..b5792cc 100755
--- a/wicket-request/src/main/java/org/apache/wicket/request/parameter/CombinedRequestParametersAdapter.java
+++ b/wicket-request/src/main/java/org/apache/wicket/request/parameter/CombinedRequestParametersAdapter.java
@@ -19,10 +19,12 @@ package org.apache.wicket.request.parameter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
+import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import org.apache.wicket.request.IRequestParameters;
+import org.apache.wicket.util.lang.Args;
import org.apache.wicket.util.string.StringValue;
/**
@@ -41,11 +43,7 @@ public class CombinedRequestParametersAdapter implements IRequestParameters
*/
public CombinedRequestParametersAdapter(final IRequestParameters... parameters)
{
- if (parameters == null)
- {
- throw new IllegalStateException("Argument 'parameters' may not be null");
- }
- this.parameters = parameters;
+ this.parameters = Args.notNull(parameters, "parameters");
}
/**
@@ -53,7 +51,7 @@ public class CombinedRequestParametersAdapter implements IRequestParameters
*/
public Set<String> getParameterNames()
{
- Set<String> result = new HashSet<String>();
+ Set<String> result = new LinkedHashSet<String>();
for (IRequestParameters p : parameters)
{
result.addAll(p.getParameterNames());
diff --git a/wicket-request/src/main/java/org/apache/wicket/request/parameter/UrlRequestParametersAdapter.java b/wicket-request/src/main/java/org/apache/wicket/request/parameter/UrlRequestParametersAdapter.java
index d65d1d6..bbdd1da 100755
--- a/wicket-request/src/main/java/org/apache/wicket/request/parameter/UrlRequestParametersAdapter.java
+++ b/wicket-request/src/main/java/org/apache/wicket/request/parameter/UrlRequestParametersAdapter.java
@@ -18,7 +18,7 @@ package org.apache.wicket.request.parameter;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.HashSet;
+import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
@@ -55,7 +55,7 @@ public class UrlRequestParametersAdapter implements IRequestParameters
*/
public Set<String> getParameterNames()
{
- Set<String> result = new HashSet<String>();
+ Set<String> result = new LinkedHashSet<String>();
for (QueryParameter parameter : url.getQueryParameters())
{
result.add(parameter.getName());
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-4338_9decad35.diff |
bugs-dot-jar_data_WICKET-5784_b6259e5f | ---
BugID: WICKET-5784
Summary: arraycopy with bad length in AbstractRequestLogger:172
Description: "When clicking on DebugBar org.apache.wicket.devutils.inspector.LiveSessionsPage
NullPointerException is thrown.\nAfter investigating the reason I think AbstractRequestLogger:172
arraycopy params cause it. \n{{arraycopy(requestWindow, 0, copy, requestWindow.length
- oldestPos, indexInWindow);}}\nShould be changed to:\n{{arraycopy(requestWindow,
0, copy, requestWindow.length - oldestPos, oldestPos);}}"
diff --git a/wicket-core/src/main/java/org/apache/wicket/protocol/http/AbstractRequestLogger.java b/wicket-core/src/main/java/org/apache/wicket/protocol/http/AbstractRequestLogger.java
index d6a3287..34964d3 100644
--- a/wicket-core/src/main/java/org/apache/wicket/protocol/http/AbstractRequestLogger.java
+++ b/wicket-core/src/main/java/org/apache/wicket/protocol/http/AbstractRequestLogger.java
@@ -160,20 +160,17 @@ public abstract class AbstractRequestLogger implements IRequestLogger
*/
private void copyRequestsInOrder(RequestData[] copy)
{
+ int destPos = 0;
+
if (hasBufferRolledOver())
{
+ destPos = requestWindow.length - indexInWindow;
+
// first copy the oldest requests stored behind the cursor into the copy
- int oldestPos = indexInWindow + 1;
- if (oldestPos < requestWindow.length)
- arraycopy(requestWindow, oldestPos, copy, 0, requestWindow.length - oldestPos);
-
- // then append the newer requests stored from index 0 til the cursor position.
- arraycopy(requestWindow, 0, copy, requestWindow.length - oldestPos, indexInWindow);
- }
- else
- {
- arraycopy(requestWindow, 0, copy, 0, indexInWindow);
+ arraycopy(requestWindow, indexInWindow, copy, 0, destPos);
}
+
+ arraycopy(requestWindow, 0, copy, destPos, indexInWindow);
}
/**
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5784_b6259e5f.diff |
bugs-dot-jar_data_WICKET-5204_9e6efa61 | ---
BugID: WICKET-5204
Summary: The DateTimeField.onBeforeRender() method does not format the fields correctly.
Description: The current implementation relies on the org.joda.time.MutableDateTime
instance to format the date, hours, amOrPm, and minutes fields. Unfortunately, the
MutableDateTime constructor is not provided with the client's TimeZone value (assuming
it is set). As a result, the joda library uses the JVM's default timezone. If the
defaul timezone differs from the client's timezone, the formatted fields may turn
out to be incorrect.
diff --git a/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/DateTimeField.java b/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/DateTimeField.java
index 2534f48..13b9cb8 100644
--- a/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/DateTimeField.java
+++ b/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/DateTimeField.java
@@ -435,19 +435,15 @@ public class DateTimeField extends FormComponentPanel<Date>
}
else
{
- MutableDateTime mDate;
+ MutableDateTime mDate = new MutableDateTime(modelObject);
// convert date to the client's time zone if we have that info
TimeZone zone = getClientTimeZone();
if (zone != null)
{
- mDate = new MutableDateTime(modelObject, DateTimeZone.forTimeZone(zone));
- }
- else
- {
- mDate = new MutableDateTime(modelObject);
+ mDate.setZone(DateTimeZone.forTimeZone(zone));
}
- date = mDate.toDate();
+ date = mDate.toDateTime().toLocalDate().toDate();
if (use12HourFormat)
{
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5204_9e6efa61.diff |
bugs-dot-jar_data_WICKET-3333_ddf7e8a2 | ---
BugID: WICKET-3333
Summary: Links with multiple parameters are wrongly generated
Description: |-
If you have a PageParameters, with multiple params, then the resulting link will be something like this /url?id=123&sid=456, so for some reason the & sign is encoded to & which will result in the following parameters on the receiving page:
id=[123], amp;sid=[456]
See the attached quickstart for example.
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/link/Link.java b/wicket-core/src/main/java/org/apache/wicket/markup/html/link/Link.java
index f674c75..bc4b4f1 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/html/link/Link.java
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/link/Link.java
@@ -21,7 +21,6 @@ import org.apache.wicket.Page;
import org.apache.wicket.WicketRuntimeException;
import org.apache.wicket.markup.ComponentTag;
import org.apache.wicket.model.IModel;
-import org.apache.wicket.util.string.Strings;
/**
* Implementation of a hyperlink component. A link can be used with an anchor (<a href...)
@@ -368,7 +367,7 @@ public abstract class Link<T> extends AbstractLink implements ILinkListener
tag.getName().equalsIgnoreCase("area"))
{
// generate the href attribute
- tag.put("href", Strings.replaceAll(url, "&", "&"));
+ tag.put("href", url);
// Add any popup script
if (popupSettings != null)
@@ -381,7 +380,7 @@ public abstract class Link<T> extends AbstractLink implements ILinkListener
else if (tag.getName().equalsIgnoreCase("script") ||
tag.getName().equalsIgnoreCase("style"))
{
- tag.put("src", Strings.replaceAll(url, "&", "&"));
+ tag.put("src", url);
}
else
{
@@ -401,7 +400,8 @@ public abstract class Link<T> extends AbstractLink implements ILinkListener
"onclick",
"var win = this.ownerDocument.defaultView || this.ownerDocument.parentWindow; " +
"if (win == window) { window.location.href='" +
- Strings.replaceAll(url, "&", "&") + "'; } ;return false");
+ url +
+ "'; } ;return false");
}
}
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-3333_ddf7e8a2.diff |
bugs-dot-jar_data_WICKET-4658_ef3adb12 | ---
BugID: WICKET-4658
Summary: TabbedPanel CSS "last" is wrong if last step is not visible
Description: TabbedPanel renders a "last" CSS class for the last tab, this fails however
if the last tab is not visible.
diff --git a/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/tabs/TabbedPanel.java b/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/tabs/TabbedPanel.java
index 10be55d..f70ef2b 100644
--- a/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/tabs/TabbedPanel.java
+++ b/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/tabs/TabbedPanel.java
@@ -84,7 +84,7 @@ public class TabbedPanel<T extends ITab> extends Panel
/** the current tab */
private int currentTab = -1;
- private transient Boolean[] tabsVisibilityCache;
+ private transient VisibilityCache visibilityCache;
/**
* Constructor
@@ -204,9 +204,18 @@ public class TabbedPanel<T extends ITab> extends Panel
private static final long serialVersionUID = 1L;
@Override
+ protected void onConfigure()
+ {
+ super.onConfigure();
+
+ setVisible(getVisiblityCache().isVisible(tabIndex));
+ }
+
+ @Override
protected void onComponentTag(final ComponentTag tag)
{
super.onComponentTag(tag);
+
String cssClass = tag.getAttribute("class");
if (cssClass == null)
{
@@ -218,18 +227,12 @@ public class TabbedPanel<T extends ITab> extends Panel
{
cssClass += ' ' + getSelectedTabCssClass();
}
- if (getIndex() == getTabs().size() - 1)
+ if (getVisiblityCache().getLastVisible() == getIndex())
{
cssClass += ' ' + getLastTabCssClass();
}
tag.put("class", cssClass.trim());
}
-
- @Override
- public boolean isVisible()
- {
- return getTabs().get(tabIndex).isVisible();
- }
};
}
@@ -238,13 +241,13 @@ public class TabbedPanel<T extends ITab> extends Panel
{
int index = getSelectedTab();
- if ((index == -1) || (isTabVisible(index) == false))
+ if ((index == -1) || (getVisiblityCache().isVisible(index) == false))
{
// find first visible tab
index = -1;
for (int i = 0; i < tabs.size(); i++)
{
- if (isTabVisible(i))
+ if (getVisiblityCache().isVisible(i))
{
index = i;
break;
@@ -253,9 +256,7 @@ public class TabbedPanel<T extends ITab> extends Panel
if (index != -1)
{
- /*
- * found a visible tab, so select it
- */
+ // found a visible tab, so select it
setSelectedTab(index);
}
}
@@ -401,7 +402,7 @@ public class TabbedPanel<T extends ITab> extends Panel
final Component component;
- if (currentTab == -1 || (tabs.size() == 0) || !isTabVisible(currentTab))
+ if (currentTab == -1 || (tabs.size() == 0) || !getVisiblityCache().isVisible(currentTab))
{
// no tabs or the current tab is not visible
component = newPanel();
@@ -443,45 +444,84 @@ public class TabbedPanel<T extends ITab> extends Panel
return (Integer)getDefaultModelObject();
}
- /**
- *
- * @param tabIndex
- * @return visible
- */
- private boolean isTabVisible(final int tabIndex)
+ @Override
+ protected void onDetach()
+ {
+ visibilityCache = null;
+
+ super.onDetach();
+ }
+
+ private VisibilityCache getVisiblityCache()
{
- if (tabsVisibilityCache == null)
+ if (visibilityCache == null)
{
- tabsVisibilityCache = new Boolean[tabs.size()];
+ visibilityCache = new VisibilityCache();
}
- if (tabsVisibilityCache.length < tabIndex + 1)
+ return visibilityCache;
+ }
+
+ /**
+ * A cache for visibilities of {@link ITab}s.
+ */
+ private class VisibilityCache
+ {
+
+ /**
+ * Visibility for each tab.
+ */
+ private Boolean[] visibilities;
+
+ /**
+ * Last visible tab.
+ */
+ private int lastVisible = -1;
+
+ public VisibilityCache()
{
- Boolean[] resized = new Boolean[tabIndex + 1];
- System.arraycopy(tabsVisibilityCache, 0, resized, 0, tabsVisibilityCache.length);
- tabsVisibilityCache = resized;
+ visibilities = new Boolean[tabs.size()];
}
- if (tabsVisibilityCache.length > 0)
+ public int getLastVisible()
{
- Boolean visible = tabsVisibilityCache[tabIndex];
- if (visible == null)
+ if (lastVisible == -1)
{
- visible = tabs.get(tabIndex).isVisible();
- tabsVisibilityCache[tabIndex] = visible;
+ for (int t = 0; t < tabs.size(); t++)
+ {
+ if (isVisible(t))
+ {
+ lastVisible = t;
+ }
+ }
}
- return visible;
+
+ return lastVisible;
}
- else
+
+ public boolean isVisible(int index)
{
- return false;
- }
- }
+ if (visibilities.length < index + 1)
+ {
+ Boolean[] resized = new Boolean[index + 1];
+ System.arraycopy(visibilities, 0, resized, 0, visibilities.length);
+ visibilities = resized;
+ }
- @Override
- protected void onDetach()
- {
- tabsVisibilityCache = null;
- super.onDetach();
+ if (visibilities.length > 0)
+ {
+ Boolean visible = visibilities[index];
+ if (visible == null)
+ {
+ visible = tabs.get(index).isVisible();
+ visibilities[index] = visible;
+ }
+ return visible;
+ }
+ else
+ {
+ return false;
+ }
+ }
}
-}
+}
\ No newline at end of file
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-4658_ef3adb12.diff |
bugs-dot-jar_data_WICKET-4766_cda34428 | ---
BugID: WICKET-4766
Summary: multiple <style> tags in header are rendered incorrectly
Description: "I created a small quickstart. \nThe BasePage has some multiple <style>
tags. Only he first one is rendered correctly, all following render the tag body
only, the surrounding <style></style> is missing.\n"
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/internal/HtmlHeaderContainer.java b/wicket-core/src/main/java/org/apache/wicket/markup/html/internal/HtmlHeaderContainer.java
index dc5d080..42e63b6 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/html/internal/HtmlHeaderContainer.java
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/internal/HtmlHeaderContainer.java
@@ -30,12 +30,10 @@ import org.apache.wicket.markup.MarkupStream;
import org.apache.wicket.markup.WicketTag;
import org.apache.wicket.markup.head.IHeaderResponse;
import org.apache.wicket.markup.head.PageHeaderItem;
-import org.apache.wicket.markup.head.StringHeaderItem;
import org.apache.wicket.markup.head.internal.HeaderResponse;
import org.apache.wicket.markup.html.TransparentWebMarkupContainer;
import org.apache.wicket.markup.renderStrategy.AbstractHeaderRenderStrategy;
import org.apache.wicket.request.Response;
-import org.apache.wicket.request.cycle.RequestCycle;
import org.apache.wicket.response.StringResponse;
@@ -227,7 +225,7 @@ public class HtmlHeaderContainer extends TransparentWebMarkupContainer
CharSequence bodyOutput = getCleanResponse(bodyResponse);
if (bodyOutput.length() > 0)
{
- getHeaderResponse().render(StringHeaderItem.forString(bodyOutput));
+ getHeaderResponse().render(new PageHeaderItem(bodyOutput));
}
}
finally
@@ -354,32 +352,6 @@ public class HtmlHeaderContainer extends TransparentWebMarkupContainer
return headerResponse;
}
- /**
- * THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT USE IT.
- *
- * Temporarily replaces the response with a StringResponse to capture the header output for this
- * part of the stream and pass it to {@link IHeaderResponse}.
- *
- * @see org.apache.wicket.MarkupContainer#renderNext(org.apache.wicket.markup.MarkupStream)
- */
- @Override
- protected final boolean renderNext(MarkupStream markupStream)
- {
- StringResponse markupHeaderResponse = new StringResponse();
- Response oldResponse = getResponse();
- RequestCycle.get().setResponse(markupHeaderResponse);
- try
- {
- boolean ret = super.renderNext(markupStream);
- getHeaderResponse().render(new PageHeaderItem(markupHeaderResponse.getBuffer()));
- return ret;
- }
- finally
- {
- RequestCycle.get().setResponse(oldResponse);
- }
- }
-
@Override
public IMarkupFragment getMarkup()
{
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-4766_cda34428.diff |
bugs-dot-jar_data_WICKET-5578_5cdc1c8d | ---
BugID: WICKET-5578
Summary: Stateless/Statefull pages - incorrect behaviour
Description: |-
Please advise how to do in following situation or confirm that's a bug and should be fixed.
There is a page (login page) with stateless form. That page has lots of common components (menu and etc.). There are some stateful components in the components tree that are visible only for signed in users: but once user isn't signed in - that components are hidden. That's why page is becoming "stateless" (no visible components) and form prepared correspondingly. But when form data is submitted: during obtaining of form component to process request - wicket thinks that page actually is stateful. As a result - the page is recreated and fully rendered - instead of processing of the form.
There is a workaround: setStatelessHint(false). But imho reason is a little bit another:
1) After construction of page: page is stateful - because of some stateful components are in the tree.
2) After initialization of page: page is still stateful - because there are that stateful components
3) After configuration of page (method onConfigure) - page is becoming stateless - because all stateful components marked as invisible.
4) Form has been rendered as stateless - with no version number is in the URL.
5) Page can'be reconstructed correctly because of p.1 and p.2
I think that stateless flag should be precalculated right after initialization step and should be changed due to some stuff in "configuration" methods.
What do you think?
Will provide "quick start" in near future!
diff --git a/wicket-core/src/main/java/org/apache/wicket/Component.java b/wicket-core/src/main/java/org/apache/wicket/Component.java
index 9a72a11..c1d1826 100644
--- a/wicket-core/src/main/java/org/apache/wicket/Component.java
+++ b/wicket-core/src/main/java/org/apache/wicket/Component.java
@@ -4544,6 +4544,7 @@ public abstract class Component
@Override
public boolean canCallListenerInterfaceAfterExpiry()
{
- return getApplication().getPageSettings().getCallListenerInterfaceAfterExpiry();
+ return getApplication().getPageSettings()
+ .getCallListenerInterfaceAfterExpiry() || isStateless();
}
}
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5578_5cdc1c8d.diff |
bugs-dot-jar_data_WICKET-5981_eb125865 | ---
BugID: WICKET-5981
Summary: Significant Performance Degradation From Wicket 6.20.0 to Wicket 7.0.0
Description: "I am experiencing a significant performance degradation for component
adds in Wicket 7.0.0, once the component tree for a page gets reasonably large.\n\nThe
attached quick start can be used to reproduce the issue. Please note that NUM_ROWS
is set to 10,000 to exaggerate the performance degradation as the size of the component
tree increases. The same degradation (to a lesser extent) can be viewed with a
smaller NUM_ROWS variable.\n\nIn Wicket 6.20.0, as the size of the component tree
increases, the cost of add() remains relatively constant time-wise. In Wicket 7.0.0,
a component add () is much more expensive (and actually makes our internal web application
unusable) with form submits taking more than two or three minutes to come back from
the server.\n\nHere's some timing examples. \n\n=============================================================================================================\n\nNUM_ROWS
= 5000\nWicket 6.20.0 -> ~200 milliseconds of server side rendering (before browser
paints HTML).\nWicket 7.0.0 -> ~ 10 seconds of server side rendering\n\nNUM_ROWS
= 10000\nWicket 6.20.0 -> ~ 500 milliseconds of server side rendering\nWicket 7.0.0
-> ~ 40 seconds of server side rendering\n\n=============================================================================================================\n\nThe
attached quickstart can be used to reproduce the issue on your side. My guess is
that this has to do with the new component queuing feature that was added as part
of Wicket 7.0.0."
diff --git a/wicket-core/src/main/java/org/apache/wicket/MarkupContainer.java b/wicket-core/src/main/java/org/apache/wicket/MarkupContainer.java
index 7941203..b739d47 100644
--- a/wicket-core/src/main/java/org/apache/wicket/MarkupContainer.java
+++ b/wicket-core/src/main/java/org/apache/wicket/MarkupContainer.java
@@ -1016,15 +1016,17 @@ public abstract class MarkupContainer extends Component implements Iterable<Comp
@Deprecated
public final Component get(int index)
{
+ final int requestedIndex = index;
Component childAtIndex = null;
Iterator<Component> childIterator = iterator();
- while (index-- >= 0 && childIterator.hasNext())
+ while (index >= 0 && childIterator.hasNext())
{
childAtIndex = childIterator.next();
+ index--;
}
- if(childAtIndex == null)
+ if(index >= 0 || childAtIndex == null)
{
- throw new ArrayIndexOutOfBoundsException(Integer.toString(index));
+ throw new ArrayIndexOutOfBoundsException(Integer.toString(requestedIndex));
}
return childAtIndex;
}
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5981_eb125865.diff |
bugs-dot-jar_data_WICKET-3563_c62b66c1 | ---
BugID: WICKET-3563
Summary: Interaction betwen IAjaxRegionMarkupIdProvider, renderPlaceholderTag and
visibility
Description: "I've just discovered what I think is a bug with\nIAjaxRegionMarkupIdProvider.
We are using it on a Behavior that provides\na border to form components (label,
mandatory marker, etc), which for\nthe most part works great.\n\nWe have encountered
a problem when toggling the visibility of a form\ncomponent with this behavior via
ajax. \n\nThe component is first sent out visible and the markup is all correct.\n\nA
change elsewhere on the page causes the component to be set to not\nvisible and
redrawn via ajax. The ajax response contains a tag with a\nmarkupid generated via
renderPlaceholderTag. This does not take into\naccount the IAjaxRegionMarkupIdProvider
behaviour.\n\nAnother change happens on the page causing the component to become\nvisible,
and the ajax replace can't happen because the component with\nthe correct markupId
is not present.\n"
diff --git a/wicket-core/src/main/java/org/apache/wicket/Component.java b/wicket-core/src/main/java/org/apache/wicket/Component.java
index 238b278..6644c24 100644
--- a/wicket-core/src/main/java/org/apache/wicket/Component.java
+++ b/wicket-core/src/main/java/org/apache/wicket/Component.java
@@ -23,6 +23,7 @@ import java.util.List;
import java.util.Locale;
import java.util.Stack;
+import org.apache.wicket.ajax.IAjaxRegionMarkupIdProvider;
import org.apache.wicket.authorization.Action;
import org.apache.wicket.authorization.AuthorizationException;
import org.apache.wicket.authorization.IAuthorizationStrategy;
@@ -2463,7 +2464,7 @@ public abstract class Component
}
response.write(tag.getName());
response.write(" id=\"");
- response.write(getMarkupId());
+ response.write(getAjaxRegionMarkupId());
response.write("\" style=\"display:none\"></");
if (ns != null)
{
@@ -2473,6 +2474,39 @@ public abstract class Component
response.write(">");
}
+
+ /**
+ * Returns the id of the markup region that will be updated via ajax. This can be different to
+ * the markup id of the component if a {@link IAjaxRegionMarkupIdProvider} behavior has been
+ * added.
+ *
+ * @return the markup id of the region to be updated via ajax.
+ */
+ public final String getAjaxRegionMarkupId()
+ {
+ String markupId = null;
+ for (Behavior behavior : getBehaviors())
+ {
+ if (behavior instanceof IAjaxRegionMarkupIdProvider)
+ {
+ markupId = ((IAjaxRegionMarkupIdProvider)behavior).getAjaxRegionMarkupId(this);
+ }
+ }
+ if (markupId == null)
+ {
+ if (this instanceof IAjaxRegionMarkupIdProvider)
+ {
+ markupId = ((IAjaxRegionMarkupIdProvider)this).getAjaxRegionMarkupId(this);
+ }
+ }
+ if (markupId == null)
+ {
+ markupId = getMarkupId();
+ }
+ return markupId;
+ }
+
+
/**
* THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT USE IT.
* <p>
diff --git a/wicket-core/src/main/java/org/apache/wicket/ajax/AjaxRequestTarget.java b/wicket-core/src/main/java/org/apache/wicket/ajax/AjaxRequestTarget.java
index f6ff1ad..7b2467e 100644
--- a/wicket-core/src/main/java/org/apache/wicket/ajax/AjaxRequestTarget.java
+++ b/wicket-core/src/main/java/org/apache/wicket/ajax/AjaxRequestTarget.java
@@ -31,7 +31,6 @@ import org.apache.wicket.Application;
import org.apache.wicket.Component;
import org.apache.wicket.MarkupContainer;
import org.apache.wicket.Page;
-import org.apache.wicket.behavior.Behavior;
import org.apache.wicket.event.Broadcast;
import org.apache.wicket.markup.html.IHeaderResponse;
import org.apache.wicket.markup.html.internal.HeaderResponse;
@@ -753,7 +752,7 @@ public class AjaxRequestTarget implements IPageRequestHandler
if (!containsAncestorFor(component))
{
- respondComponent(response, getAjaxRegionMarkupId(component), component);
+ respondComponent(response, component.getAjaxRegionMarkupId(), component);
}
}
@@ -803,30 +802,6 @@ public class AjaxRequestTarget implements IPageRequestHandler
}
}
- private String getAjaxRegionMarkupId(Component component)
- {
- String markupId = null;
- for (Behavior behavior : component.getBehaviors())
- {
- if (behavior instanceof IAjaxRegionMarkupIdProvider)
- {
- markupId = ((IAjaxRegionMarkupIdProvider)behavior).getAjaxRegionMarkupId(component);
- }
- }
- if (markupId == null)
- {
- if (component instanceof IAjaxRegionMarkupIdProvider)
- {
- markupId = ((IAjaxRegionMarkupIdProvider)component).getAjaxRegionMarkupId(component);
- }
- }
- if (markupId == null)
- {
- markupId = component.getMarkupId();
- }
- return markupId;
- }
-
/**
* Checks if the target contains an ancestor for the given component
*
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-3563_c62b66c1.diff |
bugs-dot-jar_data_WICKET-5251_6ce34ccf | ---
BugID: WICKET-5251
Summary: Minified name resolves incorrectly if default resource reference is used
Description: "In PackageResourceReference.\n\nWhen a default reference to a minified
resource is used (i.e. the resource wasn't mounted) the resource reference name
includes '.min'. \n\nWhen trying to resolve the minified name, another '.min' is
appended, resulting in the minified name resolving to 'html5.min.min.js'. \n\nAs
a result, the PackageResourceReference concludes that the resource was not minified,
and adds compression."
diff --git a/wicket-core/src/main/java/org/apache/wicket/request/resource/PackageResourceReference.java b/wicket-core/src/main/java/org/apache/wicket/request/resource/PackageResourceReference.java
index cc72731..710eef2 100644
--- a/wicket-core/src/main/java/org/apache/wicket/request/resource/PackageResourceReference.java
+++ b/wicket-core/src/main/java/org/apache/wicket/request/resource/PackageResourceReference.java
@@ -207,7 +207,14 @@ public class PackageResourceReference extends ResourceReference
if (idxOfExtension > -1)
{
String extension = name.substring(idxOfExtension);
- minifiedName = name.substring(0, name.length() - extension.length() + 1) + "min" + extension;
+ final String baseName = name.substring(0, name.length() - extension.length() + 1);
+ if (!".min".equals(extension) && !baseName.endsWith(".min."))
+ {
+ minifiedName = baseName + "min" + extension;
+ } else
+ {
+ minifiedName = name;
+ }
} else
{
minifiedName = name + ".min";
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5251_6ce34ccf.diff |
bugs-dot-jar_data_WICKET-5770_cf6172bd | ---
BugID: WICKET-5770
Summary: PageParametersEncoder should not decode parameters with no name
Description: |-
From dev@ mailing list: http://markmail.org/message/khuc2v37aakzyfth
PageParametersEncoder should ignore query parameters like "&=&" and "&=value" because they make no sene and lead to exceptions later at PageParameters#add() call.
diff --git a/wicket-request/src/main/java/org/apache/wicket/request/mapper/parameter/PageParametersEncoder.java b/wicket-request/src/main/java/org/apache/wicket/request/mapper/parameter/PageParametersEncoder.java
index 13e45ec..aa095de 100644
--- a/wicket-request/src/main/java/org/apache/wicket/request/mapper/parameter/PageParametersEncoder.java
+++ b/wicket-request/src/main/java/org/apache/wicket/request/mapper/parameter/PageParametersEncoder.java
@@ -18,6 +18,7 @@ package org.apache.wicket.request.mapper.parameter;
import org.apache.wicket.request.Url;
import org.apache.wicket.request.Url.QueryParameter;
+import org.apache.wicket.util.string.Strings;
/**
* Simple encoder with direct indexed/named parameters mapping.
@@ -47,7 +48,11 @@ public class PageParametersEncoder implements IPageParametersEncoder
for (QueryParameter p : url.getQueryParameters())
{
- parameters.add(p.getName(), p.getValue(), INamedParameters.Type.QUERY_STRING);
+ String parameterName = p.getName();
+ if (Strings.isEmpty(parameterName) == false)
+ {
+ parameters.add(parameterName, p.getValue(), INamedParameters.Type.QUERY_STRING);
+ }
}
return parameters.isEmpty() ? null : parameters;
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5770_cf6172bd.diff |
bugs-dot-jar_data_WICKET-4659_ccd74641 | ---
BugID: WICKET-4659
Summary: The default exception mapper is replying cacheable exceptional responses
Description: The problem is that some common URLs in the application like to a page
instance are responding the cached exception page rather than hitting the server
for the page instance being requested. It happens because at some moment in the
past a exception page were replied and cached for a request in this URL.
diff --git a/wicket-core/src/main/java/org/apache/wicket/DefaultExceptionMapper.java b/wicket-core/src/main/java/org/apache/wicket/DefaultExceptionMapper.java
index 1a787ea..eea361d 100644
--- a/wicket-core/src/main/java/org/apache/wicket/DefaultExceptionMapper.java
+++ b/wicket-core/src/main/java/org/apache/wicket/DefaultExceptionMapper.java
@@ -17,21 +17,23 @@
package org.apache.wicket;
import org.apache.wicket.authorization.AuthorizationException;
+import org.apache.wicket.core.request.handler.IPageRequestHandler;
+import org.apache.wicket.core.request.handler.ListenerInvocationNotAllowedException;
+import org.apache.wicket.core.request.handler.PageProvider;
+import org.apache.wicket.core.request.handler.RenderPageRequestHandler;
+import org.apache.wicket.core.request.mapper.StalePageException;
import org.apache.wicket.markup.html.pages.ExceptionErrorPage;
import org.apache.wicket.protocol.http.PageExpiredException;
import org.apache.wicket.protocol.http.servlet.ResponseIOException;
import org.apache.wicket.request.IExceptionMapper;
import org.apache.wicket.request.IRequestHandler;
import org.apache.wicket.request.Request;
+import org.apache.wicket.request.Response;
import org.apache.wicket.request.cycle.RequestCycle;
import org.apache.wicket.request.handler.EmptyRequestHandler;
-import org.apache.wicket.core.request.handler.IPageRequestHandler;
-import org.apache.wicket.core.request.handler.ListenerInvocationNotAllowedException;
-import org.apache.wicket.core.request.handler.PageProvider;
-import org.apache.wicket.core.request.handler.RenderPageRequestHandler;
import org.apache.wicket.request.http.WebRequest;
+import org.apache.wicket.request.http.WebResponse;
import org.apache.wicket.request.http.handler.ErrorCodeRequestHandler;
-import org.apache.wicket.core.request.mapper.StalePageException;
import org.apache.wicket.settings.IExceptionSettings;
import org.apache.wicket.settings.IExceptionSettings.UnexpectedExceptionDisplay;
import org.slf4j.Logger;
@@ -51,6 +53,12 @@ public class DefaultExceptionMapper implements IExceptionMapper
{
try
{
+ Response response = RequestCycle.get().getResponse();
+ if (response instanceof WebResponse)
+ {
+ // we don't wan't to cache an exceptional reply in the browser
+ ((WebResponse)response).disableCaching();
+ }
return internalMap(e);
}
catch (RuntimeException e2)
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-4659_ccd74641.diff |
bugs-dot-jar_data_WICKET-2621_c849f986 | ---
BugID: WICKET-2621
Summary: Ajax buttons inside ModalWindows don't submit properly
Description: "I have a ModalWindow that contains an IndicatingAjaxButton. When I click
the button, I get a big Java error complaining that the form submit wasn't multipart.\n\nDigging
into the javascript in wicket-ajax.js, I found this from line 1102 in the method
handleMultipart\n\n{code}\nmultipart=multipart||form.enctype==\"multipart/form-data\";\n\nif
(multipart==false) {\n // nothing to handle\n return false;\n }\n{code}\n\nWhen
this executed, multipart was false, and enctype was \"\" and therefore the submit
aborted. This may be the cause.\n\nHere's the Java stacktrace\n\n{noformat}\njava.lang.IllegalStateException:
ServletRequest does not contain multipart content\n\tat org.apache.wicket.protocol.http.servlet.MultipartServletWebRequest.<init>(MultipartServletWebRequest.java:113)\n\tat
org.apache.wicket.protocol.http.servlet.MultipartServletWebRequest.<init>(MultipartServletWebRequest.java:83)\n\tat
org.apache.wicket.extensions.ajax.markup.html.form.upload.MultipartRequest.<init>(MultipartRequest.java:41)\n\tat
org.apache.wicket.extensions.ajax.markup.html.form.upload.UploadWebRequest.newMultipartWebRequest(UploadWebRequest.java:66)\n\tat
org.apache.wicket.markup.html.form.Form.handleMultiPart(Form.java:1651)\n\tat org.apache.wicket.markup.html.form.Form.onFormSubmitted(Form.java:850)\n\tat
org.apache.wicket.ajax.form.AjaxFormSubmitBehavior.onEvent(AjaxFormSubmitBehavior.java:135)\n\tat
org.apache.wicket.ajax.AjaxEventBehavior.respond(AjaxEventBehavior.java:177)\n\tat
org.apache.wicket.ajax.AbstractDefaultAjaxBehavior.onRequest(AbstractDefaultAjaxBehavior.java:299)\n\tat
org.apache.wicket.request.target.component.listener.BehaviorRequestTarget.processEvents(BehaviorRequestTarget.java:119)\n\tat
org.apache.wicket.request.AbstractRequestCycleProcessor.processEvents(AbstractRequestCycleProcessor.java:92)\n\tat
org.apache.wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:1250)\n\tat
org.apache.wicket.RequestCycle.step(RequestCycle.java:1329)\n\tat org.apache.wicket.RequestCycle.steps(RequestCycle.java:1428)\n\tat
org.apache.wicket.RequestCycle.request(RequestCycle.java:545)\n\tat org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:479)\n\tat
org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:312)\n\tat
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)\n{noformat}"
diff --git a/wicket/src/main/java/org/apache/wicket/markup/html/form/Form.java b/wicket/src/main/java/org/apache/wicket/markup/html/form/Form.java
index a5d3b39..806e3a5 100644
--- a/wicket/src/main/java/org/apache/wicket/markup/html/form/Form.java
+++ b/wicket/src/main/java/org/apache/wicket/markup/html/form/Form.java
@@ -376,7 +376,10 @@ public class Form<T> extends WebMarkupContainer implements IFormSubmitListener,
private Bytes maxSize = null;
/** True if the form has enctype of multipart/form-data */
- private boolean multiPart = false;
+ private short multiPart = 0;
+
+ private static short MULTIPART_HARD = 0x01;
+ private static short MULTIPART_HINT = 0x02;
/**
* Constructs a form with no validation.
@@ -1051,7 +1054,14 @@ public class Form<T> extends WebMarkupContainer implements IFormSubmitListener,
*/
public void setMultiPart(boolean multiPart)
{
- this.multiPart = multiPart;
+ if (multiPart)
+ {
+ this.multiPart |= MULTIPART_HARD;
+ }
+ else
+ {
+ this.multiPart &= ~MULTIPART_HARD;
+ }
}
/**
@@ -1399,7 +1409,7 @@ public class Form<T> extends WebMarkupContainer implements IFormSubmitListener,
private boolean isMultiPart()
{
- if (multiPart)
+ if (multiPart != 0)
{
return true;
}
@@ -1411,7 +1421,7 @@ public class Form<T> extends WebMarkupContainer implements IFormSubmitListener,
public Object component(Form<?> form)
{
- if (form.multiPart)
+ if (form.multiPart != 0)
{
anyEmbeddedMultipart[0] = true;
return STOP_TRAVERSAL;
@@ -1788,6 +1798,9 @@ public class Form<T> extends WebMarkupContainer implements IFormSubmitListener,
@Override
protected void onRender()
{
+ // clear multipart hint, it will be set if necessary by the visitor
+ this.multiPart &= ~MULTIPART_HINT;
+
// Force multi-part on if any child form component is multi-part
visitFormComponents(new FormComponent.AbstractVisitor()
{
@@ -1796,7 +1809,7 @@ public class Form<T> extends WebMarkupContainer implements IFormSubmitListener,
{
if (formComponent.isVisible() && formComponent.isMultiPart())
{
- setMultiPart(true);
+ multiPart |= MULTIPART_HINT;
}
}
});
diff --git a/wicket/src/main/java/org/apache/wicket/markup/html/form/upload/MultiFileUploadField.java b/wicket/src/main/java/org/apache/wicket/markup/html/form/upload/MultiFileUploadField.java
index ef2b286..9b49e7a 100644
--- a/wicket/src/main/java/org/apache/wicket/markup/html/form/upload/MultiFileUploadField.java
+++ b/wicket/src/main/java/org/apache/wicket/markup/html/form/upload/MultiFileUploadField.java
@@ -193,9 +193,13 @@ public class MultiFileUploadField extends FormComponentPanel<Collection<FileUplo
throw new IllegalStateException("Component " + getClass().getName() + " must have a " +
Form.class.getName() + " component above in the hierarchy");
}
- form.setMultiPart(true);
}
+ @Override
+ public boolean isMultiPart()
+ {
+ return true;
+ }
/**
* @see org.apache.wicket.markup.html.IHeaderContributor#renderHead(org.apache.wicket.markup.html.IHeaderResponse)
diff --git a/wicket/src/main/java/org/apache/wicket/protocol/http/servlet/MultipartServletWebRequest.java b/wicket/src/main/java/org/apache/wicket/protocol/http/servlet/MultipartServletWebRequest.java
index 6c95e95..b4ce08b 100644
--- a/wicket/src/main/java/org/apache/wicket/protocol/http/servlet/MultipartServletWebRequest.java
+++ b/wicket/src/main/java/org/apache/wicket/protocol/http/servlet/MultipartServletWebRequest.java
@@ -110,7 +110,8 @@ public class MultipartServletWebRequest extends ServletWebRequest implements IMu
final boolean isMultipart = ServletFileUpload.isMultipartContent(request);
if (!isMultipart)
{
- throw new IllegalStateException("ServletRequest does not contain multipart content");
+ throw new IllegalStateException(
+ "ServletRequest does not contain multipart content. One possible solution is to explicitly call Form.setMultipart(true), Wicket tries its best to auto-detect multipart forms but there are certain situation where it cannot.");
}
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-2621_c849f986.diff |
bugs-dot-jar_data_WICKET-5891_2d9ebf9a | ---
BugID: WICKET-5891
Summary: Parsing of ChinUnionPay credit card should use the first 6 characters
Description: "User report:\n\nA China UnionPay number has to start with 622 (622126-622925)
and has to have a length between 16 and 19. The source code of CreditCardValidator
is:\n\n 220 \tprivate boolean isChinaUnionPay(String creditCardNumber)\n 221
\ \t{\n 222 \t\tcardId = CreditCardValidator.INVALID;\n 223 \t\tboolean returnValue
= false;\n 224 \n 225 \t\tif ((creditCardNumber.length() >= 16 && creditCardNumber.length()
<= 19) &&\n 226 \t\t\t(creditCardNumber.startsWith(\"622\")))\n 227 \t\t{\n
\ 228 \t\t\tint firstDigits = Integer.parseInt(creditCardNumber.substring(0, 5));\n
\ 229 \t\t\tif (firstDigits >= 622126 && firstDigits <= 622925)\n 230 \t\t\t{\n
\ 231 \t\t\t\tcardId = CreditCardValidator.CHINA_UNIONPAY;\n 232 \t\t\t\treturnValue
= true;\n 233 \t\t\t}\n 234 \t\t}\n 235 \n 236 \t\treturn returnValue;\n
\ 237 \t}\nThe problem is on the line 228 because the substring returns the first
5 digits and it is compared to 6 digits, so \"firstDigits\" is always < than 622126.
The fix is to do #substring(0, 6)."
diff --git a/wicket-core/src/main/java/org/apache/wicket/validation/validator/CreditCardValidator.java b/wicket-core/src/main/java/org/apache/wicket/validation/validator/CreditCardValidator.java
index 28225c2..eeff47b 100644
--- a/wicket-core/src/main/java/org/apache/wicket/validation/validator/CreditCardValidator.java
+++ b/wicket-core/src/main/java/org/apache/wicket/validation/validator/CreditCardValidator.java
@@ -322,7 +322,7 @@ public class CreditCardValidator implements IValidator<String>
if ((creditCardNumber.length() >= 16 && creditCardNumber.length() <= 19) &&
(creditCardNumber.startsWith("622")))
{
- int firstDigits = Integer.parseInt(creditCardNumber.substring(0, 5));
+ int firstDigits = Integer.parseInt(creditCardNumber.substring(0, 6));
if (firstDigits >= 622126 && firstDigits <= 622925)
{
return CreditCard.CHINA_UNIONPAY;
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5891_2d9ebf9a.diff |
bugs-dot-jar_data_WICKET-5082_217fbb3b | ---
BugID: WICKET-5082
Summary: Ajax update renders parent/child JS in different order than initial Page
render
Description: |-
See attached quickstart. On initial page load, the child Javascripts are rendered and executed first, followed by the parent's JS - in this case a Datatables.net JS. Everything works fine.
However, if you click on a link in the DefaultDataTable, we trigger a DDT refresh via Ajax, and then you can see that the parent's JS is executed first, before the child JS - this causes a problem since the parent JS modifies the visible rows in the table and Wicket can no longer find some of the child rows.
I expected the order of JS contributions to be the same for initial page render and any Ajax updates.
diff --git a/wicket-core/src/main/java/org/apache/wicket/ajax/AbstractAjaxResponse.java b/wicket-core/src/main/java/org/apache/wicket/ajax/AbstractAjaxResponse.java
index 80624bf..1e3cd1a 100644
--- a/wicket-core/src/main/java/org/apache/wicket/ajax/AbstractAjaxResponse.java
+++ b/wicket-core/src/main/java/org/apache/wicket/ajax/AbstractAjaxResponse.java
@@ -25,7 +25,6 @@ import java.util.List;
import java.util.Map;
import org.apache.wicket.Component;
-import org.apache.wicket.MarkupContainer;
import org.apache.wicket.Page;
import org.apache.wicket.markup.head.HeaderItem;
import org.apache.wicket.markup.head.IHeaderResponse;
@@ -34,6 +33,8 @@ import org.apache.wicket.markup.head.OnLoadHeaderItem;
import org.apache.wicket.markup.head.internal.HeaderResponse;
import org.apache.wicket.markup.html.internal.HtmlHeaderContainer;
import org.apache.wicket.markup.parser.filter.HtmlHeaderSectionHandler;
+import org.apache.wicket.markup.renderStrategy.AbstractHeaderRenderStrategy;
+import org.apache.wicket.markup.renderStrategy.IHeaderRenderStrategy;
import org.apache.wicket.markup.repeater.AbstractRepeater;
import org.apache.wicket.request.IRequestCycle;
import org.apache.wicket.request.Response;
@@ -44,8 +45,6 @@ import org.apache.wicket.util.lang.Classes;
import org.apache.wicket.util.lang.Generics;
import org.apache.wicket.util.string.AppendingStringBuffer;
import org.apache.wicket.util.string.Strings;
-import org.apache.wicket.util.visit.IVisit;
-import org.apache.wicket.util.visit.IVisitor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -460,28 +459,9 @@ public abstract class AbstractAjaxResponse
try {
encodingHeaderResponse.reset();
- // render the head of component and all it's children
+ IHeaderRenderStrategy strategy = AbstractHeaderRenderStrategy.get();
- component.renderHead(header);
-
- if (component instanceof MarkupContainer)
- {
- ((MarkupContainer)component).visitChildren(new IVisitor<Component, Void>()
- {
- @Override
- public void component(final Component component, final IVisit<Void> visit)
- {
- if (component.isVisibleInHierarchy())
- {
- component.renderHead(header);
- }
- else
- {
- visit.dontGoDeeper();
- }
- }
- });
- }
+ strategy.renderHeader(header, null, component);
} finally {
// revert to old response
requestCycle.setResponse(oldResponse);
diff --git a/wicket-core/src/main/java/org/apache/wicket/ajax/AjaxEventBehavior.java b/wicket-core/src/main/java/org/apache/wicket/ajax/AjaxEventBehavior.java
index 8998cb5..0cee432 100644
--- a/wicket-core/src/main/java/org/apache/wicket/ajax/AjaxEventBehavior.java
+++ b/wicket-core/src/main/java/org/apache/wicket/ajax/AjaxEventBehavior.java
@@ -82,15 +82,7 @@ public abstract class AjaxEventBehavior extends AbstractDefaultAjaxBehavior
{
CharSequence js = getCallbackScript(component);
- AjaxRequestTarget target = component.getRequestCycle().find(AjaxRequestTarget.class);
- if (target == null)
- {
- response.render(OnDomReadyHeaderItem.forScript(js.toString()));
- }
- else
- {
- target.appendJavaScript(js);
- }
+ response.render(OnDomReadyHeaderItem.forScript(js.toString()));
}
}
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5082_217fbb3b.diff |
bugs-dot-jar_data_WICKET-5043_2b1ce91d | ---
BugID: WICKET-5043
Summary: Page not mounted with WebApplication#mountPackage
Description: |-
A bookmarkable page FormPage is mounted via WebApplication#mountPackage().
If this page is opened via IModel model; setResponsePage(new FormPage(IModel model)); then the URL is /wicket/page?0 which is not mounted.
If the page is mounted via WebApplication#mountPage() then the URL is mounted as expected.
If the page is not mounted then the users get PageExpiredException which in this case is unrecoverable.
diff --git a/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/PackageMapper.java b/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/PackageMapper.java
index 54729e9..63e5914 100644
--- a/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/PackageMapper.java
+++ b/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/PackageMapper.java
@@ -216,7 +216,7 @@ public class PackageMapper extends AbstractBookmarkableMapper
@Override
protected boolean pageMustHaveBeenCreatedBookmarkable()
{
- return true;
+ return false;
}
/**
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5043_2b1ce91d.diff |
bugs-dot-jar_data_WICKET-5466_c1c1f794 | ---
BugID: WICKET-5466
Summary: ListenerInterfaceRequestHandler#respond throws ComponentNotFoundException
as a side-effect
Description: "The following exception occurs instead of a generic WicketRuntimeException:\n\n16:27:56.181
WARN (RequestCycle.java:343) Handling the following exception [qtp9826071-207]\norg.apache.wicket.core.request.handler.ComponentNotFoundException:
Could not find component 'xyz' on page 'class MyPage’\n at org.apache.wicket.core.request.handler.PageAndComponentProvider.getComponent(PageAndComponentProvider.java:182)
~[org.apache.wicket.core_6.12.0.jar:6.12.0]\n at org.apache.wicket.core.request.handler.ListenerInterfaceRequestHandler.getComponent(ListenerInterfaceRequestHandler.java:90)
~[org.apache.wicket.core_6.12.0.jar:6.12.0]\n at org.apache.wicket.core.request.handler.ListenerInterfaceRequestHandler.respond(ListenerInterfaceRequestHandler.java:231)
~[org.apache.wicket.core_6.12.0.jar:6.12.0]\n at org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:861)
~[org.apache.wicket.core_6.12.0.jar:6.12.0]\n at org.apache.wicket.request.RequestHandlerStack.execute(RequestHandlerStack.java:64)
~[org.apache.wicket.request_6.12.0.jar:6.12.0]\n at org.apache.wicket.request.cycle.RequestCycle.execute(RequestCycle.java:261)
[org.apache.wicket.core_6.12.0.jar:6.12.0]\n at org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:218)
[org.apache.wicket.core_6.12.0.jar:6.12.0]\n at org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:289)
[org.apache.wicket.core_6.12.0.jar:6.12.0]\n at org.apache.wicket.protocol.http.WicketFilter.processRequestCycle(WicketFilter.java:259)
[org.apache.wicket.core_6.12.0.jar:6.12.0]\n\nin fact, this is a side effect, if
you look at the code:\n\n @Override\n public void respond(final IRequestCycle
requestCycle)\n {\n final IRequestablePage page = getPage();\n
\ final boolean freshPage = pageComponentProvider.isPageInstanceFresh();\n
\ final boolean isAjax = ((WebRequest)requestCycle.getRequest()).isAjax();\n
\ IRequestableComponent component = null;\n try\n {\n
\ component = getComponent();\n }\n catch
(ComponentNotFoundException e)\n {\n // either the
page is stateless and the component we are looking for is not added in the\n //
constructor\n // or the page is stateful+stale and a new instances
was created by pageprovider\n // we denote this by setting component
to null\n component = null;\n }\n if
((component == null && freshPage) ||\n\n (component != null &&
getComponent().getPage() == page))\n\n {\n [....]\n }\n\n
\ else\n\n {\n\n throw new WicketRuntimeException(\"Component
\" + getComponent() +\n\n \" has been removed from page.\");\n\n
\ }\n\n }\n\nYou see that getComponent() is called twice.\n\n1)
Once guarded by a catch \n - and -\n2) once unguarded\n\nSo if the component can't
be found AND freshPage is false, as a sideeffect instead of the WicketRuntimeException
with the removed message a componentnotfound exception is raised as a side effect.\n\nI
see two possible solutions for this\n\na) either it is intentional that a ComponentNotFoundException
is thrown, then it should be thrown from the catch block like\n\n catch
(ComponentNotFoundException e)\n {\n if (!freshPage)
{\n throw e;\n }\n }\n\nb)
if it is unintentionall in the else case ther should be a simple check like this\n\n
if (component == null) {\n throw new WicketRuntimeException(\"Component
for path \" + getPath() +\n \" and page \"+page.getClass().getName()+\"
has been removed from page.\");\n } else {\n throw
new WicketRuntimeException(\"Component \" + component +\n \"
has been removed from page.\");\n }\n\n\nBeside this: it would
be a good idea to mention at least the page class in either case.\n"
diff --git a/wicket-core/src/main/java/org/apache/wicket/core/request/handler/ListenerInterfaceRequestHandler.java b/wicket-core/src/main/java/org/apache/wicket/core/request/handler/ListenerInterfaceRequestHandler.java
index 84592d7..1e24206 100644
--- a/wicket-core/src/main/java/org/apache/wicket/core/request/handler/ListenerInterfaceRequestHandler.java
+++ b/wicket-core/src/main/java/org/apache/wicket/core/request/handler/ListenerInterfaceRequestHandler.java
@@ -172,65 +172,62 @@ public class ListenerInterfaceRequestHandler
component = null;
}
- if ((component == null && freshPage) ||
- (component != null && getComponent().getPage() == page))
+ if ((component == null && !freshPage) || (component != null && component.getPage() != page))
{
- if (page instanceof Page)
- {
- // initialize the page to be able to check whether it is stateless
- ((Page)page).internalInitialize();
- }
- final boolean isStateless = page.isPageStateless();
+ throw new WicketRuntimeException("Component '" + getComponentPath()
+ + "' has been removed from page.");
+ }
- RedirectPolicy policy = isStateless ? RedirectPolicy.NEVER_REDIRECT
- : RedirectPolicy.AUTO_REDIRECT;
- final IPageProvider pageProvider = new PageProvider(page);
+ if (page instanceof Page)
+ {
+ // initialize the page to be able to check whether it is stateless
+ ((Page)page).internalInitialize();
+ }
+ final boolean isStateless = page.isPageStateless();
+
+ RedirectPolicy policy = isStateless
+ ? RedirectPolicy.NEVER_REDIRECT
+ : RedirectPolicy.AUTO_REDIRECT;
+ final IPageProvider pageProvider = new PageProvider(page);
- if (freshPage && (isStateless == false || component == null))
+ if (freshPage && (isStateless == false || component == null))
+ {
+ // A listener interface is invoked on an expired page.
+
+ // If the page is stateful then we cannot assume that the listener interface is
+ // invoked on its initial state (right after page initialization) and that its
+ // component and/or behavior will be available. That's why the listener interface
+ // should be ignored and the best we can do is to re-paint the newly constructed
+ // page.
+
+ if (LOG.isDebugEnabled())
{
- // A listener interface is invoked on an expired page.
-
- // If the page is stateful then we cannot assume that the listener interface is
- // invoked on its initial state (right after page initialization) and that its
- // component and/or behavior will be available. That's why the listener interface
- // should be ignored and the best we can do is to re-paint the newly constructed
- // page.
-
- if (LOG.isDebugEnabled())
- {
- LOG.debug(
- "A ListenerInterface '{}' assigned to '{}' is executed on an expired stateful page. "
- + "Scheduling re-create of the page and ignoring the listener interface...",
- listenerInterface, getComponentPath());
- }
-
- if (isAjax)
- {
- policy = RedirectPolicy.ALWAYS_REDIRECT;
- }
-
- requestCycle.scheduleRequestHandlerAfterCurrent(new RenderPageRequestHandler(
- pageProvider, policy));
- return;
+ LOG.debug(
+ "A ListenerInterface '{}' assigned to '{}' is executed on an expired stateful page. "
+ + "Scheduling re-create of the page and ignoring the listener interface...",
+ listenerInterface, getComponentPath());
}
- if (isAjax == false && listenerInterface.isRenderPageAfterInvocation())
+ if (isAjax)
{
- // schedule page render after current request handler is done. this can be
- // overridden during invocation of listener
- // method (i.e. by calling RequestCycle#setResponsePage)
- requestCycle.scheduleRequestHandlerAfterCurrent(new RenderPageRequestHandler(
- pageProvider, policy));
+ policy = RedirectPolicy.ALWAYS_REDIRECT;
}
- invokeListener();
-
+ requestCycle.scheduleRequestHandlerAfterCurrent(new RenderPageRequestHandler(
+ pageProvider, policy));
+ return;
}
- else
+
+ if (isAjax == false && listenerInterface.isRenderPageAfterInvocation())
{
- throw new WicketRuntimeException("Component " + getComponent() +
- " has been removed from page.");
+ // schedule page render after current request handler is done. this can be
+ // overridden during invocation of listener
+ // method (i.e. by calling RequestCycle#setResponsePage)
+ requestCycle.scheduleRequestHandlerAfterCurrent(new RenderPageRequestHandler(
+ pageProvider, policy));
}
+
+ invokeListener();
}
private void invokeListener()
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5466_c1c1f794.diff |
bugs-dot-jar_data_WICKET-4775_1ac05533 | ---
BugID: WICKET-4775
Summary: PageParameters#mergeWith may loose values of the 'other' PP
Description: "The code at org.apache.wicket.request.mapper.parameter.PageParameters#mergeWith()
looks like:\n\nfor (NamedPair curNamed : other.getAllNamed())\n\t\tset(curNamed.getKey(),
curNamed.getValue());\n\nmay loose some values if 'other' has a named parameter
with several values.With the current code only the last name/value pair is preserved."
diff --git a/wicket-request/src/main/java/org/apache/wicket/request/mapper/parameter/PageParameters.java b/wicket-request/src/main/java/org/apache/wicket/request/mapper/parameter/PageParameters.java
index 5c5391f..956ea75 100644
--- a/wicket-request/src/main/java/org/apache/wicket/request/mapper/parameter/PageParameters.java
+++ b/wicket-request/src/main/java/org/apache/wicket/request/mapper/parameter/PageParameters.java
@@ -456,9 +456,20 @@ public class PageParameters implements IClusterable, IIndexedParameters, INamedP
if (this != other)
{
for (int index = 0; index < other.getIndexedCount(); index++)
- set(index, other.get(index));
+ {
+ if (!other.get(index).isNull())
+ {
+ set(index, other.get(index));
+ }
+ }
+ for (String name : other.getNamedKeys())
+ {
+ remove(name);
+ }
for (NamedPair curNamed : other.getAllNamed())
- set(curNamed.getKey(), curNamed.getValue());
+ {
+ add(curNamed.getKey(), curNamed.getValue());
+ }
}
return this;
}
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-4775_1ac05533.diff |
bugs-dot-jar_data_WICKET-4379_7a162f77 | ---
BugID: WICKET-4379
Summary: org.apache.wicket.validation.ValidatorAdapter class causes problem with validator
properties to be loaded
Description: "\nPROBLEM:\n<e1nPL> hi I am having such problem: \n<e1nPL> I have implemented
validator by implementing IValidator<T> interface\n<e1nPL> and I have impelemnted
the same validator by extending AbstractValidator<T> class\n\nCODE:\n =====================
VALIDATOR EXTENDED FROM AbstractValidator =====================\n package com.mycompany;\n
\ \n import java.util.regex.Pattern;\n import org.apache.wicket.IClusterable;\n
\ import org.apache.wicket.util.lang.Classes;\n import org.apache.wicket.validation.IValidatable;\n
\ import org.apache.wicket.validation.IValidator;\n import org.apache.wicket.validation.ValidationError;\n
\ import org.apache.wicket.validation.validator.AbstractValidator;\n \n /**\n
\ *\n * @author e1n\n */\n public class PasswordPolicyValidator<T>
extends AbstractValidator<T> {\n \n private static final Pattern UPPER
= Pattern.compile(\"[A-Z]\");\n private static final Pattern LOWER = Pattern.compile(\"[a-z]\");\n
\ private static final Pattern NUMBER = Pattern.compile(\"[0-9]\");\n \n
\ @Override\n public void onValidate(IValidatable<T> validatable) {\n
\ final String password = (String)validatable.getValue();\n \n
\ if (!NUMBER.matcher(password).find()) {\n error(validatable,
\"no-digit\");\n }\n if (!LOWER.matcher(password).find())
{\n error(validatable, \"no-lower\");\n }\n if
(!UPPER.matcher(password).find()) {\n error(validatable, \"no-upper\");\n
\ }\n \n }\n \n @Override\n public void
error(IValidatable<T> validatable, String errorKey) {\n ValidationError
err = new ValidationError();\n err.addMessageKey(Classes.simpleName(getClass())
+ \".\" + errorKey);\n validatable.error(err);\n }\n \n
\ }\n \n \n =============== VALIDATOR directly implementing IValidator
interfce ====================\n package com.mycompany;\n \n import java.util.regex.Pattern;\n
\ import org.apache.wicket.IClusterable;\n import org.apache.wicket.util.lang.Classes;\n
\ import org.apache.wicket.validation.IValidatable;\n import org.apache.wicket.validation.IValidator;\n
\ import org.apache.wicket.validation.ValidationError;\n import org.apache.wicket.validation.validator.AbstractValidator;\n
\ \n /**\n *\n * @author e1n\n */\n public class PasswordPolicyValidator<T>
implements IValidator<T> {\n \n private static final Pattern UPPER =
Pattern.compile(\"[A-Z]\");\n private static final Pattern LOWER = Pattern.compile(\"[a-z]\");\n
\ private static final Pattern NUMBER = Pattern.compile(\"[0-9]\");\n \n
\ public void validate(IValidatable<T> validatable) {\n final String
password = (String)validatable.getValue();\n \n if (!NUMBER.matcher(password).find())
{\n error(validatable, \"no-digit\");\n }\n if
(!LOWER.matcher(password).find()) {\n error(validatable, \"no-lower\");\n
\ }\n if (!UPPER.matcher(password).find()) {\n error(validatable,
\"no-upper\");\n }\n \n }\n \n public void error(IValidatable<T>
validatable, String errorKey) {\n ValidationError err = new ValidationError();\n
\ err.addMessageKey(Classes.simpleName(getClass()) + \".\" + errorKey);\n
\ validatable.error(err);\n }\n \n }\n\n\n\n<e1nPL> I
also have properties file which is named after validator class\n<e1nPL> and placed
in the same package\n<e1nPL> my problem is that when i use to validate my form field
validator which implements IValidator interface it is not capable of loading error
messages from properties file\n<e1nPL> but when i am using validator which is extending
AbstractValidator class\n<e1nPL> properties file with error msgs gets loaded\nPOSSIBLE
FIX:\n<e1nPL> ok i have found class which is responsible for my problem and it is
probably a bug\n<e1nPL> org.apache.wicket.validation.ValidatorAdapter\n<e1nPL> which
wraps classes that directly implements IValidator interface\n<e1nPL> then when resources
are loaded, and properties file are searched in class path etc., loaders search
in wrong path that is build against org.apache.wicket.validation.ValidatorAdapter
\nPLACE WHER FIX SHOULD OCCOUR\norg.apache.wicket.resource.loader.ValidatorStringResourceLoader::loadStringResource(java.lang.Class,java.lang.String,java.util.Locale,java.lang.String,java.lang.String)\n\n"
diff --git a/wicket-core/src/main/java/org/apache/wicket/resource/loader/ValidatorStringResourceLoader.java b/wicket-core/src/main/java/org/apache/wicket/resource/loader/ValidatorStringResourceLoader.java
index f3f03a2..ad7a610 100644
--- a/wicket-core/src/main/java/org/apache/wicket/resource/loader/ValidatorStringResourceLoader.java
+++ b/wicket-core/src/main/java/org/apache/wicket/resource/loader/ValidatorStringResourceLoader.java
@@ -21,6 +21,7 @@ import java.util.Locale;
import org.apache.wicket.Component;
import org.apache.wicket.markup.html.form.FormComponent;
import org.apache.wicket.validation.IValidator;
+import org.apache.wicket.validation.ValidatorAdapter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -81,7 +82,8 @@ public class ValidatorStringResourceLoader extends ComponentStringResourceLoader
FormComponent<?> fc = (FormComponent<?>)component;
for (IValidator<?> validator : fc.getValidators())
{
- String resource = loadStringResource(validator.getClass(), key, locale, style,
+ Class<?> scope = getScope(validator);
+ String resource = loadStringResource(scope, key, locale, style,
variation);
if (resource != null)
{
@@ -92,4 +94,18 @@ public class ValidatorStringResourceLoader extends ComponentStringResourceLoader
// not found
return null;
}
+
+ private Class<? extends IValidator> getScope(IValidator<?> validator)
+ {
+ Class<? extends IValidator> scope;
+ if (validator instanceof ValidatorAdapter)
+ {
+ scope = ((ValidatorAdapter) validator).getValidator().getClass();
+ }
+ else
+ {
+ scope = validator.getClass();
+ }
+ return scope;
+ }
}
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-4379_7a162f77.diff |
bugs-dot-jar_data_WICKET-2961_3d8c9d75 | ---
BugID: WICKET-2961
Summary: Adding a component in Component#onInitialize() leads to StackOverflowError
Description: |-
Adding a component in Page#onInitialize() leads to StackOverflowError:
at org.apache.wicket.MarkupContainer.addedComponent(MarkupContainer.java:978)
at org.apache.wicket.MarkupContainer.add(MarkupContainer.java:168)
at org.apache.wicket.examples.WicketExamplePage.onInitialize(WicketExamplePage.java:67)
at org.apache.wicket.Component.initialize(Component.java:970)
at org.apache.wicket.MarkupContainer.initialize(MarkupContainer.java:992)
at org.apache.wicket.Page.componentAdded(Page.java:1130)
at org.apache.wicket.MarkupContainer.addedComponent(MarkupContainer.java:978)
at org.apache.wicket.MarkupContainer.add(MarkupContainer.java:168)
at org.apache.wicket.examples.WicketExamplePage.onInitialize(WicketExamplePage.java:67)
at org.apache.wicket.Component.initialize(Component.java:970)
at org.apache.wicket.MarkupContainer.initialize(MarkupContainer.java:992)
at org.apache.wicket.Page.componentAdded(Page.java:1130)
at org.apache.wicket.MarkupContainer.addedComponent(MarkupContainer.java:978)
at org.apache.wicket.MarkupContainer.add(MarkupContainer.java:168)
at org.apache.wicket.examples.WicketExamplePage.onInitialize(WicketExamplePage.java:67)
at org.apache.wicket.Component.initialize(Component.java:970)
at org.apache.wicket.MarkupContainer.initialize(MarkupContainer.java:992)
at org.apache.wicket.Page.componentAdded(Page.java:1130)
at org.apache.wicket.MarkupContainer.addedComponent(MarkupContainer.java:978)
at org.apache.wicket.MarkupContainer.add(MarkupContainer.java:168)
at org.apache.wicket.examples.WicketExamplePage.onInitialize(WicketExamplePage.java:67)
at org.apache.wicket.Component.initialize(Component.java:970)
at org.apache.wicket.MarkupContainer.initialize(MarkupContainer.java:992)
at org.apache.wicket.Page.componentAdded(Page.java:1130)
at org.apache.wicket.MarkupContainer.addedComponent(MarkupContainer.java:978)
at org.apache.wicket.MarkupContainer.add(MarkupContainer.java:168)
at org.apache.wicket.examples.WicketExamplePage.onInitialize(WicketExamplePage.java:67)
at org.apache.wicket.Component.initialize(Component.java:970)
...
diff --git a/wicket/src/main/java/org/apache/wicket/Component.java b/wicket/src/main/java/org/apache/wicket/Component.java
index 380637b..f71a97a 100644
--- a/wicket/src/main/java/org/apache/wicket/Component.java
+++ b/wicket/src/main/java/org/apache/wicket/Component.java
@@ -967,8 +967,8 @@ public abstract class Component implements IClusterable, IConverterLocator, IReq
{
if (!getFlag(FLAG_INITIALIZED))
{
- onInitialize();
setFlag(FLAG_INITIALIZED, true);
+ onInitialize();
}
}
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-2961_3d8c9d75.diff |
bugs-dot-jar_data_WICKET-5345_3fc7234e | ---
BugID: WICKET-5345
Summary: Url.canonical() breaks when there are two consecutive "parent" segments followed
by a normal segment
Description: "assertEquals(\"a/d\", Url.parse(\"a/b/c/../../d\").canonical().getPath());
\n\nbreaks with :\nExpected :a/d\nActual :a/b/../d"
diff --git a/wicket-request/src/main/java/org/apache/wicket/request/Url.java b/wicket-request/src/main/java/org/apache/wicket/request/Url.java
index 11f6b47..e950f6f 100755
--- a/wicket-request/src/main/java/org/apache/wicket/request/Url.java
+++ b/wicket-request/src/main/java/org/apache/wicket/request/Url.java
@@ -1219,17 +1219,21 @@ public class Url implements Serializable
// drop '.' from path
if (".".equals(segment))
{
- continue;
+ // skip
+ }
+ else if ("..".equals(segment) && url.segments.isEmpty() == false)
+ {
+ url.segments.remove(url.segments.size() - 1);
}
-
// skip segment if following segment is a '..'
- if ((i + 1) < segments.size() && "..".equals(segments.get(i + 1)))
+ else if ((i + 1) < segments.size() && "..".equals(segments.get(i + 1)))
{
i++;
- continue;
}
-
- url.segments.add(segment);
+ else
+ {
+ url.segments.add(segment);
+ }
}
return url;
}
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5345_3fc7234e.diff |
bugs-dot-jar_data_WICKET-5426_fb45a781 | ---
BugID: WICKET-5426
Summary: 'Page not recognized as stateless although stateful component is hidden in
#onConfigure()'
Description: 'Page#stateless gets cached. If Page#isStateless() is called before rendering,
a page might not be considered stateless although in #onConfigure() all stateful
components are hidden.'
diff --git a/wicket-core/src/main/java/org/apache/wicket/Page.java b/wicket-core/src/main/java/org/apache/wicket/Page.java
index 2be236d..1a3e9aa 100644
--- a/wicket-core/src/main/java/org/apache/wicket/Page.java
+++ b/wicket-core/src/main/java/org/apache/wicket/Page.java
@@ -801,11 +801,8 @@ public abstract class Page extends MarkupContainer implements IRedirectListener,
// Make sure it is really empty
renderedComponents = null;
- // if the page is stateless, reset the flag so that it is tested again
- if (Boolean.TRUE.equals(stateless))
- {
- stateless = null;
- }
+ // rendering might remove or add stateful components, so clear flag to force reevaluation
+ stateless = null;
super.onBeforeRender();
@@ -1020,6 +1017,8 @@ public abstract class Page extends MarkupContainer implements IRedirectListener,
{
++renderCount;
render();
+
+ // stateless = null;
}
finally
{
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5426_fb45a781.diff |
bugs-dot-jar_data_WICKET-5965_31c88569 | ---
BugID: WICKET-5965
Summary: Queuing a component in head
Description: "Queuing a component which is in the head section doesn't work :\n<head>\n\t<meta
charset=\"utf-8\" />\n\t<title wicket:id=\"titre\">Test</title>\n</head>"
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/parser/filter/HtmlHeaderSectionHandler.java b/wicket-core/src/main/java/org/apache/wicket/markup/parser/filter/HtmlHeaderSectionHandler.java
index 0ea0002..5b79f80 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/parser/filter/HtmlHeaderSectionHandler.java
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/parser/filter/HtmlHeaderSectionHandler.java
@@ -18,11 +18,16 @@ package org.apache.wicket.markup.parser.filter;
import java.text.ParseException;
+import org.apache.wicket.Component;
+import org.apache.wicket.MarkupContainer;
import org.apache.wicket.markup.ComponentTag;
+import org.apache.wicket.markup.ComponentTag.IAutoComponentFactory;
import org.apache.wicket.markup.Markup;
import org.apache.wicket.markup.MarkupElement;
import org.apache.wicket.markup.MarkupException;
import org.apache.wicket.markup.MarkupStream;
+import org.apache.wicket.markup.html.internal.HtmlHeaderContainer;
+import org.apache.wicket.markup.html.internal.HtmlHeaderItemsContainer;
import org.apache.wicket.markup.parser.AbstractMarkupFilter;
import org.apache.wicket.markup.parser.XmlTag.TagType;
import org.apache.wicket.markup.resolver.HtmlHeaderResolver;
@@ -72,6 +77,24 @@ public final class HtmlHeaderSectionHandler extends AbstractMarkupFilter
/** The Markup available so far for the resource */
private final Markup markup;
+ private static final IAutoComponentFactory HTML_HEADER_FACTORY = new IAutoComponentFactory()
+ {
+ @Override
+ public Component newComponent(MarkupContainer container, ComponentTag tag)
+ {
+ return new HtmlHeaderContainer(tag.getId());
+ }
+ };
+
+ private static final IAutoComponentFactory HTML_HEADER_ITEMS_FACTORY = new IAutoComponentFactory()
+ {
+ @Override
+ public Component newComponent(MarkupContainer container, ComponentTag tag)
+ {
+ return new HtmlHeaderItemsContainer(tag.getId());
+ }
+ };
+
/**
* Construct.
*
@@ -164,6 +187,7 @@ public final class HtmlHeaderSectionHandler extends AbstractMarkupFilter
tag.setId(HEADER_ID);
tag.setAutoComponentTag(true);
tag.setModified(true);
+ tag.setAutoComponentFactory(HTML_HEADER_ITEMS_FACTORY);
}
/**
@@ -188,6 +212,7 @@ public final class HtmlHeaderSectionHandler extends AbstractMarkupFilter
tag.setId(HEADER_ID);
tag.setAutoComponentTag(true);
tag.setModified(true);
+ tag.setAutoComponentFactory(HTML_HEADER_FACTORY);
}
}
else if (tag.isClose())
@@ -201,6 +226,7 @@ public final class HtmlHeaderSectionHandler extends AbstractMarkupFilter
headOpenTag.setAutoComponentTag(false);
headOpenTag.setModified(false);
headOpenTag.setFlag(ComponentTag.RENDER_RAW, true);
+ headOpenTag.setAutoComponentFactory(null);
}
foundClosingHead = true;
@@ -217,6 +243,7 @@ public final class HtmlHeaderSectionHandler extends AbstractMarkupFilter
openTag.setId(HEADER_ID);
openTag.setAutoComponentTag(true);
openTag.setModified(true);
+ openTag.setAutoComponentFactory(HTML_HEADER_FACTORY);
final ComponentTag closeTag = new ComponentTag(HEAD, TagType.CLOSE);
closeTag.setOpenTag(openTag);
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5965_31c88569.diff |
bugs-dot-jar_data_WICKET-5114_518c933b | ---
BugID: WICKET-5114
Summary: Url#toString(StringMode.FULL) throws exception if a segment contains two
dots
Description: |+
When invoking toString(StringMode.FULL) for a URL like
/mountPoint/whatever.../
an IllegalStateException is thrown with message: Cannot render this url in FULL mode because it has a `..` segment: /mountPoint/whatever.../
The method does not actually check for `..` segments but rather checks whether path.contains("..")
diff --git a/wicket-request/src/main/java/org/apache/wicket/request/Url.java b/wicket-request/src/main/java/org/apache/wicket/request/Url.java
index 12ca5f0..9ca2c0d 100755
--- a/wicket-request/src/main/java/org/apache/wicket/request/Url.java
+++ b/wicket-request/src/main/java/org/apache/wicket/request/Url.java
@@ -674,7 +674,7 @@ public class Url implements Serializable
result.append(port);
}
- if (path.contains(".."))
+ if (segments.contains(".."))
{
throw new IllegalStateException("Cannot render this url in " +
StringMode.FULL.name() + " mode because it has a `..` segment: " + toString());
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5114_518c933b.diff |
bugs-dot-jar_data_WICKET-2337_36a41358 | ---
BugID: WICKET-2337
Summary: IndexOutOfBoundsException when PropertyResolver is using an invalid list
index
Description: "When using PropertyResolver.getValue(\"myList[1]\", myBean), the PropertyResolver$ListGetSet.getValue()
(line 762) unconditionally does:\nreturn ((List)object).get(index);\nwhich throws
an java.lang.IndexOutOfBoundsException: Index: 1, Size: 1 if the backing list
contains only one element (at index 0).\nShouldn't the implementation rather return
null like with every other property not found? Like when using \"bla.bli.blo\" as
a lookup string and there is no bla field and no getBla() method?\n\nSo this method
should rather be:\n\norg.apache.wicket.util.lang.PropertyResolver$ListGetSet.getValue():\n\n\t\t/**\n\t\t
* @see org.apache.wicket.util.lang.PropertyResolver.IGetAndSet#getValue(java.lang.Object)\n\t\t
*/\n\t\tpublic Object getValue(Object object)\n\t\t{\n\t\t\tList list = (List) object;\n\t\t\tif
(index >= list.size()) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\treturn list.get(index);\n\t\t}"
diff --git a/wicket/src/main/java/org/apache/wicket/util/lang/PropertyResolver.java b/wicket/src/main/java/org/apache/wicket/util/lang/PropertyResolver.java
index ae38446..d83ba14 100644
--- a/wicket/src/main/java/org/apache/wicket/util/lang/PropertyResolver.java
+++ b/wicket/src/main/java/org/apache/wicket/util/lang/PropertyResolver.java
@@ -217,6 +217,12 @@ public final class PropertyResolver
while (index != -1)
{
exp = expressionBracketsSeperated.substring(lastIndex, index);
+ if (exp.length() == 0)
+ {
+ exp = expressionBracketsSeperated.substring(index + 1);
+ break;
+ }
+
IGetAndSet getAndSetter = null;
try
{
@@ -762,6 +768,8 @@ public final class PropertyResolver
*/
public Object getValue(Object object)
{
+ if (((List<?>)object).size() <= index)
+ return null;
return ((List<?>)object).get(index);
}
@@ -819,7 +827,11 @@ public final class PropertyResolver
*/
public Object getValue(Object object)
{
- return Array.get(object, index);
+ if (Array.getLength(object) > index)
+ {
+ return Array.get(object, index);
+ }
+ return null;
}
/**
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-2337_36a41358.diff |
bugs-dot-jar_data_WICKET-3931_8fbdc68f | ---
BugID: WICKET-3931
Summary: Component markup caching inconsistencies
Description: "In WICKET-3891 we found that Component#markup field is not being reset
between requests. The problem is that this field is transient and it is null-ified
only when the page is read from the second level page cache (see https://cwiki.apache.org/confluence/x/qIaoAQ).
If the page instance is read from first level cache (http session) then its non-serialized
version is used and the markup field value is still non-null.\n\nIn WICKET-3891
this looked like a minor issue with the markup caching in development mode but actually
this problem is valid even in production mode.\nSee the attached application. When
the panel's variation is changed every MarkupContainer inside still uses its old
markup. "
diff --git a/wicket-core/src/main/java/org/apache/wicket/Component.java b/wicket-core/src/main/java/org/apache/wicket/Component.java
index 956df88..94bef50 100644
--- a/wicket-core/src/main/java/org/apache/wicket/Component.java
+++ b/wicket-core/src/main/java/org/apache/wicket/Component.java
@@ -36,6 +36,7 @@ import org.apache.wicket.feedback.FeedbackMessage;
import org.apache.wicket.feedback.IFeedback;
import org.apache.wicket.markup.ComponentTag;
import org.apache.wicket.markup.IMarkupFragment;
+import org.apache.wicket.markup.MarkupCache;
import org.apache.wicket.markup.MarkupElement;
import org.apache.wicket.markup.MarkupException;
import org.apache.wicket.markup.MarkupNotFoundException;
@@ -1170,6 +1171,8 @@ public abstract class Component
requestFlags = 0;
+ internalDetach();
+
// notify any detach listener
IDetachListener detachListener = getApplication().getFrameworkSettings()
.getDetachListener();
@@ -1180,6 +1183,15 @@ public abstract class Component
}
/**
+ * Removes the cached markup at the end of the request. For the next request it will be get
+ * either from the parent's markup or from {@link MarkupCache}.
+ */
+ private void internalDetach()
+ {
+ markup = null;
+ }
+
+ /**
* Detaches all models
*/
public void detachModels()
@@ -3065,7 +3077,7 @@ public abstract class Component
{
setFlag(FLAG_PLACEHOLDER, false);
// I think it's better to not setOutputMarkupId to false...
- // user can do it if we want
+ // user can do it if she want
}
}
return this;
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/internal/InlineEnclosure.java b/wicket-core/src/main/java/org/apache/wicket/markup/html/internal/InlineEnclosure.java
index 614ccb6..9caac6d 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/html/internal/InlineEnclosure.java
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/internal/InlineEnclosure.java
@@ -17,6 +17,8 @@
package org.apache.wicket.markup.html.internal;
import org.apache.wicket.markup.ComponentTag;
+import org.apache.wicket.markup.IMarkupFragment;
+import org.apache.wicket.markup.Markup;
import org.apache.wicket.markup.parser.filter.InlineEnclosureHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -42,6 +44,8 @@ public class InlineEnclosure extends Enclosure
private static final Logger log = LoggerFactory.getLogger(InlineEnclosure.class);
+ private String enclosureMarkupAsString;
+
/**
* Construct.
*
@@ -53,8 +57,9 @@ public class InlineEnclosure extends Enclosure
{
super(id, childId);
+ enclosureMarkupAsString = null;
+
// ensure that the Enclosure is ready for ajax updates
- setOutputMarkupId(true);
setOutputMarkupPlaceholderTag(true);
setMarkupId(getId());
}
@@ -79,4 +84,32 @@ public class InlineEnclosure extends Enclosure
setVisible(visible);
return visible;
}
+
+ /**
+ * {@link InlineEnclosure}s keep their own cache of their markup because Component#markup is
+ * detached and later during Ajax request it is hard to re-lookup {@link InlineEnclosure}'s
+ * markup from its parent.
+ *
+ * @see org.apache.wicket.Component#getMarkup()
+ */
+ @Override
+ public IMarkupFragment getMarkup()
+ {
+ IMarkupFragment enclosureMarkup = null;
+ if (enclosureMarkupAsString == null)
+ {
+ IMarkupFragment markup = super.getMarkup();
+ if (markup != null && markup != Markup.NO_MARKUP)
+ {
+ enclosureMarkup = markup;
+ enclosureMarkupAsString = markup.toString(true);
+ }
+ }
+ else
+ {
+ enclosureMarkup = Markup.of(enclosureMarkupAsString);
+ }
+
+ return enclosureMarkup;
+ }
}
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-3931_8fbdc68f.diff |
bugs-dot-jar_data_WICKET-4988_a4a3a9a6 | ---
BugID: WICKET-4988
Summary: AbstractNumberConverter issue when used with NumberFormat#getCurrencyInstance
Description: |-
Summary of the discussion on users@:
There is an issue when using AbstractNumberConverter when #getNumberFormat returns NumberFormat#getCurrencyInstance()
I think the problem is due to AbstractNumberConverter#parse(Object, double, double, Locale):
if (value instanceof String)
{
// Convert spaces to no-break space (U+00A0) to fix problems with
// browser conversions.
// Space is not valid thousands-separator, but no-br space is.
value = ((String)value).replace(' ', '\u00A0');
}
Which replace spaces, so a string like "1,5 €" is invalid while being parsed.
public class CurrencyConverter extends AbstractNumberConverter<Double>
{
private static final long serialVersionUID = 1L;
public CurrencyConverter()
{
}
@Override
protected Class<Double> getTargetType()
{
return Double.class;
}
@Override
public NumberFormat getNumberFormat(Locale locale)
{
return NumberFormat.getCurrencyInstance(locale);
}
@Override
public Double convertToObject(String value, Locale locale)
{
locale = Locale.FRANCE;
return this.parse(value, Double.MIN_VALUE, Double.MAX_VALUE, locale);
// This does work:
// final NumberFormat format = this.getNumberFormat(locale);
// return this.parse(format, value, locale);
}
}
As Sven indicates, there is (yet another) issue in Java currency formating (space as thousand separator)
http://matthiaswessendorf.wordpress.com/2007/12/03/javas-numberformat-bug/
http://bugs.sun.com/view_bug.do?bug_id=4510618
So will I let you decide whether or not you wish to fix it (the space before the currency symbol).
Thanks & best regards,
Sebastien.
diff --git a/wicket-util/src/main/java/org/apache/wicket/util/convert/converter/AbstractNumberConverter.java b/wicket-util/src/main/java/org/apache/wicket/util/convert/converter/AbstractNumberConverter.java
index b3b970e..5c448c0 100644
--- a/wicket-util/src/main/java/org/apache/wicket/util/convert/converter/AbstractNumberConverter.java
+++ b/wicket-util/src/main/java/org/apache/wicket/util/convert/converter/AbstractNumberConverter.java
@@ -65,10 +65,9 @@ public abstract class AbstractNumberConverter<N extends Number> extends Abstract
}
else if (value instanceof String)
{
- // Convert spaces to no-break space (U+00A0) to fix problems with
- // browser conversions.
- // Space is not valid thousands-separator, but no-br space is.
- value = ((String)value).replace(' ', '\u00A0');
+ // Convert spaces to no-break space (U+00A0) as required by Java formats:
+ // http://bugs.sun.com/view_bug.do?bug_id=4510618
+ value = ((String)value).replaceAll("(\\d+)\\s(?=\\d)", "$1\u00A0");
}
final NumberFormat numberFormat = getNumberFormat(locale);
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-4988_a4a3a9a6.diff |
bugs-dot-jar_data_WICKET-4102_e743fd7e | ---
BugID: WICKET-4102
Summary: AutoLabelTextResolver fails to pick up locale changes in the session
Description: |-
When using <wicket:label key="..."> AutoLabelTextResolver correctly picks up the localized message identified by the key. However, if the Session locale is changed, neither the printed label nor the FormComponent's label model get updated - both will still contain the initial message. This is inconsistent with the behavior of <wicket:message> and StringResourceModel. The principle of least surprise (and in my opinion, also that of highest usefulness ;-) ) suggests that AutoLabelTextResolver should dynamically get the localized string whenever it deals with something that can be localized. That includes the <wicket:label key="..."> case mentioned above, as well as when using FormComponent#getDefaultLabel.
I have only tested this in trunk 1.5 (since it recently came up during a training I gave on Wicket 1.5). I suspect it also affects 1.4.x.
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/AutoLabelTextResolver.java b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/AutoLabelTextResolver.java
index 85cf7ce..34cfe82 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/AutoLabelTextResolver.java
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/AutoLabelTextResolver.java
@@ -28,7 +28,10 @@ import org.apache.wicket.markup.html.internal.ResponseBufferZone;
import org.apache.wicket.markup.parser.XmlTag;
import org.apache.wicket.markup.parser.filter.WicketTagIdentifier;
import org.apache.wicket.markup.resolver.IComponentResolver;
+import org.apache.wicket.model.IModel;
+import org.apache.wicket.model.LoadableDetachableModel;
import org.apache.wicket.model.Model;
+import org.apache.wicket.model.StringResourceModel;
import org.apache.wicket.request.cycle.RequestCycle;
import org.apache.wicket.util.string.Strings;
@@ -130,76 +133,95 @@ public class AutoLabelTextResolver implements IComponentResolver
@Override
public void onComponentTagBody(final MarkupStream markupStream, final ComponentTag openTag)
{
- boolean storeLabelText = false;
// try and find some form of label content...
- String labelText = null;
+ IModel<String> labelModel = findLabelContent(markupStream, openTag);
+ // print the label text
+ replaceComponentTagBody(markupStream, openTag,
+ labelModel != null ? labelModel.getObject() : "");
- // check if the labeled component is a label provider
+ // store the label text in FormComponent's label model so its available to errors
+ if (labelModel != null)
+ {
+ if (labeled instanceof FormComponent)
+ {
+ FormComponent<?> fc = (FormComponent<?>)labeled;
+ fc.setLabel(labelModel);
+ }
+ else
+ {
+ // if we can't hand off the labelmodel to a component, we have to detach it
+ labelModel.detach();
+ }
+ }
+ }
+ private IModel<String> findLabelContent(final MarkupStream markupStream,
+ final ComponentTag tag)
+ {
if (labeled instanceof ILabelProvider)
{
+ // check if the labeled component is a label provider
ILabelProvider<String> provider = (ILabelProvider<String>)labeled;
if (provider.getLabel() != null)
{
- String text = provider.getLabel().getObject();
- if (!Strings.isEmpty(text))
+ if (!Strings.isEmpty(provider.getLabel().getObject()))
+
{
- labelText = text;
+ return provider.getLabel();
}
}
}
// check if the labeled component is a form component
-
- if (labelText == null && labeled instanceof FormComponent)
+ if (labeled instanceof FormComponent)
{
- String text = ((FormComponent<?>)labeled).getDefaultLabel("wicket:unknown");
+ final FormComponent<?> formComponent = (FormComponent<?>)labeled;
+ String text = formComponent.getDefaultLabel("wicket:unknown");
if (!"wicket:unknown".equals(text) && !Strings.isEmpty(text))
{
- labelText = text;
+ return new LoadableDetachableModel<String>()
+ {
+ @Override
+ protected String load()
+ {
+ return formComponent.getDefaultLabel("wicket:unknown");
+ }
+ };
}
}
// check if wicket:label tag has a message key
- if (labelText == null && openTag.getAttribute("key") != null)
{
- String text = labeled.getString(openTag.getAttribute("key"));
- if (!Strings.isEmpty(text))
+ String resourceKey = tag.getAttribute("key");
+ if (resourceKey != null)
{
- labelText = text;
- storeLabelText = true;
+ String text = labeled.getString(resourceKey);
+ if (!Strings.isEmpty(text))
+ {
+ return new StringResourceModel(resourceKey, labeled, null);
+ }
}
}
// as last resort use the tag body
- if (labelText == null)
{
String text = new ResponseBufferZone(RequestCycle.get(), markupStream)
{
@Override
protected void executeInsideBufferedZone()
{
- TextLabel.super.onComponentTagBody(markupStream, openTag);
+ TextLabel.super.onComponentTagBody(markupStream, tag);
}
}.execute().toString();
if (!Strings.isEmpty(text))
{
- labelText = text;
- storeLabelText = true;
+ return Model.of(text);
}
}
- // print the label text
- replaceComponentTagBody(markupStream, openTag, labelText);
-
- // store the label text in FormComponent's label model so its available to errors
- if (labeled instanceof FormComponent)
- {
- FormComponent<?> fc = (FormComponent<?>)labeled;
- fc.setLabel(Model.of(labelText));
- }
+ return null;
}
}
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-4102_e743fd7e.diff |
bugs-dot-jar_data_WICKET-3197_be70e608 | ---
BugID: WICKET-3197
Summary: getMarkupId() can be used only if the component's markup is attached
Description: |
With change r1037139 Component#getMarkupImpl() first tries to get the markup id from the component's markup.
If the markup is not available/attached yet for this component the call ends with :
org.apache.wicket.markup.MarkupException: Can not determine Markup. Component is not yet connected to a parent. [Component id = label]
diff --git a/wicket/src/main/java/org/apache/wicket/Component.java b/wicket/src/main/java/org/apache/wicket/Component.java
index aeba674..1660a13 100644
--- a/wicket/src/main/java/org/apache/wicket/Component.java
+++ b/wicket/src/main/java/org/apache/wicket/Component.java
@@ -64,6 +64,7 @@ import org.apache.wicket.request.resource.ResourceReference;
import org.apache.wicket.settings.IDebugSettings;
import org.apache.wicket.util.IHierarchical;
import org.apache.wicket.util.convert.IConverter;
+import org.apache.wicket.util.lang.Args;
import org.apache.wicket.util.lang.Classes;
import org.apache.wicket.util.lang.WicketObjects;
import org.apache.wicket.util.string.ComponentStrings;
@@ -224,8 +225,6 @@ public abstract class Component
IEventSink,
IEventSource
{
-
-
/** Log. */
private static final Logger log = LoggerFactory.getLogger(Component.class);
@@ -2775,6 +2774,21 @@ public abstract class Component
}
/**
+ * Copy markupId
+ *
+ * @param comp
+ */
+ final void setMarkupId(Component comp)
+ {
+ Args.notNull(comp, "comp");
+
+ generatedMarkupId = comp.generatedMarkupId;
+ setMetaData(MARKUP_ID_KEY, comp.getMetaData(MARKUP_ID_KEY));
+ setOutputMarkupId(comp.getOutputMarkupId());
+ return;
+ }
+
+ /**
* Sets this component's markup id to a user defined value. It is up to the user to ensure this
* value is unique.
* <p>
diff --git a/wicket/src/main/java/org/apache/wicket/MarkupContainer.java b/wicket/src/main/java/org/apache/wicket/MarkupContainer.java
index 07536ee..cff9056 100644
--- a/wicket/src/main/java/org/apache/wicket/MarkupContainer.java
+++ b/wicket/src/main/java/org/apache/wicket/MarkupContainer.java
@@ -804,7 +804,7 @@ public abstract class MarkupContainer extends Component implements Iterable<Comp
addedComponent(child);
// The generated markup id remains the same
- child.setMarkupIdImpl(replaced.getMarkupIdImpl());
+ child.setMarkupId(replaced);
}
return this;
diff --git a/wicket/src/main/java/org/apache/wicket/markup/html/panel/Panel.java b/wicket/src/main/java/org/apache/wicket/markup/html/panel/Panel.java
index 8fa10e2..3245a54 100644
--- a/wicket/src/main/java/org/apache/wicket/markup/html/panel/Panel.java
+++ b/wicket/src/main/java/org/apache/wicket/markup/html/panel/Panel.java
@@ -106,6 +106,13 @@ public abstract class Panel extends WebMarkupContainerWithAssociatedMarkup
// <span wicket:id="myPanel">...</span>
tag.setType(XmlTag.OPEN);
}
+
+// IMarkupFragment markup = getMarkup(null);
+// ComponentTag panelTag = (ComponentTag)markup.get(0);
+// for (String key : panelTag.getAttributes().keySet())
+// {
+// tag.append(key, panelTag.getAttribute(key), ", ");
+// }
super.onComponentTag(tag);
}
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-3197_be70e608.diff |
bugs-dot-jar_data_WICKET-4290_e1953357 | ---
BugID: WICKET-4290
Summary: Confusion between a form component's wicket:id and a PageParameter in Wicket
1.5.x
Description: "A Form has a strange behavior when a component has the same wicket:id
than a page parameter.\n\nTo create a Bookmarkable link after a form is submited,
setResponsePage is called, and a PageParameter object is given as a parameter :
\n\t\t\tPageParameters params = new PageParameters();\n\t\t\tparams.add(\"searchString\",
searchField.getValue());\n\t\t\tsetResponsePage(SomePage.class, params);\n\nIn Wicket
1.5, if \"searchString\" is also a form-component's wicket:id, the form will only
be submitted once : \nsearchField.getValue() will always return the first value
entered by the user.\n\n\nHere's an example : \n\npublic class SearchPanel extends
Panel {\n\n\tpublic SearchPanel(String id) {\n\t\tsuper(id);\n\t\tadd(new SearchForm(\"searchForm\"));\n\t}\n\n\tprivate
class SearchForm extends Form<String> {\n\n\t\tprivate static final long serialVersionUID
= 1L;\n\t\tprivate TextField<String> searchField;\n\n\t\tpublic SearchForm(String
id) {\n\t\t\tsuper(id);\n\t\t\tsearchField = new TextField<String>(\"searchString\",
new Model<String>(\"\"));\n\t\t\tadd(searchField);\n\t\t}\n\n\t\t@Override\n\t\tpublic
void onSubmit() {\n\t\t\tPageParameters params = new PageParameters();\n\t\t\tparams.add(\"searchString\",
searchField.getValue());\n\t\t\tsetResponsePage(ListContactsPage.class, params);\n\t\t}\n\t}\n}\n\n\nI
tested the same application with Wicket 1.4.17 and it was fine. I only had this
problem in Wicket 1.5.2 and 1.5.3."
diff --git a/wicket-core/src/main/java/org/apache/wicket/request/mapper/MountedMapper.java b/wicket-core/src/main/java/org/apache/wicket/request/mapper/MountedMapper.java
index 3137b6c..f5271c5 100644
--- a/wicket-core/src/main/java/org/apache/wicket/request/mapper/MountedMapper.java
+++ b/wicket-core/src/main/java/org/apache/wicket/request/mapper/MountedMapper.java
@@ -385,7 +385,7 @@ public class MountedMapper extends AbstractBookmarkableMapper
handler.getBehaviorIndex());
PageComponentInfo pageComponentInfo = new PageComponentInfo(pageInfo, componentInfo);
UrlInfo urlInfo = new UrlInfo(pageComponentInfo, page.getClass(),
- handler.getPageParameters());
+ page.getPageParameters());
url = buildUrl(urlInfo);
}
}
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-4290_e1953357.diff |
bugs-dot-jar_data_WICKET-4276_32c76c4a | ---
BugID: WICKET-4276
Summary: Select component loses it's value
Description: |-
Select component loses selected option and shows the first option in some situations (one example is when you try to submit a form, but there are validation errors).
It was working fine in 1.4.18, but it's broken in 1.4.19.This must be caused by the solution from this issue https://issues.apache.org/jira/browse/WICKET-3962
I think the problem is likely in Select.isSelected method, where String[] paths = getInputAsArray() is actually an array of uuid-s, so uuid-s are compared to paths.
I haven't tested wicket 1.5, but this problem may also affect 1.5 versions.
diff --git a/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/form/select/Select.java b/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/form/select/Select.java
index 56fec8d..8284d59 100644
--- a/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/form/select/Select.java
+++ b/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/form/select/Select.java
@@ -180,7 +180,7 @@ public class Select<T> extends FormComponent<T>
/**
* @see FormComponent#updateModel()
*/
- @SuppressWarnings({ "unchecked", "rawtypes" })
+ @SuppressWarnings( { "unchecked", "rawtypes" })
@Override
public void updateModel()
{
@@ -214,7 +214,7 @@ public class Select<T> extends FormComponent<T>
* Checks if the specified option is selected based on raw input
*
* @param option
- * @return true} iff the option is selected
+ * @return {@code true} if the option is selected, {@code false} otherwise
*/
boolean isSelected(final SelectOption<?> option)
{
@@ -223,12 +223,13 @@ public class Select<T> extends FormComponent<T>
// if the raw input is specified use that, otherwise use model
if (hasRawInput())
{
- String[] paths = getInputAsArray();
- if ((paths != null) && (paths.length > 0))
+ String[] values = getInputAsArray();
+ if (values != null && values.length > 0)
{
- for (String path : paths)
+ for (int i = 0; i < values.length; i++)
{
- if (path.equals(option.getPath()))
+ String value = values[i];
+ if (value.equals(option.getValue()))
{
return true;
}
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-4276_32c76c4a.diff |
bugs-dot-jar_data_WICKET-4000_38e928c1 | ---
BugID: WICKET-4000
Summary: Header contributions order is not stable
Description: |-
In the last RCs, I started to experience problems with the contributions order.
For example, I add jQuery, and until 1.5RC5, it worked well, but now the call to the jQuery script has been moved to the bottom of the page head, and this disables all my other scripts that are expecting jQuery's $ to be defined.
I attach a quickstart to demonstrate the problem.
Maybe the order in the quickstart is not the expected one, but what it shows is that the order does not make real sense (at least to me) :
In the quickstart, the wicket:head tag contributions are in the order 3 - 8 - 9 - 5, and the renderHead methods contributions are in the order 4 - 1 - 2 - 6 - 7.
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/renderStrategy/ChildFirstHeaderRenderStrategy.java b/wicket-core/src/main/java/org/apache/wicket/markup/renderStrategy/ChildFirstHeaderRenderStrategy.java
index cf4d8da..8938182 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/renderStrategy/ChildFirstHeaderRenderStrategy.java
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/renderStrategy/ChildFirstHeaderRenderStrategy.java
@@ -80,7 +80,10 @@ public class ChildFirstHeaderRenderStrategy extends AbstractHeaderRenderStrategy
@Override
public void component(final Component component, final IVisit<Void> visit)
{
- component.renderHead(headerContainer);
+ if (component != rootComponent)
+ {
+ component.renderHead(headerContainer);
+ }
}
@Override
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-4000_38e928c1.diff |
bugs-dot-jar_data_WICKET-2552_12e1f39b | ---
BugID: WICKET-2552
Summary: CreditCardValidator accepts invalid inputs
Description: "(1) The onValidate() method of the CreditCardValidator class returns
true for invalid inputs with null or unicode character such as 4\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0.
\n(2) Also there is no length check on the input, therefore even invalid length
inputs such as 9845 are accepted. \n(3) There is no check for invalid issuer identifier,
i.e., 840898920205250 is accepted, where 84XXXX is not a valid issuer identifier"
diff --git a/wicket/src/main/java/org/apache/wicket/validation/validator/CreditCardValidator.java b/wicket/src/main/java/org/apache/wicket/validation/validator/CreditCardValidator.java
index 96ba9c0..b84d461 100644
--- a/wicket/src/main/java/org/apache/wicket/validation/validator/CreditCardValidator.java
+++ b/wicket/src/main/java/org/apache/wicket/validation/validator/CreditCardValidator.java
@@ -19,27 +19,586 @@ package org.apache.wicket.validation.validator;
import org.apache.wicket.validation.IValidatable;
/**
- * Performs the so-called "mod 10" algorithm to check the validity of credit card numbers such as
- * VISA.
+ * Checks if a credit card number is valid. The number will be checked for "American Express",
+ * "China UnionPay", "Diners Club Carte Blanche", "Diners Club International",
+ * "Diners Club US & Canada", "Discover Card", "JCB", "Laser", "Maestro", "MasterCard", "Solo",
+ * "Switch", "Visa" and "Visa Electron". If none of those apply to the credit card number, the
+ * credit card number is considered invalid.
+ *
* <p>
- * In addition to this, the credit card number can be further validated by its length and prefix,
- * but those properties depend upon the credit card type, and such validation is not performed by
- * this validator.
+ * Card prefixes and lengths have been taken from <a
+ * href="http://en.wikipedia.org/w/index.php?title=Bank_card_number&oldid=322132931">Wikipedia</a>.
*
* @author Johan Compagner
+ * @author Joachim F. Rohde
* @since 1.2.6
*/
public class CreditCardValidator extends AbstractValidator<String>
{
private static final long serialVersionUID = 1L;
+ /** The credit card number, which should be validated. */
+ private String creditCardNumber = null;
+
+ /** The ID which represents the credit card institute. */
+ private int cardId = -1;
+
+ /** */
+ public static final int INVALID = -1;
+ public static final int AMERICAN_EXPRESS = 0;
+ public static final int CHINA_UNIONPAY = 1;
+ public static final int DINERS_CLUB_CARTE_BLANCHE = 2;
+ public static final int DINERS_CLUB_INTERNATIONAL = 3;
+ public static final int DINERS_CLUB_US_AND_CANADA = 4;
+ public static final int DISCOVER_CARD = 5;
+ public static final int JCB = 6;
+ public static final int LASER = 7;
+ public static final int MAESTRO = 8;
+ public static final int MASTERCARD = 9;
+ public static final int SOLO = 10;
+ public static final int SWITCH = 11;
+ public static final int VISA = 12;
+ public static final int VISA_ELECTRON = 13;
+
+ private static final String[] creditCardNames = { "American Express", "China UnionPay",
+ "Diners Club Carte Blanche", "Diners Club International", "Diners Club US & Canada",
+ "Discover Card", "JCB", "Laser", "Maestro", "MasterCard", "Solo", "Switch", "Visa",
+ "Visa Electron" };
+
/**
* @see AbstractValidator#onValidate(IValidatable)
*/
@Override
protected void onValidate(IValidatable<String> validatable)
{
- String input = (validatable.getValue());
+ creditCardNumber = validatable.getValue();
+ if (!isLengthAndPrefixCorrect(creditCardNumber))
+ {
+ error(validatable);
+ }
+ }
+
+ /**
+ * Checks if the credit card number can be determined as a valid number.
+ *
+ * @param creditCardNumber
+ * the credit card number as a string
+ * @return <code>TRUE</code> if the credit card number could be determined as a valid number,
+ * else <code>FALSE</code> is returned
+ */
+ private boolean isLengthAndPrefixCorrect(String creditCardNumber)
+ {
+ if (creditCardNumber != null)
+ {
+ // strip spaces and dashes
+ creditCardNumber = creditCardNumber.replaceAll("[ -]", "");
+ }
+
+ // the length of the credit card number has to be between 12 and 19.
+ // else the number is invalid.
+ if (creditCardNumber != null && creditCardNumber.length() >= 12 &&
+ creditCardNumber.length() <= 19)
+ {
+ if (isAmericanExpress(creditCardNumber))
+ {
+ return true;
+ }
+ else if (isChinaUnionPay(creditCardNumber))
+ {
+ return true;
+ }
+ else if (isDinersClubCarteBlanche(creditCardNumber))
+ {
+ return true;
+ }
+ else if (isDinersClubInternational(creditCardNumber))
+ {
+ return true;
+ }
+ else if (isDinersClubUsAndCanada(creditCardNumber))
+ {
+ return true;
+ }
+ else if (isDiscoverCard(creditCardNumber))
+ {
+ return true;
+ }
+ else if (isJCB(creditCardNumber))
+ {
+ return true;
+ }
+ else if (isLaser(creditCardNumber))
+ {
+ return true;
+ }
+ else if (isMaestro(creditCardNumber))
+ {
+ return true;
+ }
+ else if (isMastercard(creditCardNumber))
+ {
+ return true;
+ }
+ else if (isSolo(creditCardNumber))
+ {
+ return true;
+ }
+ else if (isSwitch(creditCardNumber))
+ {
+ return true;
+ }
+ else if (isVisa(creditCardNumber))
+ {
+ return true;
+ }
+ else if (isVisaElectron(creditCardNumber))
+ {
+ return true;
+ }
+ else if (isUnknown(creditCardNumber))
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Can be used (subclassed) to extend the test with a credit card not yet known by the
+ * validator.
+ *
+ * @param creditCardNumber
+ * the credit card number as a string
+ * @return <code>TRUE</code> if the credit card number seems to be a valid American Express
+ * number. Else <code>FALSE</code> will be returned
+ */
+ protected boolean isUnknown(String creditCardNumber)
+ {
+ return false;
+ }
+
+ /**
+ * Check if the credit card is an American Express. An American Express number has to start with
+ * 34 or 37 and has to have a length of 15. The number has to be validated with the Luhn
+ * alorithm.
+ *
+ * @param creditCardNumber
+ * the credit card number as a string
+ * @return <code>TRUE</code> if the credit card number seems to be a valid American Express
+ * number. Else <code>FALSE</code> will be returned
+ */
+ private boolean isAmericanExpress(String creditCardNumber)
+ {
+ cardId = CreditCardValidator.INVALID;
+ boolean returnValue = false;
+
+ if (creditCardNumber.length() == 15 &&
+ (creditCardNumber.startsWith("34") || creditCardNumber.startsWith("37")))
+ {
+ if (isChecksumCorrect(creditCardNumber))
+ {
+ cardId = CreditCardValidator.AMERICAN_EXPRESS;
+ returnValue = true;
+ }
+ }
+
+ return returnValue;
+ }
+
+ /**
+ * Check if the credit card is a China UnionPay. A China UnionPay number has to start with 622
+ * (622126-622925) and has to have a length between 16 and 19. No further validation takes
+ * place.<br/>
+ * <br/>
+ *
+ * @param creditCardNumber
+ * the credit card number as a string
+ * @return <code>TRUE</code> if the credit card number seems to be a valid China UnionPay
+ * number. Else <code>FALSE</code> will be returned.
+ */
+ private boolean isChinaUnionPay(String creditCardNumber)
+ {
+ cardId = CreditCardValidator.INVALID;
+ boolean returnValue = false;
+
+ if ((creditCardNumber.length() >= 16 && creditCardNumber.length() <= 19) &&
+ (creditCardNumber.startsWith("622")))
+ {
+ int firstDigits = Integer.parseInt(creditCardNumber.substring(0, 5));
+ if (firstDigits >= 622126 && firstDigits <= 622925)
+ {
+ cardId = CreditCardValidator.CHINA_UNIONPAY;
+ returnValue = true;
+ }
+ }
+
+ return returnValue;
+ }
+
+ /**
+ * Check if the credit card is a Diners Club Carte Blanche. A Diners Club Carte Blanche number
+ * has to start with a number between 300 and 305 and has to have a length of 14. The number has
+ * to be validated with the Luhn alorithm.
+ *
+ * @param creditCardNumber
+ * the credit card number as a string
+ * @return <code>TRUE</code> if the credit card number seems to be a valid Diners Club Carte
+ * Blanche number. Else <code>FALSE</code> will be returned
+ */
+ private boolean isDinersClubCarteBlanche(String creditCardNumber)
+ {
+ cardId = CreditCardValidator.INVALID;
+ boolean returnValue = false;
+
+ if (creditCardNumber.length() == 14 && creditCardNumber.startsWith("30"))
+ {
+ int firstDigits = Integer.parseInt(creditCardNumber.substring(0, 3));
+ if (firstDigits >= 300 && firstDigits <= 305 && isChecksumCorrect(creditCardNumber))
+ {
+ cardId = CreditCardValidator.DINERS_CLUB_CARTE_BLANCHE;
+ returnValue = true;
+ }
+ }
+
+ return returnValue;
+ }
+
+ /**
+ * Check if the credit card is a Diners Club International. A Diners Club International number
+ * has to start with the number 36 and has to have a length of 14. The number has to be
+ * validated with the Luhn alorithm.
+ *
+ * @param creditCardNumber
+ * the credit card number as a string
+ * @return <code>TRUE</code> if the credit card number seems to be a valid Diners Club
+ * International number. Else <code>FALSE</code> will be returned
+ */
+ private boolean isDinersClubInternational(String creditCardNumber)
+ {
+ cardId = CreditCardValidator.INVALID;
+ boolean returnValue = false;
+
+ if (creditCardNumber.length() == 14 && creditCardNumber.startsWith("36") &&
+ isChecksumCorrect(creditCardNumber))
+ {
+ cardId = CreditCardValidator.DINERS_CLUB_INTERNATIONAL;
+ returnValue = true;
+ }
+
+ return returnValue;
+ }
+
+ /**
+ * Check if the credit card is a Diners Club US & Canada. A Diners Club US & Canada number has
+ * to start with the number 54 or 55 and has to have a length of 16. The number has to be
+ * validated with the Luhn alorithm.
+ *
+ * @param creditCardNumber
+ * the credit card number as a string
+ * @return <code>TRUE</code> if the credit card number seems to be a valid Diners Club US &
+ * Canada number. Else <code>FALSE</code> will be returned
+ */
+ private boolean isDinersClubUsAndCanada(String creditCardNumber)
+ {
+ cardId = CreditCardValidator.INVALID;
+ boolean returnValue = false;
+
+ if (creditCardNumber.length() == 16 &&
+ (creditCardNumber.startsWith("54") || creditCardNumber.startsWith("55")) &&
+ isChecksumCorrect(creditCardNumber))
+ {
+ cardId = CreditCardValidator.DINERS_CLUB_US_AND_CANADA;
+ returnValue = true;
+ }
+
+ return returnValue;
+ }
+
+ /**
+ * Check if the credit card is a Discover Card. A Discover Card number has to start with 6011,
+ * 622126-622925, 644-649 or 65 and has to have a length of 16. The number has to be validated
+ * with the Luhn alorithm.
+ *
+ * @param creditCardNumber
+ * the credit card number as a string
+ * @return <code>TRUE</code> if the credit card number seems to be a valid Discover Card number.
+ * Else <code>FALSE</code> will be returned
+ */
+ private boolean isDiscoverCard(String creditCardNumber)
+ {
+ cardId = CreditCardValidator.INVALID;
+ boolean returnValue = false;
+
+ if (creditCardNumber.length() == 16 && creditCardNumber.startsWith("6") &&
+ isChecksumCorrect(creditCardNumber))
+ {
+ int firstThreeDigits = Integer.parseInt(creditCardNumber.substring(0, 3));
+ int firstSixDigits = Integer.parseInt(creditCardNumber.substring(0, 6));
+ if (creditCardNumber.startsWith("6011") || creditCardNumber.startsWith("65") ||
+ (firstThreeDigits >= 644 && firstThreeDigits <= 649) ||
+ (firstSixDigits >= 622126 && firstSixDigits <= 622925))
+ {
+ cardId = CreditCardValidator.DISCOVER_CARD;
+ returnValue = true;
+ }
+ }
+
+ return returnValue;
+ }
+
+ /**
+ * Check if the credit card is a JCB. A JCB number has to start with a number between 3528 and
+ * 3589 and has to have a length of 16. The number has to be validated with the Luhn alorithm.
+ *
+ * @param creditCardNumber
+ * the credit card number as a string
+ * @return <code>TRUE</code> if the credit card number seems to be a valid JCB number. Else
+ * <code>FALSE</code> will be returned
+ */
+ private boolean isJCB(String creditCardNumber)
+ {
+ cardId = CreditCardValidator.INVALID;
+ boolean returnValue = false;
+
+ if (creditCardNumber.length() == 16 && isChecksumCorrect(creditCardNumber))
+ {
+ int firstFourDigits = Integer.parseInt(creditCardNumber.substring(0, 4));
+ if (firstFourDigits >= 3528 && firstFourDigits <= 3589)
+ {
+ cardId = CreditCardValidator.JCB;
+ returnValue = true;
+ }
+ }
+
+ return returnValue;
+ }
+
+ /**
+ * Check if the credit card is a Laser. A Laser number has to start with 6304, 6706, 6771 or
+ * 6709 and has to have a length between 16 and 19 digits. The number has to be validated with
+ * the Luhn alorithm.
+ *
+ * @param creditCardNumber
+ * the credit card number as a string
+ * @return <code>TRUE</code> if the credit card number seems to be a valid Laser number. Else
+ * <code>FALSE</code> will be returned
+ */
+ private boolean isLaser(String creditCardNumber)
+ {
+ cardId = CreditCardValidator.INVALID;
+ boolean returnValue = false;
+
+ if (creditCardNumber.length() >= 16 && creditCardNumber.length() <= 19 &&
+ isChecksumCorrect(creditCardNumber))
+ {
+ if (creditCardNumber.startsWith("6304") || creditCardNumber.startsWith("6706") ||
+ creditCardNumber.startsWith("6771") || creditCardNumber.startsWith("6709"))
+ {
+ cardId = CreditCardValidator.LASER;
+ returnValue = true;
+ }
+ }
+
+ return returnValue;
+ }
+
+ /**
+ * Check if the credit card is a Maestro. A Maestro number has to start with
+ * 5018,5020,5038,6304,6759,6761 or 6763 and has to have a length between 12 and 19 digits. The
+ * number has to be validated with the Luhn alorithm.
+ *
+ * @param creditCardNumber
+ * the credit card number as a string
+ * @return <code>TRUE</code> if the credit card number seems to be a valid Maestro number. Else
+ * <code>FALSE</code> will be returned
+ */
+ private boolean isMaestro(String creditCardNumber)
+ {
+ cardId = CreditCardValidator.INVALID;
+ boolean returnValue = false;
+
+ if (creditCardNumber.length() >= 12 && creditCardNumber.length() <= 19 &&
+ isChecksumCorrect(creditCardNumber))
+ {
+ if (creditCardNumber.startsWith("5018") || creditCardNumber.startsWith("5020") ||
+ creditCardNumber.startsWith("5038") || creditCardNumber.startsWith("6304") ||
+ creditCardNumber.startsWith("6759") || creditCardNumber.startsWith("6761") ||
+ creditCardNumber.startsWith("6763"))
+ {
+ cardId = CreditCardValidator.MAESTRO;
+ returnValue = true;
+ }
+ }
+
+ return returnValue;
+ }
+
+ /**
+ * Check if the credit card is a Solo. A Solo number has to start with 6334 or 6767 and has to
+ * have a length of 16, 18 or 19 digits. The number has to be validated with the Luhn alorithm.
+ *
+ * @param creditCardNumber
+ * the credit card number as a string
+ * @return <code>TRUE</code> if the credit card number seems to be a valid Solo number. Else
+ * <code>FALSE</code> will be returned
+ */
+ private boolean isSolo(String creditCardNumber)
+ {
+ cardId = CreditCardValidator.INVALID;
+ boolean returnValue = false;
+
+ if ((creditCardNumber.length() == 16 || creditCardNumber.length() == 18 || creditCardNumber.length() == 19) &&
+ isChecksumCorrect(creditCardNumber))
+ {
+ if (creditCardNumber.startsWith("6334") || creditCardNumber.startsWith("6767"))
+ {
+ cardId = CreditCardValidator.SOLO;
+ returnValue = true;
+ }
+ }
+
+ return returnValue;
+ }
+
+ /**
+ * Check if the credit card is a Switch. A Switch number has to start with
+ * 4903,4905,4911,4936,564182,633110,6333 or 6759 and has to have a length of 16, 18 or 19
+ * digits. The number has to be validated with the Luhn alorithm.
+ *
+ * @param creditCardNumber
+ * the credit card number as a string
+ * @return <code>TRUE</code> if the credit card number seems to be a valid Switch number. Else
+ * <code>FALSE</code> will be returned
+ */
+ private boolean isSwitch(String creditCardNumber)
+ {
+ cardId = CreditCardValidator.INVALID;
+ boolean returnValue = false;
+
+ if ((creditCardNumber.length() == 16 || creditCardNumber.length() == 18 || creditCardNumber.length() == 19) &&
+ isChecksumCorrect(creditCardNumber))
+ {
+ if (creditCardNumber.startsWith("4903") || creditCardNumber.startsWith("4905") ||
+ creditCardNumber.startsWith("4911") || creditCardNumber.startsWith("4936") ||
+ creditCardNumber.startsWith("564182") || creditCardNumber.startsWith("633110") ||
+ creditCardNumber.startsWith("6333") || creditCardNumber.startsWith("6759"))
+ {
+ cardId = CreditCardValidator.SWITCH;
+ returnValue = true;
+ }
+ }
+
+ return returnValue;
+ }
+
+ /**
+ * Check if the credit card is a Visa. A Visa number has to start with a 4 and has to have a
+ * length of 13 or 16 digits. The number has to be validated with the Luhn alorithm.
+ *
+ * @param creditCardNumber
+ * the credit card number as a string
+ * @return <code>TRUE</code> if the credit card number seems to be a valid Visa number. Else
+ * <code>FALSE</code> will be returned
+ */
+ private boolean isVisa(String creditCardNumber)
+ {
+ cardId = CreditCardValidator.INVALID;
+ boolean returnValue = false;
+
+ if (creditCardNumber.length() == 13 || creditCardNumber.length() == 16)
+ {
+ if (creditCardNumber.startsWith("4"))
+ {
+ cardId = CreditCardValidator.SWITCH;
+ returnValue = true;
+ }
+ }
+
+ return returnValue;
+ }
+
+ /**
+ * Check if the credit card is a Visa Electron. A Visa Electron number has to start with
+ * 417500,4917,4913,4508 or 4844 and has to have a length of 16 digits. The number has to be
+ * validated with the Luhn alorithm.
+ *
+ * @param creditCardNumber
+ * the credit card number as a string
+ * @return <code>TRUE</code> if the credit card number seems to be a valid Visa Electron number.
+ * Else <code>FALSE</code> will be returned
+ */
+ private boolean isVisaElectron(String creditCardNumber)
+ {
+ cardId = CreditCardValidator.INVALID;
+ boolean returnValue = false;
+
+ if (creditCardNumber.length() == 16 &&
+ (creditCardNumber.startsWith("417500") || creditCardNumber.startsWith("4917") ||
+ creditCardNumber.startsWith("4913") || creditCardNumber.startsWith("4508") || creditCardNumber.startsWith("4844")))
+ {
+ cardId = CreditCardValidator.VISA_ELECTRON;
+ returnValue = true;
+ }
+
+ return returnValue;
+ }
+
+ /**
+ * Check if the credit card is a Mastercard. A Mastercard number has to start with a number
+ * between 51 and 55 and has to have a length of 16. The number has to be validated with the
+ * Luhn alorithm.
+ *
+ * @param creditCardNumber
+ * the credit card number as a string
+ * @return <code>TRUE</code> if the credit card number seems to be a valid Mastercard number.
+ * Else <code>FALSE</code> will be returned
+ */
+ private boolean isMastercard(String creditCardNumber)
+ {
+ cardId = CreditCardValidator.INVALID;
+ boolean returnValue = false;
+
+ if (creditCardNumber.length() == 16 && isChecksumCorrect(creditCardNumber))
+ {
+ int firstTwoDigits = Integer.parseInt(creditCardNumber.substring(0, 2));
+ if (firstTwoDigits >= 51 && firstTwoDigits <= 55)
+ {
+ cardId = CreditCardValidator.MASTERCARD;
+ returnValue = true;
+ }
+ }
+
+ return returnValue;
+ }
+
+ /**
+ * Just used for debugging purposes.<br>
+ * Due to re-branding (e.g. Switch was re-branded as Maestro in mid 2007) some rules might
+ * overlap, but those overlappings are not considered. So it might happen, that a Switch-card is
+ * identified as a Maestro. <br>
+ * So you shouldn't rely on the name which is returned here.
+ *
+ * @return the name of the credit card if it could be determined, else an empty string
+ */
+ private String getCardName()
+ {
+ return (cardId > -1 && cardId < creditCardNames.length ? creditCardNames[cardId] : "");
+ }
+
+ /**
+ * Calculates the checksum of a credit card number using the Luhn algorithm (the so-called
+ * "mod 10" algorithm).
+ *
+ * @param creditCardNumber
+ * the credit card number for which the checksum should be calculated
+ * @return <code>TRUE</code> if the checksum for the given credit card number is valid, else
+ * return <code>FALSE</code>
+ * @see <a href="http://en.wikipedia.org/wiki/Luhn_algorithm">Wikipedie - Luhn algorithm</a>
+ */
+ private boolean isChecksumCorrect(String creditCardNumber)
+ {
+ String input = creditCardNumber;
String numberToCheck = input.replaceAll("[ -]", "");
int nulOffset = '0';
int sum = 0;
@@ -57,9 +616,7 @@ public class CreditCardValidator extends AbstractValidator<String>
sum += currentDigit;
}
}
- if (!((sum % 10) == 0))
- {
- error(validatable);
- }
+
+ return (sum % 10) == 0;
}
}
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-2552_12e1f39b.diff |
bugs-dot-jar_data_WICKET-4109_8f7805f8 | ---
BugID: WICKET-4109
Summary: AutocompleteTextField after Submit does not work
Description: "I use an AutocompleteTextfield together with a submit-Button. After
once submitting the content oft the AutocompleteTextField the parameter q is added
to the URL. After that the autocompletion will only complete the parameter q in
the url and not the parameter given by ajax.\n\nI tracked the problem down to the
callbackURL. \nIt contains a pattern looking as follows: ....&q=<paramproducedbysubmit>&q=<paramproducedbyajaxautocomplete>
\nThe callbackurl is build of the parameter q and the extraction of parameters only
accepts the first parameter\n"
diff --git a/wicket-core/src/main/java/org/apache/wicket/request/handler/PageProvider.java b/wicket-core/src/main/java/org/apache/wicket/request/handler/PageProvider.java
index ed01ddb..f000bad 100644
--- a/wicket-core/src/main/java/org/apache/wicket/request/handler/PageProvider.java
+++ b/wicket-core/src/main/java/org/apache/wicket/request/handler/PageProvider.java
@@ -292,12 +292,6 @@ public class PageProvider implements IPageProvider
(pageClass == null || pageClass.equals(storedPageInstance.getClass())))
{
pageInstance = storedPageInstance;
-
- if (pageParameters != null)
- {
- storedPageInstance.getPageParameters().overwriteWith(pageParameters);
- }
-
}
return storedPageInstance;
}
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-4109_8f7805f8.diff |
bugs-dot-jar_data_WICKET-3872_3feb0e3a | ---
BugID: WICKET-3872
Summary: MarkupContainer.removeAll() does not detach models recursively
Description: 'ML thread at: http://markmail.org/message/ybdfd2ts4i3j2b72'
diff --git a/wicket-core/src/main/java/org/apache/wicket/MarkupContainer.java b/wicket-core/src/main/java/org/apache/wicket/MarkupContainer.java
index 17f43d7..b72702e 100644
--- a/wicket-core/src/main/java/org/apache/wicket/MarkupContainer.java
+++ b/wicket-core/src/main/java/org/apache/wicket/MarkupContainer.java
@@ -644,7 +644,7 @@ public abstract class MarkupContainer extends Component implements Iterable<Comp
// Do not call remove() because the state change would than be
// recorded twice.
child.internalOnRemove();
- child.detachModel();
+ child.detach();
child.setParent(null);
}
}
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-3872_3feb0e3a.diff |
bugs-dot-jar_data_WICKET-1897_8ee095bf | ---
BugID: WICKET-1897
Summary: StatelessForm submitted to the wrong page
Description: |-
I made a small application to reproduce the problem. You can download it from http://aditsu.net/wickettest.zip , I'll try to attach it too.
Dependencies: jetty 6, wicket 1.4-m3, slf4j, log4j
Steps to reproduce:
1. Run the test.Start class
2. Open http://localhost:8080 in a browser
3. Open http://localhost:8080/page2 in a new tab
4. Go to the first tab and click submit
Result:
WicketRuntimeException: unable to find component with path form on stateless page [Page class = test.Page2, id = 0, version = 0]
It looks like the 2 pages are created with the same id in 2 different pagemaps, but when I submit the form, it goes to the second pagemap and finds the second page (with no form on it).
diff --git a/wicket/src/main/java/org/apache/wicket/request/target/component/BookmarkableListenerInterfaceRequestTarget.java b/wicket/src/main/java/org/apache/wicket/request/target/component/BookmarkableListenerInterfaceRequestTarget.java
index 097d44b..892b17a 100644
--- a/wicket/src/main/java/org/apache/wicket/request/target/component/BookmarkableListenerInterfaceRequestTarget.java
+++ b/wicket/src/main/java/org/apache/wicket/request/target/component/BookmarkableListenerInterfaceRequestTarget.java
@@ -1,196 +1,196 @@
-/*
- * 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.request.target.component;
-
-import org.apache.wicket.Component;
-import org.apache.wicket.Page;
-import org.apache.wicket.PageParameters;
-import org.apache.wicket.RequestCycle;
-import org.apache.wicket.RequestListenerInterface;
-import org.apache.wicket.Session;
-import org.apache.wicket.WicketRuntimeException;
-import org.apache.wicket.protocol.http.PageExpiredException;
-import org.apache.wicket.protocol.http.request.WebRequestCodingStrategy;
-import org.apache.wicket.util.string.AppendingStringBuffer;
-import org.apache.wicket.util.string.Strings;
-
-/**
- * Request target for bookmarkable page links that also contain component path and interface name.
- * This is used for stateless forms and stateless links.
- *
- * @author Matej Knopp
- */
-public class BookmarkableListenerInterfaceRequestTarget extends BookmarkablePageRequestTarget
-{
- private final String componentPath;
- private final String interfaceName;
-
- /**
- * This constructor is called when a stateless link is clicked on but the page wasn't found in
- * the session. Then this class will recreate the page and call the interface method on the
- * component that is targeted with the component path.
- *
- * @param pageMapName
- * @param pageClass
- * @param pageParameters
- * @param componentPath
- * @param interfaceName
- * @param versionNumber
- */
- public BookmarkableListenerInterfaceRequestTarget(String pageMapName,
- Class<? extends Page> pageClass, PageParameters pageParameters, String componentPath,
- String interfaceName, int versionNumber)
- {
- super(pageMapName, pageClass, pageParameters);
- this.componentPath = componentPath;
- this.interfaceName = interfaceName;
- }
-
- /**
- * This constructor is called for generating the urls (RequestCycle.urlFor()) So it will alter
- * the PageParameters to include the 2 org.apache.wicket params
- * {@link WebRequestCodingStrategy#BOOKMARKABLE_PAGE_PARAMETER_NAME} and
- * {@link WebRequestCodingStrategy#INTERFACE_PARAMETER_NAME}
- *
- * @param pageMapName
- * @param pageClass
- * @param pageParameters
- * @param component
- * @param listenerInterface
- */
- public BookmarkableListenerInterfaceRequestTarget(String pageMapName,
- Class<? extends Page> pageClass, PageParameters pageParameters, Component component,
- RequestListenerInterface listenerInterface)
- {
- this(pageMapName, pageClass, pageParameters, component.getPath(),
- listenerInterface.getName(), component.getPage().getCurrentVersionNumber());
-
- int version = component.getPage().getCurrentVersionNumber();
- setPage(component.getPage());
-
- // add the wicket:interface param to the params.
- // pagemap:(pageid:componenta:componentb:...):version:interface:behavior:urlDepth
- AppendingStringBuffer param = new AppendingStringBuffer(4 + componentPath.length() +
- interfaceName.length());
- if (pageMapName != null)
- {
- param.append(pageMapName);
- }
- param.append(Component.PATH_SEPARATOR);
- param.append(getComponentPath());
- param.append(Component.PATH_SEPARATOR);
- if (version != 0)
- {
- param.append(version);
- }
- // Interface
- param.append(Component.PATH_SEPARATOR);
- param.append(getInterfaceName());
-
- // Behavior (none)
- param.append(Component.PATH_SEPARATOR);
-
- // URL depth (not required)
- param.append(Component.PATH_SEPARATOR);
-
- pageParameters.put(WebRequestCodingStrategy.INTERFACE_PARAMETER_NAME, param.toString());
- }
-
- @Override
- public void processEvents(RequestCycle requestCycle)
- {
- Page page = getPage();
- if (page == null)
- {
- page = Session.get().getPage(getPageMapName(), componentPath, -1);
- if (page != null)
- {
- setPage(page);
- }
- else if (page == null)
- {
- page = getPage(requestCycle);
- }
- }
-
- if (page == null)
- {
- throw new PageExpiredException(
- "Request cannot be processed. The target page does not exist anymore.");
- }
-
- final String pageRelativeComponentPath = Strings.afterFirstPathComponent(componentPath,
- Component.PATH_SEPARATOR);
- Component component = page.get(pageRelativeComponentPath);
- if (component == null)
- {
- // this is quite a hack to get components in repeater work.
- // But it still can fail if the repeater is a paging one or on every render
- // it will generate new index for the items...
- page.prepareForRender(false);
- component = page.get(pageRelativeComponentPath);
- if (component == null)
- {
- throw new WicketRuntimeException(
- "unable to find component with path " +
- pageRelativeComponentPath +
- " on stateless page " +
- page +
- " it could be that the component is inside a repeater make your component return false in getStatelessHint()");
- }
- }
- RequestListenerInterface listenerInterface = RequestListenerInterface.forName(interfaceName);
- if (listenerInterface == null)
- {
- throw new WicketRuntimeException("unable to find listener interface " + interfaceName);
- }
- listenerInterface.invoke(page, component);
- }
-
- @Override
- public void respond(RequestCycle requestCycle)
- {
- Page page = getPage(requestCycle);
- // if the listener call wanted to redirect
- // then do that if the page is not stateless.
- if (requestCycle.isRedirect() && !page.isPageStateless())
- {
- requestCycle.redirectTo(page);
- }
- else
- {
- // else render the page directly
- page.renderPage();
- }
- }
-
- /**
- * @return The component path.
- */
- public String getComponentPath()
- {
- return componentPath;
- }
-
- /**
- * @return The interface name
- */
- public String getInterfaceName()
- {
- return interfaceName;
- }
-}
+/*
+ * 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.request.target.component;
+
+import org.apache.wicket.Component;
+import org.apache.wicket.Page;
+import org.apache.wicket.PageParameters;
+import org.apache.wicket.RequestCycle;
+import org.apache.wicket.RequestListenerInterface;
+import org.apache.wicket.Session;
+import org.apache.wicket.WicketRuntimeException;
+import org.apache.wicket.protocol.http.PageExpiredException;
+import org.apache.wicket.protocol.http.request.WebRequestCodingStrategy;
+import org.apache.wicket.util.string.AppendingStringBuffer;
+import org.apache.wicket.util.string.Strings;
+
+/**
+ * Request target for bookmarkable page links that also contain component path and interface name.
+ * This is used for stateless forms and stateless links.
+ *
+ * @author Matej Knopp
+ */
+public class BookmarkableListenerInterfaceRequestTarget extends BookmarkablePageRequestTarget
+{
+ private final String componentPath;
+ private final String interfaceName;
+
+ /**
+ * This constructor is called when a stateless link is clicked on but the page wasn't found in
+ * the session. Then this class will recreate the page and call the interface method on the
+ * component that is targeted with the component path.
+ *
+ * @param pageMapName
+ * @param pageClass
+ * @param pageParameters
+ * @param componentPath
+ * @param interfaceName
+ * @param versionNumber
+ */
+ public BookmarkableListenerInterfaceRequestTarget(String pageMapName,
+ Class<? extends Page> pageClass, PageParameters pageParameters, String componentPath,
+ String interfaceName, int versionNumber)
+ {
+ super(pageMapName, pageClass, pageParameters);
+ this.componentPath = componentPath;
+ this.interfaceName = interfaceName;
+ }
+
+ /**
+ * This constructor is called for generating the urls (RequestCycle.urlFor()) So it will alter
+ * the PageParameters to include the 2 org.apache.wicket params
+ * {@link WebRequestCodingStrategy#BOOKMARKABLE_PAGE_PARAMETER_NAME} and
+ * {@link WebRequestCodingStrategy#INTERFACE_PARAMETER_NAME}
+ *
+ * @param pageMapName
+ * @param pageClass
+ * @param pageParameters
+ * @param component
+ * @param listenerInterface
+ */
+ public BookmarkableListenerInterfaceRequestTarget(String pageMapName,
+ Class<? extends Page> pageClass, PageParameters pageParameters, Component component,
+ RequestListenerInterface listenerInterface)
+ {
+ this(pageMapName, pageClass, pageParameters, component.getPath(),
+ listenerInterface.getName(), component.getPage().getCurrentVersionNumber());
+
+ int version = component.getPage().getCurrentVersionNumber();
+ setPage(component.getPage());
+
+ // add the wicket:interface param to the params.
+ // pagemap:(pageid:componenta:componentb:...):version:interface:behavior:urlDepth
+ AppendingStringBuffer param = new AppendingStringBuffer(4 + componentPath.length() +
+ interfaceName.length());
+ if (pageMapName != null)
+ {
+ param.append(pageMapName);
+ }
+ param.append(Component.PATH_SEPARATOR);
+ param.append(getComponentPath());
+ param.append(Component.PATH_SEPARATOR);
+ if (version != 0)
+ {
+ param.append(version);
+ }
+ // Interface
+ param.append(Component.PATH_SEPARATOR);
+ param.append(getInterfaceName());
+
+ // Behavior (none)
+ param.append(Component.PATH_SEPARATOR);
+
+ // URL depth (not required)
+ param.append(Component.PATH_SEPARATOR);
+
+ pageParameters.put(WebRequestCodingStrategy.INTERFACE_PARAMETER_NAME, param.toString());
+ }
+
+ @Override
+ public void processEvents(RequestCycle requestCycle)
+ {
+ Page page = getPage();
+ if (page == null)
+ {
+ page = Session.get().getPage(getPageMapName(), componentPath, -1);
+ if (page != null && page.getClass() == getPageClass())
+ {
+ setPage(page);
+ }
+ else
+ {
+ page = getPage(requestCycle);
+ }
+ }
+
+ if (page == null)
+ {
+ throw new PageExpiredException(
+ "Request cannot be processed. The target page does not exist anymore.");
+ }
+
+ final String pageRelativeComponentPath = Strings.afterFirstPathComponent(componentPath,
+ Component.PATH_SEPARATOR);
+ Component component = page.get(pageRelativeComponentPath);
+ if (component == null)
+ {
+ // this is quite a hack to get components in repeater work.
+ // But it still can fail if the repeater is a paging one or on every render
+ // it will generate new index for the items...
+ page.prepareForRender(false);
+ component = page.get(pageRelativeComponentPath);
+ if (component == null)
+ {
+ throw new WicketRuntimeException(
+ "unable to find component with path " +
+ pageRelativeComponentPath +
+ " on stateless page " +
+ page +
+ " it could be that the component is inside a repeater make your component return false in getStatelessHint()");
+ }
+ }
+ RequestListenerInterface listenerInterface = RequestListenerInterface.forName(interfaceName);
+ if (listenerInterface == null)
+ {
+ throw new WicketRuntimeException("unable to find listener interface " + interfaceName);
+ }
+ listenerInterface.invoke(page, component);
+ }
+
+ @Override
+ public void respond(RequestCycle requestCycle)
+ {
+ Page page = getPage(requestCycle);
+ // if the listener call wanted to redirect
+ // then do that if the page is not stateless.
+ if (requestCycle.isRedirect() && !page.isPageStateless())
+ {
+ requestCycle.redirectTo(page);
+ }
+ else
+ {
+ // else render the page directly
+ page.renderPage();
+ }
+ }
+
+ /**
+ * @return The component path.
+ */
+ public String getComponentPath()
+ {
+ return componentPath;
+ }
+
+ /**
+ * @return The interface name
+ */
+ public String getInterfaceName()
+ {
+ return interfaceName;
+ }
+}
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-1897_8ee095bf.diff |
bugs-dot-jar_data_WICKET-3454_f1e854b3 | ---
BugID: WICKET-3454
Summary: Value exchange in a wicket:message throws an exception
Description: |-
i tried to exchange values in a <wicket:message> like described in wiki <https://cwiki.apache.org/WICKET/wickets-xhtml-tags.html#Wicket%27sXHTMLtags-Elementwicket:message>.
But i get an exception:
ERROR - RequestCycle - No get method defined for class:
class org.apache.wicket.markup.resolver.MarkupInheritanceResolver$TransparentWebMarkupContainer expression: vat1value
org.apache.wicket.WicketRuntimeException: No get method defined for class:
class org.apache.wicket.markup.resolver.MarkupInheritanceResolver$TransparentWebMarkupContainer expression: vat1value
at org.apache.wicket.util.lang.PropertyResolver.getGetAndSetter(PropertyResolver.java:488)
at org.apache.wicket.util.lang.PropertyResolver.getObjectAndGetSetter(PropertyResolver.java:330)
at org.apache.wicket.util.lang.PropertyResolver.getObjectAndGetSetter(PropertyResolver.java:237)
...
Maybe it's caused by usage of border. I've debugged a bit, but could get a real glue.
I added a quick start with test case.
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/resolver/WicketMessageResolver.java b/wicket-core/src/main/java/org/apache/wicket/markup/resolver/WicketMessageResolver.java
index 03d7acd..fa4122a 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/resolver/WicketMessageResolver.java
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/resolver/WicketMessageResolver.java
@@ -344,10 +344,12 @@ public class WicketMessageResolver implements IComponentResolver
while (markupStream.hasMore() && !markupStream.get().closes(openTag))
{
MarkupElement element = markupStream.get();
+
// If it a tag like <wicket..> or <span wicket:id="..." >
if ((element instanceof ComponentTag) && !markupStream.atCloseTag())
{
- String id = ((ComponentTag)element).getId();
+ ComponentTag currentTag = (ComponentTag)element;
+ String id = currentTag.getId();
// Temporarily replace the web response with a String response
final Response webResponse = getResponse();
@@ -358,6 +360,18 @@ public class WicketMessageResolver implements IComponentResolver
getRequestCycle().setResponse(response);
Component component = getParent().get(id);
+ if (component == null)
+ {
+ component = ComponentResolvers.resolve(getParent(), markupStream,
+ currentTag, null);
+
+ // Must not be a Page and it must be connected to a parent.
+ if (component.getParent() == null)
+ {
+ component = null;
+ }
+ }
+
if (component != null)
{
component.render();
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-3454_f1e854b3.diff |
bugs-dot-jar_data_WICKET-3598_7c364566 | ---
BugID: WICKET-3598
Summary: DatePicker issues with locale medium date format
Description: |-
DateTextField as follows: DateTextField d = new DateTextField(id, model, new StyleDateConverter("M-",false));
Case 1:
- en-US locale
- for example DatePicker insert 04 rather than Apr in DateTextField, even though pattern clearly says MMM
Case 2:
- pl-PL locale
- 2010-10-25 is in the DateTextField
- DatePicker opens on April 2031 rather than October 2010
I believe the problem lies in wicket-date.js, in functions substituteDate and parseDate.
I know this might be duplicate of WICKET-2427 and WICKET-2375, but apparently this hasn't been properly fixed yet.
diff --git a/wicket-datetime/src/main/java/org/apache/wicket/datetime/StyleDateConverter.java b/wicket-datetime/src/main/java/org/apache/wicket/datetime/StyleDateConverter.java
index d68b04a..92ade4c 100644
--- a/wicket-datetime/src/main/java/org/apache/wicket/datetime/StyleDateConverter.java
+++ b/wicket-datetime/src/main/java/org/apache/wicket/datetime/StyleDateConverter.java
@@ -16,14 +16,14 @@
*/
package org.apache.wicket.datetime;
-import java.util.Locale;
-
import org.apache.wicket.datetime.markup.html.form.DateTextField;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
+import java.util.Locale;
+
/**
* Date converter that uses Joda Time and can be configured to take the time zone difference between
@@ -52,15 +52,13 @@ public class StyleDateConverter extends DateConverter
/**
* Construct. The dateStyle 'S-' (which is the same as {@link DateTimeFormat#shortDate()}) will
- * be used for constructing the date format for the current locale.
- * </p>
- * When applyTimeZoneDifference is true, the current time is applied on the parsed date, and the
- * date will be corrected for the time zone difference between the server and the client. For
+ * be used for constructing the date format for the current locale. </p> When
+ * applyTimeZoneDifference is true, the current time is applied on the parsed date, and the date
+ * will be corrected for the time zone difference between the server and the client. For
* instance, if I'm in Seattle and the server I'm working on is in Amsterdam, the server is 9
* hours ahead. So, if I'm inputting say 12/24 at a couple of hours before midnight, at the
* server it is already 12/25. If this boolean is true, it will be transformed to 12/25, while
- * the client sees 12/24.
- * </p>
+ * the client sees 12/24. </p>
*
* @param applyTimeZoneDifference
* whether to apply the difference in time zones between client and server
@@ -72,15 +70,13 @@ public class StyleDateConverter extends DateConverter
/**
* Construct. The provided pattern will be used as the base format (but they will be localized
- * for the current locale) and if null, {@link DateTimeFormat#shortDate()} will be used.
- * </p>
+ * for the current locale) and if null, {@link DateTimeFormat#shortDate()} will be used. </p>
* When applyTimeZoneDifference is true, the current time is applied on the parsed date, and the
* date will be corrected for the time zone difference between the server and the client. For
* instance, if I'm in Seattle and the server I'm working on is in Amsterdam, the server is 9
* hours ahead. So, if I'm inputting say 12/24 at a couple of hours before midnight, at the
* server it is already 12/25. If this boolean is true, it will be transformed to 12/25, while
- * the client sees 12/24.
- * </p>
+ * the client sees 12/24. </p>
*
* @param dateStyle
* Date style to use. The first character is the date style, and the second character
@@ -119,6 +115,8 @@ public class StyleDateConverter extends DateConverter
@Override
protected DateTimeFormatter getFormat(Locale locale)
{
- return DateTimeFormat.forPattern(getDatePattern(locale)).withPivotYear(2000);
+ return DateTimeFormat.forPattern(getDatePattern(locale))
+ .withLocale(locale)
+ .withPivotYear(2000);
}
}
\ No newline at end of file
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-3598_7c364566.diff |
bugs-dot-jar_data_WICKET-2839_15477252 | ---
BugID: WICKET-2839
Summary: ajax not working due to bugs in resource handling
Description: |-
A couple of bugs were found that were preventing .js resources to be returned to the client correctly. One bug was returning the jar file size as the content length of the resource if it is in a jar file. The other was copying past a source buffer into the response.
After fixing these bugs, the ajax functions in the trunk seems to be working.
A patch is provided. Test cases included.
diff --git a/wicket/src/main/java/org/apache/wicket/request/resource/AbstractResource.java b/wicket/src/main/java/org/apache/wicket/request/resource/AbstractResource.java
index 1f6f526..00358a06 100644
--- a/wicket/src/main/java/org/apache/wicket/request/resource/AbstractResource.java
+++ b/wicket/src/main/java/org/apache/wicket/request/resource/AbstractResource.java
@@ -463,7 +463,7 @@ public abstract class AbstractResource implements IResource
@Override
public void write(byte[] b, int off, int len) throws IOException
{
- if (off == 0 || len == b.length)
+ if (off == 0 && len == b.length)
{
write(b);
}
diff --git a/wicket/src/main/java/org/apache/wicket/util/resource/UrlResourceStream.java b/wicket/src/main/java/org/apache/wicket/util/resource/UrlResourceStream.java
index 8a0cef7..02a144b 100644
--- a/wicket/src/main/java/org/apache/wicket/util/resource/UrlResourceStream.java
+++ b/wicket/src/main/java/org/apache/wicket/util/resource/UrlResourceStream.java
@@ -193,26 +193,26 @@ public class UrlResourceStream extends AbstractResourceStream
@Override
public Time lastModifiedTime()
{
- if (file != null)
+ try
{
- // in case the file has been removed by now
- if (file.exists() == false)
+ if (file != null)
{
- return null;
- }
+ // in case the file has been removed by now
+ if (file.exists() == false)
+ {
+ return null;
+ }
- long lastModified = file.lastModified();
+ long lastModified = file.lastModified();
- // if last modified changed update content length and last modified date
- if (lastModified != this.lastModified)
- {
- this.lastModified = lastModified;
- contentLength = (int)file.length();
+ // if last modified changed update content length and last modified date
+ if (lastModified != this.lastModified)
+ {
+ this.lastModified = lastModified;
+ setContentLength();
+ }
}
- }
- else
- {
- try
+ else
{
long lastModified = Connections.getLastModified(url);
@@ -221,31 +221,35 @@ public class UrlResourceStream extends AbstractResourceStream
{
this.lastModified = lastModified;
- URLConnection connection = url.openConnection();
- contentLength = connection.getContentLength();
- Connections.close(connection);
+ setContentLength();
}
}
- catch (IOException e)
+ return Time.milliseconds(lastModified);
+ }
+ catch (IOException e)
+ {
+ if (url.toString().indexOf(".jar!") >= 0)
{
- if (url.toString().indexOf(".jar!") >= 0)
+ if (log.isDebugEnabled())
{
- if (log.isDebugEnabled())
- {
- log.debug("getLastModified for " + url + " failed: " + e.getMessage());
- }
+ log.debug("getLastModified for " + url + " failed: " + e.getMessage());
}
- else
- {
- log.warn("getLastModified for " + url + " failed: " + e.getMessage());
- }
-
- // allow modification watcher to detect the problem
- return null;
+ }
+ else
+ {
+ log.warn("getLastModified for " + url + " failed: " + e.getMessage());
}
+ // allow modification watcher to detect the problem
+ return null;
}
- return Time.milliseconds(lastModified);
+ }
+
+ private void setContentLength() throws IOException
+ {
+ URLConnection connection = url.openConnection();
+ contentLength = connection.getContentLength();
+ Connections.close(connection);
}
/**
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-2839_15477252.diff |
bugs-dot-jar_data_WICKET-2033_420ac965 | ---
BugID: WICKET-2033
Summary: "& instead of & in javascript"
Description: "the non httpsessionstore part of:\nhttps://issues.apache.org/jira/browse/WICKET-1971\n\nis
that \n\nin the \nwicket:ignoreIfNotActive actually becomes\n\namp;wicket:ignoreIfNotActive=true\n\nin:\n\n\tprotected
CharSequence encode(RequestCycle requestCycle,\n\t\t\tIListenerInterfaceRequestTarget
requestTarget)\n\nof WebRequestCodingStrategy on the line:\n\n\t\t\turl.append(url.indexOf(\"?\")
> -1 ? \"&\" : \"?\").append(\n\t\t\t\t\tIGNORE_IF_NOT_ACTIVE_PARAMETER_NAME).append(\"=true\");\n\n\nso
when this happens in \n\tpublic final RequestParameters decode(final Request request)
{\n\n---\n\t\tif (request.getParameter(IGNORE_IF_NOT_ACTIVE_PARAMETER_NAME) != null)\n\t\t{\n\t\t\tparameters.setOnlyProcessIfPathActive(true);\n\t\t}\n---\n\nthis
never actually happens.\n\n\nthen if you have a throttle, ajaxlazyloadpanel etc
with onlyprocessifpathactive set to true, and you logout, but go to another wicket
page, then the original session is destroyed and a new one is created\n\nif this
is worked around in the way the guys on WICKET-1971 suggest,\nWebRequestCycleProcessor\n\nmethod\n\n\tpublic
IRequestTarget resolve(final RequestCycle requestCycle,\n\t\t\tfinal RequestParameters
requestParameters)\n\n\n\t\t\t\tif (requestParameters.isOnlyProcessIfPathActive())\nlast
branch falls through:\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\t// TODO also this
should work..\n\t\t\t\t\t}\n\n\nand it throws PageExpiredException because the request
component/page/behavior does not exist in this new session. even though onlyprocessifpathactive
was set to true, and it's purpose is precisely to avoid pageexpiredexception."
diff --git a/wicket/src/main/java/org/apache/wicket/ajax/AjaxEventBehavior.java b/wicket/src/main/java/org/apache/wicket/ajax/AjaxEventBehavior.java
index ca42719..7f6afe7 100644
--- a/wicket/src/main/java/org/apache/wicket/ajax/AjaxEventBehavior.java
+++ b/wicket/src/main/java/org/apache/wicket/ajax/AjaxEventBehavior.java
@@ -108,9 +108,20 @@ public abstract class AjaxEventBehavior extends AbstractDefaultAjaxBehavior
Component myComponent = getComponent();
if (myComponent.isEnabledInHierarchy())
{
- tag.put(event, getEventHandler());
+ tag.put(event, escapeAttribute(getEventHandler()));
}
}
+
+ private CharSequence escapeAttribute(final CharSequence attr)
+ {
+ if(null == attr)
+ {
+ return null;
+ }
+ CharSequence escaped = Strings.escapeMarkup(attr.toString());
+ // No need to escape the apostrophe; it just clutters the markup
+ return Strings.replaceAll(escaped, "'", "'");
+ }
/**
*
diff --git a/wicket/src/main/java/org/apache/wicket/ajax/form/AjaxFormSubmitBehavior.java b/wicket/src/main/java/org/apache/wicket/ajax/form/AjaxFormSubmitBehavior.java
index 5ae018a..5a226c0 100644
--- a/wicket/src/main/java/org/apache/wicket/ajax/form/AjaxFormSubmitBehavior.java
+++ b/wicket/src/main/java/org/apache/wicket/ajax/form/AjaxFormSubmitBehavior.java
@@ -176,6 +176,6 @@ public abstract class AjaxFormSubmitBehavior extends AjaxEventBehavior
@Override
protected CharSequence getPreconditionScript()
{
- return "return Wicket.$$(this)&&Wicket.$$('" + getForm().getMarkupId() + "')";
+ return "return Wicket.$$(this)&&Wicket.$$('" + getForm().getMarkupId() + "')";
}
}
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-2033_420ac965.diff |
bugs-dot-jar_data_WICKET-5247_44a4132f | ---
BugID: WICKET-5247
Summary: Broken Link in Tomcat because of Page Mount
Description: "I post this message on the user mailing List (http://apache-wicket.1842946.n4.nabble.com/Broken-Link-in-Tomcat-because-of-Page-Mount-tt4659663.html)
and Martin Grigorov asked me, to create a ticket on Jira.\n\nBroken Link in Tomcat
because of Page Mount\n\nFollowing situation:\n-I have a Wicket Application(6.8.0)
which runs under the context \"webapp\" on a Tomcat 7.0.41\n-I mount a Page with
two parameters (this is important) in the WicketApplication.\n\tmountPage(\"/mount/${parameter1}/${parameter2}\",
MountedPage.class);\n-The mounted Page(MountedPage.class) has only a simple Link\n-There
are two links on the HomePage to the mounted Page.\n They are declared as follows:\n
\n\tadd(new Link<Void>(\"link\") {\n\t\t\t@Override\n\t\t\tpublic void onClick()
{\n\t\t\t\tsetResponsePage(MountedPage.class, linkParameters);\n\t\t\t}\n\t});\n\n\tadd(new
Link<Void>(\"brokenLink\") {\n\t\t\t@Override\n\t\t\tpublic void onClick() {\n\t\t\t\tsetResponsePage(new
MountedPage(linkParameters));\n\t\t\t}\n\t});\n\t\nI deploy this Application as
a war file on a Tomcat under the context \"webapp\".\nWhen I call the first Link
on the HomePage and then the Link on the mounted Page, everything works fine.\n\nBut
if I call the second Link and then the Link on the mounted Page, the link is broken.\nThe
context is missing in the generated link\n\thttp://localhost:8080/wicket/bookmarkable/com.mycompany.LinkedPage\n\nDoes
anyone have an idea, why the second link does not work on Tomcat?\n\nI add a Quickstart
and the war file as attachment.\n\nPs: Both links works fine in Jetty. \nPss:If
I remove the mount command, both links will work in Tomcat too."
diff --git a/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/MountedMapper.java b/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/MountedMapper.java
index 12f8985..c55222e 100644
--- a/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/MountedMapper.java
+++ b/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/MountedMapper.java
@@ -424,6 +424,11 @@ public class MountedMapper extends AbstractBookmarkableMapper
String optionalPlaceholder = getOptionalPlaceholder(mountSegments[i]);
if (placeholder != null)
{
+ if (!copy.getNamedKeys().contains(placeholder))
+ {
+ // no value for placeholder - cannot mount
+ return null;
+ }
url.getSegments().set(i - dropped, copy.get(placeholder).toString(""));
copy.remove(placeholder);
}
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5247_44a4132f.diff |
bugs-dot-jar_data_WICKET-4715_4fc82e35 | ---
BugID: WICKET-4715
Summary: WebApplication doesn't recognize if an incoming request is multipart.
Description: "Thanks to the mail at http://apache-wicket.1842946.n4.nabble.com/Read-POST-based-request-from-external-site-td4651269.html
we have spotted a problem with method newWebRequest of class WebApplication. \nIt
seems that this method doesn't test if the original request is multipart and doing
so post parameters go lost. \nWe should create a MultipartServletWebRequestImpl
when such a type of request is being served. I attach a possible patch but I'm not
100% about two things:\n- which is the best way to determinate if a HttpServletRequest
is multipart?\n- in order to build a MultipartServletWebRequestImpl we need to provide
a string identifier for the upload. How can we generate it (in my patch it's a
constant value)?\n"
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/Form.java b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/Form.java
index 9d0245d..9d46baf 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/Form.java
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/Form.java
@@ -147,6 +147,11 @@ public class Form<T> extends WebMarkupContainer implements IFormSubmitListener
private static final String HIDDEN_DIV_START = "<div style=\"width:0px;height:0px;position:absolute;left:-100px;top:-100px;overflow:hidden\">";
/**
+ * The value of HTMLFormElement's <code>enctype</code> attribute needed for file uploading.
+ */
+ public static final String ENCTYPE_MULTIPART_FORM_DATA = "multipart/form-data";
+
+ /**
* Visitor used for validation
*
* @author Igor Vaynberg (ivaynberg)
@@ -1540,7 +1545,7 @@ public class Form<T> extends WebMarkupContainer implements IFormSubmitListener
tag.put("method", METHOD_POST.toLowerCase(Locale.ENGLISH));
}
- tag.put("enctype", "multipart/form-data");
+ tag.put("enctype", ENCTYPE_MULTIPART_FORM_DATA);
//
// require the application-encoding for multipart/form-data to be sure to
// get multipart-uploaded characters with the proper encoding on the following
@@ -1555,7 +1560,7 @@ public class Form<T> extends WebMarkupContainer implements IFormSubmitListener
{
// sanity check
String enctype = (String)tag.getAttributes().get("enctype");
- if ("multipart/form-data".equalsIgnoreCase(enctype))
+ if (ENCTYPE_MULTIPART_FORM_DATA.equalsIgnoreCase(enctype))
{
// though not set explicitly in Java, this is a multipart
// form
diff --git a/wicket-core/src/main/java/org/apache/wicket/protocol/http/WebApplication.java b/wicket-core/src/main/java/org/apache/wicket/protocol/http/WebApplication.java
index 42ab5d1..117947d 100644
--- a/wicket-core/src/main/java/org/apache/wicket/protocol/http/WebApplication.java
+++ b/wicket-core/src/main/java/org/apache/wicket/protocol/http/WebApplication.java
@@ -44,6 +44,7 @@ import org.apache.wicket.markup.head.JavaScriptHeaderItem;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.form.AutoLabelResolver;
import org.apache.wicket.markup.html.form.AutoLabelTextResolver;
+import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.pages.AccessDeniedPage;
import org.apache.wicket.markup.html.pages.InternalErrorPage;
import org.apache.wicket.markup.html.pages.PageExpiredErrorPage;
@@ -79,6 +80,7 @@ import org.apache.wicket.util.lang.Args;
import org.apache.wicket.util.lang.PackageName;
import org.apache.wicket.util.string.Strings;
import org.apache.wicket.util.time.Duration;
+import org.apache.wicket.util.upload.FileUploadException;
import org.apache.wicket.util.watch.IModificationWatcher;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -486,6 +488,23 @@ public abstract class WebApplication extends Application
WebRequest webRequest = newWebRequest(servletRequest, filterPath);
+ String contentType = servletRequest.getContentType();
+ String method = servletRequest.getMethod();
+
+ if (webRequest instanceof ServletWebRequest && Form.METHOD_POST.equalsIgnoreCase(method) &&
+ Strings.isEmpty(contentType) == false && contentType.toLowerCase().startsWith(Form.ENCTYPE_MULTIPART_FORM_DATA))
+ {
+ try
+ {
+ return ((ServletWebRequest)webRequest).newMultipartWebRequest(
+ getApplicationSettings().getDefaultMaximumUploadSize(), "externalForm");
+ }
+ catch (FileUploadException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
return webRequest;
}
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-4715_4fc82e35.diff |
bugs-dot-jar_data_WICKET-3769_b4e9d426 | ---
BugID: WICKET-3769
Summary: WicketSessionFilter and HttpSessionStore use different attribute name for
Wicket Session
Description: "from this topic \nhttp://apache-wicket.1842946.n4.nabble.com/WicketSessionFilter-and-ignorePaths-in-WicketFilter-td3570291.html\nPlease,
look at the second post (the ignorePaths param is not linked with this issue as
the title suggests).\n\nHow to reproduce with the quickstart:\n1. open localhost:8080
- a wicket test page is displayed.\n2. open localhost:8080/external - this is the
external servlet that tries to access the wicket session. An exception is thrown."
diff --git a/wicket-core/src/main/java/org/apache/wicket/mock/MockSessionStore.java b/wicket-core/src/main/java/org/apache/wicket/mock/MockSessionStore.java
index 0eb0abe..61c1581 100644
--- a/wicket-core/src/main/java/org/apache/wicket/mock/MockSessionStore.java
+++ b/wicket-core/src/main/java/org/apache/wicket/mock/MockSessionStore.java
@@ -86,12 +86,13 @@ public class MockSessionStore implements ISessionStore
public void invalidate(Request request)
{
+ String sessId = sessionId;
+ cleanup();
for (UnboundListener l : unboundListeners)
{
- l.sessionUnbound(sessionId);
+ l.sessionUnbound(sessId);
}
- cleanup();
}
public Session lookup(Request request)
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-3769_b4e9d426.diff |
bugs-dot-jar_data_WICKET-5441_8ccb1f6d | ---
BugID: WICKET-5441
Summary: IResourceCachingStrategy implementations should only set caching if version
matches
Description: Implementations of IResourceCachingStrategy (FilenameWithVersionResourceCachingStrategy
and QueryStringWithVersionResourceCachingStrategy) should only set cache duration
to maximum if the version matches. Currently, if a user requests a resource with
an arbitrary version, the version will be cached for one year (WebResponse.MAX_CACHE_DURATION).
So people could polute proxy caches with potentially upcoming version.
diff --git a/wicket-core/src/main/java/org/apache/wicket/request/resource/caching/FilenameWithVersionResourceCachingStrategy.java b/wicket-core/src/main/java/org/apache/wicket/request/resource/caching/FilenameWithVersionResourceCachingStrategy.java
index 2125f35..087ea13 100644
--- a/wicket-core/src/main/java/org/apache/wicket/request/resource/caching/FilenameWithVersionResourceCachingStrategy.java
+++ b/wicket-core/src/main/java/org/apache/wicket/request/resource/caching/FilenameWithVersionResourceCachingStrategy.java
@@ -196,7 +196,12 @@ public class FilenameWithVersionResourceCachingStrategy implements IResourceCach
@Override
public void decorateResponse(AbstractResource.ResourceResponse response, IStaticCacheableResource resource)
{
- response.setCacheDurationToMaximum();
- response.setCacheScope(WebResponse.CacheScope.PUBLIC);
+ String requestedVersion = RequestCycle.get().getMetaData(URL_VERSION);
+ String calculatedVersion = this.resourceVersion.getVersion(resource);
+ if (calculatedVersion != null && calculatedVersion.equals(requestedVersion))
+ {
+ response.setCacheDurationToMaximum();
+ response.setCacheScope(WebResponse.CacheScope.PUBLIC);
+ }
}
}
diff --git a/wicket-core/src/main/java/org/apache/wicket/request/resource/caching/QueryStringWithVersionResourceCachingStrategy.java b/wicket-core/src/main/java/org/apache/wicket/request/resource/caching/QueryStringWithVersionResourceCachingStrategy.java
index 292f159..e40e082 100644
--- a/wicket-core/src/main/java/org/apache/wicket/request/resource/caching/QueryStringWithVersionResourceCachingStrategy.java
+++ b/wicket-core/src/main/java/org/apache/wicket/request/resource/caching/QueryStringWithVersionResourceCachingStrategy.java
@@ -127,7 +127,12 @@ public class QueryStringWithVersionResourceCachingStrategy implements IResourceC
@Override
public void decorateResponse(AbstractResource.ResourceResponse response, IStaticCacheableResource resource)
{
- response.setCacheDurationToMaximum();
- response.setCacheScope(WebResponse.CacheScope.PUBLIC);
+ String requestedVersion = RequestCycle.get().getMetaData(URL_VERSION);
+ String calculatedVersion = this.resourceVersion.getVersion(resource);
+ if (calculatedVersion != null && calculatedVersion.equals(requestedVersion))
+ {
+ response.setCacheDurationToMaximum();
+ response.setCacheScope(WebResponse.CacheScope.PUBLIC);
+ }
}
}
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5441_8ccb1f6d.diff |
bugs-dot-jar_data_WICKET-3767_84c3baac | ---
BugID: WICKET-3767
Summary: INullAcceptingValidator behavior seems broken in 1.5-RC4.2
Description: |
As discussed in this forum thread:
http://apache-wicket.1842946.n4.nabble.com/INullAcceptingValidator-behavior-tp3570352p3570352.html
It appears that Wicket no longer calls INullAcceptingValidator intances when the validatable value is null.
Wicket wraps validators as behaviors, using the adapter pattern. The adapter class (org.apache.wicket.validation.ValidatorAdapter) implements the interface IValidator<T>. This "hides" the case where the actual validator is an INullAcceptingValidator. Therefore, when going through a component's attached validators, the code of org.apache.wicket.markup.html.form.FormComponent will never call INullAcceptingValidators when the value is null.
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
index 52612b2..1f2d23e 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
@@ -1405,9 +1405,17 @@ public abstract class FormComponent<T> extends LabeledWebMarkupContainer
{
for (Behavior behavior : getBehaviors())
{
- if (behavior instanceof IValidator)
+ validator = null;
+ if (behavior instanceof ValidatorAdapter)
+ {
+ validator = ((ValidatorAdapter<T>)behavior).getValidator();
+ }
+ else if (behavior instanceof IValidator)
{
validator = (IValidator<T>)behavior;
+ }
+ if (validator != null)
+ {
if (isNull == false || validator instanceof INullAcceptingValidator<?>)
{
validator.validate(validatable);
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-3767_84c3baac.diff |
bugs-dot-jar_data_WICKET-5518_c2e12216 | ---
BugID: WICKET-5518
Summary: FormComponent.updateCollectionModel does not handle unmodifiableList
Description: "FormComponent.updateCollectionModel should handle situation, when getter
returns unmodifiable list.\n\nProposed solution:\n\n\t\t\tformComponent.modelChanging();\n\t\t\tbooelan
isChanged;\n\t\t\ttry {\n\t\t\t\tcollection.clear();\n\t\t\t\tif (convertedInput
!= null)\n\t\t\t\t{\n\t\t\t\t\tcollection.addAll(convertedInput);\n\t\t\t\t}\n\t\t\t\tisChanged
= true;\n\t\t\tcatch (Exception e)\n\t\t\t{\n\t\t\t\t// ignore this exception as
Unmodifiable list does not allow change \t\t\t\t\n\t\t\t\tlogger.info(\"An error
occurred while trying to modify list attached to \" + formComponent, e);\n\t\t\t}\n\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif(isChanged)\t\t\t\t\n\t\t\t\t\tformComponent.getModel().setObject(collection);\n\t\t\t\telse
\n\t\t\t\t\t// TODO: create here collection as non-abstract successor of setObject
declared argument\n\t\t\t\t\tformComponent.getModel().setObject(new ArrayList(convertedInput));\n\t\t\t\tisChanged
= true;\n\t\t\t}\n\t\t\tcatch (Exception e)\n\t\t\t{\n\t\t\t\t// ignore this exception
because it could be that there\n\t\t\t\t// is not setter for this collection.\n\t\t\t\tlogger.info(\"An
error occurred while trying to set the new value for the property attached to \"
+ formComponent, e);\n\t\t\t}\n\t\t\t// at least one update method should pass successfully\t\t\t\n\t\t\tif(isChanged)\n\t\t\t\tformComponent.modelChanged();\n\t\t\telse\n\t\t\t\tthrow
new RuntimeException(\"An error occurred while trying to modify value for the property
attached to \" + formComponent);\t "
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
index fdeb8c6..cb4ad05 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
@@ -1610,8 +1610,8 @@ public abstract class FormComponent<T> extends LabeledWebMarkupContainer impleme
* @param formComponent
* the form component to update
* @see FormComponent#updateModel()
- * @throws UnsupportedOperationException
- * if the existing model object Collection cannot be modified
+ * @throws WicketRuntimeException
+ * if the existing model object collection is unmodifiable and no setter exists
*/
public static <S> void updateCollectionModel(FormComponent<Collection<S>> formComponent)
{
@@ -1625,23 +1625,42 @@ public abstract class FormComponent<T> extends LabeledWebMarkupContainer impleme
}
else
{
+ Exception failure;
+
formComponent.modelChanging();
- collection.clear();
- if (convertedInput != null)
- {
- collection.addAll(convertedInput);
- }
- formComponent.modelChanged();
+
+ try {
+ collection.clear();
+ if (convertedInput != null)
+ {
+ collection.addAll(convertedInput);
+ }
+ failure = null;
+ } catch (UnsupportedOperationException unmodifiable) {
+ logger.debug("An error occurred while trying to change the collection attached to " + formComponent, unmodifiable);
+ failure = unmodifiable;
+ collection = new ArrayList<>(convertedInput);
+ }
+
try
{
formComponent.getModel().setObject(collection);
+ failure = null;
}
- catch (Exception e)
+ catch (Exception noSetter)
{
- // ignore this exception because it could be that there
- // is not setter for this collection.
- logger.info("An error occurred while trying to set the new value for the property attached to " + formComponent, e);
+ logger.debug("An error occurred while trying to set the collection attached to " + formComponent, noSetter);
+
+ if (failure != null) {
+ failure = noSetter;
+ }
+ }
+
+ if (failure == null) {
+ formComponent.modelChanged();
+ } else {
+ throw new WicketRuntimeException("Unable to update the collection attached to " + formComponent);
}
}
}
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5518_c2e12216.diff |
bugs-dot-jar_data_WICKET-3617_7ae109a6 | ---
BugID: WICKET-3617
Summary: Using render strategy ONE_PASS_RENDER fails for Ajax requests
Description: |-
I have an application which has two pages. Page A has an AjaxLink which makes some checks and either sets some error feedback and stays on the same page (e.g. login page with "Invalid user" error) or if everything is OK then redirects to page B (via setResponsePage(B.class)).
The problem comes when the current render strategy is ONE_PASS_RENDER. In this case no matter that fromUrl and toUrl are different and the request is Ajax the current code directly writes the page markup to the response.
I think it should trigger a redirect instead.
I am not sure whether it should be redirect to render or to buffer ...
diff --git a/wicket-core/src/main/java/org/apache/wicket/request/handler/render/WebPageRenderer.java b/wicket-core/src/main/java/org/apache/wicket/request/handler/render/WebPageRenderer.java
index 37b718b..c3a0166 100644
--- a/wicket-core/src/main/java/org/apache/wicket/request/handler/render/WebPageRenderer.java
+++ b/wicket-core/src/main/java/org/apache/wicket/request/handler/render/WebPageRenderer.java
@@ -163,7 +163,8 @@ public class WebPageRenderer extends PageRenderer
// if there is saved response for this URL render it
bufferedResponse.writeTo((WebResponse)requestCycle.getResponse());
}
- else if (getRedirectPolicy() == RedirectPolicy.NEVER_REDIRECT || isOnePassRender() //
+ else if (getRedirectPolicy() == RedirectPolicy.NEVER_REDIRECT ||
+ (isOnePassRender() && isAjax == false) //
||
(!isAjax //
&&
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-3617_7ae109a6.diff |
bugs-dot-jar_data_WICKET-4777_eccb3b11 | ---
BugID: WICKET-4777
Summary: JavaScriptReference escapes given URL
Description: "\nwhile trying to integrate gmaps3 in our webapp i had issues with the
wicketstuff-gmap3 stuff ( - we need a client-id for our request) ...\n\nso i have:\n{noformat}\npublic
static final String GMAP_API_URL = \"%s://maps.google.com/maps/api/js?v=3&sensor=%s&client-id=%s\";\n\nresponse.render(JavaScriptHeaderItem.forUrl(String.format(GMAP_API_URL,
schema, sensor, clientid)));\n{noformat}\n\nthe rendered result of this is:\n{noformat}\n<script
type=\"text/javascript\" src=\"http://maps.google.com/maps/api/js?v=3&sensor=false&client-id=....\"></script>\n{noformat}\n\nso
the requestparameters are encoded\n\nwhich is happening in the JavaScriptUtils Helper:\n{noformat}\npublic
static void writeJavaScriptUrl(final Response response, final CharSequence url,
final String id, boolean defer, String charset)\n{\n response.write(\"<script
type=\\\"text/javascript\\\" \");\n if (id != null)\n {\n response.write(\"id=\\\"\"
+ Strings.escapeMarkup(id) + \"\\\" \");\n }\n if (defer)\n {\n
\ response.write(\"defer=\\\"defer\\\" \");\n }\n if (charset
!= null)\n {\n response.write(\"charset=\\\"\" + Strings.escapeMarkup(charset)
+ \"\\\" \");\n }\n response.write(\"src=\\\"\");\n response.write(Strings.escapeMarkup(url));\n
\ response.write(\"\\\"></script>\");\n response.write(\"\\n\");\n}\n{noformat}\nbut
... is this right to escape the url?\n\nwhen i open the above mentioned script,
google tells me i have no parameter \"sensor\" ... which i can understand as ther
is only a parameter amp ... "
diff --git a/wicket-core/src/main/java/org/apache/wicket/core/util/string/JavaScriptUtils.java b/wicket-core/src/main/java/org/apache/wicket/core/util/string/JavaScriptUtils.java
index f07d515..42d9274 100644
--- a/wicket-core/src/main/java/org/apache/wicket/core/util/string/JavaScriptUtils.java
+++ b/wicket-core/src/main/java/org/apache/wicket/core/util/string/JavaScriptUtils.java
@@ -143,7 +143,7 @@ public class JavaScriptUtils
response.write("charset=\"" + Strings.escapeMarkup(charset) + "\" ");
}
response.write("src=\"");
- response.write(Strings.escapeMarkup(url));
+ response.write(url);
response.write("\"></script>");
response.write("\n");
}
@@ -201,7 +201,7 @@ public class JavaScriptUtils
response.write("<script type=\"text/javascript\" ");
if (id != null)
{
- response.write("id=\"" + id + "\"");
+ response.write("id=\"" + Strings.escapeMarkup(id) + "\"");
}
response.write(">");
response.write(SCRIPT_CONTENT_PREFIX);
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-4777_eccb3b11.diff |
bugs-dot-jar_data_WICKET-4138_7c89598a | ---
BugID: WICKET-4138
Summary: BookmarkablePageLinks not working on a forwarded page
Description: |-
While migrating our app from 1.4 to 1.5 we have discovered a problem with how BookmarkablePageLinks are rendered.
The attached quickstart demonstrates the problem:
Two pages: HomePage and OtherPage mounted at: /content/home and /content/other respectively.
These are mounted using the encoder UrlPathPageParametersEncoder for backwards compatibility with existing 1.4 style URLs.
A filter has been established in web.xml to forward requests to root (eg., localhost) to localhost/content/home
[Note: I have left out the port :8080 part from all URL references so please insert when testing]
Point browser to http://localhost and the page is forwarded to http://localhost/content/home and displays correctly (browser URL still shows http://localhost as desired) but the links do not work because they remove the 'content' segment of the URL:
eg., Home link -> http://localhost/home - fails - should have been http://localhost/content/home
If you type in the full URL: http://localhost/content/home
then the home page displays and the links work correctly.
A similar page set up works fine in 1.4.
diff --git a/wicket-core/src/main/java/org/apache/wicket/protocol/http/servlet/ForwardAttributes.java b/wicket-core/src/main/java/org/apache/wicket/protocol/http/servlet/ForwardAttributes.java
new file mode 100644
index 0000000..45c3389
--- /dev/null
+++ b/wicket-core/src/main/java/org/apache/wicket/protocol/http/servlet/ForwardAttributes.java
@@ -0,0 +1,141 @@
+/*
+ * 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.protocol.http.servlet;
+
+import javax.servlet.ServletRequest;
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.wicket.util.lang.Args;
+import org.apache.wicket.util.string.Strings;
+
+/**
+ * Represents additional error parameters present in a {@link ServletRequest} when the servlet
+ * container is handling an error or a forward to an error page mapped by {@code error-page} element
+ * in {@code web.xml}.
+ *
+ * See documentation for the following request attributes for the values stored in this object:
+ * <ul>
+ * <li>javax.servlet.error.status_code</li>
+ * <li>javax.servlet.error.message</li>
+ * <li>javax.servlet.error.request_uri</li>
+ * <li>javax.servlet.error.servlet_name</li>
+ * <li>javax.servlet.error.exception_type</li>
+ * <li>javax.servlet.error.exception</li>
+ * </ul>
+ *
+ */
+public class ForwardAttributes
+{
+ // javax.servlet.forward.request_uri
+ private final String requestUri;
+
+ // javax.servlet.forward.servlet_path
+ private final String servletPath;
+
+ // javax.servlet.forward.context_path
+ private final String contextPath;
+
+ // javax.servlet.forward.query_string
+ private final String queryString;
+
+ /**
+ * Constructor.
+ *
+ * @param requestUri
+ * @param servletPath
+ * @param contextPath
+ * @param queryString
+ */
+ private ForwardAttributes(String requestUri, String servletPath, String contextPath,
+ String queryString)
+ {
+ this.requestUri = requestUri;
+ this.servletPath = servletPath;
+ this.contextPath = contextPath;
+ this.queryString = queryString;
+ }
+
+ /**
+ * Gets requestUri.
+ *
+ * @return requestUri
+ */
+ public String getRequestUri()
+ {
+ return requestUri;
+ }
+
+ /**
+ * Gets servletPath.
+ *
+ * @return servletPath
+ */
+ public String getServletPath()
+ {
+ return servletPath;
+ }
+
+ /**
+ * Gets contextPath.
+ *
+ * @return contextPath
+ */
+ public String getContextPath()
+ {
+ return contextPath;
+ }
+
+ /**
+ * Gets the query string.
+ *
+ * @return the query string
+ */
+ public String getQueryString()
+ {
+ return queryString;
+ }
+
+ /**
+ * Factory for creating instances of this class.
+ *
+ * @param request
+ * @return instance of request contains forward attributes or {@code null} if it does not.
+ */
+ public static ForwardAttributes of(HttpServletRequest request)
+ {
+ Args.notNull(request, "request");
+
+ final String requestUri = (String)request.getAttribute("javax.servlet.forward.request_uri");
+ final String servletPath = (String)request.getAttribute("javax.servlet.forward.servlet_path");
+ final String contextPath = (String)request.getAttribute("javax.servlet.forward.context_path");
+ final String queryString = (String)request.getAttribute("javax.servlet.forward.query_string");
+
+ if (!Strings.isEmpty(requestUri) || !Strings.isEmpty(servletPath) ||
+ !Strings.isEmpty(contextPath) || !Strings.isEmpty(queryString))
+ {
+ return new ForwardAttributes(requestUri, servletPath, contextPath, queryString);
+ }
+ return null;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "ForwardAttributes [requestUri=" + requestUri + ", servletPath=" + servletPath +
+ ", contextPath=" + contextPath + ", queryString=" + queryString + "]";
+ }
+}
diff --git a/wicket-core/src/main/java/org/apache/wicket/protocol/http/servlet/ServletWebRequest.java b/wicket-core/src/main/java/org/apache/wicket/protocol/http/servlet/ServletWebRequest.java
index 68f263b..576f44c 100644
--- a/wicket-core/src/main/java/org/apache/wicket/protocol/http/servlet/ServletWebRequest.java
+++ b/wicket-core/src/main/java/org/apache/wicket/protocol/http/servlet/ServletWebRequest.java
@@ -66,6 +66,8 @@ public class ServletWebRequest extends WebRequest
private final ErrorAttributes errorAttributes;
+ private final ForwardAttributes forwardAttributes;
+
/**
* Construct.
*
@@ -96,6 +98,8 @@ public class ServletWebRequest extends WebRequest
errorAttributes = ErrorAttributes.of(httpServletRequest);
+ forwardAttributes = ForwardAttributes.of(httpServletRequest);
+
if (url != null)
{
this.url = url;
@@ -129,6 +133,12 @@ public class ServletWebRequest extends WebRequest
.toString();
return getContextRelativeUrl(problematicURI, filterPrefix);
}
+ else if (forwardAttributes != null && !Strings.isEmpty(forwardAttributes.getRequestUri()))
+ {
+ String forwardURI = Url.parse(forwardAttributes.getRequestUri(), getCharset())
+ .toString();
+ return getContextRelativeUrl(forwardURI, filterPrefix);
+ }
else if (!isAjax())
{
return getContextRelativeUrl(httpServletRequest.getRequestURI(), filterPrefix);
@@ -456,6 +466,7 @@ public class ServletWebRequest extends WebRequest
@Override
public boolean shouldPreserveClientUrl()
{
- return errorAttributes != null && !Strings.isEmpty(errorAttributes.getRequestUri());
+ return (errorAttributes != null && !Strings.isEmpty(errorAttributes.getRequestUri()) || forwardAttributes != null &&
+ !Strings.isEmpty(forwardAttributes.getRequestUri()));
}
}
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-4138_7c89598a.diff |
bugs-dot-jar_data_WICKET-3304_7e7ab76c | ---
BugID: WICKET-3304
Summary: TextField ingnores convertEmptyInputStringToNull = true property when the
String type is set
Description: I posted this patch on WICKET-3269, but the discussion on this ticket
is about an improvement request, not a bug. I opened this one for the bug.
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/AbstractTextComponent.java b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/AbstractTextComponent.java
index 845187c..b9a4244 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/AbstractTextComponent.java
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/AbstractTextComponent.java
@@ -21,7 +21,6 @@ import java.text.SimpleDateFormat;
import org.apache.wicket.Component;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.IObjectClassAwareModel;
-import org.apache.wicket.util.convert.ConversionException;
import org.apache.wicket.util.string.Strings;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -109,6 +108,8 @@ public abstract class AbstractTextComponent<T> extends FormComponent<T>
}
/**
+ * Convert the input respecting the flag convertEmptyInputStringToNull. Subclasses that override
+ * this method should test this flag also.
*
* @see org.apache.wicket.markup.html.form.FormComponent#convertInput()
*/
@@ -118,7 +119,16 @@ public abstract class AbstractTextComponent<T> extends FormComponent<T>
// Stateless forms don't have to be rendered first, convertInput could be called before
// onBeforeRender calling resolve type here again to check if the type is correctly set.
resolveType();
- super.convertInput();
+ String[] value = getInputAsArray();
+ String tmp = value != null && value.length > 0 ? value[0] : null;
+ if (getConvertEmptyInputStringToNull() && Strings.isEmpty(tmp))
+ {
+ setConvertedInput(null);
+ }
+ else
+ {
+ super.convertInput();
+ }
}
/**
@@ -140,13 +150,8 @@ public abstract class AbstractTextComponent<T> extends FormComponent<T>
{
if (!getFlag(TYPE_RESOLVED) && getType() == null)
{
- // Set the type, but only if it's not a String (see WICKET-606).
- // Otherwise, getConvertEmptyInputStringToNull() won't work.
Class<?> type = getModelType(getDefaultModel());
- if (!String.class.equals(type))
- {
- setType(type);
- }
+ setType(type);
setFlag(TYPE_RESOLVED, true);
}
}
@@ -186,18 +191,4 @@ public abstract class AbstractTextComponent<T> extends FormComponent<T>
setFlag(FLAG_CONVERT_EMPTY_INPUT_STRING_TO_NULL, flag);
return this;
}
-
- /**
- * @see org.apache.wicket.markup.html.form.FormComponent#convertValue(String[])
- */
- @Override
- protected T convertValue(String[] value) throws ConversionException
- {
- String tmp = value != null && value.length > 0 ? value[0] : null;
- if (getConvertEmptyInputStringToNull() && Strings.isEmpty(tmp))
- {
- return null;
- }
- return super.convertValue(value);
- }
}
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-3304_7e7ab76c.diff |
bugs-dot-jar_data_WICKET-5157_961f2477 | ---
BugID: WICKET-5157
Summary: URL query parameter values containing equals sign get cut off
Description: When calling a page with a query parameter like 'param1=val1=val2' the
value of 'param1' obtained from PageParameters will be 'val1'. Everything after
the equals sign inside the parameter value gets cut off.
diff --git a/wicket-request/src/main/java/org/apache/wicket/request/Url.java b/wicket-request/src/main/java/org/apache/wicket/request/Url.java
index 6aa6e25..5297857 100755
--- a/wicket-request/src/main/java/org/apache/wicket/request/Url.java
+++ b/wicket-request/src/main/java/org/apache/wicket/request/Url.java
@@ -337,15 +337,16 @@ public class Url implements Serializable
*/
private static QueryParameter parseQueryParameter(final String qp, final Charset charset)
{
- if (qp.indexOf('=') == -1)
+ int idxOfEquals = qp.indexOf('=');
+ if (idxOfEquals == -1)
{
// name => empty value
return new QueryParameter(decodeParameter(qp, charset), "");
}
- String parts[] = Strings.split(qp, '=');
- return new QueryParameter(decodeParameter(parts[0], charset), decodeParameter(parts[1],
- charset));
+ String parameterName = qp.substring(0, idxOfEquals);
+ String parameterValue = qp.substring(idxOfEquals + 1);
+ return new QueryParameter(decodeParameter(parameterName, charset), decodeParameter(parameterValue, charset));
}
/**
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5157_961f2477.diff |
bugs-dot-jar_data_WICKET-4757_fd910746 | ---
BugID: WICKET-4757
Summary: FormComponents remain invalid forever if there is no feedback panel
Description: |-
if there is no feedback panel the error messages are not removed in ondetach and form component re-validation is skipped so the form component, once marked as invalid, will remain invalid forever or at least until its error messages are rendered.
the error messages should be dropped and the form component should be re-validated on every form submit.
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/Form.java b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/Form.java
index 9d46baf..d3c9b8b 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/Form.java
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/Form.java
@@ -170,8 +170,7 @@ public class Form<T> extends WebMarkupContainer implements IFormSubmitListener
return;
}
- if (formComponent.isVisibleInHierarchy() && formComponent.isValid() &&
- formComponent.isEnabledInHierarchy())
+ if (formComponent.isVisibleInHierarchy() && formComponent.isEnabledInHierarchy())
{
validate(formComponent);
}
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-4757_fd910746.diff |
bugs-dot-jar_data_WICKET-3196_f1c0f263 | ---
BugID: WICKET-3196
Summary: UrlValidator failes to validate urls that containt multiple dots in path
Description: |+
refer to UrlValidator.java:466 (isValidPath).
if we have an url, that contains more than two consequent dots, for example "http://www.somedomain.com/this_one_is_tricky...but...still.....valid", validator will fail.
btw, the other side effect is that countTokens actually counts '...' a two 2dots.
One possible workaround is not just count '..' tokens, but count them along with slash, like '../'.
diff --git a/wicket/src/main/java/org/apache/wicket/validation/validator/UrlValidator.java b/wicket/src/main/java/org/apache/wicket/validation/validator/UrlValidator.java
index cf42f3e..b9db5ee 100644
--- a/wicket/src/main/java/org/apache/wicket/validation/validator/UrlValidator.java
+++ b/wicket/src/main/java/org/apache/wicket/validation/validator/UrlValidator.java
@@ -484,7 +484,7 @@ public class UrlValidator extends AbstractValidator<String>
}
int slashCount = countToken("/", path);
- int dot2Count = countToken("..", path);
+ int dot2Count = countToken("/..", path);
if (dot2Count > 0)
{
if ((slashCount - slash2Count - 1) <= dot2Count)
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-3196_f1c0f263.diff |
bugs-dot-jar_data_WICKET-4679_f3ec1503 | ---
BugID: WICKET-4679
Summary: XmlPullParser doesn't parse correctly attributes with complex namespace
Description: |-
Having a markup like:
<a class="addthis_button_google_plusone_badge" g:plusone:size="smallbadge" g:plusone:href="https://plus.google.com/25252/"></a> causes XmlPullParser to throw the following exception:
java.text.ParseException: Same attribute found twice: g:plusone (line 19, column 100)
at org.apache.wicket.markup.parser.XmlPullParser.parseTagText(XmlPullParser.java:673)
at org.apache.wicket.markup.parser.XmlPullParser.next(XmlPullParser.java:294)
at org.apache.wicket.markup.parser.filter.RootMarkupFilter.nextElement(RootMarkupFilter.java:58)
.....
diff --git a/wicket-util/src/main/java/org/apache/wicket/util/parse/metapattern/parsers/VariableAssignmentParser.java b/wicket-util/src/main/java/org/apache/wicket/util/parse/metapattern/parsers/VariableAssignmentParser.java
index dc49c17..ee4f443 100644
--- a/wicket-util/src/main/java/org/apache/wicket/util/parse/metapattern/parsers/VariableAssignmentParser.java
+++ b/wicket-util/src/main/java/org/apache/wicket/util/parse/metapattern/parsers/VariableAssignmentParser.java
@@ -29,11 +29,11 @@ import org.apache.wicket.util.parse.metapattern.OptionalMetaPattern;
*/
public final class VariableAssignmentParser extends MetaPatternParser
{
- /** The optional namespace like "namespace:*" */
+ /** The optional namespace like "namespace:*[:*]" */
private static final MetaPattern namespace = new OptionalMetaPattern(new MetaPattern[] {
- MetaPattern.VARIABLE_NAME, MetaPattern.COLON });
+ MetaPattern.VARIABLE_NAME, MetaPattern.COLON, new OptionalMetaPattern(new MetaPattern[] {MetaPattern.VARIABLE_NAME, MetaPattern.COLON })});
- /** The key (lvalue) like "name" or "namespace:name" */
+ /** The key (lvalue) like "name" or "namespace:name" or "namespace:name:subname" */
private final Group key = new Group(new MetaPattern(namespace, MetaPattern.XML_ATTRIBUTE_NAME));
/** The rvalue of the assignment */
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-4679_f3ec1503.diff |
bugs-dot-jar_data_WICKET-5319_c863b032 | ---
BugID: WICKET-5319
Summary: CryptoMapper encrypts external URLs in ResourceReferences making the resources
inaccessible
Description: "Short Description: \n\nCryptoMapper encrypts links to resources with
URLs of the form:\n - http://domain/path/script.js\n - /local/absolute/path/script.js\n\nAdditionally
there might be some inconsistencies in handling URLs in instances of ResourceReference.\n\nThe
problem occurs when JavaScript resources are included in the following way:\n\n@Override\npublic
void renderHead(IHeaderResponse response)\n{\n\tsuper.renderHead(response);\n\t\n\tUrlResourceReference
reference = new UrlResourceReference(Url.parse(\"http://domain/path/script.js\"));\n\tresponse.render(reference);\n}\n\nThe
resulting JavaScript links can't be loaded (404 is returned) when CryptoMapper is
used.\n\nThis is a minor problem, because the following always works for JavaScript
files not served by Wicket (\"external JavaScript files\"):\n\nresponse.render(new
StringHeaderItem(\"<script type=\\\"text/javascript\\\" src=\\\"//domain/myPath/manual.js\\\"></script>\");\n\n\nWays
to reproduce: \n\n A code example for wicket-examples is attached (example.zip)\n
\ Local URLs:\n http://localhost:8080/enc/index\n http://localhost:8080/unenc/index\n\n\nPossible
fix: \n\n - disable encryption for URLs beginning with '/', '<schema>://' and '//'
and not served/filtered by Wicket\n\n (\n - define different reference classes for
external files and files served/filtered by Wicket, issue warnings when a wrong
URL type is supplied by the user or treat URLs beginning with '/', '<schema>://'
and '//' differently\n )\n\nThank you\n"
diff --git a/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/CryptoMapper.java b/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/CryptoMapper.java
index 58e704e..91708a3 100755
--- a/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/CryptoMapper.java
+++ b/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/CryptoMapper.java
@@ -42,8 +42,7 @@ import org.slf4j.LoggerFactory;
* in the encrypted URL. If the segment does not match the expected checksum, then the segment is
* deemed a plain text sibling of the corresponding segment in the encrypted URL, and all subsequent
* segments are considered plain text children of the current segment.
- *
- *
+ *
* @author igor.vaynberg
* @author Jesse Long
* @author svenmeier
@@ -57,7 +56,7 @@ public class CryptoMapper implements IRequestMapper
/**
* Construct.
- *
+ *
* @param wrappedMapper
* the non-crypted request mapper
* @param application
@@ -70,7 +69,7 @@ public class CryptoMapper implements IRequestMapper
/**
* Construct.
- *
+ *
* @param wrappedMapper
* the non-crypted request mapper
* @param cryptProvider
@@ -98,6 +97,12 @@ public class CryptoMapper implements IRequestMapper
return null;
}
+ if (url.isFull())
+ {
+ // do not encrypt full urls
+ return url;
+ }
+
return encryptUrl(url);
}
@@ -117,7 +122,7 @@ public class CryptoMapper implements IRequestMapper
if (handler != null)
{
- handler = new RequestSettingRequestHandler(decryptedRequest, handler);
+ handler = new RequestSettingRequestHandler(decryptedRequest, handler);
}
return handler;
@@ -163,8 +168,8 @@ public class CryptoMapper implements IRequestMapper
protected Url decryptUrl(final Request request, final Url encryptedUrl)
{
/*
- * If the encrypted URL has no segments it is the home page URL,
- * and does not need decrypting.
+ * If the encrypted URL has no segments it is the home page URL, and does not need
+ * decrypting.
*/
if (encryptedUrl.getSegments().isEmpty())
{
@@ -177,8 +182,8 @@ public class CryptoMapper implements IRequestMapper
try
{
/*
- * The first encrypted segment contains an encrypted version of the
- * entire plain text url.
+ * The first encrypted segment contains an encrypted version of the entire plain text
+ * url.
*/
String encryptedUrlString = encryptedSegments.get(0);
if (Strings.isEmpty(encryptedUrlString))
@@ -210,17 +215,16 @@ public class CryptoMapper implements IRequestMapper
if (!next.equals(encryptedSegment))
{
/*
- * This segment received from the browser is not the same as the
- * expected segment generated by the HashSegmentGenerator. Hence it,
- * and all subsequent segments are considered plain text siblings of the
- * original encrypted url.
+ * This segment received from the browser is not the same as the expected
+ * segment generated by the HashSegmentGenerator. Hence it, and all subsequent
+ * segments are considered plain text siblings of the original encrypted url.
*/
break;
}
/*
- * This segments matches the expected checksum, so we add the corresponding
- * segment from the original URL.
+ * This segments matches the expected checksum, so we add the corresponding segment
+ * from the original URL.
*/
url.getSegments().add(originalUrl.getSegments().get(segNo - 1));
}
@@ -278,7 +282,7 @@ public class CryptoMapper implements IRequestMapper
/**
* Generate the next segment
- *
+ *
* @return segment
*/
public String next()
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5319_c863b032.diff |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.