id
stringlengths
33
40
content
stringlengths
662
61.5k
max_stars_repo_path
stringlengths
85
97
bugs-dot-jar_data_WICKET-4753_21a47387
--- BugID: WICKET-4753 Summary: Resource bundles are not resolved on PriorityHeaderItems Description: If a bundle X provides resource A, and resource A is rendered as priority header item, the resource A is rendered, not bundle X. diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/head/ResourceAggregator.java b/wicket-core/src/main/java/org/apache/wicket/markup/head/ResourceAggregator.java index bce6a11..02221e7 100644 --- a/wicket-core/src/main/java/org/apache/wicket/markup/head/ResourceAggregator.java +++ b/wicket-core/src/main/java/org/apache/wicket/markup/head/ResourceAggregator.java @@ -126,7 +126,7 @@ public class ResourceAggregator extends DecoratingHeaderResponse public RecordedHeaderItem(HeaderItem item) { this.item = item; - this.locations = new ArrayList<RecordedHeaderItemLocation>(); + locations = new ArrayList<RecordedHeaderItemLocation>(); } /** @@ -186,9 +186,9 @@ public class ResourceAggregator extends DecoratingHeaderResponse { super(real); - this.itemsToBeRendered = new LinkedHashMap<HeaderItem, RecordedHeaderItem>(); - this.domReadyItemsToBeRendered = new ArrayList<OnDomReadyHeaderItem>(); - this.loadItemsToBeRendered = new ArrayList<OnLoadHeaderItem>(); + itemsToBeRendered = new LinkedHashMap<HeaderItem, RecordedHeaderItem>(); + domReadyItemsToBeRendered = new ArrayList<OnDomReadyHeaderItem>(); + loadItemsToBeRendered = new ArrayList<OnLoadHeaderItem>(); } @Override @@ -375,6 +375,10 @@ public class ResourceAggregator extends DecoratingHeaderResponse */ private HeaderItem getItemToBeRendered(HeaderItem item) { + while (item instanceof IWrappedHeaderItem) + { + item = ((IWrappedHeaderItem)item).getWrapped(); + } if (getRealResponse().wasRendered(item)) { return NoHeaderItem.get();
bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-4753_21a47387.diff
bugs-dot-jar_data_WICKET-2624_ef880545
--- BugID: WICKET-2624 Summary: MethodGetAndSet.setValue uses wrong source to determine which type to convert to when there's no setter Description: "MethodGetAndSet.setValue uses wrong source to determine which type to convert to when there's no setter, resulting in exceptions like this:\norg.apache.wicket.WicketRuntimeException: Error setting field: private int PropertyResolverTest$DirectFieldSetWithDifferentTypeThanGetter.value on object: PropertyResolverTest$DirectFieldSetWithDifferentTypeThanGetter@396477d9\n\tat org.apache.wicket.util.lang.PropertyResolver$MethodGetAndSet.setValue(PropertyResolver.java:1150)\n\tat org.apache.wicket.util.lang.PropertyResolver$ObjectAndGetSetter.setValue(PropertyResolver.java:588)\n\tat org.apache.wicket.util.lang.PropertyResolver.setValue(PropertyResolver.java:136)\n\tat PropertyResolverTest.testDirectFieldSetWithDifferentTypeThanGetter(PropertyResolverTest.java:12)\n\nBug is located in:\nconverted = converter.convert(value, getMethod.getReturnType());\n\nInstead, it should read:\nconverted = converter.convert(value, type);\n\nTestcase attached.\n\nAdditional thoughts:\nif (setMethod != null)\n{\n type = getMethod.getReturnType();\n}\nThis is really confusing (we check setMethod presence but get type from getMethod). Luckily, this works as expected because in MethodGetAndSet.findSetter only methods with same (or superclass) type as getter are returned.\n" diff --git a/wicket/src/main/java/org/apache/wicket/util/convert/ConverterLocator.java b/wicket/src/main/java/org/apache/wicket/util/convert/ConverterLocator.java index fc09b99..0b9b093 100644 --- a/wicket/src/main/java/org/apache/wicket/util/convert/ConverterLocator.java +++ b/wicket/src/main/java/org/apache/wicket/util/convert/ConverterLocator.java @@ -101,7 +101,7 @@ public class ConverterLocator implements IConverterLocator else { throw new ConversionException("Could not convert value: " + value + - " to type: " + theType.getName() + "(Could not find compatible converter).").setSourceValue(value); + " to type: " + theType.getName() + ". Could not find compatible converter.").setSourceValue(value); } } catch (Exception e) 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 d83ba14..64a717b 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 @@ -1094,6 +1094,9 @@ public final class PropertyResolver Class type = null; if (setMethod != null) { + // getMethod is always there and if the value will be set through a setMethod then + // the getMethod return type will be its type. Else we have to look at the + // parameters if the setter but getting the return type is quicker type = getMethod.getReturnType(); } else if (field != null) @@ -1104,7 +1107,7 @@ public final class PropertyResolver Object converted = null; if (type != null) { - converted = converter.convert(value, getMethod.getReturnType()); + converted = converter.convert(value, type); if (converted == null) { if (value != null)
bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-2624_ef880545.diff
bugs-dot-jar_data_WICKET-2065_9da430fb
--- BugID: WICKET-2065 Summary: Generated urls for mounted pages contain redundant trailing "/" Description: |- Is it OK (i.e. "by design" as opposed to "by mistake") that the urls generated for the mounted pages end up with the "/"? Provided that there's a page that expects single parameter (here: "content")... public class HelpPage extends WebPage { public HelpPage(PageParameters p) { super(p); add(new DynamicContentPanel("contentPanel", new Model<String>(p.getString("content")))); } } ...and it is mounted in the Application#init() mount(new BookmarkablePageRequestTargetUrlCodingStrategy("help", HelpPage.class, null)); ...and further referred to somewhere else as: add(new BookmarkablePageLink("helpPage", HelpPage.class, new PageParameters("content=a"))); the url in the generated markup is in the following form: http://localhost:8080/dummy-web/help/content/a/;jsessionid=11624C6125F8DF4867E3218676D79A29 While IMHO it should read: http://localhost:8080/dummy-web/help/content/a;jsessionid=11624C6125F8DF4867E3218676D79A29 It looks even more awkward when there are more parameters and part of them is encoded as a query string: http://localhost:8080/dummy-web/help/content/a/?param2=value2/;jsessionid=11624C6125F8DF4867E3218676D79A29 The page parameter for both cases is resolved correctly by the HelpPage's constructor, so it seems that even though there's an extra "/" at the end of the url it gets omitted. Then why bother generating it? I stumbled upon an issue https://issues.apache.org/jira/browse/WICKET-765. Apart from the compatibility with wicket 1.2 I see no rationale for trailing "/". Looking at implementations of IRequestTargetUrlCodingStrategy I come to the conclusion the the "append("/")" is being overused and redundant especially when it is preceded by the following code which makes sure that the "/" is in place before adding another parameter. diff --git a/wicket/src/main/java/org/apache/wicket/request/target/coding/AbstractRequestTargetUrlCodingStrategy.java b/wicket/src/main/java/org/apache/wicket/request/target/coding/AbstractRequestTargetUrlCodingStrategy.java index b1d26e9..5631502 100644 --- a/wicket/src/main/java/org/apache/wicket/request/target/coding/AbstractRequestTargetUrlCodingStrategy.java +++ b/wicket/src/main/java/org/apache/wicket/request/target/coding/AbstractRequestTargetUrlCodingStrategy.java @@ -83,25 +83,27 @@ public abstract class AbstractRequestTargetUrlCodingStrategy * @param parameters * Map object to be encoded */ - protected void appendParameters(AppendingStringBuffer url, Map<?,?> parameters) + protected void appendParameters(AppendingStringBuffer url, Map<?, ?> parameters) { if (parameters != null && parameters.size() > 0) { for (Entry<?, ?> entry1 : parameters.entrySet()) { - Object value = ((Entry<?, ?>) entry1).getValue(); + Object value = ((Entry<?, ?>)entry1).getValue(); if (value != null) { if (value instanceof String[]) { - String[] values = (String[]) value; + String[] values = (String[])value; for (String value1 : values) { - appendValue(url, ((Entry<?, ?>) entry1).getKey().toString(), value1); + appendValue(url, ((Entry<?, ?>)entry1).getKey().toString(), value1); } - } else + } + else { - appendValue(url, ((Entry<?, ?>) entry1).getKey().toString(), value.toString()); + appendValue(url, ((Entry<?, ?>)entry1).getKey().toString(), + value.toString()); } } } @@ -117,7 +119,7 @@ public abstract class AbstractRequestTargetUrlCodingStrategy { url.append("/"); } - url.append(key).append("/").append(escapedValue).append("/"); + url.append(key).append("/").append(escapedValue); } } @@ -130,7 +132,7 @@ public abstract class AbstractRequestTargetUrlCodingStrategy * query string parameters * @return Parameters created from the url fragment and query string */ - protected ValueMap decodeParameters(String urlFragment, Map<String,Object> urlParameters) + protected ValueMap decodeParameters(String urlFragment, Map<String, Object> urlParameters) { // Hack off any leading slash if (urlFragment.startsWith("/")) diff --git a/wicket/src/main/java/org/apache/wicket/request/target/coding/IndexedHybridUrlCodingStrategy.java b/wicket/src/main/java/org/apache/wicket/request/target/coding/IndexedHybridUrlCodingStrategy.java index 4a46b34..2f3ae49 100644 --- a/wicket/src/main/java/org/apache/wicket/request/target/coding/IndexedHybridUrlCodingStrategy.java +++ b/wicket/src/main/java/org/apache/wicket/request/target/coding/IndexedHybridUrlCodingStrategy.java @@ -45,6 +45,7 @@ public class IndexedHybridUrlCodingStrategy extends HybridUrlCodingStrategy super(mountPath, pageClass); } + @Override protected void appendParameters(AppendingStringBuffer url, Map parameters) { int i = 0; @@ -55,7 +56,7 @@ public class IndexedHybridUrlCodingStrategy extends HybridUrlCodingStrategy { url.append("/"); } - url.append(urlEncodePathComponent(value)).append("/"); + url.append(urlEncodePathComponent(value)); i++; } @@ -68,18 +69,19 @@ public class IndexedHybridUrlCodingStrategy extends HybridUrlCodingStrategy { url.append("/"); } - url.append(WebRequestCodingStrategy.PAGEMAP).append("/").append(urlEncodePathComponent(pageMap)) - .append("/"); + url.append(WebRequestCodingStrategy.PAGEMAP).append("/").append( + urlEncodePathComponent(pageMap)); } if (i != parameters.size()) { throw new WicketRuntimeException( - "Not all parameters were encoded. Make sure all parameter names are integers in consecutive order starting with zero. Current parameter names are: " + - parameters.keySet().toString()); + "Not all parameters were encoded. Make sure all parameter names are integers in consecutive order starting with zero. Current parameter names are: " + + parameters.keySet().toString()); } } + @Override protected ValueMap decodeParameters(String urlFragment, Map urlParameters) { PageParameters params = new PageParameters(); @@ -102,8 +104,8 @@ public class IndexedHybridUrlCodingStrategy extends HybridUrlCodingStrategy if (WebRequestCodingStrategy.PAGEMAP.equals(parts[i])) { i++; - params.put(WebRequestCodingStrategy.PAGEMAP, WebRequestCodingStrategy - .decodePageMapName(urlDecodePathComponent(parts[i]))); + params.put(WebRequestCodingStrategy.PAGEMAP, + WebRequestCodingStrategy.decodePageMapName(urlDecodePathComponent(parts[i]))); } else { diff --git a/wicket/src/main/java/org/apache/wicket/request/target/coding/IndexedParamUrlCodingStrategy.java b/wicket/src/main/java/org/apache/wicket/request/target/coding/IndexedParamUrlCodingStrategy.java index 5c97510..d6c5c1b 100644 --- a/wicket/src/main/java/org/apache/wicket/request/target/coding/IndexedParamUrlCodingStrategy.java +++ b/wicket/src/main/java/org/apache/wicket/request/target/coding/IndexedParamUrlCodingStrategy.java @@ -90,7 +90,7 @@ public class IndexedParamUrlCodingStrategy extends BookmarkablePageRequestTarget { url.append("/"); } - url.append(urlEncodePathComponent(value)).append("/"); + url.append(urlEncodePathComponent(value)); i++; } @@ -104,7 +104,7 @@ public class IndexedParamUrlCodingStrategy extends BookmarkablePageRequestTarget url.append("/"); } url.append(WebRequestCodingStrategy.PAGEMAP).append("/").append( - urlEncodePathComponent(pageMap)).append("/"); + urlEncodePathComponent(pageMap)); } String intface = (String)parameters.get(WebRequestCodingStrategy.INTERFACE_PARAMETER_NAME); @@ -116,7 +116,7 @@ public class IndexedParamUrlCodingStrategy extends BookmarkablePageRequestTarget url.append("/"); } url.append(WebRequestCodingStrategy.INTERFACE_PARAMETER_NAME).append("/").append( - urlEncodePathComponent(intface)).append("/"); + urlEncodePathComponent(intface)); } if (i != parameters.size()) { diff --git a/wicket/src/main/java/org/apache/wicket/request/target/coding/MixedParamUrlCodingStrategy.java b/wicket/src/main/java/org/apache/wicket/request/target/coding/MixedParamUrlCodingStrategy.java index 9788196..388a0df 100644 --- a/wicket/src/main/java/org/apache/wicket/request/target/coding/MixedParamUrlCodingStrategy.java +++ b/wicket/src/main/java/org/apache/wicket/request/target/coding/MixedParamUrlCodingStrategy.java @@ -129,7 +129,11 @@ public class MixedParamUrlCodingStrategy extends BookmarkablePageRequestTargetUr { value = ""; } - url.append(urlEncodePathComponent(value)).append("/"); + if (!url.endsWith("/")) + { + url.append("/"); + } + url.append(urlEncodePathComponent(value)); parameterNamesToAdd.remove(parameterName); } } diff --git a/wicket/src/main/java/org/apache/wicket/request/target/coding/PackageRequestTargetUrlCodingStrategy.java b/wicket/src/main/java/org/apache/wicket/request/target/coding/PackageRequestTargetUrlCodingStrategy.java index 9519fe8..1808f3a 100644 --- a/wicket/src/main/java/org/apache/wicket/request/target/coding/PackageRequestTargetUrlCodingStrategy.java +++ b/wicket/src/main/java/org/apache/wicket/request/target/coding/PackageRequestTargetUrlCodingStrategy.java @@ -39,8 +39,7 @@ import org.slf4j.LoggerFactory; */ public class PackageRequestTargetUrlCodingStrategy extends AbstractRequestTargetUrlCodingStrategy { - private static final Logger log = LoggerFactory - .getLogger(PackageRequestTargetUrlCodingStrategy.class); + private static final Logger log = LoggerFactory.getLogger(PackageRequestTargetUrlCodingStrategy.class); /** package for this mount. */ private final PackageName packageName; @@ -93,7 +92,7 @@ public class PackageRequestTargetUrlCodingStrategy extends AbstractRequestTarget try { bookmarkablePageClass = Session.get().getClassResolver().resolveClass( - bookmarkablePageClassName); + bookmarkablePageClassName); } catch (Exception e) { @@ -101,7 +100,7 @@ public class PackageRequestTargetUrlCodingStrategy extends AbstractRequestTarget return null; } PageParameters parameters = new PageParameters(decodeParameters(parametersFragment, - requestParameters.getParameters())); + requestParameters.getParameters())); String pageMapName = (String)parameters.remove(WebRequestCodingStrategy.PAGEMAP); pageMapName = WebRequestCodingStrategy.decodePageMapName(pageMapName); @@ -110,15 +109,14 @@ public class PackageRequestTargetUrlCodingStrategy extends AbstractRequestTarget // do some extra work for checking whether this is a normal request to a // bookmarkable page, or a request to a stateless page (in which case a // wicket:interface parameter should be available - final String interfaceParameter = (String)parameters - .remove(WebRequestCodingStrategy.INTERFACE_PARAMETER_NAME); + final String interfaceParameter = (String)parameters.remove(WebRequestCodingStrategy.INTERFACE_PARAMETER_NAME); if (interfaceParameter != null) { WebRequestCodingStrategy.addInterfaceParameters(interfaceParameter, requestParameters); return new BookmarkableListenerInterfaceRequestTarget(pageMapName, - bookmarkablePageClass, parameters, requestParameters.getComponentPath(), - requestParameters.getInterfaceName(), requestParameters.getVersionNumber()); + bookmarkablePageClass, parameters, requestParameters.getComponentPath(), + requestParameters.getInterfaceName(), requestParameters.getVersionNumber()); } else { @@ -134,18 +132,18 @@ public class PackageRequestTargetUrlCodingStrategy extends AbstractRequestTarget if (!(requestTarget instanceof IBookmarkablePageRequestTarget)) { throw new IllegalArgumentException("this encoder can only be used with instances of " + - IBookmarkablePageRequestTarget.class.getName()); + IBookmarkablePageRequestTarget.class.getName()); } AppendingStringBuffer url = new AppendingStringBuffer(40); url.append(getMountPath()); IBookmarkablePageRequestTarget target = (IBookmarkablePageRequestTarget)requestTarget; - url.append("/").append(Classes.simpleName(target.getPageClass())).append("/"); + url.append("/").append(Classes.simpleName(target.getPageClass())); PageParameters pageParameters = target.getPageParameters(); if (target.getPageMapName() != null) { - pageParameters.put(WebRequestCodingStrategy.PAGEMAP, WebRequestCodingStrategy - .encodePageMapName(target.getPageMapName())); + pageParameters.put(WebRequestCodingStrategy.PAGEMAP, + WebRequestCodingStrategy.encodePageMapName(target.getPageMapName())); } appendParameters(url, pageParameters); @@ -171,6 +169,7 @@ public class PackageRequestTargetUrlCodingStrategy extends AbstractRequestTarget /** * @see java.lang.Object#toString() */ + @Override public String toString() { return "PackageEncoder[package=" + packageName + "]";
bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-2065_9da430fb.diff
bugs-dot-jar_data_WICKET-3838_97514205
--- BugID: WICKET-3838 Summary: In wicket 1.5 urlFor returns incorrect string for package mounted pages Description: |- Attached two quickstart projects for 1.4 and 1.5. Then access http://localhost:8080/app/Page1 and see 1.5 returns wrong address. diff --git a/wicket-core/src/main/java/org/apache/wicket/request/mapper/PackageMapper.java b/wicket-core/src/main/java/org/apache/wicket/request/mapper/PackageMapper.java index 563afd0..f6082e3 100644 --- a/wicket-core/src/main/java/org/apache/wicket/request/mapper/PackageMapper.java +++ b/wicket-core/src/main/java/org/apache/wicket/request/mapper/PackageMapper.java @@ -16,11 +16,11 @@ */ package org.apache.wicket.request.mapper; +import org.apache.wicket.protocol.http.WebApplication; import org.apache.wicket.request.Request; import org.apache.wicket.request.Url; import org.apache.wicket.request.component.IRequestablePage; import org.apache.wicket.request.mapper.info.PageComponentInfo; -import org.apache.wicket.request.mapper.mount.MountMapper; import org.apache.wicket.request.mapper.parameter.IPageParametersEncoder; import org.apache.wicket.request.mapper.parameter.PageParameters; import org.apache.wicket.request.mapper.parameter.PageParametersEncoder; @@ -30,10 +30,14 @@ import org.apache.wicket.util.lang.PackageName; /** * A request mapper that mounts all bookmarkable pages in a given package. * <p> - * To mount this mapper onto a path use the {@link MountMapper}, ex: + * To mount this mapper onto a path use the {@link WebApplication#mountPackage(String, Class)}, ex: * * <pre> - * new MountMapper(&quot;/my/path&quot;, new packageMapper(PackageName.forClass(MyPage.class))); + * MyApp#init() { + * + * super.init(); + * mountPackage(&quot;/my/path&quot;, MyPage.class); + * } * </pre> * * will result in urls like {@code /my/path/MyPage} @@ -96,10 +100,19 @@ public class PackageMapper extends AbstractBookmarkableMapper protected Url buildUrl(UrlInfo info) { Class<? extends IRequestablePage> pageClass = info.getPageClass(); - if (PackageName.forClass(pageClass).equals(packageName)) + PackageName pageClassPackageName = PackageName.forClass(pageClass); + if (pageClassPackageName.equals(packageName)) { Url url = new Url(); - url.getSegments().add(pageClass.getSimpleName()); + + String fullyQualifiedClassName = pageClass.getName(); + String packageRelativeClassName = fullyQualifiedClassName; + int packageNameLength = packageName.getName().length(); + if (packageNameLength > 0) + { + packageRelativeClassName = fullyQualifiedClassName.substring(packageNameLength + 1); + } + url.getSegments().add(packageRelativeClassName); encodePageComponentInfo(url, info.getPageComponentInfo()); return encodePageParameters(url, info.getPageParameters(), pageParametersEncoder); }
bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-3838_97514205.diff
bugs-dot-jar_data_WICKET-3455_f30bd1cb
--- BugID: WICKET-3455 Summary: onremove() in RefreshingView.onPopulate Description: | file a bug with a quickstart. onremove() should be called on all removed components. -igor On Fri, Feb 18, 2011 at 5:38 AM, Benedikt Rothe <[email protected]> wrote: > > Hi > > > > Are the existing children of a RepeatingView/RefreshingView being informed, > > when > > the View is newly populated (RefreshingView.onPopulate). > > > > I'd like to clean some internal references in this case. > > I tried: > > - aChild.onRemove is not called in this situation > > - aChild.setParent(null) is called. I treid to override setParent it. But > > setParent is private. > > > > Any suggestions? > > Benedikt 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 422dc3f..beca6b1 100644 --- a/wicket-core/src/main/java/org/apache/wicket/MarkupContainer.java +++ b/wicket-core/src/main/java/org/apache/wicket/MarkupContainer.java @@ -631,6 +631,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.setParent(null); }
bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-3455_f30bd1cb.diff
bugs-dot-jar_data_WICKET-5759_0374c040
--- BugID: WICKET-5759 Summary: AjaxRequestAttributes extra parameters aren't properly handled in getCallbackFunction() Description: "extra parameters of an Ajax behaviour can be accessed by getRequest().getRequestParameters().getParameterValue(key)\n\nbut if one uses getCallbackFunction() of an AbstractDefaultAjaxBehavior, these parameters get screwed and can no longer be accessed in the same manner. \n\nthe problem seems to be the merge in attrs.ep = Wicket.merge(attrs.ep, params);\n" diff --git a/wicket-core/src/main/java/org/apache/wicket/ajax/AbstractDefaultAjaxBehavior.java b/wicket-core/src/main/java/org/apache/wicket/ajax/AbstractDefaultAjaxBehavior.java index a309635..bc0989d 100644 --- a/wicket-core/src/main/java/org/apache/wicket/ajax/AbstractDefaultAjaxBehavior.java +++ b/wicket-core/src/main/java/org/apache/wicket/ajax/AbstractDefaultAjaxBehavior.java @@ -504,30 +504,28 @@ public abstract class AbstractDefaultAjaxBehavior extends AbstractAjaxBehavior sb.append("var attrs = "); sb.append(attrsJson); sb.append(";\n"); - sb.append("var params = {"); - boolean first = true; + JSONArray jsonArray = new JSONArray(); for (CallbackParameter curExtraParameter : extraParameters) { if (curExtraParameter.getAjaxParameterName() != null) { - if (!first) - sb.append(','); - else - first = false; - sb.append('\'').append(curExtraParameter.getAjaxParameterName()).append("': ") - .append(curExtraParameter.getAjaxParameterCode()); + try + { + JSONObject object = new JSONObject(); + object.put("name", curExtraParameter.getAjaxParameterName()); + object.put("value", new JsonFunction(curExtraParameter.getAjaxParameterCode())); + jsonArray.put(object); + } + catch (JSONException e) + { + throw new WicketRuntimeException(e); + } } } - sb.append("};\n"); - if (attributes.getExtraParameters().isEmpty()) - { - sb.append("attrs.").append(AjaxAttributeName.EXTRA_PARAMETERS).append(" = params;\n"); - } - else - { - sb.append("attrs.").append(AjaxAttributeName.EXTRA_PARAMETERS).append(" = Wicket.merge(attrs.") - .append(AjaxAttributeName.EXTRA_PARAMETERS).append(", params);\n"); - } + sb.append("var params = ").append(jsonArray).append(";\n"); + sb.append("attrs.").append(AjaxAttributeName.EXTRA_PARAMETERS) + .append(" = params.concat(attrs.") + .append(AjaxAttributeName.EXTRA_PARAMETERS).append(");\n"); sb.append("Wicket.Ajax.ajax(attrs);\n"); return sb; }
bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5759_0374c040.diff
bugs-dot-jar_data_WICKET-4038_f3d7565c
--- BugID: WICKET-4038 Summary: MountedMapper.mapHandler ruins Links inside mounted pages appending parameters wicket-ajax and wicket-ajax-baseurl Description: |- With the last commit n° 1166194 method mapHandler has been added to MountedMapper class in order to solve WICKET-4014. Unfortunately this method seems to ruin Link url inside mounted page (for example home page) if this page uses AJAX. mapHandler modifies Link url appending parameters 'wicket-ajax' and 'wicket-ajax-baseur'l to it. In this way when we click Link we get an error from browser like this: " This XML file does not appear to have any style information associated with it. The document tree is shown below. <ajax-response><redirect>wicket/page?41</redirect></ajax-response> " The error message is the same for Firefox and Chromium. See attached quickstart. Warning: as I'm writing this issue, Wicket snapshot is not affected yet by this bug, so you have to run quickstart with the last source from repository. diff --git a/wicket-core/src/main/java/org/apache/wicket/request/mapper/AbstractBookmarkableMapper.java b/wicket-core/src/main/java/org/apache/wicket/request/mapper/AbstractBookmarkableMapper.java index 2f6bfc6..caa61ca 100644 --- a/wicket-core/src/main/java/org/apache/wicket/request/mapper/AbstractBookmarkableMapper.java +++ b/wicket-core/src/main/java/org/apache/wicket/request/mapper/AbstractBookmarkableMapper.java @@ -88,13 +88,16 @@ public abstract class AbstractBookmarkableMapper extends AbstractComponentMapper */ private PageParameters cleanPageParameters(final PageParameters originalParameters) { - PageParameters cleanParameters = new PageParameters(originalParameters); - - // WICKET-4038: Ajax related parameters are set by wicket-ajax.js when needed. - // They shouldn't be propagated to the next requests - cleanParameters.remove(WebRequest.PARAM_AJAX); - cleanParameters.remove(WebRequest.PARAM_AJAX_BASE_URL); + PageParameters cleanParameters = null; + if (originalParameters != null) + { + cleanParameters = new PageParameters(originalParameters); + // WICKET-4038: Ajax related parameters are set by wicket-ajax.js when needed. + // They shouldn't be propagated to the next requests + cleanParameters.remove(WebRequest.PARAM_AJAX); + cleanParameters.remove(WebRequest.PARAM_AJAX_BASE_URL); + } return cleanParameters; }
bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-4038_f3d7565c.diff
bugs-dot-jar_data_WICKET-5398_19e7c1cd
--- BugID: WICKET-5398 Summary: XmlPullParser fails to properly parse from String with encoding declaration Description: |- When parsing from a string, XmlPullParser fails if the encoding from the XML declaration is different than the system's file encoding. Examples: -Dfile.encoding=ISO-8859-1 parser.parse("<?xml encoding='UTF-8' ?><span id='umlaut-äöü'></span>"); -Dfile.encoding=UTF-8 parser.parse("<?xml encoding='ISO-8859-1' ?><span id='umlaut-äöü'></span>"); Both fail because the string is read with the system's file encoding while the parser expects the stream to be encoded in the declarated encoding. diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/parser/XmlPullParser.java b/wicket-core/src/main/java/org/apache/wicket/markup/parser/XmlPullParser.java index 262b795..377138a 100644 --- a/wicket-core/src/main/java/org/apache/wicket/markup/parser/XmlPullParser.java +++ b/wicket-core/src/main/java/org/apache/wicket/markup/parser/XmlPullParser.java @@ -17,9 +17,9 @@ package org.apache.wicket.markup.parser; import java.io.BufferedInputStream; -import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; +import java.io.StringReader; import java.text.ParseException; import org.apache.wicket.markup.parser.XmlTag.TagType; @@ -48,10 +48,9 @@ public final class XmlPullParser implements IXmlPullParser public static final String SCRIPT = "script"; /** - * Reads the xml data from an input stream and converts the chars according to its encoding - * (<?xml ... encoding="..." ?>) + * The encoding of the XML. */ - private XmlReader xmlReader; + private String encoding; /** * A XML independent reader which loads the whole source data into memory and which provides @@ -84,7 +83,7 @@ public final class XmlPullParser implements IXmlPullParser @Override public final String getEncoding() { - return xmlReader.getEncoding(); + return encoding; } @Override @@ -544,7 +543,10 @@ public final class XmlPullParser implements IXmlPullParser @Override public void parse(final CharSequence string) throws IOException { - parse(new ByteArrayInputStream(string.toString().getBytes()), null); + Args.notNull(string, "string"); + + this.input = new FullyBufferedReader(new StringReader(string.toString())); + this.encoding = null; } /** @@ -554,6 +556,8 @@ public final class XmlPullParser implements IXmlPullParser * @param in * The input stream to read and parse * @throws IOException + * + * @see {@link #parse(InputStream, String)} */ @Override public void parse(final InputStream in) throws IOException @@ -563,7 +567,9 @@ public final class XmlPullParser implements IXmlPullParser } /** - * Reads and parses markup from an input stream + * Reads and parses markup from an input stream. + * <p> + * Note: The input is closed after parsing. * * @param inputStream * The input stream to read and parse @@ -578,13 +584,14 @@ public final class XmlPullParser implements IXmlPullParser try { - xmlReader = new XmlReader(new BufferedInputStream(inputStream, 4000), encoding); - input = new FullyBufferedReader(xmlReader); + XmlReader xmlReader = new XmlReader(new BufferedInputStream(inputStream, 4000), + encoding); + this.input = new FullyBufferedReader(xmlReader); + this.encoding = xmlReader.getEncoding(); } finally { IOUtils.closeQuietly(inputStream); - IOUtils.closeQuietly(xmlReader); } }
bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5398_19e7c1cd.diff
bugs-dot-jar_data_WICKET-5883_cd3b9234
--- BugID: WICKET-5883 Summary: Feedback messages not cleared for invisible/disabled form components on submit. Description: "Having: \n- IFeedbackMessageFilter.NONE used as the default application's feedback message cleanup filter (in order to make feedback messages not to disappear after page refresh, i.e. persistent)\n- form with validatable component whose enabled/visible state may be dynamically changed by user (e.g. checkbox \"send me email\" and text field \"email\")\n\nFirst, user tries to submit form having invalid value - as the result validation error occurs. \nThen user makes that component invisible and retries form submitting - as the result no validation errors, but form wasn't submitted.\n\nThis happens because that component still has error feedback message got from first submit. Note that when using default application's feedback message cleanup filter, form is successfully submitted.\n\nProbably, feedback messages should be cleared for invisible/disabled form components on submit, as it done for visible/enabled components in FormComponent.validate()" diff --git a/wicket-core/src/main/java/org/apache/wicket/feedback/IFeedbackMessageFilter.java b/wicket-core/src/main/java/org/apache/wicket/feedback/IFeedbackMessageFilter.java index 83706e5..fdd3057 100644 --- a/wicket-core/src/main/java/org/apache/wicket/feedback/IFeedbackMessageFilter.java +++ b/wicket-core/src/main/java/org/apache/wicket/feedback/IFeedbackMessageFilter.java @@ -28,7 +28,7 @@ public interface IFeedbackMessageFilter extends IClusterable /** * Filter that returns simply all available messages. */ - public static final IFeedbackMessageFilter ALL = new IFeedbackMessageFilter() + IFeedbackMessageFilter ALL = new IFeedbackMessageFilter() { private static final long serialVersionUID = 1L; @@ -42,7 +42,7 @@ public interface IFeedbackMessageFilter extends IClusterable /** * Filter that does not match any message */ - public static final IFeedbackMessageFilter NONE = new IFeedbackMessageFilter() + IFeedbackMessageFilter NONE = new IFeedbackMessageFilter() { private static final long serialVersionUID = 1L; @@ -59,4 +59,4 @@ public interface IFeedbackMessageFilter extends IClusterable * @return True if the message should be included, false to exclude it */ boolean accept(FeedbackMessage message); -} \ No newline at end of file +} 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 93adebe..aa6ba63 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 @@ -1145,7 +1145,7 @@ public class Form<T> extends WebMarkupContainer implements IFormSubmitListener, @Override public void component(final Component component, final IVisit<Boolean> visit) { - if (component.hasErrorMessage()) + if (component.isVisibleInHierarchy() && component.isEnabledInHierarchy() && component.hasErrorMessage()) { visit.stop(true); }
bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5883_cd3b9234.diff
bugs-dot-jar_data_WICKET-5712_145da021
--- BugID: WICKET-5712 Summary: SecuritySettings.setEnforceMounts() does not work when the mounted mapper is not in the root compound mapper Description: |- BookmarkableMapper.isPageMounted() assumes that all mounted mappers are in Application.getRootRequestMapperAsCompound(). Sometimes the mappers make a tree structure, with multiple compounds existing, sometimes separated by wrappers, like HttpsMapper and CryptoMapper. Because of this, BookmarkableMapper fails to realise that a page is mounted and so does not enforce mounting. diff --git a/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/BookmarkableMapper.java b/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/BookmarkableMapper.java index eca607b..bf1d888 100644 --- a/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/BookmarkableMapper.java +++ b/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/BookmarkableMapper.java @@ -24,6 +24,7 @@ import org.apache.wicket.request.Request; import org.apache.wicket.request.Url; import org.apache.wicket.request.component.IRequestablePage; import org.apache.wicket.request.mapper.ICompoundRequestMapper; +import org.apache.wicket.request.mapper.IRequestMapperDelegate; import org.apache.wicket.request.mapper.info.PageComponentInfo; import org.apache.wicket.request.mapper.parameter.IPageParametersEncoder; import org.apache.wicket.request.mapper.parameter.PageParameters; @@ -119,7 +120,7 @@ public class BookmarkableMapper extends AbstractBookmarkableMapper if (!pageClass.equals(application.getHomePage())) { // WICKET-5094 only enforce mount if page is mounted - if (isPageMounted(pageClass, application)) + if (isPageMounted(pageClass, application.getRootRequestMapperAsCompound())) { return null; } @@ -137,21 +138,34 @@ public class BookmarkableMapper extends AbstractBookmarkableMapper return null; } - private boolean isPageMounted(Class<? extends IRequestablePage> pageClass, Application application) + private boolean isPageMounted(Class<? extends IRequestablePage> pageClass, ICompoundRequestMapper compoundMapper) { - ICompoundRequestMapper applicationMappers = application.getRootRequestMapperAsCompound(); - - for (IRequestMapper requestMapper : applicationMappers) + for (IRequestMapper requestMapper : compoundMapper) { - if (requestMapper instanceof AbstractBookmarkableMapper && requestMapper != this) + while (requestMapper instanceof IRequestMapperDelegate) { - AbstractBookmarkableMapper mapper = (AbstractBookmarkableMapper) requestMapper; + requestMapper = ((IRequestMapperDelegate)requestMapper).getDelegateMapper(); + } - if (mapper.checkPageClass(pageClass)) + if (requestMapper instanceof ICompoundRequestMapper) + { + if (isPageMounted(pageClass, (ICompoundRequestMapper)requestMapper)) { return true; } } + else + { + if (requestMapper instanceof AbstractBookmarkableMapper && requestMapper != this) + { + AbstractBookmarkableMapper mapper = (AbstractBookmarkableMapper) requestMapper; + + if (mapper.checkPageClass(pageClass)) + { + return true; + } + } + } } return false;
bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5712_145da021.diff
bugs-dot-jar_data_WICKET-2882_ebe56869
--- BugID: WICKET-2882 Summary: Dynamically adding component via an IComponentResolver fails within an enclosure for versions after 1.4.1 Description: |- We have been using an IComponentResolver implementation for a long time to allow the inclusion of certain panels to be determined by the markup. Some panels are included inside enclosures and some are not. Both cases worked fine in wicket 1.4.1 but in versions 1.4.2 and later a 'Tag expected' error occurs if the component is wrapped inside a wicket enclosure. A quickstart example has been included to demonstrate the problem. diff --git a/wicket/src/main/java/org/apache/wicket/MarkupContainer.java b/wicket/src/main/java/org/apache/wicket/MarkupContainer.java index c2d8431..a7a1964 100644 --- a/wicket/src/main/java/org/apache/wicket/MarkupContainer.java +++ b/wicket/src/main/java/org/apache/wicket/MarkupContainer.java @@ -34,6 +34,7 @@ import org.apache.wicket.markup.MarkupStream; import org.apache.wicket.markup.MarkupType; import org.apache.wicket.markup.RawMarkup; import org.apache.wicket.markup.WicketTag; +import org.apache.wicket.markup.html.border.Border; import org.apache.wicket.markup.resolver.ComponentResolvers; import org.apache.wicket.model.IComponentInheritedModel; import org.apache.wicket.model.IModel; @@ -138,6 +139,24 @@ public abstract class MarkupContainer extends Component implements Iterable<Comp throw new IllegalArgumentException("argument child may not be null"); } + MarkupContainer parent = getParent(); + while (parent != null) + { + if (child == parent) + { + 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(); + } + checkHierarchyChange(child); if (log.isDebugEnabled()) @@ -951,14 +970,10 @@ public abstract class MarkupContainer extends Component implements Iterable<Comp } final Page page = findPage(); - if (page != null) { child.initialize(); - } - if (page != null) - { // Tell the page a component has been added page.componentAdded(child); } diff --git a/wicket/src/main/java/org/apache/wicket/markup/html/internal/Enclosure.java b/wicket/src/main/java/org/apache/wicket/markup/html/internal/Enclosure.java index 4398671..e2f0076 100644 --- a/wicket/src/main/java/org/apache/wicket/markup/html/internal/Enclosure.java +++ b/wicket/src/main/java/org/apache/wicket/markup/html/internal/Enclosure.java @@ -23,12 +23,14 @@ import org.apache.wicket.application.IComponentOnAfterRenderListener; import org.apache.wicket.markup.ComponentTag; import org.apache.wicket.markup.MarkupException; import org.apache.wicket.markup.MarkupStream; -import org.apache.wicket.markup.html.TransparentWebMarkupContainer; +import org.apache.wicket.markup.html.WebMarkupContainer; import org.apache.wicket.markup.html.basic.EnclosureContainer; import org.apache.wicket.markup.html.form.Form; import org.apache.wicket.markup.html.form.FormComponent; import org.apache.wicket.markup.html.form.IFormSubmittingComponent; import org.apache.wicket.markup.parser.filter.EnclosureHandler; +import org.apache.wicket.markup.resolver.ComponentResolvers; +import org.apache.wicket.markup.resolver.IComponentResolver; import org.apache.wicket.request.Response; import org.apache.wicket.request.cycle.RequestCycle; import org.apache.wicket.response.NullResponse; @@ -82,7 +84,7 @@ import org.slf4j.LoggerFactory; * @author Juergen Donnerstag * @since 1.3 */ -public class Enclosure extends TransparentWebMarkupContainer +public class Enclosure extends WebMarkupContainer implements IComponentResolver { private static final long serialVersionUID = 1L; @@ -114,6 +116,25 @@ public class Enclosure extends TransparentWebMarkupContainer } /** + * @see org.apache.wicket.Component#onInitialize() + */ + @Override + protected void onInitialize() + { + super.onInitialize(); + + // enclosure's parent container + MarkupContainer container = getEnclosureParent(); + + // clear the cache + childComponent = null; + + // get Child Component. If not "added", ask a resolver to find it. + childComponent = getChildComponent(new MarkupStream(getMarkup()), container); + checkChildComponent(childComponent); + } + + /** * Get the real parent container * * @return enclosure's parent markup container @@ -121,7 +142,7 @@ public class Enclosure extends TransparentWebMarkupContainer private MarkupContainer getEnclosureParent() { MarkupContainer parent = getParent(); - while (parent.isAuto()) + while ((parent != null) && parent.isAuto()) { parent = parent.getParent(); } @@ -139,16 +160,11 @@ public class Enclosure extends TransparentWebMarkupContainer * org.apache.wicket.markup.ComponentTag) */ @Override - protected void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag) + protected void onComponentTagBody(final MarkupStream markupStream, final ComponentTag openTag) { - // enclosure's parent container - MarkupContainer container = getEnclosureParent(); - - Component controller = container.get(childId.toString()); - checkChildComponent(controller); - + // TODO this is where I wish we had something like "enum(TAG, BODY, NONE, ALL) isVisible()" // set the enclosure visibility - boolean visible = controller.determineVisibility(); + boolean visible = childComponent.determineVisibility(); // We want to know which components are rendered inside the enclosure final IComponentOnAfterRenderListener listener = new EnclosureListener(this); @@ -186,6 +202,59 @@ public class Enclosure extends TransparentWebMarkupContainer } /** + * @param markupStream + * @param container + * @return The component associated with the + */ + private Component getChildComponent(final MarkupStream markupStream, MarkupContainer container) + { + Component controller = container.get(childId.toString()); + if (controller == null) + { + int orgIndex = markupStream.getCurrentIndex(); + try + { + while (markupStream.hasMore()) + { + markupStream.next(); + if (markupStream.skipUntil(ComponentTag.class)) + { + ComponentTag tag = markupStream.getTag(); + if ((tag != null) && (tag.isOpen() || tag.isOpenClose())) + { + if (childId.equals(tag.getId())) + { + controller = ComponentResolvers.resolveByComponentHierarchy( + container, markupStream, tag); + break; + } + } + } + } + } + finally + { + markupStream.setCurrentIndex(orgIndex); + } + } + return controller; + } + + /** + * + * @see org.apache.wicket.markup.resolver.IComponentResolver#resolve(org.apache.wicket.MarkupContainer, + * org.apache.wicket.markup.MarkupStream, org.apache.wicket.markup.ComponentTag) + */ + public Component resolve(MarkupContainer container, MarkupStream markupStream, ComponentTag tag) + { + if (childId.equals(tag.getId())) + { + return childComponent; + } + return getEnclosureParent().get(tag.getId()); + } + + /** * * @param controller */ @@ -218,6 +287,7 @@ public class Enclosure extends TransparentWebMarkupContainer /** * @see org.apache.wicket.application.IComponentOnBeforeRenderListener#onBeforeRender(org.apache.wicket.Component) */ + @SuppressWarnings("unchecked") public void onAfterRender(final Component component) { if (log.isWarnEnabled()) diff --git a/wicket/src/main/java/org/apache/wicket/markup/resolver/ComponentResolvers.java b/wicket/src/main/java/org/apache/wicket/markup/resolver/ComponentResolvers.java index d94dc48..daf1ab6 100644 --- a/wicket/src/main/java/org/apache/wicket/markup/resolver/ComponentResolvers.java +++ b/wicket/src/main/java/org/apache/wicket/markup/resolver/ComponentResolvers.java @@ -50,24 +50,28 @@ public class ComponentResolvers final MarkupStream markupStream, final ComponentTag tag) { // try to resolve using component hierarchy + Component component = resolveByComponentHierarchy(container, markupStream, tag); - Component cursor = container; - while (cursor != null) + if (component == null) { - if (cursor instanceof IComponentResolver) - { - IComponentResolver resolver = (IComponentResolver)cursor; - Component component = resolver.resolve(container, markupStream, tag); - if (component != null) - { - return component; - } - } - cursor = cursor.getParent(); + // fallback to application-level resolvers + component = resolveByApplication(container, markupStream, tag); } - // fallback to application-level resolvers + return component; + } + /** + * Attempts to resolve a component via application registered resolvers. + * + * @param container + * @param markupStream + * @param tag + * @return Null, if no component was found + */ + public static Component resolveByApplication(final MarkupContainer container, + final MarkupStream markupStream, final ComponentTag tag) + { for (final IComponentResolver resolver : Application.get() .getPageSettings() .getComponentResolvers()) @@ -81,4 +85,33 @@ public class ComponentResolvers return null; } + + /** + * Attempts to resolve a component via the component hierarchy using resolvers. + * + * @param container + * @param markupStream + * @param tag + * @return Null, if no component was found + */ + public static Component resolveByComponentHierarchy(final MarkupContainer container, + final MarkupStream markupStream, final ComponentTag tag) + { + Component cursor = container; + while (cursor != null) + { + if (cursor instanceof IComponentResolver) + { + IComponentResolver resolver = (IComponentResolver)cursor; + Component component = resolver.resolve(container, markupStream, tag); + if (component != null) + { + return component; + } + } + cursor = cursor.getParent(); + } + + return null; + } } diff --git a/wicket/src/main/java/org/apache/wicket/protocol/http/BufferedWebResponse.java b/wicket/src/main/java/org/apache/wicket/protocol/http/BufferedWebResponse.java index 983dc58..7bb4948 100644 --- a/wicket/src/main/java/org/apache/wicket/protocol/http/BufferedWebResponse.java +++ b/wicket/src/main/java/org/apache/wicket/protocol/http/BufferedWebResponse.java @@ -493,4 +493,13 @@ public class BufferedWebResponse extends WebResponse response.write(stream.toByteArray()); } } + + /** + * @see java.lang.Object#toString() + */ + @Override + public String toString() + { + return charSequenceAction.builder.toString(); + } }
bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-2882_ebe56869.diff
bugs-dot-jar_data_WICKET-5259_a9e56e1e
--- BugID: WICKET-5259 Summary: Url can't parse urls with username and password Description: "Url tries to parse the password as the portnumber, because it's after the :, resulting in the following exception:\njava.lang.NumberFormatException: For input string: \"23dc429c-4ffa-4e99-8e24-984571f4c3b6@digdag-rest-dev2.topicusonderwijs.nl\"\n\tjava.lang.NumberFormatException.forInputString(NumberFormatException.java:65)\n\tjava.lang.Integer.parseInt(Integer.java:492)\n\tjava.lang.Integer.parseInt(Integer.java:527)\n\torg.apache.wicket.request.Url.parse(Url.java:276)\n\torg.apache.wicket.request.Url.parse(Url.java:192)\n\torg.apache.wicket.protocol.http.servlet.ServletWebResponse.encodeRedirectURL(ServletWebResponse.java:212)\n\torg.apache.wicket.protocol.http.servlet.ServletWebResponse.sendRedirect(ServletWebResponse.java:236)\n\torg.apache.wicket.protocol.http.BufferedWebResponse$SendRedirectAction.invoke(BufferedWebResponse.java:400)\n\torg.apache.wicket.protocol.http.BufferedWebResponse.writeTo(BufferedWebResponse.java:588)\n\torg.apache.wicket.protocol.http.HeaderBufferingWebResponse.stopBuffering(HeaderBufferingWebResponse.java:60)\n\torg.apache.wicket.protocol.http.HeaderBufferingWebResponse.flush(HeaderBufferingWebResponse.java:97)\n\torg.apache.wicket.protocol.http.WicketFilter.processRequestCycle(WicketFilter.java:269)\n\torg.apache.wicket.protocol.http.WicketFilter.processRequest(WicketFilter.java:201)\n\torg.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:282)\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 b9769e8..596163e 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 @@ -263,7 +263,8 @@ public class Url implements Serializable hostAndPort = afterProto.substring(0, relativeAt); } - final int portAt = hostAndPort.lastIndexOf(':'); + final int credentialsAt = hostAndPort.lastIndexOf('@') + 1; + final int portAt = hostAndPort.substring(credentialsAt).lastIndexOf(':'); if (portAt == -1) { @@ -272,8 +273,8 @@ public class Url implements Serializable } else { - result.host = hostAndPort.substring(0, portAt); - result.port = Integer.parseInt(hostAndPort.substring(portAt + 1)); + result.host = hostAndPort.substring(0, portAt + credentialsAt); + result.port = Integer.parseInt(hostAndPort.substring(portAt + credentialsAt + 1)); } if (relativeAt < 0)
bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5259_a9e56e1e.diff
bugs-dot-jar_data_WICKET-4070_d450acb0
--- BugID: WICKET-4070 Summary: Errors reported from Form#onValidateModelObjects() are ignored Description: 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 17fe546..e97e0b1 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 @@ -797,6 +797,7 @@ public class Form<T> extends WebMarkupContainer implements IFormSubmitListener if (hasError()) { callOnError(submittingComponent); + return; } // Form has no error
bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-4070_d450acb0.diff
bugs-dot-jar_data_WICKET-4505_a4caaa57
--- BugID: WICKET-4505 Summary: AbstractTextComponent not escaping html data by default therefore user text is not redisplayed correctly Description: |- User input is not escaped in all text fields by default (and the default is not configurable). This leads to user entered text not being redisplayed correctly. * You can replicate using the project from WICKET-3330. * Just enter the text my&frac12;companyname and press enter * The field will not redisplay the text entered properly diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/parser/TagAttributes.java b/wicket-core/src/main/java/org/apache/wicket/markup/parser/TagAttributes.java index 6f9719d..041b0cdb 100644 --- a/wicket-core/src/main/java/org/apache/wicket/markup/parser/TagAttributes.java +++ b/wicket-core/src/main/java/org/apache/wicket/markup/parser/TagAttributes.java @@ -54,7 +54,7 @@ public class TagAttributes extends ValueMap public final Object put(String key, Object value) { - return super.put(key, unescapeHtml(value)); + return super.put(key, value); } @Override diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/parser/XmlPullParser.java b/wicket-core/src/main/java/org/apache/wicket/markup/parser/XmlPullParser.java index 0ec91c9..93c57d0 100644 --- a/wicket-core/src/main/java/org/apache/wicket/markup/parser/XmlPullParser.java +++ b/wicket-core/src/main/java/org/apache/wicket/markup/parser/XmlPullParser.java @@ -31,6 +31,7 @@ import org.apache.wicket.util.lang.Args; import org.apache.wicket.util.parse.metapattern.parsers.TagNameParser; import org.apache.wicket.util.parse.metapattern.parsers.VariableAssignmentParser; import org.apache.wicket.util.resource.ResourceStreamNotFoundException; +import org.apache.wicket.util.string.Strings; /** * A fairly shallow markup pull parser which parses a markup string of a given type of markup (for @@ -665,6 +666,9 @@ public final class XmlPullParser implements IXmlPullParser // Trim trailing whitespace value = value.trim(); + // Unescape + value = Strings.unescapeMarkup(value).toString(); + // Get key final String key = attributeParser.getKey();
bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-4505_a4caaa57.diff
bugs-dot-jar_data_WICKET-5980_294b0b2f
--- BugID: WICKET-5980 Summary: When using Servlet 3.0 filter Wicket calculates filter path wrong Description: | When using a servlet 3.0 filter with annotations Wicket calculates the filter path wrong causing it to not match any pages other than the home page. e.g. {code} @WebFilter(value = "/web/*", initParams = {@WebInitParam(name = "applicationClassName", value = "com.example.CheesrApplication")}) public class CheesrFilter extends WicketFilter { } {code} Will cause Wicket to create a filter path of /web/*/ instead of the expected /web. diff --git a/wicket-core/src/main/java/org/apache/wicket/protocol/http/WicketFilter.java b/wicket-core/src/main/java/org/apache/wicket/protocol/http/WicketFilter.java index 679cfbf..d73a4a7 100644 --- a/wicket-core/src/main/java/org/apache/wicket/protocol/http/WicketFilter.java +++ b/wicket-core/src/main/java/org/apache/wicket/protocol/http/WicketFilter.java @@ -519,6 +519,10 @@ public class WicketFilter implements Filter pattern = ""; } + if (pattern.endsWith("*")) + { + pattern = pattern.substring(0, pattern.length() - 1); + } return pattern; } return null;
bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5980_294b0b2f.diff
bugs-dot-jar_data_WICKET-5486_a79ed51e
--- BugID: WICKET-5486 Summary: WebPageRenderer should honor RedirectPolicy.ALWAYS_REDIRECT more consistently Description: "In WebPageRenderer shouldPreserveClientUrl() currently has precedence over RedirectPolicy.ALWAYS_REDIRECT.\n\nThis can lead to confusion or unexpected behavior when RedirectPolicy.ALWAYS_REDIRECT is explicitely set, but for some reason shouldPreserveClientUrl() returns true and thus no redirect is performed due to the logic in WebPageRenderer.\n\nA fix for this particular problem could be implemented in \nWebPageRenderer as of Wicket 6.12.0 by changing line 211 to:\n\n || (shouldPreserveClientUrl && getRedirectPolicy() != RedirectPolicy.ALWAYS_REDIRECT)) //\n\n\nNote that this problem is slightly related to WICKET-5484. Both fixes combined the line could look like this:\n\n || (shouldPreserveClientUrl && !isAjax && getRedirectPolicy() != RedirectPolicy.ALWAYS_REDIRECT)) //\n\n" 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 8c99c13..1b98bed 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 @@ -342,7 +342,7 @@ public class WebPageRenderer extends PageRenderer || ((isOnePassRender() && notForcedRedirect(getRedirectPolicy())) || (targetUrl .equals(currentUrl) && notNewAndNotStatelessPage(isNewPageInstance(), isPageStateless()))) || (targetUrl.equals(currentUrl) && isRedirectToRender()) - || shouldPreserveClientUrl(cycle); + || (shouldPreserveClientUrl(cycle) && notForcedRedirect(getRedirectPolicy())); } private static boolean notNewAndNotStatelessPage(boolean newPageInstance, boolean pageStateless)
bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5486_a79ed51e.diff
bugs-dot-jar_data_WICKET-4824_ad849602
--- BugID: WICKET-4824 Summary: Redirect to HTTPS is using wrong port 80 if HttpsConfig with default ports 80/443 is used Description: |- HttpsMapper#mapHandler() doesn't set the Url's port, if the desired protocol uses the standard port. This leads to UrlRenderer choosing to the request's port as fallback (which is 80 before switching to https). diff --git a/wicket-core/src/main/java/org/apache/wicket/protocol/https/HttpsMapper.java b/wicket-core/src/main/java/org/apache/wicket/protocol/https/HttpsMapper.java index a5f765a..aaa1a3e 100644 --- a/wicket-core/src/main/java/org/apache/wicket/protocol/https/HttpsMapper.java +++ b/wicket-core/src/main/java/org/apache/wicket/protocol/https/HttpsMapper.java @@ -170,10 +170,7 @@ public class HttpsMapper implements IRequestMapper // the generated url does not have the correct scheme, set it (which in turn will cause // the url to be rendered in its full representation) url.setProtocol(desired.urlName()); - if (url.getPort() != null || !desired.usesStandardPort(config)) - { - url.setPort(desired.getPort(config)); - } + url.setPort(desired.getPort(config)); } return url; }
bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-4824_ad849602.diff
bugs-dot-jar_data_WICKET-4384_614e3b50
--- BugID: WICKET-4384 Summary: improve wicket's handling of empty / null page parameters Description: "- DefaultPageFactory#newPage() should be sure to not pass 'null' to a page constructor with page parameters" diff --git a/wicket-core/src/main/java/org/apache/wicket/request/mapper/AbstractBookmarkableMapper.java b/wicket-core/src/main/java/org/apache/wicket/request/mapper/AbstractBookmarkableMapper.java index d66f32e..ad48cf1 100644 --- a/wicket-core/src/main/java/org/apache/wicket/request/mapper/AbstractBookmarkableMapper.java +++ b/wicket-core/src/main/java/org/apache/wicket/request/mapper/AbstractBookmarkableMapper.java @@ -98,6 +98,11 @@ public abstract class AbstractBookmarkableMapper extends AbstractComponentMapper cleanParameters.remove(WebRequest.PARAM_AJAX); cleanParameters.remove(WebRequest.PARAM_AJAX_BASE_URL); cleanParameters.remove(WebRequest.PARAM_AJAX_REQUEST_ANTI_CACHE); + + if (cleanParameters.isEmpty()) + { + cleanParameters = null; + } } return cleanParameters; }
bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-4384_614e3b50.diff
bugs-dot-jar_data_WICKET-5019_917dd2b5
--- BugID: WICKET-5019 Summary: 'Handling of NO_MINIFIED_NAME in PackageResourceReference#internalGetMinifiedName() ' Description: "The Value NO_MINIFIED_NAME is not handled correctly as entry in the MINIFIED_NAMES_CACHE in PackageResourceReference#internalGetMinifiedName() \n\n\tprivate String internalGetMinifiedName()\n\t{\n\t\tString minifiedName = MINIFIED_NAMES_CACHE.get(this);\n\t\tif (minifiedName != null && minifiedName != NO_MINIFIED_NAME)\n\t\t{ ^^^^^^^\n\t\t\treturn minifiedName;\n }\n ...\n\nYou should remove the condition \"minifiedName != NO_MINIFIED_NAME\" here to leverage the \nMINIFIED_NAMES_CACHE for NO_MINIFIED_NAME cache entries. Otherwise you always run into the resource resolving code if there is no minified resource.\n " 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 ea2ddb6..cc72731 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 @@ -173,7 +173,7 @@ public class PackageResourceReference extends ResourceReference private String internalGetMinifiedName() { String minifiedName = MINIFIED_NAMES_CACHE.get(this); - if (minifiedName != null && minifiedName != NO_MINIFIED_NAME) + if (minifiedName != null) { return minifiedName; }
bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5019_917dd2b5.diff
bugs-dot-jar_data_WICKET-5203_2293764f
--- BugID: WICKET-5203 Summary: Base url is incorrect for error dispatched pages Description: "The fix for https://issues.apache.org/jira/browse/WICKET-4387 includes the following code in org.apache.wicket.protocol.http.servlet.ServletWebRequest#ServletWebRequest(HttpServletRequest httpServletRequest, String filterPrefix, Url url):\n\nif (forwardAttributes != null || errorAttributes != null)\n\t\t{\n\t\t\tif (LOG.isDebugEnabled())\n\t\t\t{\n\t\t\t\tLOG.debug(\"Setting filterPrefix('{}') to '' because there is either an error or a forward. {}, {}\",\n\t\t\t\t\t\tnew Object[] {filterPrefix, forwardAttributes, errorAttributes});\n\t\t\t}\n\t\t\t// the filter prefix is not needed when the current request is internal\n\t\t\t// see WICKET-4387\n\t\t\tthis.filterPrefix = \"\";\n\nThe filterPrefix is actually needed later when a request is made due to an error (e.g. 404):\n\npublic Url getClientUrl()\n\t{\n\t\tif (errorAttributes != null && !Strings.isEmpty(errorAttributes.getRequestUri()))\n\t\t{\n\t\t\tString problematicURI = Url.parse(errorAttributes.getRequestUri(), getCharset())\n\t\t\t\t.toString();\n\t\t\treturn getContextRelativeUrl(problematicURI, filterPrefix);\n\nWith filterPrefix==\"\" the urls for any resources in the error page are wrong.\n" 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 83df540..24947bb 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 @@ -102,20 +102,7 @@ public class ServletWebRequest extends WebRequest forwardAttributes = ForwardAttributes.of(httpServletRequest, filterPrefix); - if (forwardAttributes != null || errorAttributes != null) - { - if (LOG.isDebugEnabled()) - { - LOG.debug("Setting filterPrefix('{}') to '' because there is either an error or a forward. {}, {}", - new Object[] {filterPrefix, forwardAttributes, errorAttributes}); - } - // the filter prefix is not needed when the current request is internal - // see WICKET-4387 - this.filterPrefix = ""; - } else - { - this.filterPrefix = filterPrefix; - } + this.filterPrefix = filterPrefix; if (url != null) {
bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5203_2293764f.diff
bugs-dot-jar_data_WICKET-5838_e93fdd5a
--- BugID: WICKET-5838 Summary: Last-modified header of external markup is ignored Description: "When using external base markup(in my case a drupal page with a wicket:child element in it) this markup is supposed to be cached after first fetch. For subsequent requests the last-modified header is checked to see if the markup has changed and when it has the markup is fetched again.\n\nThis does not work, Connections.getLastModified(URL url) always returns 0 when the URL is a http url(in fact, when url.openConnection returns a sun.net.www.protocol.http.HttpURLConnection.\n\nSolution could be to not setDoInput to false on this URLConnection(tested that)\n " diff --git a/wicket-util/src/main/java/org/apache/wicket/util/io/Connections.java b/wicket-util/src/main/java/org/apache/wicket/util/io/Connections.java index 5336af6..167cefd 100644 --- a/wicket-util/src/main/java/org/apache/wicket/util/io/Connections.java +++ b/wicket-util/src/main/java/org/apache/wicket/util/io/Connections.java @@ -57,7 +57,6 @@ public class Connections // otherwise open the url and proceed URLConnection connection = url.openConnection(); - connection.setDoInput(false); final long milliseconds;
bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5838_e93fdd5a.diff
bugs-dot-jar_data_WICKET-5209_55eb5212
--- BugID: WICKET-5209 Summary: NPE when using ComponentRenderer.renderComponent on a panel with <wicket:enclosure> Description: "Hi,\n\nConsider this example:\n<wicket:panel>\n\t<wicket:enclosure child=\"externalLink\">\n\t\t<a wicket:id=\"externalLink\">Link</a>\n\t</wicket:enclosure>\n</wicket:panel>\n\nWhen trying to render such a panel with ComponentRenderer.renderComponent, a NPE is thrown because Wicket try to render Enclosure without initializing it.\n\nRoot cause:\njava.lang.NullPointerException\n\tat org.apache.wicket.markup.html.internal.Enclosure.isVisible(Enclosure.java:143)\n\tat org.apache.wicket.Component.determineVisibility(Component.java:4363)\n\tat org.apache.wicket.Component.internalBeforeRender(Component.java:916)\n\tat org.apache.wicket.Component.beforeRender(Component.java:991)\n\tat org.apache.wicket.Component.internalPrepareForRender(Component.java:2214)\n\tat org.apache.wicket.Component.render(Component.java:2303)\n\tat org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java:1390)\n\tat org.apache.wicket.MarkupContainer.renderAll(MarkupContainer.java:1554)\n\tat org.apache.wicket.MarkupContainer.renderComponentTagBody(MarkupContainer.java:1529)\n\tat org.apache.wicket.MarkupContainer.renderAssociatedMarkup(MarkupContainer.java:689)\n\tat org.apache.wicket.markup.html.panel.AssociatedMarkupSourcingStrategy.renderAssociatedMarkup(AssociatedMarkupSourcingStrategy.java:76)\n\tat org.apache.wicket.markup.html.panel.PanelMarkupSourcingStrategy.onComponentTagBody(PanelMarkupSourcingStrategy.java:112)\n\tat org.apache.wicket.Component.internalRenderComponent(Component.java:2549)\n\t... 29 more\n\nSee the attached quickstart.\n\nI've looked a little into it, and it seems that RenderPage (used by ComponentRenderer to render components) is never initialized.\nTherefore the panel's children are never initialized too (see MarkupContainer l.930), and this causes Enclosure to have a null childComponent.\n\nThanks." diff --git a/wicket-core/src/main/java/org/apache/wicket/core/util/string/ComponentRenderer.java b/wicket-core/src/main/java/org/apache/wicket/core/util/string/ComponentRenderer.java index 308b548..41704a6 100644 --- a/wicket-core/src/main/java/org/apache/wicket/core/util/string/ComponentRenderer.java +++ b/wicket-core/src/main/java/org/apache/wicket/core/util/string/ComponentRenderer.java @@ -100,6 +100,7 @@ public class ComponentRenderer RenderPage page = new RenderPage(); page.add(component); + page.internalInitialize(); component.render(); }
bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5209_55eb5212.diff
bugs-dot-jar_data_WICKET-3166_4d7f7359
--- BugID: WICKET-3166 Summary: isVisibleInHierarchy() possibly unnecessarily checks children whose parents are invisible? Description: |- Hi! See attached quickstart with junit test reproducing the bug. See also patch proposal. I have a page with two panels: page.form.add(panel1); page.form.add(panel2); in some situations panel1 is not visible. However, a form submit event will visit all formcomponents of panel1 via: at org.apache.wicket.markup.html.form.FormComponent.visitFormComponentsPostOrder(FormComponent.java:400) at org.apache.wicket.markup.html.form.Form.visitFormComponentsPostOrder(Form.java:1209) at org.apache.wicket.markup.html.form.Form.inputChanged(Form.java:1403) at org.apache.wicket.markup.html.form.Form.onFormSubmitted(Form.java:865) This results in a crash because panel1 components are not prepared to be invoked via isvisible when the panel itself is not visible. I wonder if the component.isVisibleInHierarchy could be changed as follows, to first check parent visibility: public final boolean isVisibleInHierarchy() { Component component = this; while (component != null) { Component componentParent = component.getParent(); if (((componentParent == null) || componentParent.isVisibleInHierarchy()) && component.determineVisibility()) { component = componentParent; } else { return false; } } return true; } Similar change could/should maybe be possible also for isEnabledInHierarchy ? diff --git a/wicket/src/main/java/org/apache/wicket/Component.java b/wicket/src/main/java/org/apache/wicket/Component.java index c9d7bde..fa7e85a 100644 --- a/wicket/src/main/java/org/apache/wicket/Component.java +++ b/wicket/src/main/java/org/apache/wicket/Component.java @@ -430,16 +430,6 @@ public abstract class Component }; /** - * Keeps metadata about the visibility state of the component - * - * The states are: null - not calculated, true and false - */ - private static final MetaDataKey<Boolean> VISIBLE_IN_HIERARCHY_CACHE_KEY = new MetaDataKey<Boolean>() - { - private static final long serialVersionUID = 1L; - }; - - /** * Keeps metadata about the enabled state of the component * * The states are: null - not calculated, true and false @@ -2148,21 +2138,15 @@ public abstract class Component */ public final boolean isVisibleInHierarchy() { - Boolean state = getMetaData(VISIBLE_IN_HIERARCHY_CACHE_KEY); - if (state == null) + Component parent = getParent(); + if (parent != null && !parent.isVisibleInHierarchy()) { - Component parent = getParent(); - if (parent != null && !parent.isVisibleInHierarchy()) - { - state = false; - } - else - { - state = determineVisibility(); - } - setMetaData(VISIBLE_IN_HIERARCHY_CACHE_KEY, state); + return false; + } + else + { + return determineVisibility(); } - return state; } /**
bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-3166_4d7f7359.diff
bugs-dot-jar_data_WICKET-5989_a255bbca
--- BugID: WICKET-5989 Summary: BaseWicketTester#startComponentInPage fails for pages with <wicket:header-items></wicket:header> placeholder Description: "I am using the {{[BaseWicketTester.html#startComponentInPage(C)|https://ci.apache.org/projects/wicket/apidocs/6.x/org/apache/wicket/util/tester/BaseWicketTester.html#startComponentInPage(C)]}} to validate individual components/panels.\n\nI am overriding the {{[BaseWicketTester.html#createPage()|https://ci.apache.org/projects/wicket/apidocs/6.x/org/apache/wicket/util/tester/BaseWicketTester.html#createPage()]}} and {{[BaseWicketTester.html#createPageMarkup(java.lang.String)|https://ci.apache.org/projects/wicket/apidocs/6.x/org/apache/wicket/util/tester/BaseWicketTester.html#createPageMarkup(java.lang.String)]}} methods to return a dummy page that contains a placeholder for components-to-be-tested. The dummy page extends my base page class.\n\nMy base page class makes use of the [<wicket:header-items/>|https://cwiki.apache.org/confluence/display/WICKET/Wicket's+XHTML+tags#Wicket'sXHTMLtags-Elementwicket:header-items] placeholder tag.\n\nWhen attempting to use {{[BaseWicketTester.html#createPage()|https://ci.apache.org/projects/wicket/apidocs/6.x/org/apache/wicket/util/tester/BaseWicketTester.html#createPage()]}} method, the method fails with the following error message:\n|Error while parsing the markup for the autogenerated page: More than one <wicket:header-items/> detected in the <head> element. Only one is allowed.\n\nIf I remove the {{[<wicket:header-items/>|https://cwiki.apache.org/confluence/display/WICKET/Wicket's+XHTML+tags#Wicket'sXHTMLtags-Elementwicket:header-items]}} placeholder tag from my base page class, the test runs successfully.\n\nThe test only fails when using the {{[BaseWicketTester.html#startComponentInPage(C)|https://ci.apache.org/projects/wicket/apidocs/6.x/org/apache/wicket/util/tester/BaseWicketTester.html#startComponentInPage(C)]}}, which only accepts one argument. If I use the {{[BaseWicketTester.html#startComponentInPage(C, org.apache.wicket.markup.IMarkupFragment)|https://ci.apache.org/projects/wicket/apidocs/6.x/org/apache/wicket/util/tester/BaseWicketTester.html#startComponentInPage(C, org.apache.wicket.markup.IMarkupFragment)]}} and pass in the {{MarkupFragment}} of the test class as the second argument, then the test runs successfully, e.g. \n{code}\ntester.startComponentInPage(new MyPanel(DummyPanelPage.TEST_PANEL_ID), \ new MyDummyPanelPage(new PageParameters()).getMarkup());\n{code}\n\nIt would seem that the {{[<wicket:header-items/>|https://cwiki.apache.org/confluence/display/WICKET/Wicket's+XHTML+tags#Wicket'sXHTMLtags-Elementwicket:header-items]}} placeholder tag clashes with the {{[ContainerInfo|https://ci.apache.org/projects/wicket/apidocs/6.x/org/apache/wicket/markup/ContainerInfo.html]}} class used by the testing framework, but this is by no means my area of expertise.\n\nI am attaching a quick-start app with a {{TestHomePage}} test class that reproduces the issue.\n\nThank you in advance!" 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 5b79f80..b695713 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 @@ -31,6 +31,7 @@ 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; +import org.apache.wicket.util.tester.BaseWicketTester; /** @@ -172,7 +173,7 @@ public final class HtmlHeaderSectionHandler extends AbstractMarkupFilter */ private void handleHeaderItemsTag(ComponentTag tag) { - if (foundHeaderItemsTag) + if ((tag.isOpen() || tag.isOpenClose()) && foundHeaderItemsTag) { throw new MarkupException(new MarkupStream(markup), "More than one <wicket:header-items/> detected in the <head> element. Only one is allowed.");
bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5989_a255bbca.diff
bugs-dot-jar_data_WICKET-4664_2fcb3417
--- BugID: WICKET-4664 Summary: Url#getQueryString(charset) method returns quesrystring with "?" prefixed to it Description: "i have just pointed out 6.0.0-beta3/6.x but it must be same in 1.5.x too ,afaik \"?\" is not considered part of querystring ,\"?\" is considered separator see http://tools.ietf.org/html/rfc3986#section-3\nthis method is used in Url#toString() too which can be easily fixed but it may be used at other places too so i don't know if removing \"?\" will break things now.\n\nso how things break currently\nRequestUtils.decodeParameters(url.getQueryString(),parameters);\ndecodeparameters will considered first key to be \"?key\" \nso may be requestutils#decodeparameters method should strip away \"?\" if it's present in the query string before populating pageparameters\n\nthanks!\n\n\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 c9ddc69..2e24b5c 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 @@ -714,7 +714,12 @@ public class Url implements Serializable result.append(path); - result.append(getQueryString(charset)); + + final String queryString = getQueryString(charset); + if (queryString != null) + { + result.append('?').append(queryString); + } return result.toString(); }
bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-4664_2fcb3417.diff
bugs-dot-jar_data_WICKET-16_3431e60d
--- BugID: WICKET-16 Summary: missing base64/ URL encoding Description: "yesterday i showed the concept of omponents to a friend and stumled into something i dont understand and think it might be a bug. \n \nI have a small panelcompoment that holds a searchform (textfield + submit) nothing special here, the code behind looks like: \n \n @Override\n public void onSubmit() \n {\n \ String suchFeld = getSuchfeld();\n if(suchFeld.length()>0)\n \ {\n PageParameters params = new PageParameters();\n params.add(\"finde\",suchFeld);\n \ setResponsePage(Suche.class,params);\n }\n else\n \ {\n setResponsePage(getPage().getClass());\n } \ \n }\n \nthe component is put into a \"BasePage\":\n \n public BasePage() {\n .... \n add(bar);\n add(new SuchPanel(\"SuchPanel\"));\n \ .....\n}\n \nwich is then extended by the real page:\n \npublic class Foo extends BasePage{\n \n /** Creates a new instance of Zigarren */\n public Foo() {\n }\n \nwich works all fine, however if the class name contains non ascii letters\n(e.g: ö ä ü etc.) it gives me a bug if nothing is entered into the search and the part\n \npublic class Zubehör extends BasePage{\n \n /** Creates a new instance of Zubehör */\n public Zubehör() {\n }\n \n\"setResponsePage(getPage().getClass());\" comes to action, the trouble is that the page might have the URL:\n?wicket:bookmarkablePage=:de.pages.Zubeh%C3%B6r\nbut the form tries to go to : \nwicket:bookmarkablePage=:de.pages.Zubeh%F6r\n \nwich results in a CODE 404 in the App Server \n" diff --git a/wicket/src/main/java/wicket/protocol/http/request/AbstractWebRequestCodingStrategy.java b/wicket/src/main/java/wicket/protocol/http/request/AbstractWebRequestCodingStrategy.java index 35342cd..dadc062 100644 --- a/wicket/src/main/java/wicket/protocol/http/request/AbstractWebRequestCodingStrategy.java +++ b/wicket/src/main/java/wicket/protocol/http/request/AbstractWebRequestCodingStrategy.java @@ -333,7 +333,26 @@ public abstract class AbstractWebRequestCodingStrategy implements IRequestCoding // Add <page-map-name>:<bookmarkable-page-class> - url.append(pageMapName + Component.PATH_SEPARATOR + pageClass.getName()); + String pageClassName = pageClass.getName(); + + /* + * Encode the url so it is correct even for class names containing + * non ASCII characters, like ä, æ, ø, å etc. + * + * The reason for this is that when redirecting to these + * bookmarkable pages, we need to have the url encoded correctly + * because we can't rely on the browser to interpret the unencoded + * url correctly. + */ + try + { + pageClassName = URLEncoder.encode(pageClassName, "UTF-8"); + } + catch (UnsupportedEncodingException e) + { + throw new RuntimeException(e); + } + url.append(pageMapName + Component.PATH_SEPARATOR + pageClassName); } // Is it a bookmarkable interface listener?
bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-16_3431e60d.diff
bugs-dot-jar_data_WICKET-4477_2624d2db
--- BugID: WICKET-4477 Summary: SmartLinkLabel failing to process email with - Description: "In a similar vein to WICKET-3174 - using SmartLinkLabel with an email address that includes a \"-\" generates a link only on the right-most part of the address. \n\nExample: \n- [email protected] \nWill generate a link like: \n- my-<a href=\"mailto:[email protected]\">[email protected]</a> \n\nThe 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 54705e4..515bba9 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-4477_2624d2db.diff
bugs-dot-jar_data_WICKET-5094_74e77676
--- BugID: WICKET-5094 Summary: ISecuritySettings#getEnforceMounts(true) prevents access to *all* non-mounted bookmarkable pages Description: |- ISecuritySettings#setEnforceMounts(true) is meant to be used to prevent access to mounted-pages via BookmarkableMapper, e.g. when Page1.class is mounted: http://localhost:8080/niceurl/a/nice/path/to/the/first/page ... then the following url will not be accepted: http://localhost:8080/niceurl/wicket/bookmarkable/org.apache.wicket.examples.niceurl.Page1 But starting with Wicket 1.5.x access to *all* non-mounted pages via BookmarkableMapper is prevented, i.e. no url "http://localhost:8080/niceurl/wicket/bookmarkable/*" is matched. diff --git a/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/BookmarkableMapper.java b/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/BookmarkableMapper.java index f8c7ffe..b1418bf 100644 --- a/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/BookmarkableMapper.java +++ b/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/BookmarkableMapper.java @@ -17,6 +17,8 @@ package org.apache.wicket.core.request.mapper; import org.apache.wicket.Application; +import org.apache.wicket.core.request.handler.PageProvider; +import org.apache.wicket.core.request.handler.RenderPageRequestHandler; import org.apache.wicket.request.Request; import org.apache.wicket.request.Url; import org.apache.wicket.request.component.IRequestablePage; @@ -28,21 +30,21 @@ import org.apache.wicket.util.lang.Args; /** * Decodes and encodes the following URLs: - * + * * <pre> * Page Class - Render (BookmarkablePageRequestHandler) * /wicket/bookmarkable/org.apache.wicket.MyPage * (will redirect to hybrid alternative if page is not stateless) - * + * * Page Instance - Render Hybrid (RenderPageRequestHandler for pages that were created using bookmarkable URLs) * /wicket/bookmarkable/org.apache.wicket.MyPage?2 - * + * * Page Instance - Bookmarkable Listener (BookmarkableListenerInterfaceRequestHandler) * /wicket/bookmarkable/org.apache.wicket.MyPage?2-click-foo-bar-baz * /wicket/bookmarkable/org.apache.wicket.MyPage?2-click.1-foo-bar-baz (1 is behavior index) * (these will redirect to hybrid if page is not stateless) * </pre> - * + * * @author Matej Knopp */ public class BookmarkableMapper extends AbstractBookmarkableMapper @@ -51,7 +53,7 @@ public class BookmarkableMapper extends AbstractBookmarkableMapper /** * Construct. - * + * * @param pageParametersEncoder */ public BookmarkableMapper(IPageParametersEncoder pageParametersEncoder) @@ -91,14 +93,6 @@ public class BookmarkableMapper extends AbstractBookmarkableMapper @Override protected UrlInfo parseRequest(Request request) { - if (Application.exists()) - { - if (Application.get().getSecuritySettings().getEnforceMounts()) - { - return null; - } - } - Url url = request.getUrl(); if (matches(url)) { @@ -111,6 +105,25 @@ public class BookmarkableMapper extends AbstractBookmarkableMapper if (pageClass != null && IRequestablePage.class.isAssignableFrom(pageClass)) { + if (Application.exists()) + { + Application application = Application.get(); + + if (application.getSecuritySettings().getEnforceMounts()) + { + // we make an excepion if the homepage itself was mounted, see WICKET-1898 + if (!pageClass.equals(application.getHomePage())) + { + // WICKET-5094 only enforce mount if page is mounted + Url reverseUrl = application.getRootRequestMapper().mapHandler( + new RenderPageRequestHandler(new PageProvider(pageClass))); + if (!matches(reverseUrl)) + { + return null; + } + } + } + } // extract the PageParameters from URL if there are any PageParameters pageParameters = extractPageParameters(request, 3,
bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5094_74e77676.diff
bugs-dot-jar_data_WICKET-3834_747bccb5
--- BugID: WICKET-3834 Summary: WicketTester does not follow absolute redirects Description: |- Wicket tester does not follow absolute redirects: This is a problem when using HttpsMapper. For example when requesting a page over http:// with an forced redirect to https:// for secure access will make wicket tester return 'null' for the last renderer page instead of the rendered page instance. In general all kinds of absolute redirects to another page will not be tracked by wicket tester. So this potentially a problem for all kinds of tests that rely on absolute redirects. 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 247197e..d9e0cd5 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 @@ -22,6 +22,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.List; +import java.util.Locale; import org.apache.wicket.util.lang.Args; import org.apache.wicket.util.lang.Generics; @@ -105,6 +106,7 @@ public final class Url implements Serializable * Parses the given URL string. * * @param url + * absolute or relative url with query string * @return Url object */ public static Url parse(final String url) @@ -116,7 +118,7 @@ public final class Url implements Serializable * Parses the given URL string. * * @param url - * full absolute or relative url with query string + * absolute or relative url with query string * @param charset * @return Url object */ @@ -154,12 +156,13 @@ public final class Url implements Serializable if (protocolAt != -1) { - result.protocol = absoluteUrl.substring(0, protocolAt); + result.protocol = absoluteUrl.substring(0, protocolAt).toLowerCase(Locale.US); final String afterProto = absoluteUrl.substring(protocolAt + 3); final String hostAndPort; int relativeAt = afterProto.indexOf('/'); - + + if (relativeAt == -1) { relativeUrl = ""; @@ -176,7 +179,7 @@ public final class Url implements Serializable if (portAt == -1) { result.host = hostAndPort; - result.port = null; + result.port = getDefaultPortForProtocol(result.protocol); } else { @@ -230,6 +233,33 @@ public final class Url implements Serializable } /** + * get default port number for protocol + * + * @param protocol + * name of protocol + * @return default port for protocol or <code>null</code> if unknown + */ + private static Integer getDefaultPortForProtocol(String protocol) + { + if ("http".equals(protocol)) + { + return 80; + } + else if ("https".equals(protocol)) + { + return 443; + } + else if ("ftp".equals(protocol)) + { + return 21; + } + else + { + return null; + } + } + + /** * Construct. */ public Url() @@ -281,7 +311,7 @@ public final class Url implements Serializable */ public Url(final List<String> segments, final Charset charset) { - this(segments, Collections.<QueryParameter> emptyList(), charset); + this(segments, Collections.<QueryParameter>emptyList(), charset); } /**
bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-3834_747bccb5.diff
bugs-dot-jar_data_WICKET-5250_6122df49
--- BugID: WICKET-5250 Summary: Minified css/js gets compressed Description: "Given an application with a resource reference to a minified script, i.e. html5.js and html5.min.js.\n\nWhen the ResourceRequestHandler responds \nit will set compress to false, if the resource reference was PackageResourceReference\nbut it will not change compression if the resource reference was JavaScriptResourceReference.\n\n\nPackageResourceReference handles minified resources more or less correctly (if they are minified, they should not be further compressed), but this behavior is overwritten in its subclasses.\n" diff --git a/wicket-core/src/main/java/org/apache/wicket/request/resource/CssResourceReference.java b/wicket-core/src/main/java/org/apache/wicket/request/resource/CssResourceReference.java index 55955d7..7d15d61 100644 --- a/wicket-core/src/main/java/org/apache/wicket/request/resource/CssResourceReference.java +++ b/wicket-core/src/main/java/org/apache/wicket/request/resource/CssResourceReference.java @@ -76,8 +76,10 @@ public class CssResourceReference extends PackageResourceReference @Override public CssPackageResource getResource() { - return new CssPackageResource(getScope(), getName(), getLocale(), getStyle(), - getVariation()); + final CssPackageResource resource = new CssPackageResource(getScope(), getName(), getLocale(), getStyle(), + getVariation()); + removeCompressFlagIfUnnecessary(resource); + return resource; } } diff --git a/wicket-core/src/main/java/org/apache/wicket/request/resource/JavaScriptResourceReference.java b/wicket-core/src/main/java/org/apache/wicket/request/resource/JavaScriptResourceReference.java index 43e4a0d..d320f59 100644 --- a/wicket-core/src/main/java/org/apache/wicket/request/resource/JavaScriptResourceReference.java +++ b/wicket-core/src/main/java/org/apache/wicket/request/resource/JavaScriptResourceReference.java @@ -78,7 +78,9 @@ public class JavaScriptResourceReference extends PackageResourceReference @Override public JavaScriptPackageResource getResource() { - return new JavaScriptPackageResource(getScope(), getName(), getLocale(), getStyle(), - getVariation()); + final JavaScriptPackageResource resource = new JavaScriptPackageResource(getScope(), getName(), getLocale(), getStyle(), + getVariation()); + removeCompressFlagIfUnnecessary(resource); + return resource; } } 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 ca248a0..a127aa7 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 @@ -129,16 +129,30 @@ public class PackageResourceReference extends ResourceReference getVariation()); } - String minifiedName = MINIFIED_NAMES_CACHE.get(this); - if (minifiedName != null && minifiedName != NO_MINIFIED_NAME) - { - resource.setCompress(false); - } - - return resource; - } - - private ResourceReference.UrlAttributes getUrlAttributes(Locale locale, String style, String variation) + removeCompressFlagIfUnnecessary(resource); + + return resource; + } + + /** + * Method allowing to remove the compress flag if the resource has been detected as a minified one + * (i.e. ending with .min.EXT) + * This method is to be called by subclasses overriding <code>getResource</code> + * if they want to rely on default minification detection handling + * + * see WICKET-5250 for further explanation + * @param resource resource to check + */ + protected void removeCompressFlagIfUnnecessary(final PackageResource resource) + { + String minifiedName = MINIFIED_NAMES_CACHE.get(this); + if (minifiedName != null && minifiedName != NO_MINIFIED_NAME) + { + resource.setCompress(false); + } + } + + private ResourceReference.UrlAttributes getUrlAttributes(Locale locale, String style, String variation) { IResourceStreamLocator locator = Application.get() .getResourceSettings()
bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5250_6122df49.diff
bugs-dot-jar_data_WICKET-3597_5e2c6702
--- BugID: WICKET-3597 Summary: Wicket 1.5 RC-3 Bug with conditional comments Description: IE Conditional Comments with script block causes malformed HTML on Chrome and Firefox. diff --git a/wicket-core/src/main/java/org/apache/wicket/util/string/JavaScriptUtils.java b/wicket-core/src/main/java/org/apache/wicket/util/string/JavaScriptUtils.java index 6101006..8897e62 100644 --- a/wicket-core/src/main/java/org/apache/wicket/util/string/JavaScriptUtils.java +++ b/wicket-core/src/main/java/org/apache/wicket/util/string/JavaScriptUtils.java @@ -27,22 +27,22 @@ import org.apache.wicket.request.Response; public class JavaScriptUtils { /** Script open tag */ - public final static String SCRIPT_OPEN_TAG = "<script type=\"text/javascript\"><!--/*--><![CDATA[/*><!--*/\n"; + public final static String SCRIPT_OPEN_TAG = "<script type=\"text/javascript\">\n/*<![CDATA[*/\n"; /** Script close tag */ - public final static String SCRIPT_CLOSE_TAG = "\n/*-->]]>*/</script>\n"; + public final static String SCRIPT_CLOSE_TAG = "\n/*]]>*/\n</script>\n"; /** * Script open tag. If this tag is changed, also update Wicket.Head.Contributor.processScript() * function from wicket-ajax.js */ - public final static String SCRIPT_CONTENT_PREFIX = "<!--/*--><![CDATA[/*><!--*/\n"; + public final static String SCRIPT_CONTENT_PREFIX = "\n/*<![CDATA[*/\n"; /** * Script close tag. If this tag is changed, also update Wicket.Head.Contributor.processScript() * function from wicket-ajax.js */ - public final static String SCRIPT_CONTENT_SUFFIX = "\n/*-->]]>*/"; + public final static String SCRIPT_CONTENT_SUFFIX = "\n/*]]>*/\n"; /** The response object */
bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-3597_5e2c6702.diff
bugs-dot-jar_data_WICKET-2900_0e70ce39
--- BugID: WICKET-2900 Summary: '"isPrimary" check is not applied to beans in parent contexts' Description: 'see this comment in WICKET-2771: https://issues.apache.org/jira/browse/WICKET-2771?focusedCommentId=12872246&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#action_12872246' diff --git a/wicket-spring/src/main/java/org/apache/wicket/spring/SpringBeanLocator.java b/wicket-spring/src/main/java/org/apache/wicket/spring/SpringBeanLocator.java index 35d3be3..dfa2181 100644 --- a/wicket-spring/src/main/java/org/apache/wicket/spring/SpringBeanLocator.java +++ b/wicket-spring/src/main/java/org/apache/wicket/spring/SpringBeanLocator.java @@ -26,9 +26,11 @@ import org.apache.wicket.proxy.IProxyTargetLocator; import org.apache.wicket.util.lang.Objects; import org.apache.wicket.util.lang.WicketObjects; import org.apache.wicket.util.string.Strings; +import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.BeanFactoryUtils; import org.springframework.beans.factory.NoSuchBeanDefinitionException; import org.springframework.beans.factory.config.BeanDefinition; +import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import org.springframework.beans.factory.support.AbstractBeanDefinition; import org.springframework.context.ApplicationContext; import org.springframework.context.support.AbstractApplicationContext; @@ -120,12 +122,15 @@ public class SpringBeanLocator implements IProxyTargetLocator while (it.hasNext()) { final String possibility = it.next(); - BeanDefinition beanDef = ((AbstractApplicationContext)ctx).getBeanFactory() - .getBeanDefinition(possibility); - if (BeanFactoryUtils.isFactoryDereference(possibility) || - possibility.startsWith("scopedTarget.") || !beanDef.isAutowireCandidate()) + if (ctx instanceof AbstractApplicationContext) { - it.remove(); + BeanDefinition beanDef = getBeanDefinition(((AbstractApplicationContext)ctx) + .getBeanFactory(), possibility); + if (BeanFactoryUtils.isFactoryDereference(possibility) || + possibility.startsWith("scopedTarget.") || !beanDef.isAutowireCandidate()) + { + it.remove(); + } } } @@ -137,18 +142,23 @@ public class SpringBeanLocator implements IProxyTargetLocator { if (ctx instanceof AbstractApplicationContext) { + List<String> primaries = new ArrayList<String>(); for (String name : names) { - BeanDefinition beanDef = ((AbstractApplicationContext)ctx).getBeanFactory() - .getBeanDefinition(name); + BeanDefinition beanDef = getBeanDefinition(((AbstractApplicationContext)ctx) + .getBeanFactory(), name); if (beanDef instanceof AbstractBeanDefinition) { if (((AbstractBeanDefinition)beanDef).isPrimary()) { - return name; + primaries.add(name); } } } + if (primaries.size() == 1) + { + return primaries.get(0); + } } StringBuilder msg = new StringBuilder(); @@ -166,6 +176,28 @@ public class SpringBeanLocator implements IProxyTargetLocator } } + private BeanDefinition getBeanDefinition(ConfigurableListableBeanFactory beanFactory, + String name) + { + if (beanFactory.containsBeanDefinition(name)) + { + return beanFactory.getBeanDefinition(name); + } + else + { + BeanFactory parent = beanFactory.getParentBeanFactory(); + if (parent != null && parent instanceof ConfigurableListableBeanFactory) + { + return getBeanDefinition(beanFactory, name); + } + else + { + return null; + } + } + } + + /** * @return returns whether the bean (the locator is supposed to istantiate) is a singleton or * not 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 5cf9d0e..6b36295 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 @@ -29,8 +29,10 @@ import org.apache.wicket.spring.ISpringContextLocator; import org.apache.wicket.spring.SpringBeanLocator; import org.apache.wicket.util.lang.Generics; import org.apache.wicket.util.string.Strings; +import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.BeanFactoryUtils; import org.springframework.beans.factory.config.BeanDefinition; +import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import org.springframework.beans.factory.support.AbstractBeanDefinition; import org.springframework.context.ApplicationContext; import org.springframework.context.support.AbstractApplicationContext; @@ -187,12 +189,15 @@ public class AnnotProxyFieldValueFactory implements IFieldValueFactory while (it.hasNext()) { final String possibility = it.next(); - BeanDefinition beanDef = ((AbstractApplicationContext)ctx).getBeanFactory() - .getBeanDefinition(possibility); - if (BeanFactoryUtils.isFactoryDereference(possibility) || - possibility.startsWith("scopedTarget.") || !beanDef.isAutowireCandidate()) + if (ctx instanceof AbstractApplicationContext) { - it.remove(); + BeanDefinition beanDef = getBeanDefinition(((AbstractApplicationContext)ctx) + .getBeanFactory(), possibility); + if (BeanFactoryUtils.isFactoryDereference(possibility) || + possibility.startsWith("scopedTarget.") || !beanDef.isAutowireCandidate()) + { + it.remove(); + } } } @@ -204,18 +209,23 @@ public class AnnotProxyFieldValueFactory implements IFieldValueFactory { if (ctx instanceof AbstractApplicationContext) { + List<String> primaries = new ArrayList<String>(); for (String name : names) { - BeanDefinition beanDef = ((AbstractApplicationContext)ctx).getBeanFactory() - .getBeanDefinition(name); + BeanDefinition beanDef = getBeanDefinition(((AbstractApplicationContext)ctx) + .getBeanFactory(), name); if (beanDef instanceof AbstractBeanDefinition) { if (((AbstractBeanDefinition)beanDef).isPrimary()) { - return name; + primaries.add(name); } } } + if (primaries.size() == 1) + { + return primaries.get(0); + } } StringBuilder msg = new StringBuilder(); msg.append("More than one bean of type ["); @@ -232,6 +242,28 @@ public class AnnotProxyFieldValueFactory implements IFieldValueFactory } } + private BeanDefinition getBeanDefinition(ConfigurableListableBeanFactory beanFactory, + String name) + { + if (beanFactory.containsBeanDefinition(name)) + { + return beanFactory.getBeanDefinition(name); + } + else + { + BeanFactory parent = beanFactory.getParentBeanFactory(); + if (parent != null && parent instanceof ConfigurableListableBeanFactory) + { + return getBeanDefinition(beanFactory, name); + } + else + { + return null; + } + } + } + + /** * @see org.apache.wicket.injection.IFieldValueFactory#supportsField(java.lang.reflect.Field) */
bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-2900_0e70ce39.diff
bugs-dot-jar_data_WICKET-3646_12124902
--- BugID: WICKET-3646 Summary: RequestHandler listeners are called with null handler Description: |- When running RequestCycleListeners with WicketTester, they get called with null for the requesthandler in onScheduleHandler(). This is an artifact of the wicket tester requestcycle, which I think should normally not occur in Wicket processing. The parameters are not marked as optional, so it is IMO safe to assume that handler should never be null. I propose to modify scheduleRequestHandlerAfterCurrent(IRequestHandler handler) to not invoke the listeners when the handler is null, but only to clear the current scheduled handler. diff --git a/wicket-core/src/main/java/org/apache/wicket/request/cycle/RequestCycle.java b/wicket-core/src/main/java/org/apache/wicket/request/cycle/RequestCycle.java index d4a45d2..f1208b6 100644 --- a/wicket-core/src/main/java/org/apache/wicket/request/cycle/RequestCycle.java +++ b/wicket-core/src/main/java/org/apache/wicket/request/cycle/RequestCycle.java @@ -668,7 +668,10 @@ public class RequestCycle implements IRequestCycle, IEventSink { // just delegating the call to {@link IRequestHandlerExecutor} and invoking listeners requestHandlerExecutor.schedule(handler); - listeners.onRequestHandlerScheduled(handler); + + // only forward calls to the listeners when handler is null + if (handler != null) + listeners.onRequestHandlerScheduled(handler); } /**
bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-3646_12124902.diff
bugs-dot-jar_data_WICKET-1931_986848f7
--- BugID: WICKET-1931 Summary: FormTester doesn't correctly submit a form when a FileUploadField was not set (which is not required) Description: |- FormTester doesn't correctly submit a form when a FileUploadField was not set. This file is not required. So it is impossible to create a real test because I am forced to always set a File to check to whole form. There was discussion about this problem here: http://www.nabble.com/FormTester-and-FileUploadField-td18566869.html I will be very grateful if you can fix it :) Artur 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 e282be1..c521441 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 @@ -487,33 +487,19 @@ public class MockHttpServletRequest implements HttpServletRequest */ public ServletInputStream getInputStream() throws IOException { - if (uploadedFiles != null && uploadedFiles.size() > 0) - { - byte[] request = buildRequest(); + byte[] request = buildRequest(); - // Ok lets make an input stream to return - final ByteArrayInputStream bais = new ByteArrayInputStream(request); + // Ok lets make an input stream to return + final ByteArrayInputStream bais = new ByteArrayInputStream(request); - return new ServletInputStream() - { - @Override - public int read() - { - return bais.read(); - } - }; - } - else + return new ServletInputStream() { - return new ServletInputStream() + @Override + public int read() { - @Override - public int read() - { - return -1; - } - }; - } + return bais.read(); + } + }; } /**
bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-1931_986848f7.diff
bugs-dot-jar_data_WICKET-4030_5f69685d
--- BugID: WICKET-4030 Summary: HeaderResponse.renderCSSReference does not render context path relative url, but wicket filter url-pattern relative url Description: In an application with a wicket filter url-pattern different than /*, if you use HeaderResponse.renderCSSReference(String url), where url is a context-path-relative url (css/main.css, for example), the generated css link is not context relative, but wicket url-pattern relative. diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/internal/HeaderResponse.java b/wicket-core/src/main/java/org/apache/wicket/markup/html/internal/HeaderResponse.java index dbde562..25e908a 100644 --- a/wicket-core/src/main/java/org/apache/wicket/markup/html/internal/HeaderResponse.java +++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/internal/HeaderResponse.java @@ -25,7 +25,6 @@ import org.apache.wicket.markup.html.IHeaderResponse; import org.apache.wicket.markup.html.WicketEventReference; import org.apache.wicket.request.IRequestHandler; import org.apache.wicket.request.Response; -import org.apache.wicket.request.Url; import org.apache.wicket.request.cycle.RequestCycle; import org.apache.wicket.request.handler.resource.ResourceReferenceRequestHandler; import org.apache.wicket.request.mapper.parameter.PageParameters; @@ -378,22 +377,22 @@ public abstract class HeaderResponse implements IHeaderResponse } /** + * Rewrites a relative url into a context-relative one, leaves absolute urls alone * - * @param location + * @param url * @return relative path */ - private String relative(final String location) + private String relative(final String url) { - Args.notEmpty(location, "location"); + Args.notEmpty(url, "location"); - if (location.startsWith("http://") || location.startsWith("https://") || - location.startsWith("/")) + if (url.startsWith("http://") || url.startsWith("https://") || url.startsWith("/")) { - return location; + return url; } RequestCycle rc = RequestCycle.get(); - return rc.getUrlRenderer().renderUrl(Url.parse(location, rc.getRequest().getCharset())); + return rc.getUrlRenderer().renderContextRelativeUrl(url); } /** diff --git a/wicket-core/src/main/java/org/apache/wicket/mock/MockWebRequest.java b/wicket-core/src/main/java/org/apache/wicket/mock/MockWebRequest.java index 3b26621..c79b716 100644 --- a/wicket-core/src/main/java/org/apache/wicket/mock/MockWebRequest.java +++ b/wicket-core/src/main/java/org/apache/wicket/mock/MockWebRequest.java @@ -47,7 +47,7 @@ public class MockWebRequest extends WebRequest private Locale locale = Locale.getDefault(); private String contextPath; private String filterPath; - private String prefixToContextPath; + private String prefixToContextPath = ""; /** * Construct.
bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-4030_5f69685d.diff
bugs-dot-jar_data_WICKET-5400_6cefb9f8
--- BugID: WICKET-5400 Summary: Behaviors#internalAdd(Behavior) erroneously gets id for stateless behaviors Description: see http://markmail.org/thread/jtd4zn527r343jbm diff --git a/wicket-core/src/main/java/org/apache/wicket/Behaviors.java b/wicket-core/src/main/java/org/apache/wicket/Behaviors.java index a743e8b..3d406f2 100644 --- a/wicket-core/src/main/java/org/apache/wicket/Behaviors.java +++ b/wicket-core/src/main/java/org/apache/wicket/Behaviors.java @@ -63,7 +63,7 @@ final class Behaviors implements IDetachable private void internalAdd(final Behavior behavior) { component.data_add(behavior); - if (behavior.getStatelessHint(component)) + if (behavior.getStatelessHint(component) == false) { getBehaviorId(behavior); }
bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5400_6cefb9f8.diff
bugs-dot-jar_data_WICKET-5447_2abc18f1
--- BugID: WICKET-5447 Summary: TableTree's NodeBorder does not properly close divs Description: NodeBorder fails to properly close generated <div>s. diff --git a/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/repeater/tree/table/NodeBorder.java b/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/repeater/tree/table/NodeBorder.java index 089a367..db1ca42 100644 --- a/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/repeater/tree/table/NodeBorder.java +++ b/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/repeater/tree/table/NodeBorder.java @@ -83,6 +83,10 @@ public class NodeBorder extends Behavior for (int i = 0; i < branches.length; i++) { + if (i > 0) + { + response.write("</div>"); + } response.write("</div>"); } }
bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5447_2abc18f1.diff
bugs-dot-jar_data_WICKET-5701_087c0a26
--- BugID: WICKET-5701 Summary: 'WebSocketRequestHandler is not set as a scheduled and thus RequestCycle#find(AjaxRequestTarget.class) doesn''t work ' Description: |- As discussed at https://groups.google.com/d/topic/wicket-jquery-ui/fw6TdyO5o18/discussion AbstractWebSocketProcessor doesn't schedules the WebSocketRequestHandler in the request cycle and thus it is not reachable for user code via RequestCycle#find(Class) API. Additionally the configured application RequestCycle listeners are not notified. diff --git a/wicket-native-websocket/wicket-native-websocket-core/src/main/java/org/apache/wicket/protocol/ws/api/AbstractWebSocketProcessor.java b/wicket-native-websocket/wicket-native-websocket-core/src/main/java/org/apache/wicket/protocol/ws/api/AbstractWebSocketProcessor.java index 9eb3d5d..f7428ea 100644 --- a/wicket-native-websocket/wicket-native-websocket-core/src/main/java/org/apache/wicket/protocol/ws/api/AbstractWebSocketProcessor.java +++ b/wicket-native-websocket/wicket-native-websocket-core/src/main/java/org/apache/wicket/protocol/ws/api/AbstractWebSocketProcessor.java @@ -23,7 +23,6 @@ import org.apache.wicket.MarkupContainer; import org.apache.wicket.Page; import org.apache.wicket.Session; import org.apache.wicket.ThreadContext; -import org.apache.wicket.event.Broadcast; import org.apache.wicket.markup.IMarkupResourceStreamProvider; import org.apache.wicket.markup.html.WebPage; import org.apache.wicket.page.IPageManager; @@ -46,17 +45,15 @@ import org.apache.wicket.protocol.ws.api.registry.IKey; import org.apache.wicket.protocol.ws.api.registry.IWebSocketConnectionRegistry; import org.apache.wicket.protocol.ws.api.registry.PageIdKey; import org.apache.wicket.protocol.ws.api.registry.ResourceNameKey; +import org.apache.wicket.request.IRequestHandler; import org.apache.wicket.request.Url; +import org.apache.wicket.request.cycle.AbstractRequestCycleListener; import org.apache.wicket.request.cycle.RequestCycle; import org.apache.wicket.request.cycle.RequestCycleContext; import org.apache.wicket.request.http.WebRequest; -import org.apache.wicket.request.resource.IResource; -import org.apache.wicket.request.resource.ResourceReference; -import org.apache.wicket.request.resource.SharedResourceReference; import org.apache.wicket.session.ISessionStore; import org.apache.wicket.util.lang.Args; import org.apache.wicket.util.lang.Checks; -import org.apache.wicket.util.lang.Classes; import org.apache.wicket.util.resource.IResourceStream; import org.apache.wicket.util.resource.StringResourceStream; import org.apache.wicket.util.string.Strings; @@ -76,7 +73,7 @@ public abstract class AbstractWebSocketProcessor implements IWebSocketProcessor /** * A pageId indicating that the endpoint is WebSocketResource */ - private static final int NO_PAGE_ID = -1; + static final int NO_PAGE_ID = -1; private final WebRequest webRequest; private final int pageId; @@ -187,20 +184,9 @@ public abstract class AbstractWebSocketProcessor implements IWebSocketProcessor WebSocketResponse webResponse = new WebSocketResponse(connection); try { - RequestCycle requestCycle; - if (oldRequestCycle == null || message instanceof IWebSocketPushMessage) - { - RequestCycleContext context = new RequestCycleContext(webRequest, webResponse, - application.getRootRequestMapper(), application.getExceptionMapperProvider().get()); - - requestCycle = application.getRequestCycleProvider().get(context); - requestCycle.getUrlRenderer().setBaseUrl(baseUrl); - ThreadContext.setRequestCycle(requestCycle); - } - else - { - requestCycle = oldRequestCycle; - } + WebSocketRequestMapper requestMapper = new WebSocketRequestMapper(application.getRootRequestMapper()); + RequestCycle requestCycle = createRequestCycle(requestMapper, webResponse); + ThreadContext.setRequestCycle(requestCycle); ThreadContext.setApplication(application); @@ -217,25 +203,20 @@ public abstract class AbstractWebSocketProcessor implements IWebSocketProcessor } IPageManager pageManager = session.getPageManager(); - try - { - Page page = getPage(pageManager); + Page page = getPage(pageManager); - WebSocketRequestHandler requestHandler = new WebSocketRequestHandler(page, connection); + WebSocketRequestHandler requestHandler = new WebSocketRequestHandler(page, connection); - WebSocketPayload payload = createEventPayload(message, requestHandler); + WebSocketPayload payload = createEventPayload(message, requestHandler); - sendPayload(payload, page); - - if (!(message instanceof ConnectedMessage || message instanceof ClosedMessage)) - { - requestHandler.respond(requestCycle); - } - } - finally + if (!(message instanceof ConnectedMessage || message instanceof ClosedMessage)) { - pageManager.commitRequest(); + requestCycle.scheduleRequestHandlerAfterCurrent(requestHandler); } + + IRequestHandler broadcastingHandler = new WebSocketMessageBroadcastHandler(pageId, resourceName, payload); + requestMapper.setHandler(broadcastingHandler); + requestCycle.processRequestAndDetach(); } catch (Exception x) { @@ -261,46 +242,26 @@ public abstract class AbstractWebSocketProcessor implements IWebSocketProcessor } } - /** - * Sends the payload either to the page (and its WebSocketBehavior) - * or to the WebSocketResource with name {@linkplain #resourceName} - * - * @param payload - * The payload with the web socket message - * @param page - * The page that owns the WebSocketBehavior, in case of behavior usage - */ - private void sendPayload(final WebSocketPayload payload, final Page page) + private RequestCycle createRequestCycle(WebSocketRequestMapper requestMapper, WebSocketResponse webResponse) { - final Runnable action = new Runnable() + RequestCycleContext context = new RequestCycleContext(webRequest, webResponse, + requestMapper, application.getExceptionMapperProvider().get()); + + RequestCycle requestCycle = application.getRequestCycleProvider().get(context); + requestCycle.getListeners().add(application.getRequestCycleListeners()); + requestCycle.getListeners().add(new AbstractRequestCycleListener() { @Override - public void run() + public void onDetach(final RequestCycle requestCycle) { - if (pageId != NO_PAGE_ID) - { - page.send(application, Broadcast.BREADTH, payload); - } else + if (Session.exists()) { - ResourceReference reference = new SharedResourceReference(resourceName); - IResource resource = reference.getResource(); - if (resource instanceof WebSocketResource) - { - WebSocketResource wsResource = (WebSocketResource) resource; - wsResource.onPayload(payload); - } else - { - throw new IllegalStateException( - String.format("Shared resource with name '%s' is not a %s but %s", - resourceName, WebSocketResource.class.getSimpleName(), - Classes.name(resource.getClass()))); - } + Session.get().getPageManager().commitRequest(); } } - }; - - WebSocketSettings webSocketSettings = WebSocketSettings.Holder.get(application); - webSocketSettings.getSendPayloadExecutor().run(action); + }); + requestCycle.getUrlRenderer().setBaseUrl(baseUrl); + return requestCycle; } /** diff --git a/wicket-native-websocket/wicket-native-websocket-core/src/main/java/org/apache/wicket/protocol/ws/api/WebSocketMessageBroadcastHandler.java b/wicket-native-websocket/wicket-native-websocket-core/src/main/java/org/apache/wicket/protocol/ws/api/WebSocketMessageBroadcastHandler.java new file mode 100644 index 0000000..0529fe3 --- /dev/null +++ b/wicket-native-websocket/wicket-native-websocket-core/src/main/java/org/apache/wicket/protocol/ws/api/WebSocketMessageBroadcastHandler.java @@ -0,0 +1,104 @@ +/* + * 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.ws.api; + +import org.apache.wicket.Application; +import org.apache.wicket.Page; +import org.apache.wicket.Session; +import org.apache.wicket.event.Broadcast; +import org.apache.wicket.protocol.ws.WebSocketSettings; +import org.apache.wicket.protocol.ws.api.event.WebSocketPayload; +import org.apache.wicket.request.IRequestCycle; +import org.apache.wicket.request.IRequestHandler; +import org.apache.wicket.request.resource.IResource; +import org.apache.wicket.request.resource.ResourceReference; +import org.apache.wicket.request.resource.SharedResourceReference; +import org.apache.wicket.util.lang.Args; +import org.apache.wicket.util.lang.Classes; + +/** + * An {@link org.apache.wicket.request.IRequestHandler} that broadcasts the payload to the + * page/resource + */ +public class WebSocketMessageBroadcastHandler implements IRequestHandler +{ + private final int pageId; + private final String resourceName; + private final WebSocketPayload<?> payload; + + /** + * Constructor. + * + * @param pageId + * The id of the page if {@link org.apache.wicket.protocol.ws.api.WebSocketBehavior} + * or {@value org.apache.wicket.protocol.ws.api.AbstractWebSocketProcessor#NO_PAGE_ID} if using a resource + * @param resourceName + * The name of the shared {@link org.apache.wicket.protocol.ws.api.WebSocketResource} + * @param payload + * The payload to broadcast + */ + WebSocketMessageBroadcastHandler(int pageId, String resourceName, WebSocketPayload<?> payload) + { + this.pageId = pageId; + this.resourceName = resourceName; + this.payload = Args.notNull(payload, "payload"); + } + + @Override + public void respond(IRequestCycle requestCycle) + { + final Application application = Application.get(); + + final Runnable action = new Runnable() + { + @Override + public void run() + { + if (pageId != AbstractWebSocketProcessor.NO_PAGE_ID) + { + Page page = (Page) Session.get().getPageManager().getPage(pageId); + page.send(application, Broadcast.BREADTH, payload); + } + else + { + ResourceReference reference = new SharedResourceReference(resourceName); + IResource resource = reference.getResource(); + if (resource instanceof WebSocketResource) + { + WebSocketResource wsResource = (WebSocketResource) resource; + wsResource.onPayload(payload); + } + else + { + throw new IllegalStateException( + String.format("Shared resource with name '%s' is not a %s but %s", + resourceName, WebSocketResource.class.getSimpleName(), + Classes.name(resource.getClass()))); + } + } + } + }; + + WebSocketSettings webSocketSettings = WebSocketSettings.Holder.get(application); + webSocketSettings.getSendPayloadExecutor().run(action); + } + + @Override + public void detach(IRequestCycle requestCycle) + { + } +} diff --git a/wicket-native-websocket/wicket-native-websocket-core/src/main/java/org/apache/wicket/protocol/ws/api/WebSocketRequestMapper.java b/wicket-native-websocket/wicket-native-websocket-core/src/main/java/org/apache/wicket/protocol/ws/api/WebSocketRequestMapper.java new file mode 100644 index 0000000..9899b04 --- /dev/null +++ b/wicket-native-websocket/wicket-native-websocket-core/src/main/java/org/apache/wicket/protocol/ws/api/WebSocketRequestMapper.java @@ -0,0 +1,74 @@ +/* + * 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.ws.api; + +import org.apache.wicket.request.IRequestHandler; +import org.apache.wicket.request.IRequestMapper; +import org.apache.wicket.request.Request; +import org.apache.wicket.request.Url; + +/** + * An {@link org.apache.wicket.request.IRequestMapper} that is used to set a custom + * {@link org.apache.wicket.request.IRequestHandler} that broadcasts the + * {@link org.apache.wicket.protocol.ws.api.event.WebSocketPayload} + */ +class WebSocketRequestMapper implements IRequestMapper +{ + private final IRequestMapper delegate; + + private IRequestHandler handler; + + /** + * Constructor. + * + * @param delegate + * The application root request mapper to delegate Url creation etc. + */ + public WebSocketRequestMapper(IRequestMapper delegate) + { + this.delegate = delegate; + } + + @Override + public IRequestHandler mapRequest(Request request) + { + return handler; + } + + @Override + public int getCompatibilityScore(Request request) + { + return delegate.getCompatibilityScore(request); + } + + @Override + public Url mapHandler(IRequestHandler requestHandler) + { + return delegate.mapHandler(requestHandler); + } + + /** + * Sets the custom request handler + * + * @param handler + * The request handler that broadcasts the web socket payload + */ + public void setHandler(IRequestHandler handler) + { + this.handler = handler; + } +}
bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5701_087c0a26.diff
bugs-dot-jar_data_WICKET-3309_debca73b
--- BugID: WICKET-3309 Summary: unable to add nodes to an empty rootless Tree (e.g. LinkTree) Description: |- 2 scenarios which adding new nodes (via ajax) to a rootless Tree is not working as expected. the node is getting added to the treemodel but non is displayed. 1) adding a node to the rootnode. the newly added node is not displayed. 2) the rootless tree already has a node. if you add additional nodes to the root node, they will be displayed (compare to 1), if you add an additional node to one of the added nodes, the complete tree will disappear. see attached quickstart diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/tree/AbstractTree.java b/wicket-core/src/main/java/org/apache/wicket/markup/html/tree/AbstractTree.java index ed9843a..2547853 100644 --- a/wicket-core/src/main/java/org/apache/wicket/markup/html/tree/AbstractTree.java +++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/tree/AbstractTree.java @@ -832,13 +832,17 @@ public abstract class AbstractTree extends Panel { wasLeaf = eventChildren.contains(getChildAt(parentNode, i)); } - - if (wasLeaf) + // if parent was a leaf, testing if wasn't an not presented root + if (wasLeaf && !(parentItem.getParentItem() == null && isRootLess())) { - // parentNode now has children for the first time, so we need to invalidate + // parentNode now has children for the first time, so we may need to invalidate // grandparent so that parentNode's junctionLink gets rebuilt with a plus/minus link Object grandparentNode = getParentNode(parentNode); - invalidateNodeWithChildren(grandparentNode); + // not invalidating if the grandparent is a not presented root + if (!(getParentNode(grandparentNode) == null && isRootLess())) + { + invalidateNodeWithChildren(grandparentNode); + } getTreeState().expandNode(parentNode); } else
bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-3309_debca73b.diff
bugs-dot-jar_data_WICKET-3998_b76f9c44
--- BugID: WICKET-3998 Summary: CreditCardValidator returns incorrect cardId for VISA Description: |+ When the validation for a VISA is correct, it returns a SWITCH cardId instead of a VISA. This error occurs in both 1.4.x and 1.5.X 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 df071d4..33c268e 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 @@ -539,7 +539,7 @@ public class CreditCardValidator extends AbstractValidator<String> { if (creditCardNumber.startsWith("4")) { - return CreditCard.SWITCH; + return CreditCard.VISA; } }
bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-3998_b76f9c44.diff
bugs-dot-jar_data_WICKET-3834_30255f11
--- BugID: WICKET-3834 Summary: WicketTester does not follow absolute redirects Description: |- Wicket tester does not follow absolute redirects: This is a problem when using HttpsMapper. For example when requesting a page over http:// with an forced redirect to https:// for secure access will make wicket tester return 'null' for the last renderer page instead of the rendered page instance. In general all kinds of absolute redirects to another page will not be tracked by wicket tester. So this potentially a problem for all kinds of tests that rely on absolute redirects. 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 6d77f1d..247197e 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 @@ -116,10 +116,11 @@ public final class Url implements Serializable * Parses the given URL string. * * @param url + * full absolute or relative url with query string * @param charset * @return Url object */ - public static Url parse(final String url, Charset charset) + public static Url parse(String url, Charset charset) { Args.notNull(url, "url"); @@ -128,36 +129,79 @@ public final class Url implements Serializable // the url object resolved the charset, use that charset = result.getCharset(); - String segments; - String query; + // extract query string part + final String queryString; + final String absoluteUrl; - int qIndex = url.indexOf('?'); + int queryAt = url.indexOf('?'); - if (qIndex == -1) + if (queryAt == -1) { - segments = url; - query = ""; + queryString = ""; + absoluteUrl = url; } else { - segments = url.substring(0, qIndex); - query = url.substring(qIndex + 1); + absoluteUrl = url.substring(0, queryAt); + queryString = url.substring(queryAt + 1); } + + // get absolute / relative part of url + String relativeUrl; - if (segments.length() > 0) + // absolute urls contain a scheme:// + final int protocolAt = absoluteUrl.indexOf("://"); + + if (protocolAt != -1) + { + result.protocol = absoluteUrl.substring(0, protocolAt); + final String afterProto = absoluteUrl.substring(protocolAt + 3); + final String hostAndPort; + + int relativeAt = afterProto.indexOf('/'); + + if (relativeAt == -1) + { + relativeUrl = ""; + hostAndPort = afterProto; + } + else + { + relativeUrl = afterProto.substring(relativeAt); + hostAndPort = afterProto.substring(0, relativeAt); + } + + int portAt = hostAndPort.indexOf(':'); + + if (portAt == -1) + { + result.host = hostAndPort; + result.port = null; + } + else + { + result.host = hostAndPort.substring(0, portAt); + result.port = Integer.parseInt(hostAndPort.substring(portAt + 1)); + } + } + else { + relativeUrl = absoluteUrl; + } + if (relativeUrl.length() > 0) + { boolean removeLast = false; - if (segments.endsWith("/")) + if (relativeUrl.endsWith("/")) { // we need to append something and remove it after splitting // because otherwise the // trailing slashes will be lost - segments += "/x"; + relativeUrl += "/x"; removeLast = true; } - String segmentArray[] = Strings.split(segments, '/'); + String segmentArray[] = Strings.split(relativeUrl, '/'); if (removeLast) { @@ -173,9 +217,9 @@ public final class Url implements Serializable } } - if (query.length() > 0) + if (queryString.length() > 0) { - String queryArray[] = Strings.split(query, '&'); + String queryArray[] = Strings.split(queryString, '&'); for (String s : queryArray) { result.parameters.add(parseQueryParameter(s, charset));
bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-3834_30255f11.diff
bugs-dot-jar_data_WICKET-3603_aa1d177a
--- BugID: WICKET-3603 Summary: DataTable row groups are present in markup even when they contain no rows. Description: |- As per the HTML spec : "When present, each THEAD, TFOOT, and TBODY contains a row group. Each row group must contain at least one row, defined by the TR element." There is no check in place to remove the row group tags from the output if they don't contain any row. diff --git a/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/repeater/data/table/DataTable.java b/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/repeater/data/table/DataTable.java index f3146d1..d7af5f7 100644 --- a/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/repeater/data/table/DataTable.java +++ b/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/repeater/data/table/DataTable.java @@ -33,6 +33,8 @@ import org.apache.wicket.markup.repeater.RepeatingView; import org.apache.wicket.markup.repeater.data.IDataProvider; import org.apache.wicket.model.IModel; import org.apache.wicket.util.string.Strings; +import org.apache.wicket.util.visit.IVisit; +import org.apache.wicket.util.visit.IVisitor; /** @@ -109,9 +111,9 @@ public class DataTable<T> extends Panel implements IPageableItems private final List<IColumn<T>> columns; - private final RepeatingView topToolbars; + private final ToolbarsContainer topToolbars; - private final RepeatingView bottomToolbars; + private final ToolbarsContainer bottomToolbars; /** * Constructor @@ -320,14 +322,14 @@ public class DataTable<T> extends Panel implements IPageableItems return datagrid.getItemCount(); } - private void addToolbar(final AbstractToolbar toolbar, final RepeatingView container) + private void addToolbar(final AbstractToolbar toolbar, final ToolbarsContainer container) { if (toolbar == null) { throw new IllegalArgumentException("argument [toolbar] cannot be null"); } - container.add(toolbar); + container.getRepeatingView().add(toolbar); } /** @@ -392,14 +394,18 @@ public class DataTable<T> extends Panel implements IPageableItems } /** - * This class acts as a repeater that will contain the toolbar. + * This class acts as a repeater that will contain the toolbar. It makes sure that the table row + * group (e.g. thead) tags are only visible when they contain rows in accordance with the HTML + * specification. * * @author igor.vaynberg */ - private static class ToolbarsContainer extends RepeatingView + private static class ToolbarsContainer extends WebMarkupContainer { private static final long serialVersionUID = 1L; + private final RepeatingView toolbars; + /** * Constructor * @@ -408,6 +414,41 @@ public class DataTable<T> extends Panel implements IPageableItems private ToolbarsContainer(final String id) { super(id); + toolbars = new RepeatingView("toolbars"); + add(toolbars); + } + + public RepeatingView getRepeatingView() + { + return toolbars; + } + + @Override + public boolean isVisible() + { + if (!super.isVisible()) + { + return false; + } + + toolbars.configure(); + + Boolean visible = toolbars.visitChildren(new IVisitor<Component, Boolean>() + { + public void component(Component object, IVisit<Boolean> visit) + { + object.configure(); + if (object.isVisible()) + { + visit.stop(Boolean.TRUE); + } + else + { + visit.dontGoDeeper(); + } + } + }); + return visible == Boolean.TRUE; } } }
bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-3603_aa1d177a.diff
bugs-dot-jar_data_WICKET-4597_9dab1bb5
--- BugID: WICKET-4597 Summary: bug in Duration.toString(Locale locale) Description: Duration.toString(Locale locale) misses milliseconds in line 529 diff --git a/wicket-util/src/main/java/org/apache/wicket/util/time/Duration.java b/wicket-util/src/main/java/org/apache/wicket/util/time/Duration.java index fc232bf..c366990 100755 --- a/wicket-util/src/main/java/org/apache/wicket/util/time/Duration.java +++ b/wicket-util/src/main/java/org/apache/wicket/util/time/Duration.java @@ -526,7 +526,7 @@ public class Duration extends AbstractTimeValue return unitString(seconds(), "second", locale); } - return unitString(seconds(), "millisecond", locale); + return unitString(getMilliseconds(), "millisecond", locale); } else {
bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-4597_9dab1bb5.diff
bugs-dot-jar_data_WICKET-5460_a3a5a40f
--- BugID: WICKET-5460 Summary: onBeforeRender called too early on stateless page Description: |- I'm having a problem with a ListView that displays an outdated list. In my test, the ListView uses a Model that returns a static variable just to make sure the model is independent from any page instance. As far as I can tell, this problem has nothing to do with the model, but with the way Wicket prepares for a request listener invocation. The exact setup is this: - the page contains a ListView and (outside of the list) a Link that adds an item to the list in its onClick(). The list itself is stored in a static variable. - the page is stateless - the page's components are created in onInitialize() Result: The list doesn't show the most recently added item. Reloading the original page shows the correct list. Note that by "reloading" I mean entering the page's original URL since the browser's address bar now contains the request listener URL due to the page being stateless. This is how I think is happens: - Initially rendering the page works fine. The page is then discarded since it's stateless. - Clicking on the link creates a new page instance to invoke the link's request listener. - IPageAndComponentProvider.getComponent() cannot find the link yet since it is not created until onInitialize() has been called. - as a consequence, it calls page.internalInitialize() and internalPrepareForRender(false) - this creates the link, but it also creates the ListView and prepares it for rendering. This in turn polls the ListView's model and creates list items. It also marks the ListView as "prepared for render", which is the crucial point. - The link's request listener runs and adds an item to the list. - After the request listener handler, the page render handler runs - That handler renders the page, including the ListView - ... but it doesn't call onBeforeRender() on the ListView anymore, because it's already marked as "prepared for render"! So it doesn't pick up the new, up-to-date list from its model. I'm not sure if I'm "doing it wrong", but then it doesn't seem quite right that onBeforeRender() gets called before invoking the listener, but not actually before rendering. There's probably some kind of logic behind the decision to run onBeforeRender() only when this hasn't yet happened, right? Is there a general way to "unprepare" the component in onClick()? --- Re: #internalPrepareForRender(false) should not mark the page as rendered (thus the false parameter). The problem is, I think, not that the component is being marked as *rendered*, but as *prepared for render*. From class Component: protected void onBeforeRender() { setFlag(FLAG_PREPARED_FOR_RENDER, true); onBeforeRenderChildren(); setRequestFlag(RFLAG_BEFORE_RENDER_SUPER_CALL_VERIFIED, true); } Note the first line. This causes subsequent invocations of internalBeforeRender() to skip the relevant part. 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 62f1eba..e139f99 100644 --- a/wicket-core/src/main/java/org/apache/wicket/Component.java +++ b/wicket-core/src/main/java/org/apache/wicket/Component.java @@ -4200,15 +4200,10 @@ public abstract class Component */ void internalMarkRendering(boolean setRenderingFlag) { - if (setRenderingFlag) - { - setFlag(FLAG_PREPARED_FOR_RENDER, false); - setFlag(FLAG_RENDERING, true); - } - else - { - setFlag(FLAG_RENDERING, false); - } + // WICKET-5460 no longer prepared for render + setFlag(FLAG_PREPARED_FOR_RENDER, false); + + setFlag(FLAG_RENDERING, setRenderingFlag); } /**
bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5460_a3a5a40f.diff
bugs-dot-jar_data_WICKET-5898_ffdd0864
--- 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/AbstractMarkupSourcingStrategy.java b/wicket-core/src/main/java/org/apache/wicket/markup/html/panel/AbstractMarkupSourcingStrategy.java index 27407cf..b49f2f4 100644 --- a/wicket-core/src/main/java/org/apache/wicket/markup/html/panel/AbstractMarkupSourcingStrategy.java +++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/panel/AbstractMarkupSourcingStrategy.java @@ -16,6 +16,8 @@ */ package org.apache.wicket.markup.html.panel; +import java.util.Iterator; + import org.apache.wicket.Component; import org.apache.wicket.MarkupContainer; import org.apache.wicket.markup.ComponentTag; @@ -26,8 +28,6 @@ import org.apache.wicket.markup.html.internal.HtmlHeaderContainer; import org.apache.wicket.markup.parser.XmlTag.TagType; import org.apache.wicket.markup.resolver.IComponentResolver; import org.apache.wicket.util.lang.Classes; -import org.apache.wicket.util.visit.IVisit; -import org.apache.wicket.util.visit.IVisitor; /** * Implements boilerplate as needed by many markup sourcing strategies. @@ -55,53 +55,58 @@ public abstract class AbstractMarkupSourcingStrategy implements IMarkupSourcingS * * @param container * the parent container. + * @param + * containerMarkup + * the markup of the container. * @param child * The component to find the markup for. * @return the markup fragment for the child, or {@code null}. */ - protected IMarkupFragment searchMarkupInTransparentResolvers(final MarkupContainer container, - final Component child) + protected IMarkupFragment searchMarkupInTransparentResolvers(MarkupContainer container, + IMarkupFragment containerMarkup, Component child) { - return container.visitChildren(MarkupContainer.class, new IVisitor<MarkupContainer, IMarkupFragment>() + IMarkupFragment childMarkupFound = null; + Iterator<Component> siblingsIterator = container.iterator(); + + while (siblingsIterator.hasNext() && childMarkupFound == null) { - @Override - public void component(MarkupContainer resolvingContainer, IVisit<IMarkupFragment> visit) + Component sibling = siblingsIterator.next(); + + if(sibling == child || !sibling.isVisible()) { - //prevents possible searching loops - if (child == resolvingContainer) - { - visit.dontGoDeeper(); - return; - } + continue; + } + + IMarkupFragment siblingMarkup = containerMarkup.find(sibling.getId()); + + if (siblingMarkup != null && sibling instanceof MarkupContainer) + { + IMarkupFragment childMarkup = siblingMarkup.find(child.getId()); - if (resolvingContainer instanceof IComponentResolver) + if (childMarkup != null && sibling instanceof IComponentResolver) { - visit.dontGoDeeper(); - - IMarkupFragment childMarkup = resolvingContainer.getMarkup(child); - - if (childMarkup != null && childMarkup.size() > 0) + IComponentResolver componentResolver = (IComponentResolver)sibling; + MarkupStream stream = new MarkupStream(childMarkup); + ComponentTag tag = stream.getTag(); + + Component resolvedComponent = sibling.get(tag.getId()); + if (resolvedComponent == null) { - IComponentResolver componentResolver = (IComponentResolver)resolvingContainer; - - MarkupStream stream = new MarkupStream(childMarkup); - - ComponentTag tag = stream.getTag(); - - Component resolvedComponent = resolvingContainer.get(tag.getId()); - if (resolvedComponent == null) - { - resolvedComponent = componentResolver.resolve(resolvingContainer, stream, tag); - } - - if (child == resolvedComponent) - { - visit.stop(childMarkup); - } + resolvedComponent = componentResolver.resolve((MarkupContainer)sibling, stream, tag); + } + + if (child == resolvedComponent) + { + childMarkupFound = childMarkup; } - } + } + else + { + childMarkupFound = searchMarkupInTransparentResolvers((MarkupContainer)sibling, siblingMarkup, child); + } } - }); + } + return childMarkupFound; } /** diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/panel/AssociatedMarkupSourcingStrategy.java b/wicket-core/src/main/java/org/apache/wicket/markup/html/panel/AssociatedMarkupSourcingStrategy.java index 0ac0647..5f547ac 100644 --- a/wicket-core/src/main/java/org/apache/wicket/markup/html/panel/AssociatedMarkupSourcingStrategy.java +++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/panel/AssociatedMarkupSourcingStrategy.java @@ -120,7 +120,7 @@ public abstract class AssociatedMarkupSourcingStrategy extends AbstractMarkupSou return associatedMarkup; } - associatedMarkup = searchMarkupInTransparentResolvers(parent, child); + associatedMarkup = searchMarkupInTransparentResolvers(parent, markup, child); if (associatedMarkup != null) { return associatedMarkup; 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 6699a68..7506d23 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 @@ -78,26 +78,24 @@ public final class DefaultMarkupSourcingStrategy extends AbstractMarkupSourcingS { // If the sourcing strategy did not provide one, than ask the component. // Get the markup for the container - IMarkupFragment markup = container.getMarkup(); - if (markup == null) + IMarkupFragment containerMarkup = container.getMarkup(); + if (containerMarkup == null) { return null; } if (child == null) { - return markup; + return containerMarkup; } - + // Find the child's markup - markup = markup.find(child.getId()); - if (markup != null) + IMarkupFragment childMarkup = containerMarkup.find(child.getId()); + if (childMarkup != null) { - return markup; + return childMarkup; } - markup = searchMarkupInTransparentResolvers(container, child); - - return markup; + return searchMarkupInTransparentResolvers(container, containerMarkup, child); } }
bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5898_ffdd0864.diff
bugs-dot-jar_data_WICKET-5176_34634266
--- BugID: WICKET-5176 Summary: StringResourceModel doesn't detach model in some cases Description: |- We have come across an issue with StringResourceModel not detaching the model it holds under a certain condition. The problem is the case where the StringResourceModel is created but it is not used - for example when it is on a tab that is not displayed. StringResourceModel is a subclass of LoadableDetachableModel and it simply implements onDetach(), letting the superclass decide whether it is attached or not. The problem is that when StringResourceModel is created, LoadableDetachableModel.attached will be false. If the StringResourceModel is never read (i.e. getObject() is not called) the LoadableDetachableModel will not be marked as attached and when detach() is called, onDetach() will not be called. Therefore StringResourceModel will not call detach() on the model that it holds. diff --git a/wicket-core/src/main/java/org/apache/wicket/model/StringResourceModel.java b/wicket-core/src/main/java/org/apache/wicket/model/StringResourceModel.java index 95b37f8..35ef7bb 100644 --- a/wicket-core/src/main/java/org/apache/wicket/model/StringResourceModel.java +++ b/wicket-core/src/main/java/org/apache/wicket/model/StringResourceModel.java @@ -590,13 +590,10 @@ public class StringResourceModel extends LoadableDetachableModel<String> return getString(); } - /** - * @see org.apache.wicket.model.IDetachable#detach() - */ @Override - protected final void onDetach() + public final void detach() { - super.onDetach(); + super.detach(); // detach any model if (model != null)
bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5176_34634266.diff
bugs-dot-jar_data_WICKET-2172_ea4a3f8a
--- BugID: WICKET-2172 Summary: PageParameters construced with keyValuePairs does not handle array values Description: |- The PageParameters constructor that takes a "keyValuePairs" argument does not convert repeated keys into an array of values. For example: {code} // specify three comma delimited values for the "a" parameters PageParameters parameters = new PageParameters("a=1,a=2,a=3"); String[] a = parameters.getStringArray("a"); assertEquals(3, a.length); // fails because a.length == 1 {code} Issue first described on the user's list: http://www.nabble.com/PageParameters-with-String-array-question-to22540294.html diff --git a/wicket/src/main/java/org/apache/wicket/PageParameters.java b/wicket/src/main/java/org/apache/wicket/PageParameters.java index 95d1a48..0a865f2 100644 --- a/wicket/src/main/java/org/apache/wicket/PageParameters.java +++ b/wicket/src/main/java/org/apache/wicket/PageParameters.java @@ -123,14 +123,14 @@ public final class PageParameters extends ValueMap final String key = pair.substring(0, pos).trim(); final String value = pair.substring(pos + 1).trim(); - put(key, value); + add(key, value); } else { final String key = pair.trim(); final String value = null; - put(key, value); + add(key, value); } } } diff --git a/wicket/src/main/java/org/apache/wicket/Resource.java b/wicket/src/main/java/org/apache/wicket/Resource.java index 85c39aa..78e62b0 100644 --- a/wicket/src/main/java/org/apache/wicket/Resource.java +++ b/wicket/src/main/java/org/apache/wicket/Resource.java @@ -149,7 +149,7 @@ public abstract class Resource implements IResourceListener * @param parameters * Map of query parameters that parameterize this resource */ - public final void setParameters(final Map<?, ?> parameters) + public final void setParameters(final Map<String, ?> parameters) { if (parameters == null) { diff --git a/wicket/src/main/java/org/apache/wicket/util/value/ValueMap.java b/wicket/src/main/java/org/apache/wicket/util/value/ValueMap.java index 3e72e8f..5b5062b 100644 --- a/wicket/src/main/java/org/apache/wicket/util/value/ValueMap.java +++ b/wicket/src/main/java/org/apache/wicket/util/value/ValueMap.java @@ -20,7 +20,6 @@ import java.lang.reflect.Array; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.Arrays; -import java.util.Iterator; import java.util.LinkedHashMap; import java.util.Map; @@ -91,7 +90,7 @@ public class ValueMap extends LinkedHashMap<String, Object> implements IValueMap * @param map * the <code>ValueMap</code> to copy */ - public ValueMap(final Map map) + public ValueMap(final Map<? extends String, ? extends Object> map) { super(); @@ -152,7 +151,7 @@ public class ValueMap extends LinkedHashMap<String, Object> implements IValueMap } String key = keyValuePairs.substring(start, equalsIndex); String value = keyValuePairs.substring(equalsIndex + 1, delimiterIndex); - put(key, value); + add(key, value); if (delimiterIndex < keyValuePairs.length()) { start = delimiterIndex + 1; @@ -490,7 +489,7 @@ public class ValueMap extends LinkedHashMap<String, Object> implements IValueMap * @see java.util.Map#putAll(java.util.Map) */ @Override - public void putAll(final Map map) + public void putAll(final Map<? extends String, ? extends Object> map) { checkMutability(); super.putAll(map); @@ -535,9 +534,15 @@ public class ValueMap extends LinkedHashMap<String, Object> implements IValueMap public String toString() { final StringBuffer buffer = new StringBuffer(); - for (final Iterator iterator = entrySet().iterator(); iterator.hasNext();) + boolean first = true; + for (Map.Entry<String, Object> entry : entrySet()) { - final Map.Entry entry = (Map.Entry)iterator.next(); + if (first == false) + { + buffer.append(' '); + } + first = false; + buffer.append(entry.getKey()); buffer.append(" = \""); final Object value = entry.getValue(); @@ -555,10 +560,6 @@ public class ValueMap extends LinkedHashMap<String, Object> implements IValueMap } buffer.append('\"'); - if (iterator.hasNext()) - { - buffer.append(' '); - } } return buffer.toString(); } @@ -585,7 +586,9 @@ public class ValueMap extends LinkedHashMap<String, Object> implements IValueMap public Boolean getAsBoolean(String key) { if (!containsKey(key)) + { return null; + } try { @@ -619,7 +622,9 @@ public class ValueMap extends LinkedHashMap<String, Object> implements IValueMap public Integer getAsInteger(String key) { if (!containsKey(key)) + { return null; + } try { @@ -652,7 +657,9 @@ public class ValueMap extends LinkedHashMap<String, Object> implements IValueMap public Long getAsLong(String key) { if (!containsKey(key)) + { return null; + } try { @@ -685,7 +692,9 @@ public class ValueMap extends LinkedHashMap<String, Object> implements IValueMap public Double getAsDouble(String key) { if (!containsKey(key)) + { return null; + } try { @@ -700,7 +709,7 @@ public class ValueMap extends LinkedHashMap<String, Object> implements IValueMap /** * @see IValueMap#getAsDouble(String, double) */ - public double getAsDouble(String key, double defaultValue) + public double getAsDouble(final String key, final double defaultValue) { try { @@ -715,7 +724,7 @@ public class ValueMap extends LinkedHashMap<String, Object> implements IValueMap /** * @see IValueMap#getAsDuration(String) */ - public Duration getAsDuration(String key) + public Duration getAsDuration(final String key) { return getAsDuration(key, null); } @@ -723,10 +732,12 @@ public class ValueMap extends LinkedHashMap<String, Object> implements IValueMap /** * @see IValueMap#getAsDuration(String, Duration) */ - public Duration getAsDuration(String key, Duration defaultValue) + public Duration getAsDuration(final String key, final Duration defaultValue) { if (!containsKey(key)) + { return defaultValue; + } try { @@ -741,7 +752,7 @@ public class ValueMap extends LinkedHashMap<String, Object> implements IValueMap /** * @see IValueMap#getAsTime(String) */ - public Time getAsTime(String key) + public Time getAsTime(final String key) { return getAsTime(key, null); } @@ -749,10 +760,12 @@ public class ValueMap extends LinkedHashMap<String, Object> implements IValueMap /** * @see IValueMap#getAsTime(String, Time) */ - public Time getAsTime(String key, Time defaultValue) + public Time getAsTime(final String key, final Time defaultValue) { if (!containsKey(key)) + { return defaultValue; + } try { @@ -765,43 +778,59 @@ public class ValueMap extends LinkedHashMap<String, Object> implements IValueMap } /** - * @see IValueMap#getAsEnum(String, Class<T>) + * @see org.apache.wicket.util.value.IValueMap#getAsEnum(java.lang.String, java.lang.Class) */ - public <T extends Enum<T>> T getAsEnum(String key, Class<T> eClass) + public <T extends Enum<T>> T getAsEnum(final String key, final Class<T> eClass) { return getEnumImpl(key, eClass, null); } /** - * @see IValueMap#getAsEnum + * @see org.apache.wicket.util.value.IValueMap#getAsEnum(java.lang.String, java.lang.Enum) */ - public <T extends Enum<T>> T getAsEnum(String key, T defaultValue) + public <T extends Enum<T>> T getAsEnum(final String key, final T defaultValue) { if (defaultValue == null) + { throw new IllegalArgumentException("Default value cannot be null"); + } + return getEnumImpl(key, defaultValue.getClass(), defaultValue); } /** - * @see IValueMap#getAsEnum(String, Class<T>, T) + * @see org.apache.wicket.util.value.IValueMap#getAsEnum(java.lang.String, java.lang.Class, + * java.lang.Enum) */ - public <T extends Enum<T>> T getAsEnum(String key, Class<T> eClass, T defaultValue) + public <T extends Enum<T>> T getAsEnum(final String key, final Class<T> eClass, + final T defaultValue) { return getEnumImpl(key, eClass, defaultValue); } /** * get enum implementation + * + * @param key + * @param eClass + * @param defaultValue + * @param <T> + * @return Enum */ @SuppressWarnings( { "unchecked" }) - private <T extends Enum<T>> T getEnumImpl(String key, Class<?> eClass, T defaultValue) + private <T extends Enum<T>> T getEnumImpl(final String key, final Class<?> eClass, + final T defaultValue) { if (eClass == null) + { throw new IllegalArgumentException("eClass value cannot be null"); + } String value = getString(key); if (value == null) + { return defaultValue; + } Method valueOf = null; try
bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-2172_ea4a3f8a.diff
bugs-dot-jar_data_WICKET-3539_a4459ef4
--- BugID: WICKET-3539 Summary: Event broadcast type "Depth" does not work when the sink is a Component but not a MarkupContainer Description: Event broadcast type "Depth" does not work when the sink is a Component but not a MarkupContainer. In this case, no sinks receive the event. diff --git a/wicket-core/src/main/java/org/apache/wicket/ComponentEventSender.java b/wicket-core/src/main/java/org/apache/wicket/ComponentEventSender.java index efbd0ff..a01f8d4 100644 --- a/wicket-core/src/main/java/org/apache/wicket/ComponentEventSender.java +++ b/wicket-core/src/main/java/org/apache/wicket/ComponentEventSender.java @@ -164,6 +164,10 @@ final class ComponentEventSender implements IEventSource { Visits.visitPostOrder(cursor, new ComponentEventVisitor(event, dispatcher)); } + else + { + dispatcher.dispatchEvent(cursor, event); + } if (event.isStop()) { return; diff --git a/wicket-core/src/main/java/org/apache/wicket/event/Broadcast.java b/wicket-core/src/main/java/org/apache/wicket/event/Broadcast.java index 401a4f2..5328637 100644 --- a/wicket-core/src/main/java/org/apache/wicket/event/Broadcast.java +++ b/wicket-core/src/main/java/org/apache/wicket/event/Broadcast.java @@ -39,6 +39,12 @@ public enum Broadcast { * <li>{@link Component}s</li> * </ol> * + * Components receive the event with a preorder breadth-first traversal, eg: Apply recursively: + * <ol> + * <li>The component receives the event</li> + * <li>The component's children receive the event</li> + * </ol> + * * Any sink along the path can be specified and traversal will start with the specified sink as * root, eg: * @@ -61,6 +67,12 @@ public enum Broadcast { * <li>{@link Application}</li> * </ol> * + * Components receive the event with a postorder depth-first traversal, eg: Apply recursively: + * <ol> + * <li>The component's children receive the event</li> + * <li>The component receives the event</li> + * </ol> + * * Any sink along the path can be specified and traversal will start with the specified sink as * root, eg: *
bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-3539_a4459ef4.diff
bugs-dot-jar_data_WICKET-5655_d558004b
--- BugID: WICKET-5655 Summary: Problem with setting of IComponentInheritedModel and FLAG_INHERITABLE_MODEL Description: |- Described in the mailing list: [http://mail-archives.apache.org/mod_mbox/wicket-users/201407.mbox/%3CCAF2_608c8TOZjprV8Md15KJpRET6YQdXHe%3DwRzF-y5G_zAXcDg%40mail.gmail.com%3E] I'm aware of the another issue ([https://issues.apache.org/jira/browse/WICKET-3413]) which dealt with the exact same code - and I believe there was a mistake in the solution that leads to this issue. Please see the attached quickstart (including a JUnit test) to reproduce the error. 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 c1d1826..d998680 100644 --- a/wicket-core/src/main/java/org/apache/wicket/Component.java +++ b/wicket-core/src/main/java/org/apache/wicket/Component.java @@ -2977,6 +2977,9 @@ public abstract class Component modelChanging(); setModelImpl(wrap(model)); modelChanged(); + + // WICKET-3413 reset 'inherited model' when model is explicitely set + setFlag(FLAG_INHERITABLE_MODEL, false); } return this; @@ -3005,12 +3008,6 @@ public abstract class Component if (model != null) { data_set(0, model); - // WICKET-3413 reset 'inherited model' flag if model changed - // and a new one is not IComponentInheritedModel - if (getFlag(FLAG_INHERITABLE_MODEL) && !(model instanceof IComponentInheritedModel)) - { - setFlag(FLAG_INHERITABLE_MODEL, false); - } } else {
bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5655_d558004b.diff
bugs-dot-jar_data_WICKET-4923_d78132be
--- BugID: WICKET-4923 Summary: CryptoMapper ignores original queryString parameters Description: "When an AjaxRequest with parameters (e.g.: Autocomplete.getChoices()) arrives and CryptoMapper decrypts it, original queryString parameters dissapears.\n\nDebugging CryptoMapper, I've checked that this method:\nprivate Url decryptUrl(final Request request, final Url encryptedUrl) {\n ...\n}\n\nreceives querystrings parameters (on field url.parameter from \"request\" parameter) and the new Url returned by the method never adds them to its own list. " 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 86c551a..bb65517 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 @@ -234,6 +234,8 @@ public class CryptoMapper implements IRequestMapper } url.getQueryParameters().addAll(originalUrl.getQueryParameters()); + // WICKET-4923 additional parameters + url.getQueryParameters().addAll(encryptedUrl.getQueryParameters()); } catch (Exception e) {
bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-4923_d78132be.diff
bugs-dot-jar_data_WICKET-5131_4b7367ef
--- BugID: WICKET-5131 Summary: Problems with cookies disabled when using 301/302 and also 303 (even with cookies) Description: "As mentioned in the mailing list by Martin, i open this as a bug...\n\nIts not possible to use 303 as redirect (SC_SEE_OTHER) because thats not supported, only 302 and 301 are supported but this is defined in RFC HTTP 1.1 from 1997. \n\n301 will add the Location header - which works as expected when disabling cookies. But a 302 (which is what i prefer) will redirect to the same page because the Location header is missing. When i enable cookies, its working.\n\nExample can be found here: https://github.com/olze/WicketRedirect" diff --git a/wicket-request/src/main/java/org/apache/wicket/request/http/handler/RedirectRequestHandler.java b/wicket-request/src/main/java/org/apache/wicket/request/http/handler/RedirectRequestHandler.java index e21856f..13c99fa 100644 --- a/wicket-request/src/main/java/org/apache/wicket/request/http/handler/RedirectRequestHandler.java +++ b/wicket-request/src/main/java/org/apache/wicket/request/http/handler/RedirectRequestHandler.java @@ -59,9 +59,10 @@ public class RedirectRequestHandler implements IRequestHandler public RedirectRequestHandler(final String redirectUrl, final int status) { if ((status != HttpServletResponse.SC_MOVED_PERMANENTLY) && - (status != HttpServletResponse.SC_MOVED_TEMPORARILY)) + (status != HttpServletResponse.SC_MOVED_TEMPORARILY) && + (status != HttpServletResponse.SC_SEE_OTHER)) { - throw new IllegalStateException("Status must be either 301 or 302, but was: " + status); + throw new IllegalStateException("Status must be either 301, 302 or 303, but was: " + status); } this.redirectUrl = redirectUrl; this.status = status; @@ -93,17 +94,19 @@ public class RedirectRequestHandler implements IRequestHandler { final String location; - if (redirectUrl.startsWith("/")) + final String url = getRedirectUrl(); + + if (url.charAt(0) == '/') { // context-absolute url - location = requestCycle.getUrlRenderer().renderContextRelativeUrl(redirectUrl); + location = requestCycle.getUrlRenderer().renderContextRelativeUrl(url); } else { // if relative url, servlet container will translate to absolute as // per the servlet spec // if absolute url still do the same - location = redirectUrl; + location = url; } WebResponse response = (WebResponse)requestCycle.getResponse(); @@ -114,7 +117,7 @@ public class RedirectRequestHandler implements IRequestHandler } else { - response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY); + response.setStatus(status); response.setHeader("Location", location); } }
bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5131_4b7367ef.diff
bugs-dot-jar_data_WICKET-4173_84bbbf68
--- BugID: WICKET-4173 Summary: Incorrect URL for setResponsePage() within a Form#onSubmit( ) Description: "If the WebApplication uses IRequestCycleSettings.RenderStrategy.ONE_PASS_RENDER, the issue described and exemplified in the attached quickstart at\n\nhttps://issues.apache.org/jira/browse/WICKET-3442\n\nprevails. \n\nClicking the link on /pageone results in this URL: /pageone?0-1.IFormSubmitListener-form" diff --git a/wicket-core/src/main/java/org/apache/wicket/request/cycle/RequestCycle.java b/wicket-core/src/main/java/org/apache/wicket/request/cycle/RequestCycle.java index 022f95a..73a3463 100644 --- a/wicket-core/src/main/java/org/apache/wicket/request/cycle/RequestCycle.java +++ b/wicket-core/src/main/java/org/apache/wicket/request/cycle/RequestCycle.java @@ -601,7 +601,7 @@ public class RequestCycle implements IRequestCycle, IEventSink { IPageProvider provider = new PageProvider(pageClass, null); scheduleRequestHandlerAfterCurrent(new RenderPageRequestHandler(provider, - RenderPageRequestHandler.RedirectPolicy.AUTO_REDIRECT)); + RenderPageRequestHandler.RedirectPolicy.ALWAYS_REDIRECT)); } @@ -616,7 +616,7 @@ public class RequestCycle implements IRequestCycle, IEventSink { IPageProvider provider = new PageProvider(pageClass, parameters); scheduleRequestHandlerAfterCurrent(new RenderPageRequestHandler(provider, - RenderPageRequestHandler.RedirectPolicy.AUTO_REDIRECT)); + RenderPageRequestHandler.RedirectPolicy.ALWAYS_REDIRECT)); } /** 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 7d85405..3c84f2c 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 @@ -164,7 +164,7 @@ public class WebPageRenderer extends PageRenderer bufferedResponse.writeTo((WebResponse)requestCycle.getResponse()); } else if (getRedirectPolicy() == RedirectPolicy.NEVER_REDIRECT || - (isOnePassRender() && isAjax == false) // + (isOnePassRender() && isAjax == false && getRedirectPolicy() != RedirectPolicy.ALWAYS_REDIRECT) // || (!isAjax // &&
bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-4173_84bbbf68.diff
bugs-dot-jar_data_WICKET-5086_ba516f02
--- BugID: WICKET-5086 Summary: FormTester throws an exception when a Palette component is added to a Form associated with a compound property model Description: |- FormTester throws an exception when a Palette component is added to a Form associated with a compound property model: org.apache.wicket.WicketRuntimeException: No get method defined for class ... expression: choices It worked fine in Wicket 6.5.0, and works fine if the form is not associated with a compound property model. diff --git a/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/form/palette/component/AbstractOptions.java b/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/form/palette/component/AbstractOptions.java index 73d6e82..f5d3fc0 100644 --- a/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/form/palette/component/AbstractOptions.java +++ b/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/form/palette/component/AbstractOptions.java @@ -199,4 +199,13 @@ public abstract class AbstractOptions<T> extends FormComponent<T> public void updateModel() { } + + /** + * {@inheritDoc} + */ + @Override + protected String getModelValue() + { + return null; + } }
bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5086_ba516f02.diff
bugs-dot-jar_data_WICKET-5505_6cceff44
--- BugID: WICKET-5505 Summary: DefaultPropertyResolver does not respect JavaBean conventions Description: "The property name code should handle the isPropertyName pattern\n\nif(getterName.startsWith(\"get\")) {\n\tname = getterName.substring(3, 4).toLowerCase() + getterName.substring(4);\n} else {\n\tname = getterName.substring(2, 3).toLowerCase() + getterName.substring(3);\n}\n\nWorkaround: providing my own property resolver." diff --git a/wicket-bean-validation/src/main/java/org/apache/wicket/bean/validation/DefaultPropertyResolver.java b/wicket-bean-validation/src/main/java/org/apache/wicket/bean/validation/DefaultPropertyResolver.java index 91eb1a3..442bca2 100644 --- a/wicket-bean-validation/src/main/java/org/apache/wicket/bean/validation/DefaultPropertyResolver.java +++ b/wicket-bean-validation/src/main/java/org/apache/wicket/bean/validation/DefaultPropertyResolver.java @@ -3,6 +3,7 @@ package org.apache.wicket.bean.validation; import java.lang.reflect.Field; import java.lang.reflect.Method; +import org.apache.wicket.WicketRuntimeException; import org.apache.wicket.markup.html.form.FormComponent; import org.apache.wicket.model.IModel; import org.apache.wicket.model.IPropertyReflectionAwareModel; @@ -50,11 +51,26 @@ public class DefaultPropertyResolver implements IPropertyResolver return new Property(field.getDeclaringClass(), field.getName()); } + String name; Method getter = delegate.getPropertyGetter(); if (getter != null) { - String name = getter.getName().substring(3, 4).toLowerCase() + - getter.getName().substring(4); + String methodName = getter.getName(); + if (methodName.startsWith("get")) + { + name = methodName.substring(3, 4).toLowerCase() + + methodName.substring(4); + } + else if (methodName.startsWith("is")) + { + name = methodName.substring(2, 3).toLowerCase() + + methodName.substring(3); + } + else + { + throw new WicketRuntimeException("Invalid name for a getter method: '" + + methodName + "'. It must start either with 'get' or 'is'."); + } return new Property(getter.getDeclaringClass(), name); }
bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5505_6cceff44.diff
bugs-dot-jar_data_WICKET-2993_0b4f78cc
--- BugID: WICKET-2993 Summary: 'ClassCastException when requesting for non-page class ' Description: "org.apache.wicket.request.mapper.BookmarkableMapper tries to instantiate Page even for classes which are not Page.\nRequesting http://localhost:8080/wicket/bookmarkable/com.mycompany.Pojo fails with:\n\nERROR - DefaultExceptionMapper - Unexpected error occurred\njava.lang.ClassCastException: com.mycompany.Pojo\n\tat org.apache.wicket.session.DefaultPageFactory.newPage(DefaultPageFactory.java:155)\n\tat org.apache.wicket.session.DefaultPageFactory.newPage(DefaultPageFactory.java:59)\n\tat org.apache.wicket.session.DefaultPageFactory.newPage(DefaultPageFactory.java:43)\n\tat org.apache.wicket.Application$2.newPageInstance(Application.java:1425)\n\tat org.apache.wicket.request.handler.PageProvider.getPageInstance(PageProvider.java:259)\n\tat org.apache.wicket.request.handler.PageProvider.getPageInstance(PageProvider.java:160)\n\tat org.apache.wicket.request.handler.render.WebPageRenderer.getPage(WebPageRenderer.java:59)\n\tat org.apache.wicket.request.handler.render.WebPageRenderer.renderPage(WebPageRenderer.java:131)\n\tat org.apache.wicket.request.handler.render.WebPageRenderer.respond(WebPageRenderer.java:232)\n\tat org.apache.wicket.request.handler.RenderPageRequestHandler.respond(RenderPageRequestHandler.java:147)\n\tat org.apache.wicket.request.RequestHandlerStack.executeRequestHandler(RequestHandlerStack.java:84)\n\tat org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:217)\n\tat org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:253)\n\tat org.apache.wicket.protocol.http.WicketFilter.processRequest(WicketFilter.java:135)\n\tat org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:188)\n\tat org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157) \n ....." diff --git a/wicket/src/main/java/org/apache/wicket/request/mapper/BookmarkableMapper.java b/wicket/src/main/java/org/apache/wicket/request/mapper/BookmarkableMapper.java index 1b82594..1b0edf9 100644 --- a/wicket/src/main/java/org/apache/wicket/request/mapper/BookmarkableMapper.java +++ b/wicket/src/main/java/org/apache/wicket/request/mapper/BookmarkableMapper.java @@ -16,7 +16,6 @@ */ package org.apache.wicket.request.mapper; -import org.apache.wicket.Page; import org.apache.wicket.request.Request; import org.apache.wicket.request.Url; import org.apache.wicket.request.component.IRequestablePage; @@ -103,7 +102,7 @@ public class BookmarkableMapper extends AbstractBookmarkableMapper String className = url.getSegments().get(2); Class<? extends IRequestablePage> pageClass = getPageClass(className); - if (Page.class.isAssignableFrom(pageClass)) + if (pageClass != null && IRequestablePage.class.isAssignableFrom(pageClass)) { // extract the PageParameters from URL if there are any
bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-2993_0b4f78cc.diff
bugs-dot-jar_data_WICKET-294_5c592d85
--- BugID: WICKET-294 Summary: 'WebRequestCodingStrategy: path mounting and matching' Description: |+ Assuming a mount path to "/p", it will match /pxyz Assuming this is the desired behavior of matching (warning), then to avoid this match it should be declared "/p/" but it will create urls such as '/app/p//SomePage'. which is wrong. In the servlet specs, the mapping syntax '/p' is an exact match, this is not what you want in your case since you're doing path mapping, so the syntax if you want to stick close to the servlet specs should be '/p/*' or if you wan to get close to mod_proxy syntax it would be '/p/' Note that the examples are also using this wrong mapping declaration. In the example below: both should throw a 404: http://www.wicket-library.com/wicket-examples/niceurl/my/mounted/packageXXX http://www.wicket-library.com/wicket-examples/niceurl/my/mounted/Xpackage diff --git a/jdk-1.4/wicket/src/main/java/wicket/protocol/http/request/WebRequestCodingStrategy.java b/jdk-1.4/wicket/src/main/java/wicket/protocol/http/request/WebRequestCodingStrategy.java index e8b8272..9580296 100644 --- a/jdk-1.4/wicket/src/main/java/wicket/protocol/http/request/WebRequestCodingStrategy.java +++ b/jdk-1.4/wicket/src/main/java/wicket/protocol/http/request/WebRequestCodingStrategy.java @@ -968,7 +968,13 @@ public class WebRequestCodingStrategy implements IRequestCodingStrategy, IReques final String key = (String)entry.getKey(); if (path.startsWith(key)) { - return (IRequestTargetUrlCodingStrategy)entry.getValue(); + /* + * We need to match /mount/point or + * /mount/point/with/extra/path, but not /mount/pointXXX + */ + String remainder = path.substring(key.length()); + if (remainder.length() == 0 || remainder.startsWith("/")) + return (IRequestTargetUrlCodingStrategy)entry.getValue(); } } return null; diff --git a/jdk-1.4/wicket/src/main/java/wicket/request/target/coding/PackageRequestTargetUrlCodingStrategy.java b/jdk-1.4/wicket/src/main/java/wicket/request/target/coding/PackageRequestTargetUrlCodingStrategy.java index eaa6fd3..f18bf62 100644 --- a/jdk-1.4/wicket/src/main/java/wicket/request/target/coding/PackageRequestTargetUrlCodingStrategy.java +++ b/jdk-1.4/wicket/src/main/java/wicket/request/target/coding/PackageRequestTargetUrlCodingStrategy.java @@ -16,6 +16,9 @@ */ package wicket.request.target.coding; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + import wicket.IRequestTarget; import wicket.PageParameters; import wicket.Session; @@ -35,6 +38,7 @@ import wicket.util.string.AppendingStringBuffer; */ public class PackageRequestTargetUrlCodingStrategy extends AbstractRequestTargetUrlCodingStrategy { + private static final Log log = LogFactory.getLog(PackageRequestTargetUrlCodingStrategy.class); /** package for this mount. */ private final PackageName packageName; @@ -57,7 +61,9 @@ public class PackageRequestTargetUrlCodingStrategy extends AbstractRequestTarget */ public IRequestTarget decode(RequestParameters requestParameters) { + log.debug("path="+requestParameters.getPath()); String remainder = requestParameters.getPath().substring(getMountPath().length()); + log.debug("remainder="+remainder); final String parametersFragment; int ix = remainder.indexOf('/', 1); if (ix == -1) @@ -75,7 +81,14 @@ public class PackageRequestTargetUrlCodingStrategy extends AbstractRequestTarget remainder = remainder.substring(1); ix--; } + else + { + // There is nothing after the mount path! + return null; + } + log.debug("remainder="+remainder); + log.debug("parametersFragment="+parametersFragment); final String bookmarkablePageClassName = packageName + "." + remainder.substring(0, ix); Class bookmarkablePageClass = Session.get().getClassResolver().resolveClass( bookmarkablePageClassName);
bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-294_5c592d85.diff
bugs-dot-jar_data_WICKET-4358_02ebc8ae
--- BugID: WICKET-4358 Summary: BufferedWebResponse fails to add/clear cookie in redirect Description: | bufferedWebResponse.addCookie( cookie ); That fails under certain conditions: (1) when called on the last of three 302 redirects during OpenID login; and (2) on single redirect immediately after container startup, though it later recovers. Failure confirmed in Firebug; no cookies sent in any of the response headers. My workaround is to bypass the buffered response. This works: ((HttpServletResponse)bufferedWebResponse.getContainerResponse()).addCookie( cookie ); 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 b92f3e3..a0dbfeb 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 @@ -20,7 +20,6 @@ import org.apache.wicket.protocol.http.BufferedWebResponse; 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.Url; import org.apache.wicket.request.cycle.RequestCycle; import org.apache.wicket.core.request.handler.RenderPageRequestHandler; @@ -91,10 +90,10 @@ public class WebPageRenderer extends PageRenderer IRequestHandler scheduled = requestCycle.getRequestHandlerScheduledAfterCurrent(); // keep the original response - final Response originalResponse = requestCycle.getResponse(); + final WebResponse originalResponse = (WebResponse) requestCycle.getResponse(); // buffered web response for page - BufferedWebResponse response = new BufferedWebResponse((WebResponse)originalResponse); + BufferedWebResponse response = new BufferedWebResponse(originalResponse); // keep the original base URL Url originalBaseUrl = requestCycle.getUrlRenderer().setBaseUrl(targetUrl); @@ -106,9 +105,12 @@ public class WebPageRenderer extends PageRenderer if (scheduled == null && requestCycle.getRequestHandlerScheduledAfterCurrent() != null) { - // This is a special case. During page render another request handler got scheduled. - // The handler - // will want to overwrite the response, so we need to let it + // This is a special case. + // During page render another request handler got scheduled and will want to overwrite + // the response, so we need to let it. + // Just preserve the meta data headers + originalResponse.reset(); // clear the initial actions because they are already copied into the new response's actions + response.writeMetaData(originalResponse); return null; } else
bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-4358_02ebc8ae.diff
bugs-dot-jar_data_WICKET-1886_5226978a
--- BugID: WICKET-1886 Summary: WicketTester Cookie handling Description: |- While trying to test my SecureForm implementation (https://issues.apache.org/jira/browse/WICKET-1885) with WicketTester I ran into this issue: A cookie set in the response never shows up in the "next" request, because both have their own lists of cookies that aren't shared. Afaik both should share the same List instance to handle cookies. That way its possible to set a cookie in the response and read it from the request. A simple testcase is attached. diff --git a/wicket/src/main/java/org/apache/wicket/protocol/http/MockWebApplication.java b/wicket/src/main/java/org/apache/wicket/protocol/http/MockWebApplication.java index aaf95f6..3ad878f 100644 --- a/wicket/src/main/java/org/apache/wicket/protocol/http/MockWebApplication.java +++ b/wicket/src/main/java/org/apache/wicket/protocol/http/MockWebApplication.java @@ -16,16 +16,18 @@ */ package org.apache.wicket.protocol.http; +import javax.servlet.FilterConfig; +import javax.servlet.ServletContext; +import javax.servlet.ServletException; +import javax.servlet.http.Cookie; +import javax.servlet.http.HttpServletResponse; import java.io.File; import java.util.Enumeration; import java.util.HashMap; +import java.util.HashSet; import java.util.Iterator; import java.util.Map; - -import javax.servlet.FilterConfig; -import javax.servlet.ServletContext; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletResponse; +import java.util.Set; import org.apache.wicket.Application; import org.apache.wicket.Component; @@ -121,6 +123,7 @@ public class MockWebApplication private final ServletContext context; private final WicketFilter filter; + private Set<Cookie> cookiesOfThisSession = new HashSet<Cookie>(); /** * Create the mock http tester that can be used for testing. @@ -195,7 +198,15 @@ public class MockWebApplication servletSession = new MockHttpSession(context); servletSession.setTemporary(initializeHttpSessionAsTemporary()); servletRequest = new MockHttpServletRequest(this.application, servletSession, context); - servletResponse = new MockHttpServletResponse(servletRequest); + servletResponse = new MockHttpServletResponse(servletRequest) + { + @Override + public void addCookie(Cookie cookie) + { + super.addCookie(cookie); + cookiesOfThisSession.add(cookie); + } + }; // Construct request and response using factories wicketRequest = this.application.newWebRequest(servletRequest); @@ -620,6 +631,7 @@ public class MockWebApplication { servletRequest.initialize(); servletResponse.initialize(); + servletRequest.addCookies(cookiesOfThisSession); servletRequest.setParameters(parametersForNextRequest); if (isAjax) {
bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-1886_5226978a.diff