id
stringlengths 33
40
| content
stringlengths 662
61.5k
| max_stars_repo_path
stringlengths 85
97
|
---|---|---|
bugs-dot-jar_data_WICKET-5881_8c83c5c5 | ---
BugID: WICKET-5881
Summary: NPE in FormComponent#updateCollectionModel in case of no converted input
and unmodifiable collection
Description: There are 2 issues with FormComponent#updateCollectionModel. 1) converted
input is not checked for null before wrapping it to ArrayList 2) converted input
is not checked for null then model returns unmodifiable collection. The both issues
causes NPE.
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
index 88c5350..c0f4f10 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
@@ -1613,6 +1613,9 @@ public abstract class FormComponent<T> extends LabeledWebMarkupContainer impleme
public static <S> void updateCollectionModel(FormComponent<Collection<S>> formComponent)
{
Collection<S> convertedInput = formComponent.getConvertedInput();
+ if (convertedInput == null) {
+ convertedInput = Collections.emptyList();
+ }
Collection<S> collection = formComponent.getModelObject();
if (collection == null)
@@ -1629,10 +1632,7 @@ public abstract class FormComponent<T> extends LabeledWebMarkupContainer impleme
try
{
collection.clear();
- if (convertedInput != null)
- {
- collection.addAll(convertedInput);
- }
+ collection.addAll(convertedInput);
modified = true;
}
catch (UnsupportedOperationException unmodifiable)
@@ -1642,7 +1642,6 @@ public abstract class FormComponent<T> extends LabeledWebMarkupContainer impleme
logger.debug("An error occurred while trying to modify the collection attached to "
+ formComponent, unmodifiable);
}
-
collection = new ArrayList<>(convertedInput);
}
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5881_8c83c5c5.diff |
bugs-dot-jar_data_WICKET-3836_843b76b1 | ---
BugID: WICKET-3836
Summary: regression on strategy to integrate cas authentication
Description: |
yes, It happens in org.apache.wicket.request.handler.PageProvider.getPageInstance() ,
but not for the WelcomePage, but the redirection page (RedirectPage).
the CASPageAuthorizationStrategy as we are not authentified a org.apache.wicket.RestartResponseAtInterceptPageException with in parameter an instance of RedirectPage.
On the second call of PageProvider.getPageInstance, the pageId is of 0, an all other parameters are nulls.
The run seems quite different on 1.5-RC4.2 version - There is only one call of the method PageProvider.getPageInstance() and it come after the CASPageAuthorizationStrategy.isPageAuthorized
Le 27/06/2011 11:24, Martin Grigorov a écrit :
> Put a breakpoint in
> org.apache.wicket.request.handler.PageProvider.getPageInstance() and
> see what happens.
> It seems the test tries to retrieve a page from the page store by id
> but there is no such.
>
> On Mon, Jun 27, 2011 at 12:20 PM, Thomas Franconville
> <[email protected]> wrote:
>> Hi,
>>
>> Upgrading wicket from 1.5-RC4.2 to 1.5-RC5.1 make my Junit Test down with
>> the error 'Page expired'
>>
>> /**
>> * Simple test using the WicketTester
>> */
>> public class TestHomePage
>> {
>> private WicketTester tester;
>>
>> @Before
>> public void setUp()
>> {
>> tester = new WicketTester(new MyApplication());
>> }
>>
>> @Test
>> public void homepageRendersSuccessfully()
>> {
>> //start and render the test page
>> tester.startPage(WelcomePage.class);
>>
>> //assert rendered page class
>> tester.assertRenderedPage(RedirectPage.class);
>> }
>> }
>>
>> My application use a CASPageAuthorizationStrategy inspired of
>> http://www.lunikon.net/2009/11/24/integrating-cas-and-wicket/
>>
>>
>> Kind Regards
>>
>> Thomas
diff --git a/wicket-core/src/main/java/org/apache/wicket/RestartResponseAtInterceptPageException.java b/wicket-core/src/main/java/org/apache/wicket/RestartResponseAtInterceptPageException.java
index 819df88..1a31878 100644
--- a/wicket-core/src/main/java/org/apache/wicket/RestartResponseAtInterceptPageException.java
+++ b/wicket-core/src/main/java/org/apache/wicket/RestartResponseAtInterceptPageException.java
@@ -52,7 +52,7 @@ public class RestartResponseAtInterceptPageException extends ResetResponseExcept
public RestartResponseAtInterceptPageException(Page interceptPage)
{
super(new RenderPageRequestHandler(new PageProvider(interceptPage),
- RedirectPolicy.ALWAYS_REDIRECT));
+ RedirectPolicy.AUTO_REDIRECT));
InterceptData.set();
}
@@ -76,7 +76,7 @@ public class RestartResponseAtInterceptPageException extends ResetResponseExcept
PageParameters parameters)
{
super(new RenderPageRequestHandler(new PageProvider(interceptPageClass, parameters),
- RedirectPolicy.ALWAYS_REDIRECT));
+ RedirectPolicy.AUTO_REDIRECT));
InterceptData.set();
}
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-3836_843b76b1.diff |
bugs-dot-jar_data_WICKET-5476_813d8bee | ---
BugID: WICKET-5476
Summary: Ajax behavior on component with setRenderBodyOnly(true) don't get called
- improve warning
Description: |-
When you put AJAX behavior on component with setRenderBodyOnly(true) and try to call it with callback script it won't get called and no error / warning is displayed. See attached quickstart sample. Just unzipp and run with: mvn jetty:run
Navigate browser to http://localhost:8080/
When you try to click on labels AJAX behavior should get called. But it won't. This kind of behavior is correct (i assume). But i think user should be warned that behavior can't be called. I think proper place is somewhere on server side? But I don't know where exactly put the warning.
Now only message is in Wicket Ajax Debug window - "Ajax request stopped because of precondition check". I had to debug wicket javascript to find what precondition check failed. Maybe more detailed message in default precondition check would be useful too?
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/Check.java b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/Check.java
index 5d09f6f..bc5c77b 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/Check.java
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/Check.java
@@ -219,19 +219,6 @@ public class Check<T> extends LabeledWebMarkupContainer implements IGenericCompo
tag.put(ATTR_DISABLED, ATTR_DISABLED);
}
- // put group id into the class so we can easily identify all radios belonging to the group
- final String marker = "wicket-" + getGroup().getMarkupId();
- String clazz = tag.getAttribute("class");
- if (Strings.isEmpty(clazz))
- {
- clazz = marker;
- }
- else
- {
- clazz = clazz + " " + marker;
- }
- tag.put("class", clazz);
-
}
/**
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/Radio.java b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/Radio.java
index d1bebbc..282b711 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/Radio.java
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/Radio.java
@@ -23,7 +23,6 @@ import org.apache.wicket.markup.ComponentTag;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.model.IModel;
import org.apache.wicket.request.mapper.parameter.PageParameters;
-import org.apache.wicket.util.string.Strings;
/**
* Component representing a single radio choice in a org.apache.wicket.markup.html.form.RadioGroup.
@@ -205,19 +204,6 @@ public class Radio<T> extends LabeledWebMarkupContainer implements IGenericCompo
tag.put(ATTR_DISABLED, ATTR_DISABLED);
}
- // put group id into the class so we can easily identify all radios belonging to the group
- final String marker = "wicket-" + getGroup().getMarkupId();
- String clazz = tag.getAttribute("class");
- if (Strings.isEmpty(clazz))
- {
- clazz = marker;
- }
- else
- {
- clazz = clazz + " " + marker;
- }
- tag.put("class", clazz);
-
}
/**
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5476_813d8bee.diff |
bugs-dot-jar_data_WICKET-4301_50b52742 | ---
BugID: WICKET-4301
Summary: ByteArrayResource throws error if data is null
Description: |-
When ByteArrayResource#getData(org.apache.wicket.request.resource.IResource.Attributes) returns null, the class throws a WicketRuntimeException.
This behavior differs from DynamicImageResource and ResourceStreamResource which instead issue the following call:
response.setError(HttpServletResponse.SC_NOT_FOUND);
ByteArrayResource should follow the same behavior. This would allow for instance to use it for resources which depend on the contents of attributes.getParameters(). When the parameters are invalid, a 404 should be issued instead of an exception.
diff --git a/wicket-core/src/main/java/org/apache/wicket/request/resource/ByteArrayResource.java b/wicket-core/src/main/java/org/apache/wicket/request/resource/ByteArrayResource.java
index d11cab8..544f7ad 100644
--- a/wicket-core/src/main/java/org/apache/wicket/request/resource/ByteArrayResource.java
+++ b/wicket-core/src/main/java/org/apache/wicket/request/resource/ByteArrayResource.java
@@ -21,6 +21,8 @@ import java.net.URLConnection;
import org.apache.wicket.WicketRuntimeException;
import org.apache.wicket.util.time.Time;
+import javax.servlet.http.HttpServletResponse;
+
/**
* An {@link IResource} for byte arrays. The byte array can be static - passed to the constructor,
* or dynamic - by overriding
@@ -119,32 +121,35 @@ public class ByteArrayResource extends AbstractResource
final byte[] data = getData(attributes);
if (data == null)
{
- throw new WicketRuntimeException("ByteArrayResource's data cannot be 'null'.");
+ response.setError(HttpServletResponse.SC_NOT_FOUND);
}
- response.setContentLength(data.length);
-
- if (response.dataNeedsToBeWritten(attributes))
+ else
{
- if (filename != null)
- {
- response.setFileName(filename);
- response.setContentDisposition(ContentDisposition.ATTACHMENT);
- }
- else
- {
- response.setContentDisposition(ContentDisposition.INLINE);
- }
+ response.setContentLength(data.length);
- response.setWriteCallback(new WriteCallback()
+ if (response.dataNeedsToBeWritten(attributes))
{
- @Override
- public void writeData(final Attributes attributes)
+ if (filename != null)
+ {
+ response.setFileName(filename);
+ response.setContentDisposition(ContentDisposition.ATTACHMENT);
+ }
+ else
{
- attributes.getResponse().write(data);
+ response.setContentDisposition(ContentDisposition.INLINE);
}
- });
- configureResponse(response, attributes);
+ response.setWriteCallback(new WriteCallback()
+ {
+ @Override
+ public void writeData(final Attributes attributes)
+ {
+ attributes.getResponse().write(data);
+ }
+ });
+
+ configureResponse(response, attributes);
+ }
}
return response;
diff --git a/wicket-core/src/main/java/org/apache/wicket/request/resource/DynamicImageResource.java b/wicket-core/src/main/java/org/apache/wicket/request/resource/DynamicImageResource.java
index 472ff45..9e023d0 100644
--- a/wicket-core/src/main/java/org/apache/wicket/request/resource/DynamicImageResource.java
+++ b/wicket-core/src/main/java/org/apache/wicket/request/resource/DynamicImageResource.java
@@ -167,8 +167,9 @@ public abstract class DynamicImageResource extends AbstractResource
attributes.getResponse().write(imageData);
}
});
+
+ configureResponse(response, attributes);
}
- configureResponse(response, attributes);
}
return response;
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-4301_50b52742.diff |
bugs-dot-jar_data_WICKET-3278_60d07288 | ---
BugID: WICKET-3278
Summary: DropDownChoice no selection value
Description: "This problem came from this topic:\nhttp://apache-wicket.1842946.n4.nabble.com/DropDownChoice-no-selection-value-td3160661.html\n\nI've
noticed that the method AbstractSingleSelectChoice.getNoSelectionValue() returns
the value for no selection. In AbstractSingleSelectChoice.getDefaultChoice(final
Object selected) on line 314: \n return \"\\n<option selected=\\\"selected\\\"
value=\\\"\\\">\" + option + \"</option>\"; \n\nand on line 296: \n buffer.append(\"
value=\\\"\\\">\").append(option).append(\"</option>\"); \n\nIn those cases the
null value option has empty value attribute. Wouldn't it be more consistent for
this option to have the \"value\" attribute with the result provided from getNoSelectionValue()?"
diff --git a/wicket/src/main/java/org/apache/wicket/markup/html/form/AbstractSingleSelectChoice.java b/wicket/src/main/java/org/apache/wicket/markup/html/form/AbstractSingleSelectChoice.java
index b86f32e..937acc9 100644
--- a/wicket/src/main/java/org/apache/wicket/markup/html/form/AbstractSingleSelectChoice.java
+++ b/wicket/src/main/java/org/apache/wicket/markup/html/form/AbstractSingleSelectChoice.java
@@ -165,7 +165,8 @@ public abstract class AbstractSingleSelectChoice<T> extends AbstractChoice<T, T>
int index = getChoices().indexOf(object);
return getChoiceRenderer().getIdValue(object, index);
}
- return getNoSelectionValue().toString();
+ Object noSelectionValue = getNoSelectionValue();
+ return noSelectionValue != null ? noSelectionValue.toString() : null;
}
/**
@@ -269,6 +270,9 @@ public abstract class AbstractSingleSelectChoice<T> extends AbstractChoice<T, T>
@Override
protected CharSequence getDefaultChoice(final Object selected)
{
+
+ final Object noSelectionValue = getNoSelectionValue();
+
// Is null a valid selection value?
if (isNullValid())
{
@@ -287,19 +291,21 @@ public abstract class AbstractSingleSelectChoice<T> extends AbstractChoice<T, T>
buffer.append("\n<option");
// If null is selected, indicate that
- if (selected == null)
+ if (selected == noSelectionValue)
{
buffer.append(" selected=\"selected\"");
}
// Add body of option tag
- buffer.append(" value=\"\">").append(option).append("</option>");
+ buffer.append(" value=\"" + noSelectionValue + "\">")
+ .append(option)
+ .append("</option>");
return buffer;
}
else
{
// Null is not valid. Is it selected anyway?
- if ((selected == null) || getNoSelectionValue().equals(selected) ||
+ if ((selected == null) || selected.equals(noSelectionValue) ||
selected.equals(EMPTY_STRING))
{
// Force the user to pick a non-null value
@@ -311,7 +317,8 @@ public abstract class AbstractSingleSelectChoice<T> extends AbstractChoice<T, T>
option = getLocalizer().getString("null", this, CHOOSE_ONE);
}
- return "\n<option selected=\"selected\" value=\"\">" + option + "</option>";
+ return "\n<option selected=\"selected\" value=\"" + noSelectionValue + "\">" +
+ option + "</option>";
}
}
return "";
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-3278_60d07288.diff |
bugs-dot-jar_data_WICKET-3884_b772ff87 | ---
BugID: WICKET-3884
Summary: Null model for AttributeAppender should not render empty attribute
Description: I can't think of a reason this would be valid, but passing in null model
renders <span class="">Test</span>. If previous and new attribute are both null,
the component should render cleanly like <span>Test</span>.
diff --git a/wicket-core/src/main/java/org/apache/wicket/behavior/AttributeAppender.java b/wicket-core/src/main/java/org/apache/wicket/behavior/AttributeAppender.java
index 13b7fe9..5db4526 100644
--- a/wicket-core/src/main/java/org/apache/wicket/behavior/AttributeAppender.java
+++ b/wicket-core/src/main/java/org/apache/wicket/behavior/AttributeAppender.java
@@ -152,9 +152,9 @@ public class AttributeAppender extends AttributeModifier
{
// Short circuit when one of the values is empty: return the other value.
if (Strings.isEmpty(currentValue))
- return appendValue != null ? appendValue : "";
+ return appendValue != null ? appendValue : null;
else if (Strings.isEmpty(appendValue))
- return currentValue != null ? currentValue : "";
+ return currentValue != null ? currentValue : null;
StringBuilder sb = new StringBuilder(currentValue);
sb.append((getSeparator() == null ? "" : getSeparator()));
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-3884_b772ff87.diff |
bugs-dot-jar_data_WICKET-4494_35843c19 | ---
BugID: WICKET-4494
Summary: HtmlHandler wrongly handles tags not requiring closed tags if the markup
does not have "top" level tag
Description: "Hi, \n\nI have custom component (extends MarkupContainer implements
IMarkupCacheKeyProvider, IMarkupResourceStreamProvider) which fetches its HTML markup
from database. \nFollowing HTML markup: \n\n<img alt=\"\" src=\"logo.png\"> \n<br>Some
text \n<br>Some more text \n\ncauses following error: \n\n2012-04-12 10:52:53,012
[http-8080-6] ERROR: Unexpected error occurred \nUnable to find close tag for: '<img
alt=\"logo\" src=\"logo.png\">' in org.apache.wicket.util.resource.StringResourceStream@3d7e16fc
\n MarkupStream: [unknown] \n at org.apache.wicket.markup.MarkupFragment.<init>(MarkupFragment.java:127)
\n at org.apache.wicket.markup.MarkupStream.getMarkupFragment(MarkupStream.java:485)
\n at org.apache.wicket.MarkupContainer.autoAdd(MarkupContainer.java:244)
\n at org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java:1421)
\n at org.apache.wicket.MarkupContainer.renderAll(MarkupContainer.java:1596)
\n at org.apache.wicket.MarkupContainer.renderComponentTagBody(MarkupContainer.java:1571)
\n at org.apache.wicket.MarkupContainer.onComponentTagBody(MarkupContainer.java:1525)
\n\nI think the problem is that org.apache.wicket.markup.parser.filter.HtmlHandler
does not handle such markup correctly. It does not call ComponentTag.setHasNoCloseTag(true)
for the img tag. Such call is missing in postProcess() method. I think that this
problem can be fixed by inserting: \n\ntop.setHasNoCloseTag(true); \n\nafter line
80 in HtmlHandler.java file. \n\n\nMichal"
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/parser/filter/HtmlHandler.java b/wicket-core/src/main/java/org/apache/wicket/markup/parser/filter/HtmlHandler.java
index b45ed7c..440e5bc 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/parser/filter/HtmlHandler.java
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/parser/filter/HtmlHandler.java
@@ -78,6 +78,7 @@ public final class HtmlHandler extends AbstractMarkupFilter
if (!requiresCloseTag(top.getName()))
{
stack.pop();
+ top.setHasNoCloseTag(true);
}
else
{
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-4494_35843c19.diff |
bugs-dot-jar_data_WICKET-3989_6a8fc1cc | ---
BugID: WICKET-3989
Summary: MarkupNotFoundException when refreshing a component with AJAX inside a TransparentWebMarkupContainer
Description: A component placed inside a TransparentWebMarkupContainer, added to its
parent cannot be refreshed with AJAX. See quickstart.
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 30671b4..d8ac442 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
@@ -24,6 +24,7 @@ import org.apache.wicket.markup.MarkupException;
import org.apache.wicket.markup.MarkupStream;
import org.apache.wicket.markup.html.internal.HtmlHeaderContainer;
import org.apache.wicket.markup.parser.XmlTag.TagType;
+import org.apache.wicket.markup.resolver.IComponentResolver;
/**
* Implements boilerplate as needed by many markup sourcing strategies.
@@ -42,6 +43,40 @@ public abstract class AbstractMarkupSourcingStrategy implements IMarkupSourcingS
public abstract IMarkupFragment getMarkup(final MarkupContainer container, final Component child);
/**
+ * If the child has not been directly added to the container, but via a
+ * TransparentWebMarkupContainer, then we are in trouble. In general Wicket iterates over the
+ * markup elements and searches for associated components, not the other way around. Because of
+ * TransparentWebMarkupContainer (or more generally resolvers), there is no "synchronous" search
+ * possible.
+ *
+ * @param container
+ * the parent 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)
+ {
+ IMarkupFragment markup = null;
+
+ for (Component ch : container)
+ {
+ if ((ch != child) && (ch instanceof MarkupContainer) &&
+ (ch instanceof IComponentResolver))
+ {
+ markup = ((MarkupContainer)ch).getMarkup(child);
+ if (markup != null)
+ {
+ break;
+ }
+ }
+ }
+
+ return markup;
+ }
+
+ /**
* Make sure we open up open-close tags to open-body-close
*/
public void onComponentTag(final Component component, final ComponentTag tag)
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 3b61f97..d3196c6 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
@@ -119,6 +119,12 @@ public abstract class AssociatedMarkupSourcingStrategy extends AbstractMarkupSou
return associatedMarkup;
}
+ associatedMarkup = searchMarkupInTransparentResolvers(parent, child);
+ if (associatedMarkup != null)
+ {
+ return associatedMarkup;
+ }
+
return findMarkupInAssociatedFileHeader(parent, child);
}
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 9173181..24a09e9 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/html/panel/DefaultMarkupSourcingStrategy.java
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/panel/DefaultMarkupSourcingStrategy.java
@@ -23,7 +23,6 @@ import org.apache.wicket.markup.IMarkupFragment;
import org.apache.wicket.markup.MarkupStream;
import org.apache.wicket.markup.html.internal.HtmlHeaderContainer;
import org.apache.wicket.markup.html.list.AbstractItem;
-import org.apache.wicket.markup.resolver.IComponentResolver;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -32,7 +31,7 @@ import org.slf4j.LoggerFactory;
*
* @author Juergen Donnerstag
*/
-public final class DefaultMarkupSourcingStrategy implements IMarkupSourcingStrategy
+public final class DefaultMarkupSourcingStrategy extends AbstractMarkupSourcingStrategy
{
/** Log for reporting. */
private static final Logger log = LoggerFactory.getLogger(DefaultMarkupSourcingStrategy.class);
@@ -58,6 +57,7 @@ public final class DefaultMarkupSourcingStrategy implements IMarkupSourcingStrat
/**
* Nothing to add to the response by default
*/
+ @Override
public void onComponentTag(final Component component, final ComponentTag tag)
{
}
@@ -65,6 +65,7 @@ public final class DefaultMarkupSourcingStrategy implements IMarkupSourcingStrat
/**
* Invoke the component's onComponentTagBody().
*/
+ @Override
public void onComponentTagBody(final Component component, final MarkupStream markupStream,
final ComponentTag openTag)
{
@@ -74,6 +75,7 @@ public final class DefaultMarkupSourcingStrategy implements IMarkupSourcingStrat
/**
* Get the markup for the child component, which is assumed to be a child of 'container'.
*/
+ @Override
public IMarkupFragment getMarkup(final MarkupContainer container, final Component child)
{
// If the sourcing strategy did not provide one, than ask the component.
@@ -96,22 +98,10 @@ public final class DefaultMarkupSourcingStrategy implements IMarkupSourcingStrat
return markup;
}
- // If the child has not been directly added to the container, but via a
- // TransparentWebMarkupContainer, then we are in trouble. In general Wicket iterates over
- // the markup elements and searches for associated components, not the other way around.
- // Because of TransparentWebMarkupContainer (or more generally resolvers), there is no
- // "synchronous" search possible.
- for (Component ch : container)
+ markup = searchMarkupInTransparentResolvers(container, child);
+ if (markup != null)
{
- if ((ch != child) && (ch instanceof MarkupContainer) &&
- (ch instanceof IComponentResolver))
- {
- markup = ((MarkupContainer)ch).getMarkup(child);
- if (markup != null)
- {
- return markup;
- }
- }
+ return markup;
}
// This is to make migration for Items from 1.4 to 1.5 more easy
@@ -156,6 +146,7 @@ public final class DefaultMarkupSourcingStrategy implements IMarkupSourcingStrat
/**
* Empty: nothing will be added to the header by default
*/
+ @Override
public void renderHead(final Component component, HtmlHeaderContainer container)
{
}
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/panel/IMarkupSourcingStrategy.java b/wicket-core/src/main/java/org/apache/wicket/markup/html/panel/IMarkupSourcingStrategy.java
index bfc2240..7cc8fb2 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/html/panel/IMarkupSourcingStrategy.java
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/panel/IMarkupSourcingStrategy.java
@@ -22,6 +22,7 @@ import org.apache.wicket.markup.ComponentTag;
import org.apache.wicket.markup.IMarkupFragment;
import org.apache.wicket.markup.MarkupStream;
import org.apache.wicket.markup.html.internal.HtmlHeaderContainer;
+import org.apache.wicket.markup.resolver.IComponentResolver;
/**
* Markup sourcing strategies determine whether a Component behaves like a "Panel" pulling its
@@ -79,10 +80,11 @@ public interface IMarkupSourcingStrategy
* @see MarkupContainer#getMarkup(Component)
*
* @param container
- * The parent containing the child. (@TODO Is container ever != child.getParent()??)
+ * The parent containing the child. This is not the direct parent, transparent
+ * component {@link IComponentResolver resolver} may be in the hierarchy between.
* @param child
* The component to find the markup for.
- * @return markup fragment
+ * @return the markup fragment for the child, or {@code null}.
*/
IMarkupFragment getMarkup(final MarkupContainer container, final Component child);
}
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-3989_6a8fc1cc.diff |
bugs-dot-jar_data_WICKET-4012_d35d2d85 | ---
BugID: WICKET-4012
Summary: Component's onAfterRender() is called so many times as it is depth in the
component tree + 1
Description: "org.apache.wicket.Component.afterRender() calls org.apache.wicket.Component.onAfterRenderChildren()
which for MarkupContainers calls afterRender() for its children.\n\nSo for code
like:\n\n WebMarkupContainer comp1 = new WebMarkupContainer(\"c1\");\n add(comp1);\n
\ \n WebMarkupContainer comp2 = new WebMarkupContainer(\"c2\");\n comp1.add(comp2);\n
\ \n WebMarkupContainer comp3 = new WebMarkupContainer(\"c3\") {\n\n
\ @Override\n protected void onAfterRender() {\n super.onAfterRender();\n
\ System.err.println(\"called\");\n }\n \n };\n
\ comp2.add(comp3);\n\nyou'll see \"called\" printed 4 times in a single request.\n\nAdditionally
I think onAfterRenderChildren() should be called before onAfterRender() in Component.afterRender().
The flow should be first-in last-out: onBeforeRender > onBeforeRenderChildren >
onAfterRenderChildren > onAfterRender,"
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 33c515d..13b32cb 100644
--- a/wicket-core/src/main/java/org/apache/wicket/Component.java
+++ b/wicket-core/src/main/java/org/apache/wicket/Component.java
@@ -941,6 +941,11 @@ public abstract class Component
try
{
setFlag(FLAG_AFTER_RENDERING, true);
+
+ // always detach children because components can be attached
+ // independently of their parents
+ onAfterRenderChildren();
+
onAfterRender();
getApplication().getComponentOnAfterRenderListeners().onAfterRender(this);
if (getFlag(FLAG_AFTER_RENDERING))
@@ -950,9 +955,6 @@ public abstract class Component
getClass().getName() +
" has not called super.onAfterRender() in the override of onAfterRender() method");
}
- // always detach children because components can be attached
- // independently of their parents
- onAfterRenderChildren();
}
finally
{
@@ -2852,10 +2854,7 @@ public abstract class Component
*/
public Component setMarkupId(String markupId)
{
- if (markupId != null && Strings.isEmpty(markupId))
- {
- throw new IllegalArgumentException("Markup id cannot be an empty string");
- }
+ Args.notEmpty(markupId, "markupId");
// TODO check if an automatic id has already been generated or getmarkupid() called
// previously and throw an illegalstateexception because something else might be depending
@@ -4112,6 +4111,10 @@ public abstract class Component
setFlag(FLAG_PREPARED_FOR_RENDER, false);
setFlag(FLAG_RENDERING, true);
}
+ else
+ {
+ setFlag(FLAG_RENDERING, false);
+ }
}
/**
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 37986ff..056d483 100644
--- a/wicket-core/src/main/java/org/apache/wicket/MarkupContainer.java
+++ b/wicket-core/src/main/java/org/apache/wicket/MarkupContainer.java
@@ -1835,13 +1835,11 @@ public abstract class MarkupContainer extends Component implements Iterable<Comp
@Override
protected void onAfterRenderChildren()
{
- // Loop through child components
for (Component child : this)
{
- // Call end request on the child
- child.afterRender();
+ // set RENDERING_FLAG to false for auto-component's children (like Enclosure)
+ child.markRendering(false);
}
-
super.onAfterRenderChildren();
}
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-4012_d35d2d85.diff |
bugs-dot-jar_data_WICKET-5237_b61fe92c | ---
BugID: WICKET-5237
Summary: Wicket generates invalid HTML by expanding col tags
Description: |-
hi,
I just noticed that wicket expands col tags, even though the (x)html specifications forbids it.
take this markup as an example:
<table>
<colgroup>
<col width="20%" />
<col width="80%" />
</colgroup>
<tbody>
<tr>
<td>I take a fifth of the available space</td>
<td>I take four fifth of the available space</td>
</tr>
</tbody>
</table>
Instead of return this as-is, it get's converted to:
<table>
<colgroup>
<col width="20%"></col>
<col width="80%"></col>
</colgroup>
<tbody>
<tr>
<td>I take a fifth of the available space</td>
<td>I take four fifth of the available space</td>
</tr>
</tbody>
</table>
But the specifications mention that col tags must not have end tags. This may be related to WICKET-2765, as this seems to be the point when col was added to the OpenCloseTagExpander class. Note that it is ok to have a non closing col tag in html (self-closing in xhtml). It's all about generating a separated end tag.
This happens in wicket 6.8, but I guess it's relevant to all versions down to wicket 1.4.
Specs for reference:
http://www.w3.org/TR/1999/REC-html401-19991224/struct/tables.html#edef-COL
http://www.w3.org/TR/html-markup/col.html
Kind regards,
Konrad
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/parser/filter/OpenCloseTagExpander.java b/wicket-core/src/main/java/org/apache/wicket/markup/parser/filter/OpenCloseTagExpander.java
index f737c74..9e3abf8 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/parser/filter/OpenCloseTagExpander.java
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/parser/filter/OpenCloseTagExpander.java
@@ -37,6 +37,10 @@ import org.apache.wicket.markup.parser.XmlTag.TagType;
*/
public class OpenCloseTagExpander extends AbstractMarkupFilter
{
+ // A list of elements which should not be expanded from TagType.OPEN_CLOSE to TagType.OPEN + TagType.CLOSE
+ // http://www.w3.org/TR/html-markup/syntax.html#void-element
+ // area, base, br, col, command, embed, hr, img, input, keygen, link, meta, param, source, track, wbr
+
private static final List<String> replaceForTags = Arrays.asList("a", "q", "sub", "sup",
"abbr", "acronym", "cite", "code", "del", "dfn", "em", "ins", "kbd", "samp", "var",
"label", "textarea", "tr", "td", "th", "caption", "thead", "tbody", "tfoot", "dl", "dt",
@@ -52,12 +56,9 @@ public class OpenCloseTagExpander extends AbstractMarkupFilter
"b",
"e",
"select",
- "col",
- // New HTML5 elements (excluding: open-close tags:
- // wbr, source, time, embed, keygen
// @TODO by now an exclude list is probably shorter
- "article", "aside", "command", "details", "summary", "figure", "figcaption", "footer",
+ "article", "aside", "details", "summary", "figure", "figcaption", "footer",
"header", "hgroup", "mark", "meter", "nav", "progress", "ruby", "rt", "rp", "section",
"audio", "video", "canvas", "datalist", "output");
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5237_b61fe92c.diff |
bugs-dot-jar_data_WICKET-3618_fbfd17e6 | ---
BugID: WICKET-3618
Summary: 'IllegalStateException: Header was already written to response!'
Description: |-
Getting this error for no apparent reason, the code works fine on wicket 1.4.17. Code example with error is attached.
Click on the 'click here' link to see the error occur in the console, below is part of the stack trace.
ERROR - DefaultExceptionMapper - Unexpected error occurred
java.lang.IllegalStateException: Header was already written to response!
at org.apache.wicket.protocol.http.HeaderBufferingWebResponse.checkHeader(HeaderBufferingWebResponse.java:62)
at org.apache.wicket.protocol.http.HeaderBufferingWebResponse.setDateHeader(HeaderBufferingWebResponse.java:131)
at org.apache.wicket.protocol.http.BufferedWebResponse$SetDateHeaderAction.invoke(BufferedWebResponse.java:241)
at org.apache.wicket.protocol.http.BufferedWebResponse.writeTo(BufferedWebResponse.java:487)
at org.apache.wicket.request.handler.render.WebPageRenderer.respond(WebPageRenderer.java:225)
at org.apache.wicket.request.handler.RenderPageRequestHandler.respond(RenderPageRequestHandler.java:139)
at org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:715)
at org.apache.wicket.request.RequestHandlerStack.execute(RequestHandlerStack.java:63)
at org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:274)
at org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:283)
at org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:283)
at org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:283)
at org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:283)
at org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:283)
at org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:227)
at org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:253)
at org.apache.wicket.protocol.http.WicketFilter.processRequest(WicketFilter.java:138)
at org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:194)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1323)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:474)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:119)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:517)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:226)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:935)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:404)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:184)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:870)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)
at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:247)
at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:151)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
at org.eclipse.jetty.server.Server.handle(Server.java:346)
at org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.java:596)
at org.eclipse.jetty.server.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:1051)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:592)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:214)
at org.eclipse.jetty.server.HttpConnection.handle(HttpConnection.java:426)
at org.eclipse.jetty.server.bio.SocketConnector$ConnectorEndPoint.run(SocketConnector.java:241)
at org.eclipse.jetty.server.ssl.SslSocketConnector$SslConnectorEndPoint.run(SslSocketConnector.java:646)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:528)
at java.lang.Thread.run(Thread.java:619)
diff --git a/wicket-core/src/main/java/org/apache/wicket/protocol/http/BufferedWebResponse.java b/wicket-core/src/main/java/org/apache/wicket/protocol/http/BufferedWebResponse.java
index 2ec9997..83c0556 100644
--- a/wicket-core/src/main/java/org/apache/wicket/protocol/http/BufferedWebResponse.java
+++ b/wicket-core/src/main/java/org/apache/wicket/protocol/http/BufferedWebResponse.java
@@ -20,6 +20,7 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import javax.servlet.http.Cookie;
@@ -88,9 +89,14 @@ public class BufferedWebResponse extends WebResponse implements IMetaDataBufferi
}
}
- private static abstract class Action
+ private static abstract class Action implements Comparable<Action>
{
protected abstract void invoke(WebResponse response);
+
+ public int compareTo(Action o)
+ {
+ return 0;
+ }
}
/**
@@ -100,6 +106,12 @@ public class BufferedWebResponse extends WebResponse implements IMetaDataBufferi
*/
private static abstract class MetaDataAction extends Action
{
+ @Override
+ public int compareTo(Action o)
+ {
+ // write first in response
+ return Integer.MIN_VALUE;
+ }
}
private static class WriteCharSequenceAction extends Action
@@ -135,6 +147,13 @@ public class BufferedWebResponse extends WebResponse implements IMetaDataBufferi
}
response.write(builder);
}
+
+ @Override
+ public int compareTo(Action o)
+ {
+ // needs to be invoked after set header actions
+ return Integer.MAX_VALUE;
+ }
}
private static class WriteDataAction extends Action
@@ -163,6 +182,13 @@ public class BufferedWebResponse extends WebResponse implements IMetaDataBufferi
{
writeStream(response, stream);
}
+
+ @Override
+ public int compareTo(Action o)
+ {
+ // needs to be invoked after set header actions
+ return Integer.MAX_VALUE;
+ }
}
private static class CloseAction extends Action
@@ -242,7 +268,7 @@ public class BufferedWebResponse extends WebResponse implements IMetaDataBufferi
}
}
- private static class SetContentLengthAction extends Action
+ private static class SetContentLengthAction extends MetaDataAction
{
private final long contentLength;
@@ -258,7 +284,7 @@ public class BufferedWebResponse extends WebResponse implements IMetaDataBufferi
}
}
- private static class SetContentTypeAction extends Action
+ private static class SetContentTypeAction extends MetaDataAction
{
private final String contentType;
@@ -482,6 +508,8 @@ public class BufferedWebResponse extends WebResponse implements IMetaDataBufferi
{
Args.notNull(response, "response");
+ Collections.sort(actions);
+
for (Action action : actions)
{
action.invoke(response);
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-3618_fbfd17e6.diff |
bugs-dot-jar_data_WICKET-5809_b1f4e6a3 | ---
BugID: WICKET-5809
Summary: URL IPv6 parsing
Description: |-
There is an issue with native IPv6 address parsing.
"https://[::1]/myapp", URL parsing fails:
org.apache.wicket.request.Url.parse("https://[::1]/myapp")
generates an exception:
java.lang.NumberFormatException: For input string: "1]"
at java.lang.NumberFormatException.forInputString(
NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:492)
However, "https://[::1]:80/myapp" works as expected.
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 9d5b401..be49640 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
@@ -290,7 +290,11 @@ public class Url implements Serializable
}
final int credentialsAt = hostAndPort.lastIndexOf('@') + 1;
- final int portAt = hostAndPort.substring(credentialsAt).lastIndexOf(':');
+ //square brackets are used for ip6 URLs
+ final int closeSqrBracketAt = hostAndPort.lastIndexOf(']') + 1;
+ final int portAt = hostAndPort.substring(credentialsAt)
+ .substring(closeSqrBracketAt)
+ .lastIndexOf(':');
if (portAt == -1)
{
@@ -299,8 +303,10 @@ public class Url implements Serializable
}
else
{
- result.host = hostAndPort.substring(0, portAt + credentialsAt);
- result.port = Integer.parseInt(hostAndPort.substring(portAt + credentialsAt + 1));
+ final int portOffset = portAt + credentialsAt + closeSqrBracketAt;
+
+ result.host = hostAndPort.substring(0, portOffset);
+ result.port = Integer.parseInt(hostAndPort.substring(portOffset + 1));
}
if (relativeAt < 0)
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5809_b1f4e6a3.diff |
bugs-dot-jar_data_WICKET-3764_48454f4d | ---
BugID: WICKET-3764
Summary: Ajax behaviors are failing in stateless pages
Description: "Stateless ajax behaviors are not working in stateless pages in 1.5-RC4.2.
I verified it with the stateless demo project of Martin Grigorov (https://github.com/martin-g/wicket-stateless),
when changing the dropdown on the start page an exception is thrown (clicking the
increment link causes a similar exception): \n\norg.apache.wicket.behavior.InvalidBehaviorIdException:
Cannot find behavior with id: 0 on component: [DropDownChoice [Component id = c]]\n\nAt
first glance the reason may be located in org.apache.wicket.Behaviors.getBehaviorById()
which does not create the ID list if missing (getBehaviorsIdList(false) in line
286 instead of getBehaviorsIdList(true)), because this error does not occur when
getBehaviorId() was manually called in the page constructor to force creation of
the list."
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 2e358e2..627d4e6 100644
--- a/wicket-core/src/main/java/org/apache/wicket/Behaviors.java
+++ b/wicket-core/src/main/java/org/apache/wicket/Behaviors.java
@@ -70,7 +70,7 @@ final class Behaviors implements IDetachable
private void internalAdd(final Behavior behavior)
{
component.data_add(behavior);
- if (behavior.isStateless(component))
+ if (behavior.getStatelessHint(component))
{
getBehaviorId(behavior);
}
diff --git a/wicket-core/src/main/java/org/apache/wicket/behavior/Behavior.java b/wicket-core/src/main/java/org/apache/wicket/behavior/Behavior.java
index ff2e04a..a809405 100644
--- a/wicket-core/src/main/java/org/apache/wicket/behavior/Behavior.java
+++ b/wicket-core/src/main/java/org/apache/wicket/behavior/Behavior.java
@@ -178,23 +178,6 @@ public abstract class Behavior
}
/**
- * Returns whether or not this behavior is stateless. Most behaviors should either not override
- * this method or return {@code false} because most behavior are not stateless.
- *
- * A small subset of behaviors are made specifically to be stateless and as such should override
- * this method and return {@code true}. One sideeffect of this method is that the behavior id
- * will be generated eagerly when the behavior is added to the component instead of before
- * render when a method to create the url is called - this allows for stateless callback urls.
- *
- * @param component
- * @return whether or not this behavior is stateless
- */
- public boolean isStateless(Component component)
- {
- return false;
- }
-
- /**
* Checks if a listener can be invoked on this behavior
*
* @param component
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-3764_48454f4d.diff |
bugs-dot-jar_data_WICKET-3520_d1b62639 | ---
BugID: WICKET-3520
Summary: SHOW_NO_EXCEPTION_PAGE responding with HTTP status 500 is overwritten by
redirect
Description: |-
If the application is configured with SHOW_NO_EXCEPTION_PAGE as unexpectedExceptionDisplay, an exception thrown while submitting a form should result in an HTTP 500 status.
Since the request is already marked as a redirect in AbstractListenerInterfaceRequestTarget#onProcessEvents(), the 500 status is overwritten with status 200 when the redirect is handled afterwards.
diff --git a/wicket-core/src/main/java/org/apache/wicket/DefaultExceptionMapper.java b/wicket-core/src/main/java/org/apache/wicket/DefaultExceptionMapper.java
index 2f71217..8d66d8a 100644
--- a/wicket-core/src/main/java/org/apache/wicket/DefaultExceptionMapper.java
+++ b/wicket-core/src/main/java/org/apache/wicket/DefaultExceptionMapper.java
@@ -121,7 +121,7 @@ public class DefaultExceptionMapper implements IExceptionMapper
else
{
// IExceptionSettings.SHOW_NO_EXCEPTION_PAGE
- return new EmptyRequestHandler();
+ return new ErrorCodeRequestHandler(500);
}
}
}
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-3520_d1b62639.diff |
bugs-dot-jar_data_WICKET-3715_557de7bc | ---
BugID: WICKET-3715
Summary: FileUpload writeToTempFile() method throws NPE for sessionless requests
Description: "I have created stateless page with stateless form containing FileUploadField,
however when I tried to post file to it, NPE was thrown.\n\nThe issue is caused
by method FileUpload#writeToTempFile() method trying to use session id as temp file
prefix. \n\nWorkaround: create temp file manually and use method FileUpload#writeToFile(
myTempFile)"
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/upload/FileUpload.java b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/upload/FileUpload.java
index 3f895d3..6bc50c4 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/upload/FileUpload.java
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/upload/FileUpload.java
@@ -27,6 +27,7 @@ import java.util.List;
import org.apache.wicket.IClusterable;
import org.apache.wicket.Session;
import org.apache.wicket.WicketRuntimeException;
+import org.apache.wicket.request.cycle.RequestCycle;
import org.apache.wicket.util.file.Files;
import org.apache.wicket.util.io.IOUtils;
import org.apache.wicket.util.lang.Args;
@@ -247,8 +248,10 @@ public class FileUpload implements IClusterable
*/
public final File writeToTempFile() throws IOException
{
- File temp = File.createTempFile(Session.get().getId(),
- Files.cleanupFilename(item.getFieldName()));
+ Session.get();
+ String sessionId = Session.exists() ? Session.get().getId() : "";
+ String tempFileName = sessionId + "_" + RequestCycle.get().getStartTime();
+ File temp = File.createTempFile(tempFileName, Files.cleanupFilename(item.getFieldName()));
writeTo(temp);
return temp;
}
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-3715_557de7bc.diff |
bugs-dot-jar_data_WICKET-4816_66bfc885 | ---
BugID: WICKET-4816
Summary: Handling of semicolons in form action URLs
Description: |-
What I expect to happen when there is no semicolon support in Wicket is that a
URL in a form like below stays intact and will not be cut off at the position of
the first semicolon:
<form action="http://localhost:8080/dor/abc_1234:56;023:456_def_78;90.html"
method="post"><input type="submit" value="Submit" /></form>
In my application the part abc_1234:56;023:456_def_78;90.html is "named1" in the
mapping below:
mount(new MountedMapper("dor/#{named1}", TestPage.class, new
MyPageParametersEncoder()));
and parsed in MyPageParametersEncoder.
The officially intended use of semicolons in URLs seems to be specified in "RFC
1808 - Relative Uniform Resource Locators, 2.4.5."
(http://www.faqs.org/rfcs/rfc1808.html). But that´s not what I´m looking for.
If I had not some pages running on this syntax, I could easily swap the
semicolon with another symbol. Nevertheless and if I´m correctly informed, I
think those URLs should not be cut off.
(Quotation from the mailing list)
The quickstart can be tested with the following URLs:
http://localhost:8080/dor/abc_1234:56;023:456_def_78;90.html
http://localhost:8080/dor/abc_1234:56%3B023:456_def_78%3B90.html
http://localhost:8080/dor/?abc=1234:56%3B023:456&def=78%3B90
The crucial part is the action attribute in the form in the page´s source code, which contains i.e. "./abc_1234:56?-1.IFormSubmitListener-form".
diff --git a/wicket-util/src/main/java/org/apache/wicket/util/string/Strings.java b/wicket-util/src/main/java/org/apache/wicket/util/string/Strings.java
index fceb499..27a9987 100755
--- a/wicket-util/src/main/java/org/apache/wicket/util/string/Strings.java
+++ b/wicket-util/src/main/java/org/apache/wicket/util/string/Strings.java
@@ -22,6 +22,7 @@ import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.ArrayList;
import java.util.List;
+import java.util.Locale;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -906,19 +907,19 @@ public final class Strings
*/
public static String stripJSessionId(final String url)
{
- if (url == null)
+ if (Strings.isEmpty(url))
{
- return null;
+ return url;
}
// http://.../abc;jsessionid=...?param=...
- int ixSemiColon = url.indexOf(";");
+ int ixSemiColon = url.toLowerCase(Locale.ENGLISH).indexOf(";jsessionid=");
if (ixSemiColon == -1)
{
return url;
}
- int ixQuestionMark = url.indexOf("?");
+ int ixQuestionMark = url.indexOf('?');
if (ixQuestionMark == -1)
{
// no query paramaters; cut off at ";"
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-4816_66bfc885.diff |
bugs-dot-jar_data_WICKET-5582_1fb66533 | ---
BugID: WICKET-5582
Summary: ServletWebResponse#encodeUrl() makes absolute Urls relative
Description: When an absolute (full) URL is passed to ServletWebResponse#encodeUrl(),
it will be returned relative if the container encodes a session ID.
diff --git a/wicket-core/src/main/java/org/apache/wicket/protocol/http/servlet/ServletWebResponse.java b/wicket-core/src/main/java/org/apache/wicket/protocol/http/servlet/ServletWebResponse.java
index e665aaf..e7e32d1 100644
--- a/wicket-core/src/main/java/org/apache/wicket/protocol/http/servlet/ServletWebResponse.java
+++ b/wicket-core/src/main/java/org/apache/wicket/protocol/http/servlet/ServletWebResponse.java
@@ -173,29 +173,39 @@ public class ServletWebResponse extends WebResponse
{
Args.notNull(url, "url");
+ UrlRenderer urlRenderer = RequestCycle.get().getUrlRenderer();
+
+ Url originalUrl = Url.parse(url);
+
/*
WICKET-4645 - always pass absolute url to the web container for encoding
because when REDIRECT_TO_BUFFER is in use Wicket may render PageB when
PageA is actually the requested one and the web container cannot resolve
the base url properly
*/
- UrlRenderer urlRenderer = RequestCycle.get().getUrlRenderer();
- Url relativeUrl = Url.parse(url);
- String fullUrl = urlRenderer.renderFullUrl(relativeUrl);
+ String fullUrl = urlRenderer.renderFullUrl(originalUrl);
String encodedFullUrl = httpServletResponse.encodeURL(fullUrl);
- final String encodedRelativeUrl;
- if (fullUrl.equals(encodedFullUrl))
+
+ final String encodedUrl;
+ if (originalUrl.isFull())
{
- // no encoding happened so just reuse the relative url
- encodedRelativeUrl = url.toString();
+ encodedUrl = encodedFullUrl;
}
else
{
- // get the relative url with the jsessionid encoded in it
- Url _encoded = Url.parse(encodedFullUrl);
- encodedRelativeUrl = urlRenderer.renderRelativeUrl(_encoded);
+ if (fullUrl.equals(encodedFullUrl))
+ {
+ // no encoding happened so just reuse the original url
+ encodedUrl = url.toString();
+ }
+ else
+ {
+ // get the relative url with the jsessionid encoded in it
+ Url _encoded = Url.parse(encodedFullUrl);
+ encodedUrl = urlRenderer.renderRelativeUrl(_encoded);
+ }
}
- return encodedRelativeUrl;
+ return encodedUrl;
}
@Override
@@ -203,29 +213,38 @@ public class ServletWebResponse extends WebResponse
{
Args.notNull(url, "url");
+ UrlRenderer urlRenderer = RequestCycle.get().getUrlRenderer();
+
+ Url originalUrl = Url.parse(url);
+
/*
- WICKET-4854 - always pass absolute url to the web container for encoding
- because when REDIRECT_TO_BUFFER is in use Wicket may render PageB when
- PageA is actually the requested one and the web container cannot resolve
- the base url properly
+ * WICKET-4645 - always pass absolute url to the web container for encoding because when
+ * REDIRECT_TO_BUFFER is in use Wicket may render PageB when PageA is actually the requested
+ * one and the web container cannot resolve the base url properly
*/
- UrlRenderer urlRenderer = new UrlRenderer(webRequest);
- Url relativeUrl = Url.parse(url);
- String fullUrl = urlRenderer.renderFullUrl(relativeUrl);
+ String fullUrl = urlRenderer.renderFullUrl(originalUrl);
String encodedFullUrl = httpServletResponse.encodeRedirectURL(fullUrl);
- final String encodedRelativeUrl;
- if (fullUrl.equals(encodedFullUrl))
+
+ final String encodedUrl;
+ if (originalUrl.isFull())
{
- // no encoding happened so just reuse the relative url
- encodedRelativeUrl = url.toString();
+ encodedUrl = encodedFullUrl;
}
else
{
- // get the relative url with the jsessionid encoded in it
- Url _encoded = Url.parse(encodedFullUrl);
- encodedRelativeUrl = urlRenderer.renderRelativeUrl(_encoded);
+ if (fullUrl.equals(encodedFullUrl))
+ {
+ // no encoding happened so just reuse the original url
+ encodedUrl = url.toString();
+ }
+ else
+ {
+ // get the relative url with the jsessionid encoded in it
+ Url _encoded = Url.parse(encodedFullUrl);
+ encodedUrl = urlRenderer.renderRelativeUrl(_encoded);
+ }
}
- return encodedRelativeUrl;
+ return encodedUrl;
}
@Override
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5582_1fb66533.diff |
bugs-dot-jar_data_WICKET-5416_87fa630f | ---
BugID: WICKET-5416
Summary: BOM in UTF markup file breaks encoding detection
Description: |-
I have project with internationalization and experienced this problem with one of the pages with non-english content. Page had UTF-8 encoding, but my JVM encoding is different. I always use "<?xml encoding ... ?>" to specify encoding for markup pages (and "MarkupSettings.defaultMarkupEncoding" is not set).
Unexpectedly I got problem with bad encoding on page. After several hours of debugging I found what source of this issue was UTF BOM (Byte order mark) at the beggining of file and inability of "XmlReader" to process it. "XmlReader.getXmlDeclaration" tries to match xml declaration with regular expression, but fails because of BOM. After that encoding defaults to JVM encoding.
It's possible to use "org.apache.commons.io.input.BOMInputStream" to handle BOM or you could handle it manually inside "XmlReader".
PS: issue found with Wicket 1.5.10 and I see same code in 6.12.0 without BOM handling, so I added it to "Affects Version/s", but no proof-in-code available from me at this moment.
diff --git a/wicket-util/src/main/java/org/apache/wicket/util/io/BOMInputStream.java b/wicket-util/src/main/java/org/apache/wicket/util/io/BOMInputStream.java
new file mode 100644
index 0000000..b870278
--- /dev/null
+++ b/wicket-util/src/main/java/org/apache/wicket/util/io/BOMInputStream.java
@@ -0,0 +1,404 @@
+/*
+ * 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.util.io;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.List;
+
+/**
+ * This class is used to wrap a stream that includes an encoded {@link ByteOrderMark} as its first bytes.
+ *
+ * This class detects these bytes and, if required, can automatically skip them and return the subsequent byte as the
+ * first byte in the stream.
+ *
+ * The {@link ByteOrderMark} implementation has the following pre-defined BOMs:
+ * <ul>
+ * <li>UTF-8 - {@link ByteOrderMark#UTF_8}</li>
+ * <li>UTF-16BE - {@link ByteOrderMark#UTF_16LE}</li>
+ * <li>UTF-16LE - {@link ByteOrderMark#UTF_16BE}</li>
+ * <li>UTF-32BE - {@link ByteOrderMark#UTF_32LE}</li>
+ * <li>UTF-32LE - {@link ByteOrderMark#UTF_32BE}</li>
+ * </ul>
+ *
+ *
+ * <h3>Example 1 - Detect and exclude a UTF-8 BOM</h3>
+ *
+ * <pre>
+ * BOMInputStream bomIn = new BOMInputStream(in);
+ * if (bomIn.hasBOM()) {
+ * // has a UTF-8 BOM
+ * }
+ * </pre>
+ *
+ * <h3>Example 2 - Detect a UTF-8 BOM (but don't exclude it)</h3>
+ *
+ * <pre>
+ * boolean include = true;
+ * BOMInputStream bomIn = new BOMInputStream(in, include);
+ * if (bomIn.hasBOM()) {
+ * // has a UTF-8 BOM
+ * }
+ * </pre>
+ *
+ * <h3>Example 3 - Detect Multiple BOMs</h3>
+ *
+ * <pre>
+ * BOMInputStream bomIn = new BOMInputStream(in,
+ * ByteOrderMark.UTF_16LE, ByteOrderMark.UTF_16BE,
+ * ByteOrderMark.UTF_32LE, ByteOrderMark.UTF_32BE
+ * );
+ * if (bomIn.hasBOM() == false) {
+ * // No BOM found
+ * } else if (bomIn.hasBOM(ByteOrderMark.UTF_16LE)) {
+ * // has a UTF-16LE BOM
+ * } else if (bomIn.hasBOM(ByteOrderMark.UTF_16BE)) {
+ * // has a UTF-16BE BOM
+ * } else if (bomIn.hasBOM(ByteOrderMark.UTF_32LE)) {
+ * // has a UTF-32LE BOM
+ * } else if (bomIn.hasBOM(ByteOrderMark.UTF_32BE)) {
+ * // has a UTF-32BE BOM
+ * }
+ * </pre>
+ *
+ * @see ByteOrderMark
+ * @see <a href="http://en.wikipedia.org/wiki/Byte_order_mark">Wikipedia - Byte Order Mark</a>
+ * @version $Id$
+ * @since 2.0
+ */
+public class BOMInputStream extends ProxyInputStream
+{
+ private final boolean include;
+ /**
+ * BOMs are sorted from longest to shortest.
+ */
+ private final List<ByteOrderMark> boms;
+ private ByteOrderMark byteOrderMark;
+ private int[] firstBytes;
+ private int fbLength;
+ private int fbIndex;
+ private int markFbIndex;
+ private boolean markedAtStart;
+
+ /**
+ * Constructs a new BOM InputStream that excludes a {@link ByteOrderMark#UTF_8} BOM.
+ *
+ * @param delegate
+ * the InputStream to delegate to
+ */
+ public BOMInputStream(final InputStream delegate) {
+ this(delegate, false, ByteOrderMark.UTF_8);
+ }
+
+ /**
+ * Constructs a new BOM InputStream that detects a a {@link ByteOrderMark#UTF_8} and optionally includes it.
+ *
+ * @param delegate
+ * the InputStream to delegate to
+ * @param include
+ * true to include the UTF-8 BOM or false to exclude it
+ */
+ public BOMInputStream(final InputStream delegate, final boolean include) {
+ this(delegate, include, ByteOrderMark.UTF_8);
+ }
+
+ /**
+ * Constructs a new BOM InputStream that excludes the specified BOMs.
+ *
+ * @param delegate
+ * the InputStream to delegate to
+ * @param boms
+ * The BOMs to detect and exclude
+ */
+ public BOMInputStream(final InputStream delegate, final ByteOrderMark... boms) {
+ this(delegate, false, boms);
+ }
+
+ /**
+ * Compares ByteOrderMark objects in descending length order.
+ */
+ private static final Comparator<ByteOrderMark> ByteOrderMarkLengthComparator = new Comparator<ByteOrderMark>() {
+
+ public int compare(final ByteOrderMark bom1, final ByteOrderMark bom2) {
+ final int len1 = bom1.length();
+ final int len2 = bom2.length();
+ if (len1 > len2) {
+ return -1;
+ }
+ if (len2 > len1) {
+ return 1;
+ }
+ return 0;
+ }
+ };
+
+ /**
+ * Constructs a new BOM InputStream that detects the specified BOMs and optionally includes them.
+ *
+ * @param delegate
+ * the InputStream to delegate to
+ * @param include
+ * true to include the specified BOMs or false to exclude them
+ * @param boms
+ * The BOMs to detect and optionally exclude
+ */
+ public BOMInputStream(final InputStream delegate, final boolean include, final ByteOrderMark... boms) {
+ super(delegate);
+ if (boms == null || boms.length == 0) {
+ throw new IllegalArgumentException("No BOMs specified");
+ }
+ this.include = include;
+ // Sort the BOMs to match the longest BOM first because some BOMs have the same starting two bytes.
+ Arrays.sort(boms, ByteOrderMarkLengthComparator);
+ this.boms = Arrays.asList(boms);
+
+ }
+
+ /**
+ * Indicates whether the stream contains one of the specified BOMs.
+ *
+ * @return true if the stream has one of the specified BOMs, otherwise false if it does not
+ * @throws IOException
+ * if an error reading the first bytes of the stream occurs
+ */
+ public boolean hasBOM() throws IOException {
+ return getBOM() != null;
+ }
+
+ /**
+ * Indicates whether the stream contains the specified BOM.
+ *
+ * @param bom
+ * The BOM to check for
+ * @return true if the stream has the specified BOM, otherwise false if it does not
+ * @throws IllegalArgumentException
+ * if the BOM is not one the stream is configured to detect
+ * @throws IOException
+ * if an error reading the first bytes of the stream occurs
+ */
+ public boolean hasBOM(final ByteOrderMark bom) throws IOException {
+ if (!boms.contains(bom)) {
+ throw new IllegalArgumentException("Stream not configure to detect " + bom);
+ }
+ return byteOrderMark != null && getBOM().equals(bom);
+ }
+
+ /**
+ * Return the BOM (Byte Order Mark).
+ *
+ * @return The BOM or null if none
+ * @throws IOException
+ * if an error reading the first bytes of the stream occurs
+ */
+ public ByteOrderMark getBOM() throws IOException {
+ if (firstBytes == null) {
+ fbLength = 0;
+ // BOMs are sorted from longest to shortest
+ final int maxBomSize = boms.get(0).length();
+ firstBytes = new int[maxBomSize];
+ // Read first maxBomSize bytes
+ for (int i = 0; i < firstBytes.length; i++) {
+ firstBytes[i] = in.read();
+ fbLength++;
+ if (firstBytes[i] < 0) {
+ break;
+ }
+ }
+ // match BOM in firstBytes
+ byteOrderMark = find();
+ if (byteOrderMark != null) {
+ if (!include) {
+ if (byteOrderMark.length() < firstBytes.length) {
+ fbIndex = byteOrderMark.length();
+ } else {
+ fbLength = 0;
+ }
+ }
+ }
+ }
+ return byteOrderMark;
+ }
+
+ /**
+ * Return the BOM charset Name - {@link ByteOrderMark#getCharsetName()}.
+ *
+ * @return The BOM charset Name or null if no BOM found
+ * @throws IOException
+ * if an error reading the first bytes of the stream occurs
+ *
+ */
+ public String getBOMCharsetName() throws IOException {
+ getBOM();
+ return byteOrderMark == null ? null : byteOrderMark.getCharsetName();
+ }
+
+ /**
+ * This method reads and either preserves or skips the first bytes in the stream. It behaves like the single-byte
+ * <code>read()</code> method, either returning a valid byte or -1 to indicate that the initial bytes have been
+ * processed already.
+ *
+ * @return the byte read (excluding BOM) or -1 if the end of stream
+ * @throws IOException
+ * if an I/O error occurs
+ */
+ private int readFirstBytes() throws IOException {
+ getBOM();
+ return fbIndex < fbLength ? firstBytes[fbIndex++] : -1;
+ }
+
+ /**
+ * Find a BOM with the specified bytes.
+ *
+ * @return The matched BOM or null if none matched
+ */
+ private ByteOrderMark find() {
+ for (final ByteOrderMark bom : boms) {
+ if (matches(bom)) {
+ return bom;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Check if the bytes match a BOM.
+ *
+ * @param bom
+ * The BOM
+ * @return true if the bytes match the bom, otherwise false
+ */
+ private boolean matches(final ByteOrderMark bom) {
+ // if (bom.length() != fbLength) {
+ // return false;
+ // }
+ // firstBytes may be bigger than the BOM bytes
+ for (int i = 0; i < bom.length(); i++) {
+ if (bom.get(i) != firstBytes[i]) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ // ----------------------------------------------------------------------------
+ // Implementation of InputStream
+ // ----------------------------------------------------------------------------
+
+ /**
+ * Invokes the delegate's <code>read()</code> method, detecting and optionally skipping BOM.
+ *
+ * @return the byte read (excluding BOM) or -1 if the end of stream
+ * @throws IOException
+ * if an I/O error occurs
+ */
+ @Override
+ public int read() throws IOException {
+ final int b = readFirstBytes();
+ return b >= 0 ? b : in.read();
+ }
+
+ /**
+ * Invokes the delegate's <code>read(byte[], int, int)</code> method, detecting and optionally skipping BOM.
+ *
+ * @param buf
+ * the buffer to read the bytes into
+ * @param off
+ * The start offset
+ * @param len
+ * The number of bytes to read (excluding BOM)
+ * @return the number of bytes read or -1 if the end of stream
+ * @throws IOException
+ * if an I/O error occurs
+ */
+ @Override
+ public int read(final byte[] buf, int off, int len) throws IOException {
+ int firstCount = 0;
+ int b = 0;
+ while (len > 0 && b >= 0) {
+ b = readFirstBytes();
+ if (b >= 0) {
+ buf[off++] = (byte) (b & 0xFF);
+ len--;
+ firstCount++;
+ }
+ }
+ final int secondCount = in.read(buf, off, len);
+ return secondCount < 0 ? firstCount > 0 ? firstCount : -1 : firstCount + secondCount;
+ }
+
+ /**
+ * Invokes the delegate's <code>read(byte[])</code> method, detecting and optionally skipping BOM.
+ *
+ * @param buf
+ * the buffer to read the bytes into
+ * @return the number of bytes read (excluding BOM) or -1 if the end of stream
+ * @throws IOException
+ * if an I/O error occurs
+ */
+ @Override
+ public int read(final byte[] buf) throws IOException {
+ return read(buf, 0, buf.length);
+ }
+
+ /**
+ * Invokes the delegate's <code>mark(int)</code> method.
+ *
+ * @param readlimit
+ * read ahead limit
+ */
+ @Override
+ public synchronized void mark(final int readlimit) {
+ markFbIndex = fbIndex;
+ markedAtStart = firstBytes == null;
+ in.mark(readlimit);
+ }
+
+ /**
+ * Invokes the delegate's <code>reset()</code> method.
+ *
+ * @throws IOException
+ * if an I/O error occurs
+ */
+ @Override
+ public synchronized void reset() throws IOException {
+ fbIndex = markFbIndex;
+ if (markedAtStart) {
+ firstBytes = null;
+ }
+
+ in.reset();
+ }
+
+ /**
+ * Invokes the delegate's <code>skip(long)</code> method, detecting and optionallyskipping BOM.
+ *
+ * @param n
+ * the number of bytes to skip
+ * @return the number of bytes to skipped or -1 if the end of stream
+ * @throws IOException
+ * if an I/O error occurs
+ */
+ @Override
+ public long skip(long n) throws IOException {
+ while (n > 0 && readFirstBytes() >= 0) {
+ n--;
+ }
+ return in.skip(n);
+ }
+}
diff --git a/wicket-util/src/main/java/org/apache/wicket/util/io/ByteOrderMark.java b/wicket-util/src/main/java/org/apache/wicket/util/io/ByteOrderMark.java
new file mode 100644
index 0000000..e1ee046
--- /dev/null
+++ b/wicket-util/src/main/java/org/apache/wicket/util/io/ByteOrderMark.java
@@ -0,0 +1,191 @@
+/*
+ * 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.util.io;
+
+import java.io.Serializable;
+
+/**
+ * Byte Order Mark (BOM) representation - see {@link BOMInputStream}.
+ *
+ * @see BOMInputStream
+ * @see <a href="http://en.wikipedia.org/wiki/Byte_order_mark">Wikipedia: Byte Order Mark</a>
+ * @see <a href="http://www.w3.org/TR/2006/REC-xml-20060816/#sec-guessing">W3C: Autodetection of Character Encodings
+ * (Non-Normative)</a>
+ * @version $Id$
+ * @since 2.0
+ */
+public class ByteOrderMark implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ /** UTF-8 BOM */
+ public static final ByteOrderMark UTF_8 = new ByteOrderMark("UTF-8", 0xEF, 0xBB, 0xBF);
+
+ /** UTF-16BE BOM (Big-Endian) */
+ public static final ByteOrderMark UTF_16BE = new ByteOrderMark("UTF-16BE", 0xFE, 0xFF);
+
+ /** UTF-16LE BOM (Little-Endian) */
+ public static final ByteOrderMark UTF_16LE = new ByteOrderMark("UTF-16LE", 0xFF, 0xFE);
+
+ /**
+ * UTF-32BE BOM (Big-Endian)
+ * @since 2.2
+ */
+ public static final ByteOrderMark UTF_32BE = new ByteOrderMark("UTF-32BE", 0x00, 0x00, 0xFE, 0xFF);
+
+ /**
+ * UTF-32LE BOM (Little-Endian)
+ * @since 2.2
+ */
+ public static final ByteOrderMark UTF_32LE = new ByteOrderMark("UTF-32LE", 0xFF, 0xFE, 0x00, 0x00);
+
+ /**
+ * Unicode BOM character; external form depends on the encoding.
+ * @see <a href="http://unicode.org/faq/utf_bom.html#BOM">Byte Order Mark (BOM) FAQ</a>
+ * @since 2.5
+ */
+ public static final char UTF_BOM = '\uFEFF';
+
+ private final String charsetName;
+ private final int[] bytes;
+
+ /**
+ * Construct a new BOM.
+ *
+ * @param charsetName The name of the charset the BOM represents
+ * @param bytes The BOM's bytes
+ * @throws IllegalArgumentException if the charsetName is null or
+ * zero length
+ * @throws IllegalArgumentException if the bytes are null or zero
+ * length
+ */
+ public ByteOrderMark(final String charsetName, final int... bytes) {
+ if (charsetName == null || charsetName.length() == 0) {
+ throw new IllegalArgumentException("No charsetName specified");
+ }
+ if (bytes == null || bytes.length == 0) {
+ throw new IllegalArgumentException("No bytes specified");
+ }
+ this.charsetName = charsetName;
+ this.bytes = new int[bytes.length];
+ System.arraycopy(bytes, 0, this.bytes, 0, bytes.length);
+ }
+
+ /**
+ * Return the name of the {@link java.nio.charset.Charset} the BOM represents.
+ *
+ * @return the character set name
+ */
+ public String getCharsetName() {
+ return charsetName;
+ }
+
+ /**
+ * Return the length of the BOM's bytes.
+ *
+ * @return the length of the BOM's bytes
+ */
+ public int length() {
+ return bytes.length;
+ }
+
+ /**
+ * The byte at the specified position.
+ *
+ * @param pos The position
+ * @return The specified byte
+ */
+ public int get(final int pos) {
+ return bytes[pos];
+ }
+
+ /**
+ * Return a copy of the BOM's bytes.
+ *
+ * @return a copy of the BOM's bytes
+ */
+ public byte[] getBytes() {
+ final byte[] copy = new byte[bytes.length];
+ for (int i = 0; i < bytes.length; i++) {
+ copy[i] = (byte)bytes[i];
+ }
+ return copy;
+ }
+
+ /**
+ * Indicates if this BOM's bytes equals another.
+ *
+ * @param obj The object to compare to
+ * @return true if the bom's bytes are equal, otherwise
+ * false
+ */
+ @Override
+ public boolean equals(final Object obj) {
+ if (!(obj instanceof ByteOrderMark)) {
+ return false;
+ }
+ final ByteOrderMark bom = (ByteOrderMark)obj;
+ if (bytes.length != bom.length()) {
+ return false;
+ }
+ for (int i = 0; i < bytes.length; i++) {
+ if (bytes[i] != bom.get(i)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Return the hashcode for this BOM.
+ *
+ * @return the hashcode for this BOM.
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ int hashCode = getClass().hashCode();
+ for (final int b : bytes) {
+ hashCode += b;
+ }
+ return hashCode;
+ }
+
+ /**
+ * Provide a String representation of the BOM.
+ *
+ * @return the length of the BOM's bytes
+ */
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder();
+ builder.append(getClass().getSimpleName());
+ builder.append('[');
+ builder.append(charsetName);
+ builder.append(": ");
+ for (int i = 0; i < bytes.length; i++) {
+ if (i > 0) {
+ builder.append(",");
+ }
+ builder.append("0x");
+ builder.append(Integer.toHexString(0xFF & bytes[i]).toUpperCase());
+ }
+ builder.append(']');
+ return builder.toString();
+ }
+
+}
diff --git a/wicket-util/src/main/java/org/apache/wicket/util/io/ProxyInputStream.java b/wicket-util/src/main/java/org/apache/wicket/util/io/ProxyInputStream.java
new file mode 100644
index 0000000..e3d424c
--- /dev/null
+++ b/wicket-util/src/main/java/org/apache/wicket/util/io/ProxyInputStream.java
@@ -0,0 +1,236 @@
+/*
+ * 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.util.io;
+
+import java.io.FilterInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * A Proxy stream which acts as expected, that is it passes the method
+ * calls on to the proxied stream and doesn't change which methods are
+ * being called.
+ * <p>
+ * It is an alternative base class to FilterInputStream
+ * to increase reusability, because FilterInputStream changes the
+ * methods being called, such as read(byte[]) to read(byte[], int, int).
+ * <p>
+ * See the protected methods for ways in which a subclass can easily decorate
+ * a stream with custom pre-, post- or error processing functionality.
+ *
+ * @version $Id$
+ */
+public abstract class ProxyInputStream extends FilterInputStream {
+
+ /**
+ * Constructs a new ProxyInputStream.
+ *
+ * @param proxy the InputStream to delegate to
+ */
+ public ProxyInputStream(final InputStream proxy) {
+ super(proxy);
+ // the proxy is stored in a protected superclass variable named 'in'
+ }
+
+ /**
+ * Invokes the delegate's <code>read()</code> method.
+ * @return the byte read or -1 if the end of stream
+ * @throws IOException if an I/O error occurs
+ */
+ @Override
+ public int read() throws IOException {
+ try {
+ beforeRead(1);
+ final int b = in.read();
+ afterRead(b != -1 ? 1 : -1);
+ return b;
+ } catch (final IOException e) {
+ handleIOException(e);
+ return -1;
+ }
+ }
+
+ /**
+ * Invokes the delegate's <code>read(byte[])</code> method.
+ * @param bts the buffer to read the bytes into
+ * @return the number of bytes read or -1 if the end of stream
+ * @throws IOException if an I/O error occurs
+ */
+ @Override
+ public int read(final byte[] bts) throws IOException {
+ try {
+ beforeRead(bts != null ? bts.length : 0);
+ final int n = in.read(bts);
+ afterRead(n);
+ return n;
+ } catch (final IOException e) {
+ handleIOException(e);
+ return -1;
+ }
+ }
+
+ /**
+ * Invokes the delegate's <code>read(byte[], int, int)</code> method.
+ * @param bts the buffer to read the bytes into
+ * @param off The start offset
+ * @param len The number of bytes to read
+ * @return the number of bytes read or -1 if the end of stream
+ * @throws IOException if an I/O error occurs
+ */
+ @Override
+ public int read(final byte[] bts, final int off, final int len) throws IOException {
+ try {
+ beforeRead(len);
+ final int n = in.read(bts, off, len);
+ afterRead(n);
+ return n;
+ } catch (final IOException e) {
+ handleIOException(e);
+ return -1;
+ }
+ }
+
+ /**
+ * Invokes the delegate's <code>skip(long)</code> method.
+ * @param ln the number of bytes to skip
+ * @return the actual number of bytes skipped
+ * @throws IOException if an I/O error occurs
+ */
+ @Override
+ public long skip(final long ln) throws IOException {
+ try {
+ return in.skip(ln);
+ } catch (final IOException e) {
+ handleIOException(e);
+ return 0;
+ }
+ }
+
+ /**
+ * Invokes the delegate's <code>available()</code> method.
+ * @return the number of available bytes
+ * @throws IOException if an I/O error occurs
+ */
+ @Override
+ public int available() throws IOException {
+ try {
+ return super.available();
+ } catch (final IOException e) {
+ handleIOException(e);
+ return 0;
+ }
+ }
+
+ /**
+ * Invokes the delegate's <code>close()</code> method.
+ * @throws IOException if an I/O error occurs
+ */
+ @Override
+ public void close() throws IOException {
+ try {
+ in.close();
+ } catch (final IOException e) {
+ handleIOException(e);
+ }
+ }
+
+ /**
+ * Invokes the delegate's <code>mark(int)</code> method.
+ * @param readlimit read ahead limit
+ */
+ @Override
+ public synchronized void mark(final int readlimit) {
+ in.mark(readlimit);
+ }
+
+ /**
+ * Invokes the delegate's <code>reset()</code> method.
+ * @throws IOException if an I/O error occurs
+ */
+ @Override
+ public synchronized void reset() throws IOException {
+ try {
+ in.reset();
+ } catch (final IOException e) {
+ handleIOException(e);
+ }
+ }
+
+ /**
+ * Invokes the delegate's <code>markSupported()</code> method.
+ * @return true if mark is supported, otherwise false
+ */
+ @Override
+ public boolean markSupported() {
+ return in.markSupported();
+ }
+
+ /**
+ * Invoked by the read methods before the call is proxied. The number
+ * of bytes that the caller wanted to read (1 for the {@link #read()}
+ * method, buffer length for {@link #read(byte[])}, etc.) is given as
+ * an argument.
+ * <p>
+ * Subclasses can override this method to add common pre-processing
+ * functionality without having to override all the read methods.
+ * The default implementation does nothing.
+ * <p>
+ * Note this method is <em>not</em> called from {@link #skip(long)} or
+ * {@link #reset()}. You need to explicitly override those methods if
+ * you want to add pre-processing steps also to them.
+ *
+ * @since 2.0
+ * @param n number of bytes that the caller asked to be read
+ * @throws IOException if the pre-processing fails
+ */
+ protected void beforeRead(final int n) throws IOException {
+ }
+
+ /**
+ * Invoked by the read methods after the proxied call has returned
+ * successfully. The number of bytes returned to the caller (or -1 if
+ * the end of stream was reached) is given as an argument.
+ * <p>
+ * Subclasses can override this method to add common post-processing
+ * functionality without having to override all the read methods.
+ * The default implementation does nothing.
+ * <p>
+ * Note this method is <em>not</em> called from {@link #skip(long)} or
+ * {@link #reset()}. You need to explicitly override those methods if
+ * you want to add post-processing steps also to them.
+ *
+ * @since 2.0
+ * @param n number of bytes read, or -1 if the end of stream was reached
+ * @throws IOException if the post-processing fails
+ */
+ protected void afterRead(final int n) throws IOException {
+ }
+
+ /**
+ * Handle any IOExceptions thrown.
+ * <p>
+ * This method provides a point to implement custom exception
+ * handling. The default behaviour is to re-throw the exception.
+ * @param e The IOException thrown
+ * @throws IOException if an I/O error occurs
+ * @since 2.0
+ */
+ protected void handleIOException(final IOException e) throws IOException {
+ throw e;
+ }
+
+}
diff --git a/wicket-util/src/main/java/org/apache/wicket/util/io/XmlReader.java b/wicket-util/src/main/java/org/apache/wicket/util/io/XmlReader.java
index ce4c041..1f3a408 100644
--- a/wicket-util/src/main/java/org/apache/wicket/util/io/XmlReader.java
+++ b/wicket-util/src/main/java/org/apache/wicket/util/io/XmlReader.java
@@ -70,11 +70,11 @@ public final class XmlReader extends Reader
if (!inputStream.markSupported())
{
- this.inputStream = new BufferedInputStream(inputStream);
+ this.inputStream = new BufferedInputStream(new BOMInputStream(inputStream));
}
else
{
- this.inputStream = inputStream;
+ this.inputStream = new BOMInputStream(inputStream);
}
encoding = defaultEncoding;
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5416_87fa630f.diff |
bugs-dot-jar_data_WICKET-5706_0f8a6d75 | ---
BugID: WICKET-5706
Summary: ResourceUtils.getLocaleFromFilename cannot handle filenames with classifiers
Description: "When I try to get PathLocale with ResourceUtils, than get wrong values,
when the files contains '.' in name.\n\nExample: 'jquery.test.js' \nPathLocale.path=jquery,
PathLocale.locale = null\n\nor jquery.test_hu.js'.\nPathLocale.path=jquery, PathLocale.locale
= null\n\nThat's why I'd like to use \njquery.test_hu.js' as resource, the ResourceStreamLocator
try to find \njquery.test_hu_hu_HU.js, jquery.test_hu_hu.js, and after jquery.test_hu.js.\nBecause
the \nResourceStreamLocator.locate\n\n\t\tPathLocale data = ResourceUtils.getLocaleFromFilename(path);\n\t\tif
((data != null) && (data.locale != null))\n\t\t{\n\t\t\tpath = data.path;\n\t\t\tlocale
= data.locale;\n\t\t}\ndoesn't work in this case.\n\nShould change the \nResourceUtils\n\n\tpublic
static PathLocale getLocaleFromFilename(String path) {\n\t\tint pos = path.indexOf('.');\n----------------\nTo\n
\ int pos = path.lastIndexOf('.');"
diff --git a/wicket-util/src/main/java/org/apache/wicket/util/resource/ResourceUtils.java b/wicket-util/src/main/java/org/apache/wicket/util/resource/ResourceUtils.java
index e7ec95a..3216707 100644
--- a/wicket-util/src/main/java/org/apache/wicket/util/resource/ResourceUtils.java
+++ b/wicket-util/src/main/java/org/apache/wicket/util/resource/ResourceUtils.java
@@ -33,10 +33,10 @@ public class ResourceUtils
{
private static final Pattern LOCALE_PATTERN = Pattern.compile("_([a-z]{2})(_([A-Z]{2})(_([^_]+))?)?$");
- private final static Set<String> isoCountries = new ConcurrentHashSet<String>(
+ private final static Set<String> isoCountries = new ConcurrentHashSet<>(
Arrays.asList(Locale.getISOCountries()));
- private final static Set<String> isoLanguages = new ConcurrentHashSet<String>(
+ private final static Set<String> isoLanguages = new ConcurrentHashSet<>(
Arrays.asList(Locale.getISOLanguages()));
/**
@@ -56,7 +56,7 @@ public class ResourceUtils
public static PathLocale getLocaleFromFilename(String path)
{
String extension = "";
- int pos = path.indexOf('.');
+ int pos = path.lastIndexOf('.');
if (pos != -1)
{
extension = path.substring(pos);
@@ -104,7 +104,7 @@ public class ResourceUtils
}
} // else skip the whole thing... probably user specific underscores used
- return new PathLocale(path, null);
+ return new PathLocale(path + extension, null);
}
/**
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5706_0f8a6d75.diff |
bugs-dot-jar_data_WICKET-4255_c250db9c | ---
BugID: WICKET-4255
Summary: bug in org.apache.wicket.validation.validator.UrlValidator
Description: |-
Looks like there is a bug in UrlValidator. It validates URLs like "http://testhost.local/pages/index.php" as invalid.
But URL is valid! Try to execute "new java.net.URL("http://testhost.local/pages/index.php");" for example. It does not throws "MalformedURLException" because URL is valid.
In method: UrlValidator.isValidAuthority() there is code: "if (topLevel.length() < 2 || topLevel.length() > 4){return false;}" Looks like this "> 4" is a wrong constraint.
diff --git a/wicket-core/src/main/java/org/apache/wicket/validation/validator/UrlValidator.java b/wicket-core/src/main/java/org/apache/wicket/validation/validator/UrlValidator.java
index 9cc917c..a259c51 100644
--- a/wicket-core/src/main/java/org/apache/wicket/validation/validator/UrlValidator.java
+++ b/wicket-core/src/main/java/org/apache/wicket/validation/validator/UrlValidator.java
@@ -427,7 +427,7 @@ public class UrlValidator implements IValidator<String>
if (segmentCount > 1)
{
String topLevel = domainSegment[segmentCount - 1];
- if (topLevel.length() < 2 || topLevel.length() > 4)
+ if (topLevel.length() < 2)
{
return false;
}
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-4255_c250db9c.diff |
bugs-dot-jar_data_WICKET-4548_9a6a06be | ---
BugID: WICKET-4548
Summary: NullPointerException in org.apache.wicket.markup.html.form.ValidationErrorFeedback
Description: |-
org.apache.wicket.markup.html.form.ValidationErrorFeedback throws a NPE in the following situation:
- Form with a TextField<Integer> that has a RangeValidator
- value outside range is entered
- form is submitted
See attached quickstart.
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/ValidationErrorFeedback.java b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/ValidationErrorFeedback.java
index f6e1ce7..48b8d0b 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/ValidationErrorFeedback.java
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/ValidationErrorFeedback.java
@@ -78,8 +78,6 @@ public class ValidationErrorFeedback implements IClusterable
@Override
public String toString()
{
- return "ValidationErrorFeedback{" +
- "message=" + message +
- '}';
+ return message != null ? message.toString() : "";
}
}
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-4548_9a6a06be.diff |
bugs-dot-jar_data_WICKET-4020_081cdeb2 | ---
BugID: WICKET-4020
Summary: ResourceMapper throws IllegalStateException when attempting to map a request
to a URL ending in a empty segment (directory)
Description: "ResourceMapper.mapRequest() calls ResourceMapper.removeCachingDecoration()
which, throws IllegalStateException if the URL's last segment is an empty string.\n\nURLs
like: path/to/my/non/wicket/directory/ end in a empty segment. \n\nWe must change
the behaviour to not attempt to undecorate a URL ending in an empty segment."
diff --git a/wicket-core/src/main/java/org/apache/wicket/request/mapper/ResourceMapper.java b/wicket-core/src/main/java/org/apache/wicket/request/mapper/ResourceMapper.java
index 9e15ba4..bc39efb 100644
--- a/wicket-core/src/main/java/org/apache/wicket/request/mapper/ResourceMapper.java
+++ b/wicket-core/src/main/java/org/apache/wicket/request/mapper/ResourceMapper.java
@@ -237,11 +237,23 @@ public class ResourceMapper extends AbstractMapper implements IRequestMapper
if (segments.isEmpty() == false)
{
+ // get filename (the last segment)
final int lastSegmentAt = segments.size() - 1;
- final ResourceUrl resourceUrl = new ResourceUrl(segments.get(lastSegmentAt), parameters);
+ String filename = segments.get(lastSegmentAt);
+
+ // ignore requests with empty filename
+ if(Strings.isEmpty(filename))
+ {
+ return;
+ }
+
+ // create resource url from filename and query parameters
+ final ResourceUrl resourceUrl = new ResourceUrl(filename, parameters);
+ // remove caching information from request
getCachingStrategy().undecorateUrl(resourceUrl);
+ // check for broken caching strategy (this must never happen)
if (Strings.isEmpty(resourceUrl.getFileName()))
{
throw new IllegalStateException("caching strategy returned empty name for " + resourceUrl);
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-4020_081cdeb2.diff |
bugs-dot-jar_data_WICKET-2569_9ced53a5 | ---
BugID: WICKET-2569
Summary: Inheritance layout excludes XML header from output
Description: |-
When using inheritance layout, if the superclass (Layout class) has an ?xml header at the top, it's excluded from the rendering of subclasses, if they have an associated html file. If the subclass has no .html file associated with it, the ?xml header is preserved in the rendering output.
To reproduce: Create a SuperPage class extending WebPage. At the top of SuperPage.html, put "<?xml version="1.0" encoding="utf-8"?>" . Create two subclasses of SuperPage, one with an HTML file and one without. View the sub pages. Notice when the one with an HTML file is rendered, the xml header is excluded.
Expected: The ?xml header should always be preserved in the rendered output as it's vital to the layout.
diff --git a/wicket/src/main/java/org/apache/wicket/markup/MergedMarkup.java b/wicket/src/main/java/org/apache/wicket/markup/MergedMarkup.java
index 1e686c2..c1194ff 100644
--- a/wicket/src/main/java/org/apache/wicket/markup/MergedMarkup.java
+++ b/wicket/src/main/java/org/apache/wicket/markup/MergedMarkup.java
@@ -63,6 +63,12 @@ public class MergedMarkup extends Markup
getMarkupResourceStream().setBaseMarkup(baseMarkup);
+ // Copy settings from derived markup
+ MarkupResourceStream baseResourceStream = baseMarkup.getMarkupResourceStream();
+ getMarkupResourceStream().setXmlDeclaration(baseResourceStream.getXmlDeclaration());
+ getMarkupResourceStream().setEncoding(baseResourceStream.getEncoding());
+ getMarkupResourceStream().setWicketNamespace(baseResourceStream.getWicketNamespace());
+
if (log.isDebugEnabled())
{
String derivedResource = Strings.afterLast(markup.getMarkupResourceStream()
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-2569_9ced53a5.diff |
bugs-dot-jar_data_WICKET-3098_1b7afefc | ---
BugID: WICKET-3098
Summary: AjaxEventBehavior#onEvent is invoked on disabled behavior
Description: |-
Security bug AjaxEventBehavior#onEvent is invoked on disabled behavior. It should not be - it is really dangerous, can you fix it.
I think it is security bug.
diff --git a/wicket/src/main/java/org/apache/wicket/RequestListenerInterface.java b/wicket/src/main/java/org/apache/wicket/RequestListenerInterface.java
index 06d4dcf..26282cc 100644
--- a/wicket/src/main/java/org/apache/wicket/RequestListenerInterface.java
+++ b/wicket/src/main/java/org/apache/wicket/RequestListenerInterface.java
@@ -255,6 +255,7 @@ public class RequestListenerInterface
{
log.warn("behavior not enabled; ignore call. Behavior {} at component {}", behavior,
component);
+ return;
}
try
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-3098_1b7afefc.diff |
bugs-dot-jar_data_WICKET-5964_86066852 | ---
BugID: WICKET-5964
Summary: Queuing a component within an enclosure
Description: "Queueing doesn't work if component is in a enclosure tag. \n\n<wicket:enclosure
child=\"inlink\">\n<a href=\"panier.html\">\n\t<span wicket:id=\"inlink\"></span>\n</a>\n</wicket:enclosure>"
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/internal/Enclosure.java b/wicket-core/src/main/java/org/apache/wicket/markup/html/internal/Enclosure.java
index 49d55c3..882a3ba 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/html/internal/Enclosure.java
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/internal/Enclosure.java
@@ -16,12 +16,17 @@
*/
package org.apache.wicket.markup.html.internal;
+import java.util.Iterator;
+
import org.apache.wicket.Component;
+import org.apache.wicket.DequeueContext;
import org.apache.wicket.MarkupContainer;
import org.apache.wicket.WicketRuntimeException;
import org.apache.wicket.markup.ComponentTag;
+import org.apache.wicket.markup.IMarkupFragment;
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.parser.filter.EnclosureHandler;
@@ -125,7 +130,7 @@ public class Enclosure extends WebMarkupContainer implements IComponentResolver
if (childComponent == null)
{
// try to find child when queued
- childComponent = get(childId);
+ childComponent = resolveChild(this);
}
if (childComponent == null)
{
@@ -134,6 +139,33 @@ public class Enclosure extends WebMarkupContainer implements IComponentResolver
}
return childComponent;
}
+
+ /**
+ * Searches for the controlling child component looking also
+ * through transparent components.
+ *
+ * @param container
+ * the current container
+ * @return the controlling child component, null if no one is found
+ */
+ private Component resolveChild(MarkupContainer container)
+ {
+ Component childController = container.get(childId);
+
+ Iterator<Component> children = container.iterator();
+
+ while (children.hasNext() && childController == null)
+ {
+ Component transparentChild = children.next();
+
+ if(transparentChild instanceof TransparentWebMarkupContainer)
+ {
+ childController = resolveChild((MarkupContainer)transparentChild);
+ }
+ }
+
+ return childController;
+ }
@Override
public boolean isVisible()
@@ -274,4 +306,16 @@ public class Enclosure extends WebMarkupContainer implements IComponentResolver
"Programming error: childComponent == enclose component; endless loop");
}
}
+
+ @Override
+ public DequeueContext newDequeueContext()
+ {
+ IMarkupFragment markup = getMarkupSourcingStrategy().getMarkup(this, null);
+ if (markup == null)
+ {
+ return null;
+ }
+
+ return new DequeueContext(markup, this, true);
+ }
}
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5964_86066852.diff |
bugs-dot-jar_data_WICKET-4755_87ae870f | ---
BugID: WICKET-4755
Summary: '"''NEW VALUE'' is not a valid Serializable" error during ajax form submission'
Description: |-
I attached a quickstart with a test in TestHomePage#formSubmitsSuccessfully.
The test throws "'NEW VALUE' is not a valid Serializable" error when "NEW VALUE" string in "value" textField is submitted as a part of myForm ajax submission.
The problem is that a call to Objects#convertValue(nonNullNonArrayValue, Object.class) will always return null if nonNullNonArrayValue is a value that is not null and not an array! Shouldn't it always return the first parameter when the second parameter is Object.class?
Sven on Wicket forum suggested to fix this as by adding another if-statement in Objects#convertValue() if (toType.isInstance(value)) {
result = toType.cast(value);
}
See the following forum thread for more information http://apache-wicket.1842946.n4.nabble.com/Issues-with-default-type-conversion-in-1-5-td4651857.html
diff --git a/wicket-core/src/main/java/org/apache/wicket/ConverterLocator.java b/wicket-core/src/main/java/org/apache/wicket/ConverterLocator.java
index 437ed8c..e2d9cc6 100644
--- a/wicket-core/src/main/java/org/apache/wicket/ConverterLocator.java
+++ b/wicket-core/src/main/java/org/apache/wicket/ConverterLocator.java
@@ -105,16 +105,19 @@ public class ConverterLocator implements IConverterLocator
{
return converted;
}
- else
+
+ if (theType.isInstance(value))
{
- throw new ConversionException("Could not convert value: " + value +
- " to type: " + theType.getName() + ". Could not find compatible converter.").setSourceValue(value);
+ return theType.cast(value);
}
}
catch (Exception e)
{
throw new ConversionException(e.getMessage(), e).setSourceValue(value);
}
+
+ throw new ConversionException("Could not convert value: " + value + " to type: " +
+ theType.getName() + ". Could not find compatible converter.").setSourceValue(value);
}
/**
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-4755_87ae870f.diff |
bugs-dot-jar_data_WICKET-5546_f1af9e03 | ---
BugID: WICKET-5546
Summary: Adding behavior in component instantiation listener causes Page.onInitialize()
being called even if constructor throws an exception
Description: "Page.onInitialize() will be called even if constructor throws an exception\nin
case below code is added in wicket WebApplication.init():\ngetComponentInstantiationListeners().add(new
IComponentInstantiationListener() {\n @Override\n public
void onInstantiation(Component component) {\n component.add(new
Behavior() {\n\n });\n }\n \n });\n\nIt
seems that the instantiation listener adds the behavior to the page at very start
of the page constructor, and then the page is marked as dirty to cause onInitialize()
being called afterwards."
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 c7d38f1..3ac6f59 100644
--- a/wicket-core/src/main/java/org/apache/wicket/Component.java
+++ b/wicket-core/src/main/java/org/apache/wicket/Component.java
@@ -680,6 +680,9 @@ public abstract class Component
public Component(final String id, final IModel<?> model)
{
setId(id);
+
+ init();
+
getApplication().getComponentInstantiationListeners().onInstantiation(this);
final DebugSettings debugSettings = getApplication().getDebugSettings();
@@ -696,6 +699,15 @@ public abstract class Component
}
/**
+ * Let subclasses initialize this instance, before constructors are executed. <br>
+ * This method is intentionally <b>not</b> declared protected, to limit overriding to classes in
+ * this package.
+ */
+ void init()
+ {
+ }
+
+ /**
* Get the Markup associated with the Component. If not subclassed, the parent container is
* asked to return the markup of this child component.
* <p/>
diff --git a/wicket-core/src/main/java/org/apache/wicket/Page.java b/wicket-core/src/main/java/org/apache/wicket/Page.java
index ea1dad2..0935942 100644
--- a/wicket-core/src/main/java/org/apache/wicket/Page.java
+++ b/wicket-core/src/main/java/org/apache/wicket/Page.java
@@ -177,7 +177,6 @@ public abstract class Page extends MarkupContainer
{
pageParameters = parameters;
}
- init();
}
/**
@@ -703,7 +702,8 @@ public abstract class Page extends MarkupContainer
/**
* Initializes Page by adding it to the Session and initializing it.
*/
- private void init()
+ @Override
+ void init()
{
if (isBookmarkable() == false)
{
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5546_f1af9e03.diff |
bugs-dot-jar_data_WICKET-4345_4f08e6f2 | ---
BugID: WICKET-4345
Summary: CryptoMapper does not work for applications having a home page that needs
query parameters
Description: "CryptoMapper.decryptUrl() should not return null for requests like http://myhost/MyApplication/app/?param=xx
\n\nAs a possible fix one can replace\n\nif (encryptedUrl.getSegments().isEmpty()
&& encryptedUrl.getQueryParameters().isEmpty()) {\n return encryptedUrl;\n}\n\nwith
\n\nif (encryptedUrl.getSegments().isEmpty()) {\n return encryptedUrl;\n}\n\nbut
I suspect that the original test is intended to answer to another use case... "
diff --git a/wicket-core/src/main/java/org/apache/wicket/request/mapper/CryptoMapper.java b/wicket-core/src/main/java/org/apache/wicket/request/mapper/CryptoMapper.java
index 417e9d0..a53ce24 100755
--- a/wicket-core/src/main/java/org/apache/wicket/request/mapper/CryptoMapper.java
+++ b/wicket-core/src/main/java/org/apache/wicket/request/mapper/CryptoMapper.java
@@ -152,7 +152,7 @@ public class CryptoMapper implements IRequestMapper
private Url decryptUrl(final Request request, final Url encryptedUrl)
{
- if (encryptedUrl.getSegments().isEmpty() && encryptedUrl.getQueryParameters().isEmpty())
+ if (encryptedUrl.getSegments().isEmpty())
{
return encryptedUrl;
}
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-4345_4f08e6f2.diff |
bugs-dot-jar_data_WICKET-4153_2737d7c7 | ---
BugID: WICKET-4153
Summary: The tbody section of a DataTable is empty when no records are returned by
the provider.
Description: |-
When a DataTable is rendered without records, the tbody section is empty. This violates the html spec.
From the 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."
and
"The THEAD, TFOOT, and TBODY sections must contain the same number of columns."
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 caa2f9e..f2e4618 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
@@ -204,7 +204,15 @@ public class DataTable<T> extends Panel implements IPageableItems
*/
protected WebMarkupContainer newBodyContainer(final String id)
{
- return new WebMarkupContainer(id);
+ return new WebMarkupContainer(id)
+ {
+ @Override
+ protected void onConfigure()
+ {
+ super.onConfigure();
+ setVisible(getRowCount() > 0);
+ }
+ };
}
/**
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-4153_2737d7c7.diff |
bugs-dot-jar_data_WICKET-3702_a08562a7 | ---
BugID: WICKET-3702
Summary: 'wicket:border: inconsistency between add() and remove()'
Description: |-
Assuming c1 is a Border and c2 is some component, the following sequence crashes with duplicate addition:
c1.add(c2);
c1.remove(c2);
c1.add(c2);
The reason for this is that remove() doesn't remove the object from the bodycontainer. The sequence can be made to work by changing the middle line to:
c1.getBodyContainer().remove(c2);
That remove() doesn't look the component from the same container as add() adds it to, seems to violate the principle of least astonishment. Unfortunately the Component structure manipulation API has more methods, such as swap(), size(), get(), etc. which are final, and can't be overridden by Border as they are. It could be best to force all users to use c1.getBodyContainer().add() instead of c1.add(), because consistent operation is probably easier to deal with in the long run than behavior that conforms to initial assumptions but has flaws elsewhere.
This ticket suggests removing the overload of add() and documenting the difference in migration guide.
diff --git a/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/repeater/data/table/HeadersToolbar.java b/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/repeater/data/table/HeadersToolbar.java
index 4fbeab2..9935c68 100644
--- a/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/repeater/data/table/HeadersToolbar.java
+++ b/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/repeater/data/table/HeadersToolbar.java
@@ -21,6 +21,7 @@ import java.util.List;
import org.apache.wicket.extensions.markup.html.repeater.data.sort.ISortStateLocator;
import org.apache.wicket.extensions.markup.html.repeater.data.sort.OrderByBorder;
import org.apache.wicket.markup.html.WebMarkupContainer;
+import org.apache.wicket.markup.html.border.Border;
import org.apache.wicket.markup.html.list.AbstractItem;
import org.apache.wicket.markup.repeater.RepeatingView;
@@ -87,7 +88,14 @@ public class HeadersToolbar extends AbstractToolbar
item.add(header);
item.setRenderBodyOnly(true);
- header.add(column.getHeader("label"));
+ if (header instanceof Border)
+ {
+ ((Border)header).addToBody(column.getHeader("label"));
+ }
+ else
+ {
+ header.add(column.getHeader("label"));
+ }
}
}
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-3702_a08562a7.diff |
bugs-dot-jar_data_WICKET-2506_0f8a2990 | ---
BugID: WICKET-2506
Summary: 'Regression: "Could not find child with id: <ID> in the wicket:enclosure"
for non-component tag'
Description: "Attached testcase passes with wicket-1.4.1 but fails with 1.4.2 saying:\n\norg.apache.wicket.WicketRuntimeException:
Could not find child with id: radio in the wicket:enclosure\n\tat org.apache.wicket.markup.html.internal.Enclosure.checkChildComponent(Enclosure.java:210)\n\tat
org.apache.wicket.markup.html.internal.Enclosure.ensureAllChildrenPresent(Enclosure.java:249)\n\tat
org.apache.wicket.markup.html.internal.Enclosure.onComponentTagBody(Enclosure.java:169)\n\tat
org.apache.wicket.Component.renderComponent(Component.java:2626)\n\tat org.apache.wicket.MarkupContainer.onRender(MarkupContainer.java:1512)\n\tat
org.apache.wicket.Component.render(Component.java:2457)\n\tat org.apache.wicket.MarkupContainer.autoAdd(MarkupContainer.java:229)\n\tat
org.apache.wicket.markup.resolver.EnclosureResolver.resolve(EnclosureResolver.java:61)\n\tat
org.apache.wicket.markup.resolver.ComponentResolvers.resolve(ComponentResolvers.java:81)\n\tat
org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java:1418)\n\tat org.apache.wicket.MarkupContainer.renderComponentTagBody(MarkupContainer.java:1577)\n\tat
org.apache.wicket.MarkupContainer.onComponentTagBody(MarkupContainer.java:1501)\n\tat
org.apache.wicket.Component.renderComponent(Component.java:2626)\n\tat org.apache.wicket.MarkupContainer.onRender(MarkupContainer.java:1512)\n\tat
org.apache.wicket.Component.render(Component.java:2457)\n\tat org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java:1414)\n\tat
org.apache.wicket.MarkupContainer.renderAll(MarkupContainer.java:1528)\n\tat org.apache.wicket.Page.onRender(Page.java:1545)\n\tat
org.apache.wicket.Component.render(Component.java:2457)\n\tat org.apache.wicket.Page.renderPage(Page.java:914)\n\tat
org.apache.wicket.request.target.component.BookmarkablePageRequestTarget.respond(BookmarkablePageRequestTarget.java:262)\n\tat
org.apache.wicket.request.AbstractRequestCycleProcessor.respond(AbstractRequestCycleProcessor.java:105)\n\tat
org.apache.wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:1258)\n\tat
org.apache.wicket.RequestCycle.step(RequestCycle.java:1329)\n\tat org.apache.wicket.RequestCycle.steps(RequestCycle.java:1428)\n\tat
org.apache.wicket.RequestCycle.request(RequestCycle.java:594)\n\tat org.apache.wicket.protocol.http.MockWebApplication.processRequestCycle(MockWebApplication.java:478)\n\tat
org.apache.wicket.protocol.http.MockWebApplication.processRequestCycle(MockWebApplication.java:390)\n\tat
org.apache.wicket.util.tester.BaseWicketTester.startPage(BaseWicketTester.java:300)\n\tat
org.apache.wicket.EnclosurePageTest.testRender(EnclosurePageTest.java:23)\n\tat
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\n\tat sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)\n\tat
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)\n\tat
java.lang.reflect.Method.invoke(Method.java:597)\n\tat junit.framework.TestCase.runTest(TestCase.java:154)\n\tat
junit.framework.TestCase.runBare(TestCase.java:127)\n\tat junit.framework.TestResult$1.protect(TestResult.java:106)\n\tat
junit.framework.TestResult.runProtected(TestResult.java:124)\n\tat junit.framework.TestResult.run(TestResult.java:109)\n\tat
junit.framework.TestCase.run(TestCase.java:118)\n\tat junit.framework.TestSuite.runTest(TestSuite.java:208)\n\tat
junit.framework.TestSuite.run(TestSuite.java:203)\n\tat sun.reflect.NativeMethodAccessorImpl.invoke0(Native
Method)\n\tat sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)\n\tat
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)\n\tat
java.lang.reflect.Method.invoke(Method.java:597)\n\tat org.apache.maven.surefire.junit.JUnitTestSet.execute(JUnitTestSet.java:213)\n\tat
org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140)\n\tat
org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127)\n\tat
org.apache.maven.surefire.Surefire.run(Surefire.java:177)\n\tat sun.reflect.NativeMethodAccessorImpl.invoke0(Native
Method)\n\tat sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)\n\tat
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)\n\tat
java.lang.reflect.Method.invoke(Method.java:597)\n\tat org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:345)\n\tat
org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1009)"
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 11d40a2..b90c80e 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
@@ -180,22 +180,36 @@ public class Enclosure extends WebMarkupContainer
}
}
+ /**
+ *
+ * @param container
+ * @param markupStream
+ * @param enclosureOpenTag
+ */
private void applyEnclosureVisibilityToChildren(final MarkupContainer container,
- final MarkupStream markupStream, ComponentTag enclosureOpenTag)
+ final MarkupStream markupStream, final ComponentTag enclosureOpenTag)
{
DirectChildTagIterator it = new DirectChildTagIterator(markupStream, enclosureOpenTag);
while (it.hasNext())
{
final ComponentTag tag = it.next();
- final Component child = container.get(tag.getId());
- // record original visiblity allowed value, will restore later
- changes.put(child, child.isVisibilityAllowed());
- child.setVisibilityAllowed(isVisible());
+ if (tag.isAutoComponentTag() == false)
+ {
+ final Component child = container.get(tag.getId());
+
+ // record original visiblity allowed value, will restore later
+ changes.put(child, child.isVisibilityAllowed());
+ child.setVisibilityAllowed(isVisible());
+ }
}
it.rewind();
}
- private void checkChildComponent(Component controller)
+ /**
+ *
+ * @param controller
+ */
+ private void checkChildComponent(final Component controller)
{
if (controller == null)
{
@@ -209,6 +223,12 @@ public class Enclosure extends WebMarkupContainer
}
}
+ /**
+ *
+ * @param container
+ * @param markupStream
+ * @param enclosureOpenTag
+ */
private void ensureAllChildrenPresent(final MarkupContainer container,
final MarkupStream markupStream, ComponentTag enclosureOpenTag)
{
@@ -217,43 +237,50 @@ public class Enclosure extends WebMarkupContainer
{
final ComponentTag tag = it.next();
- Component child = container.get(tag.getId());
- if (child == null)
+ if (tag.isAutoComponentTag() == false)
{
- // component does not yet exist in the container, attempt to resolve it using
- // resolvers
- final int tagIndex = it.getCurrentIndex();
-
- // because the resolvers can auto-add and therefore immediately render the component
- // we have to buffer the output since we do not yet know the visibility of the
- // enclosure
- CharSequence buffer = new ResponseBufferZone(getRequestCycle(), markupStream)
+ Component child = container.get(tag.getId());
+ if (child == null)
{
- @Override
- protected void executeInsideBufferedZone()
+ // component does not yet exist in the container, attempt to resolve it using
+ // resolvers
+ final int tagIndex = it.getCurrentIndex();
+
+ // because the resolvers can auto-add and therefore immediately render the
+ // component
+ // we have to buffer the output since we do not yet know the visibility of the
+ // enclosure
+ CharSequence buffer = new ResponseBufferZone(getRequestCycle(), markupStream)
+ {
+ @Override
+ protected void executeInsideBufferedZone()
+ {
+ markupStream.setCurrentIndex(tagIndex);
+ ComponentResolvers.resolve(container, markupStream, tag);
+ }
+ }.execute();
+
+ child = container.get(tag.getId());
+ checkChildComponent(child);
+
+ if (buffer.length() > 0)
{
- markupStream.setCurrentIndex(tagIndex);
- ComponentResolvers.resolve(container, markupStream, tag);
+ // we have already rendered this child component, insert a stub component
+ // that
+ // will dump the markup during the normal render process if the enclosure is
+ // visible
+ final Component stub = new AutoMarkupLabel(child.getId(), buffer);
+ container.replace(stub); // ok here because we are replacing auto with auto
}
- }.execute();
-
- child = container.get(tag.getId());
- checkChildComponent(child);
-
- if (buffer.length() > 0)
- {
- // we have already rendered this child component, insert a stub component that
- // will dump the markup during the normal render process if the enclosure is
- // visible
- final Component stub = new AutoMarkupLabel(child.getId(), buffer);
- container.replace(stub); // ok here because we are replacing auto with auto
}
}
}
it.rewind();
}
-
+ /**
+ * @see org.apache.wicket.Component#onDetach()
+ */
@Override
protected void onDetach()
{
@@ -261,6 +288,9 @@ public class Enclosure extends WebMarkupContainer
super.onDetach();
}
+ /**
+ *
+ */
private void restoreOriginalChildVisibility()
{
if (changes != null)
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-2506_0f8a2990.diff |
bugs-dot-jar_data_WICKET-3845_afc7034d | ---
BugID: WICKET-3845
Summary: support custom response headers in AbstractResource.ResourceResponse
Description: |
I'm converting an application to Wicket 1.5 and I see some problems with resources.
There is a case I need to add headers (not present in ResourceResponse properties) and it looks ugly.
This is what I need to do:
@Override
protected void configureCache(ResourceResponse data, Attributes attributes)
{
super.configureCache(data, attributes);
((WebResponse) attributes.getResponse()).setHeader("Accept-Ranges", "bytes");
}
It's a hack to use configureCache here, but this can't be added to setResponseHeaders, which seams a better apparent method name for it.
diff --git a/wicket-request/src/main/java/org/apache/wicket/request/HttpHeaderCollection.java b/wicket-request/src/main/java/org/apache/wicket/request/HttpHeaderCollection.java
index 3e97a1e..8e0cb55 100644
--- a/wicket-request/src/main/java/org/apache/wicket/request/HttpHeaderCollection.java
+++ b/wicket-request/src/main/java/org/apache/wicket/request/HttpHeaderCollection.java
@@ -99,7 +99,7 @@ public class HttpHeaderCollection
public void addHeader(String name, String value)
{
// be lenient and strip leading / trailing blanks
- value = Args.notEmpty(value, "value").trim();
+ value = Args.notNull(value, "value").trim();
internalAdd(name, value);
}
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-3845_afc7034d.diff |
bugs-dot-jar_data_WICKET-2060_0578d6ee | ---
BugID: WICKET-2060
Summary: Invalid javascript when setStripJavascriptCommentsAndWhitespace is enabled
Description: |-
When setStripJavascriptCommentsAndWhitespace is enabled (for example in deployment mode), some javascript files get corrupted. For example, the following line (notice the 2 spaces after 'return')
return this.__unbind__(type, fn);
is compacted to
return
this.__unbind__(type, fn);
which does not execute the unbind function.
diff --git a/wicket/src/main/java/org/apache/wicket/util/string/JavascriptStripper.java b/wicket/src/main/java/org/apache/wicket/util/string/JavascriptStripper.java
index e21e9d4..10d05a2 100644
--- a/wicket/src/main/java/org/apache/wicket/util/string/JavascriptStripper.java
+++ b/wicket/src/main/java/org/apache/wicket/util/string/JavascriptStripper.java
@@ -19,7 +19,7 @@ package org.apache.wicket.util.string;
/**
* Strips comments and whitespace from javascript
- *
+ *
* @author Matej Knopp
*/
public class JavascriptStripper
@@ -68,7 +68,7 @@ public class JavascriptStripper
/**
* Removes javascript comments and whitespace from specified string.
- *
+ *
* @param original
* Source string
* @return String with removed comments and whitespace
@@ -78,6 +78,7 @@ public class JavascriptStripper
// let's be optimistic
AppendingStringBuffer result = new AppendingStringBuffer(original.length() / 2);
int state = REGULAR_TEXT;
+ boolean wasNewLineInWhitespace = false;
for (int i = 0; i < original.length(); ++i)
{
@@ -87,6 +88,12 @@ public class JavascriptStripper
if (state == WHITE_SPACE)
{
+ // WICKET 2060
+ if (c == '\n' && !wasNewLineInWhitespace)
+ {
+ result.append("\n");
+ wasNewLineInWhitespace = true;
+ }
if (Character.isWhitespace(next) == false)
{
state = REGULAR_TEXT;
@@ -123,7 +130,7 @@ public class JavascriptStripper
continue;
}
if (tmp == '=' || tmp == '(' || tmp == '{' || tmp == ':' || tmp == ',' ||
- tmp == '[')
+ tmp == '[' || tmp == ';')
{
state = REG_EXP;
break;
@@ -133,9 +140,18 @@ public class JavascriptStripper
}
else if (Character.isWhitespace(c) && Character.isWhitespace(next))
{
+ // WICKET-2060
+ if (c == '\n' || next == '\n')
+ {
+ c = '\n';
+ wasNewLineInWhitespace = true;
+ }
+ else
+ {
+ c = ' ';
+ }
// ignore all whitespace characters after this one
state = WHITE_SPACE;
- c = '\n';
}
else if (c == '\'')
{
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-2060_0578d6ee.diff |
bugs-dot-jar_data_WICKET-5442_a382917f | ---
BugID: WICKET-5442
Summary: TimeOfDay.valueOf(Calendar, Time) and TimeOfDay.valueOf(Time) incorrectly
use 12-hour clock
Description: |-
TimeOfDay.valueOf(Calendar, Time) is implemented as:
return militaryTime(time.getHour(calendar), time.getMinute(calendar), time.getSecond(calendar));
This is flawed because Time.getHour() is implemented as:
return get(calendar, Calendar.HOUR);
and Calendar.HOUR is for the 12-hour clock. The result is that TimeOfDay.valueOf(Calendar, Time) incorrectly only returns 12-hour results, not 24-hour results. This affects TimeOfDay.valueOf(Time) as well since it is implemented in terms of the previously-named method.
One fix would be to change Time.getHour() to use Calendar.HOUR_OF_DAY. Since Time doesn't have an am/pm indicator this seems reasonable. An alternate, more localized fix would be to change TimeOfDay.valueOf(Calendar, Time) to call time.get(Calendar.HOUR_OF_DAY) to get the hour value.
diff --git a/wicket-util/src/main/java/org/apache/wicket/util/time/Time.java b/wicket-util/src/main/java/org/apache/wicket/util/time/Time.java
index cc5f630..2aac2be 100755
--- a/wicket-util/src/main/java/org/apache/wicket/util/time/Time.java
+++ b/wicket-util/src/main/java/org/apache/wicket/util/time/Time.java
@@ -349,7 +349,7 @@ public final class Time extends AbstractTime
*/
public int getHour(final Calendar calendar)
{
- return get(calendar, Calendar.HOUR);
+ return get(calendar, Calendar.HOUR_OF_DAY);
}
/**
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5442_a382917f.diff |
bugs-dot-jar_data_WICKET-4099_1dcaec98 | ---
BugID: WICKET-4099
Summary: SmartLinkLabel doesn't recognize already tagged links
Description: "The SmartLinkLabel works as expected for the texts without <a>..</a>
tag. \nfor text like\nextensions @ http://www.wicketframework.org/wicket-extensions/index.html
are cool!!\nSmartLinkLabel generates the html - \nextensions @ <a href=\"http://www.wicketframework.org/wicket-extensions/index.html\">http://www.wicketframework.org/wicket-extensions/index.html</a>
are cool!!\n\nbut for the text like\nextensions @ <a href='http://www.wicketframework.org/wicket-extensions/index.html'>http://www.wicketframework.org/wicket-extensions/index.html</a>
are cool!!\nSmartLinkLabel generates the html - \nextensions @ <a href='<a href=\"http://www.wicketframework.org/wicket-extensions/index.html\">http://www.wicketframework.org/wicket-extensions/index.html</a>'><a
href=\"http://www.wicketframework.org/wicket-extensions/index.html\">http://www.wicketframework.org/wicket-extensions/index.html</a></a>
are cool!!\n\nI think this is a bug & needs a fix.\n"
diff --git a/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/basic/LinkParser.java b/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/basic/LinkParser.java
index ff1aa1b..8cf4356 100644
--- a/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/basic/LinkParser.java
+++ b/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/basic/LinkParser.java
@@ -62,19 +62,24 @@ public class LinkParser implements ILinkParser
}
String work = text;
- for (String pattern : renderStrategies.keySet())
- {
- ILinkRenderStrategy strategy = renderStrategies.get(pattern);
- Matcher matcher = Pattern.compile(pattern, Pattern.DOTALL).matcher(work);
- StringBuffer buffer = new StringBuffer();
- while (matcher.find())
+ // don't try to parse markup. just plain text. WICKET-4099
+ if (work.indexOf('<') == -1)
+ {
+ for (String pattern : renderStrategies.keySet())
{
- String str = matcher.group();
- matcher.appendReplacement(buffer, strategy.buildLink(str));
+ ILinkRenderStrategy strategy = renderStrategies.get(pattern);
+
+ Matcher matcher = Pattern.compile(pattern, Pattern.DOTALL).matcher(work);
+ StringBuffer buffer = new StringBuffer();
+ while (matcher.find())
+ {
+ String str = matcher.group();
+ matcher.appendReplacement(buffer, strategy.buildLink(str));
+ }
+ matcher.appendTail(buffer);
+ work = buffer.toString();
}
- matcher.appendTail(buffer);
- work = buffer.toString();
}
return work;
}
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-4099_1dcaec98.diff |
bugs-dot-jar_data_WICKET-3511_4a875f46 | ---
BugID: WICKET-3511
Summary: Mapping ResourceReferences to Urls is slow
Description: |
PackageResourceReference is often used for stylesheets and JavaScript resources, many of which can appear on a typical page (WicketAjaxReference is one common example). Every time the page is rendered, these resources are mapped to urls in order to build the appropriate <link href="..."> or <script src="..."> tags.
The trouble is that this mapping process is extremely inefficient. To map a ResourceReference to a url, ResourceReference#getLastModified() must be consulted for FilenameWithTimestampResourceCachingStrategy, and ResourceReference#getUrlAttributes() is called to append appropriate query parameters.
In PackageResourceReference, both of these methods delegate to the very expensive PackageResourceReference#lookupStream(), which makes several attempts to locate the underlying file or classpath item using various permutations of locale, style, and variation. Each of these attempts involves I/O. The default ResourceStreamLocator, which does the actual file and classpath queries, does no caching whatsoever.
On a trivial Wicket page containing 7 total PackageResourceReferences for images, stylesheets and JavaScript files, the average response time in my tests was 211 ms. The vast majority of that time was spent in ResourceStreamLocator, due to the expensive steps described above.
It seems that putting caching at the ResourceStreamLocator would be extremely beneficial. I am attaching a simple implementation. With caching enabled in ResourceStreamLocator, the response time of my test page dropped from 211 ms to 49 ms.
diff --git a/wicket-core/src/main/java/org/apache/wicket/util/resource/locator/CachingResourceStreamLocator.java b/wicket-core/src/main/java/org/apache/wicket/util/resource/locator/CachingResourceStreamLocator.java
index 08f5b26..dba4976 100644
--- a/wicket-core/src/main/java/org/apache/wicket/util/resource/locator/CachingResourceStreamLocator.java
+++ b/wicket-core/src/main/java/org/apache/wicket/util/resource/locator/CachingResourceStreamLocator.java
@@ -22,6 +22,7 @@ import java.util.Locale;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
+import org.apache.wicket.WicketRuntimeException;
import org.apache.wicket.request.resource.ResourceReference.Key;
import org.apache.wicket.util.file.File;
import org.apache.wicket.util.lang.Args;
@@ -49,7 +50,7 @@ public class CachingResourceStreamLocator implements IResourceStreamLocator
*/
private static interface IResourceStreamReference
{
- String getReference();
+ IResourceStream getReference();
}
/**
@@ -61,7 +62,7 @@ public class CachingResourceStreamLocator implements IResourceStreamLocator
{
private final static NullResourceStreamReference INSTANCE = new NullResourceStreamReference();
- public String getReference()
+ public IResourceStream getReference()
{
return null;
}
@@ -79,9 +80,9 @@ public class CachingResourceStreamLocator implements IResourceStreamLocator
this.fileName = fileName;
}
- public String getReference()
+ public FileResourceStream getReference()
{
- return fileName;
+ return new FileResourceStream(new File(fileName));
}
}
@@ -97,9 +98,18 @@ public class CachingResourceStreamLocator implements IResourceStreamLocator
this.url = url;
}
- public String getReference()
+ public UrlResourceStream getReference()
{
- return url;
+ try
+ {
+ return new UrlResourceStream(new URL(url));
+ }
+ catch (MalformedURLException e)
+ {
+ // should not ever happen. The cached url is created by previously existing URL
+ // instance
+ throw new WicketRuntimeException(e);
+ }
}
}
@@ -133,16 +143,21 @@ public class CachingResourceStreamLocator implements IResourceStreamLocator
public IResourceStream locate(Class<?> clazz, String path)
{
Key key = new Key(clazz.getName(), path, null, null, null);
- IResourceStream resourceStream = getCopyFromCache(key);
+ IResourceStreamReference resourceStreamReference = cache.get(key);
- if (resourceStream == null)
+ final IResourceStream result;
+ if (resourceStreamReference == null)
{
- resourceStream = delegate.locate(clazz, path);
+ result = delegate.locate(clazz, path);
- updateCache(key, resourceStream);
+ updateCache(key, result);
+ }
+ else
+ {
+ result = resourceStreamReference.getReference();
}
- return resourceStream;
+ return result;
}
private void updateCache(Key key, IResourceStream stream)
@@ -165,60 +180,25 @@ public class CachingResourceStreamLocator implements IResourceStreamLocator
}
}
- /**
- * Make a copy before returning an item from the cache as resource streams are not thread-safe.
- *
- * @param key
- * the cache key
- * @return the cached File or Url resource stream
- */
- private IResourceStream getCopyFromCache(Key key)
- {
- final IResourceStreamReference orig = cache.get(key);
- if (NullResourceStreamReference.INSTANCE == orig)
- {
- return null;
- }
-
- if (orig instanceof UrlResourceStreamReference)
- {
- UrlResourceStreamReference resourceStreamReference = (UrlResourceStreamReference)orig;
- String url = resourceStreamReference.getReference();
- try
- {
- return new UrlResourceStream(new URL(url));
- }
- catch (MalformedURLException e)
- {
- return null;
- }
- }
-
- if (orig instanceof FileResourceStreamReference)
- {
- FileResourceStreamReference resourceStreamReference = (FileResourceStreamReference)orig;
- String absolutePath = resourceStreamReference.getReference();
- return new FileResourceStream(new File(absolutePath));
- }
-
- return null;
- }
-
public IResourceStream locate(Class<?> scope, String path, String style, String variation,
Locale locale, String extension, boolean strict)
{
Key key = new Key(scope.getName(), path, locale, style, variation);
- IResourceStream resourceStream = getCopyFromCache(key);
+ IResourceStreamReference resourceStreamReference = cache.get(key);
- if (resourceStream == null)
+ final IResourceStream result;
+ if (resourceStreamReference == null)
{
- resourceStream = delegate.locate(scope, path, style, variation, locale, extension,
- strict);
+ result = delegate.locate(scope, path, style, variation, locale, extension, strict);
- updateCache(key, resourceStream);
+ updateCache(key, result);
+ }
+ else
+ {
+ result = resourceStreamReference.getReference();
}
- return resourceStream;
+ return result;
}
public ResourceNameIterator newResourceNameIterator(String path, Locale locale, String style,
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-3511_4a875f46.diff |
bugs-dot-jar_data_WICKET-2261_089303f4 | ---
BugID: WICKET-2261
Summary: wicketTester.executeAjaxEvent(combo, "onchange"); works with 1.4-rc1 but
not anymore with 1.4-rc2
Description: Try the attached Unit Test.
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 59e69e0..bde3d67 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
@@ -544,7 +544,22 @@ public class MockWebApplication
cycle = createRequestCycle();
cycle.request();
}
+ else
+ {
+ String url = httpResponse.getHeader("Ajax-Location");
+ if (url != null)
+ {
+ MockHttpServletRequest newHttpRequest = new MockHttpServletRequest(application,
+ servletSession, application.getServletContext());
+ newHttpRequest.setRequestToRedirectString(url);
+ wicketRequest = application.newWebRequest(newHttpRequest);
+
+ cycle = createRequestCycle();
+ cycle.request();
+ }
+ }
}
+
lastRenderedPage = generateLastRenderedPage(cycle);
Session.set(getWicketSession());
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-2261_089303f4.diff |
bugs-dot-jar_data_WICKET-3297_71499e17 | ---
BugID: WICKET-3297
Summary: UrlAttributes are encoded incorrectly when style is null but variation is
not
Description: |-
AbstractResourceReferenceMapper.encodeResourceReferenceAttributes() method generates the same "-foo" output for these two different inputs: {locale = null, style = "foo", variation = null} and {locale = null, style = null, variation = "foo"}.
For the second input it should generate "--foo" (double dash prefix).
diff --git a/wicket-core/src/main/java/org/apache/wicket/request/mapper/AbstractResourceReferenceMapper.java b/wicket-core/src/main/java/org/apache/wicket/request/mapper/AbstractResourceReferenceMapper.java
index b0b40ec..ce4896c 100644
--- a/wicket-core/src/main/java/org/apache/wicket/request/mapper/AbstractResourceReferenceMapper.java
+++ b/wicket-core/src/main/java/org/apache/wicket/request/mapper/AbstractResourceReferenceMapper.java
@@ -47,14 +47,22 @@ public abstract class AbstractResourceReferenceMapper extends AbstractComponentM
{
res.append(attributes.getLocale().toString());
}
- if (!Strings.isEmpty(attributes.getStyle()))
+ boolean styleEmpty = Strings.isEmpty(attributes.getStyle());
+ if (!styleEmpty)
{
- res.append("-");
+ res.append('-');
res.append(attributes.getStyle());
}
if (!Strings.isEmpty(attributes.getVariation()))
{
- res.append("-");
+ if (styleEmpty)
+ {
+ res.append("--");
+ }
+ else
+ {
+ res.append('-');
+ }
res.append(attributes.getVariation());
}
return res.toString();
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-3297_71499e17.diff |
bugs-dot-jar_data_WICKET-4323_e24874da | ---
BugID: WICKET-4323
Summary: StringResourceModels doesn't seem to detach properly
Description: |-
If a StringResourceModel contains a model for property substitutions, and there has not been assigned a component it is relative to on construction time, it will not detach the property substitution model.
See this thread for a full explanation
http://apache-wicket.1842946.n4.nabble.com/StringResourceModels-doesn-t-seem-to-detach-properly-td4257267.html
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 fe74c2f..573a162 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
@@ -233,6 +233,15 @@ public class StringResourceModel extends LoadableDetachableModel<String>
}
@Override
+ protected void onDetach()
+ {
+ if (StringResourceModel.this.component == null)
+ {
+ StringResourceModel.this.onDetach();
+ }
+ }
+
+ @Override
protected String load()
{
if (StringResourceModel.this.component != null)
@@ -582,6 +591,8 @@ public class StringResourceModel extends LoadableDetachableModel<String>
@Override
protected final void onDetach()
{
+ super.onDetach();
+
// detach any model
if (model != null)
{
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-4323_e24874da.diff |
bugs-dot-jar_data_WICKET-4594_556a2236 | ---
BugID: WICKET-4594
Summary: Do not use the parsed PageParameters when re-creating an expired page
Description: |-
WICKET-4014 and WICKET-4290 provided functionality to re-create an expired page if there is a mount path in the current request's url.
There is a minor problem with that because the page parameters are passed to the freshly created page. I.e. parameters for a callback behavior are now set as page construction parameters.
Since the execution of the behavior is ignored for the recreated page these parameters should be ignored too.
diff --git a/wicket-core/src/main/java/org/apache/wicket/core/request/handler/PageProvider.java b/wicket-core/src/main/java/org/apache/wicket/core/request/handler/PageProvider.java
index 50402f6..a5ae4f2 100644
--- a/wicket-core/src/main/java/org/apache/wicket/core/request/handler/PageProvider.java
+++ b/wicket-core/src/main/java/org/apache/wicket/core/request/handler/PageProvider.java
@@ -265,7 +265,17 @@ public class PageProvider implements IPageProvider
{
if (pageClass != null)
{
- page = getPageSource().newPageInstance(pageClass, pageParameters);
+ PageParameters parameters;
+ if (pageId != null)
+ {
+ // WICKET-4594 - re-creating an expired page. Ignore the parsed parameters for the callback url
+ parameters = new PageParameters();
+ }
+ else
+ {
+ parameters = pageParameters;
+ }
+ page = getPageSource().newPageInstance(pageClass, parameters);
freshCreated = true;
}
}
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-4594_556a2236.diff |
bugs-dot-jar_data_WICKET-1677_01a3dd66 | ---
BugID: WICKET-1677
Summary: AjaxFormChoiceComponentUpdatingBehavior affects checkboxes even if component
uses radios and vice-versa
Description: "I have a form with two radio buttons. Depending which radio the user
selects, I show one form or another form. I'm using an AjaxFormChoiceComponentUpdatingBehavior
attached to the RadioGroup. One of the forms has a checkbox. The checkbox triggers
an ajax update--even though the AjaxFormChoiceComponentUpdatingBehavior is attached
to a RadioGroup. AjaxFormChoiceComponentUpdatingBehavior should only affect the
appropriate controls based on whether it is attached to a choice component that
uses radios or checkboxes. If a developer really wants both, then he can use two
AjaxFormChoiceComponentUpdatingBehavior instances.\n\nI've attached a patch. "
diff --git a/wicket/src/main/java/org/apache/wicket/ajax/form/AjaxFormChoiceComponentUpdatingBehavior.java b/wicket/src/main/java/org/apache/wicket/ajax/form/AjaxFormChoiceComponentUpdatingBehavior.java
index ce38a7c..f8f2e50 100644
--- a/wicket/src/main/java/org/apache/wicket/ajax/form/AjaxFormChoiceComponentUpdatingBehavior.java
+++ b/wicket/src/main/java/org/apache/wicket/ajax/form/AjaxFormChoiceComponentUpdatingBehavior.java
@@ -33,6 +33,9 @@ import org.apache.wicket.util.string.AppendingStringBuffer;
* <p>
* Use the normal {@link AjaxFormChoiceComponentUpdatingBehavior} for the normal single component
* fields
+ * <p>
+ * In order to be supported by this behavior the group components must output children with markup
+ * id in format of 'groupId-childId'
*
* @author jcompagner
*
@@ -67,6 +70,7 @@ public abstract class AjaxFormChoiceComponentUpdatingBehavior extends AbstractDe
asb.append(" for (var i = 0 ; i < inputNodes.length ; i ++) {\n");
asb.append(" var inputNode = inputNodes[i];\n");
asb.append(" if (!inputNode.type) continue;\n");
+ asb.append(" if (!(inputNode.id.indexOf(markupId+'-')===0)) continue;\n");
asb.append(" var inputType = inputNode.type.toLowerCase();\n");
asb.append(" if (inputType == 'checkbox' || inputType == 'radio') {\n");
asb.append(" Wicket.Event.add(inputNode, 'click', callbackScript);\n");
diff --git a/wicket/src/main/java/org/apache/wicket/markup/html/form/Check.java b/wicket/src/main/java/org/apache/wicket/markup/html/form/Check.java
index 7ebf5c3..c74b293 100644
--- a/wicket/src/main/java/org/apache/wicket/markup/html/form/Check.java
+++ b/wicket/src/main/java/org/apache/wicket/markup/html/form/Check.java
@@ -94,6 +94,7 @@ public class Check<T> extends LabeledWebMarkupContainer
{
super(id, model);
this.group = group;
+ setOutputMarkupId(true);
}
@@ -112,6 +113,32 @@ public class Check<T> extends LabeledWebMarkupContainer
return "check" + uuid;
}
+ @SuppressWarnings("unchecked")
+ private CheckGroup<T> getGroup()
+ {
+ CheckGroup<T> group = this.group;
+ if (group == null)
+ {
+ group = findParent(CheckGroup.class);
+ if (group == null)
+ {
+ throw new WicketRuntimeException("Check component [" + getPath() +
+ "] cannot find its parent CheckGroup");
+ }
+ }
+ return group;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ protected void onBeforeRender()
+ {
+ // prefix markup id of this radio with its group's id
+ // this will make it easier to identify all radios that belong to a specific group
+ setMarkupId(getGroup().getMarkupId() + "-" + getMarkupId());
+ super.onBeforeRender();
+ }
+
/**
* @see Component#onComponentTag(ComponentTag)
@@ -128,16 +155,7 @@ public class Check<T> extends LabeledWebMarkupContainer
checkComponentTag(tag, "input");
checkComponentTagAttribute(tag, "type", "checkbox");
- CheckGroup<?> group = this.group;
- if (group == null)
- {
- group = findParent(CheckGroup.class);
- if (group == null)
- {
- throw new WicketRuntimeException("Check component [" + getPath() +
- "] cannot find its parent CheckGroup");
- }
- }
+ CheckGroup<?> group = getGroup();
final String uuid = getValue();
diff --git a/wicket/src/main/java/org/apache/wicket/markup/html/form/CheckBoxMultipleChoice.java b/wicket/src/main/java/org/apache/wicket/markup/html/form/CheckBoxMultipleChoice.java
index e52fe46..65dab2f 100644
--- a/wicket/src/main/java/org/apache/wicket/markup/html/form/CheckBoxMultipleChoice.java
+++ b/wicket/src/main/java/org/apache/wicket/markup/html/form/CheckBoxMultipleChoice.java
@@ -411,7 +411,7 @@ public class CheckBoxMultipleChoice<T> extends ListMultipleChoice<T>
buffer.append(getPrefix());
String id = getChoiceRenderer().getIdValue(choice, index);
- final String idAttr = getInputName() + "_" + id;
+ final String idAttr = getMarkupId() + "-" + getInputName() + "_" + id;
// Add checkbox element
buffer.append("<input name=\"")
diff --git a/wicket/src/main/java/org/apache/wicket/markup/html/form/Radio.java b/wicket/src/main/java/org/apache/wicket/markup/html/form/Radio.java
index 130c2d9..0788018 100644
--- a/wicket/src/main/java/org/apache/wicket/markup/html/form/Radio.java
+++ b/wicket/src/main/java/org/apache/wicket/markup/html/form/Radio.java
@@ -91,6 +91,7 @@ public class Radio<T> extends LabeledWebMarkupContainer
{
super(id, model);
this.group = group;
+ setOutputMarkupId(true);
}
@@ -109,6 +110,34 @@ public class Radio<T> extends LabeledWebMarkupContainer
return "radio" + uuid;
}
+ /** {@inheritDoc} */
+ @Override
+ protected void onBeforeRender()
+ {
+ // prefix markup id of this radio with its group's id
+ // this will make it easier to identify all radios that belong to a specific group
+ setMarkupId(getGroup().getMarkupId() + "-" + getMarkupId());
+ super.onBeforeRender();
+ }
+
+
+ @SuppressWarnings("unchecked")
+ private RadioGroup<T> getGroup()
+ {
+ RadioGroup<T> group = this.group;
+ if (group == null)
+ {
+ group = findParent(RadioGroup.class);
+ if (group == null)
+ {
+ throw new WicketRuntimeException(
+ "Radio component [" +
+ getPath() +
+ "] cannot find its parent RadioGroup. All Radio components must be a child of or below in the hierarchy of a RadioGroup component.");
+ }
+ }
+ return group;
+ }
/**
* @see Component#onComponentTag(ComponentTag)
@@ -127,19 +156,7 @@ public class Radio<T> extends LabeledWebMarkupContainer
final String value = getValue();
- RadioGroup<?> group = this.group;
- if (group == null)
- {
- group = findParent(RadioGroup.class);
- if (group == null)
- {
- throw new WicketRuntimeException(
- "Radio component [" +
- getPath() +
- "] cannot find its parent RadioGroup. All Radio components must be a child of or below in the hierarchy of a RadioGroup component.");
- }
- }
-
+ RadioGroup<?> group = getGroup();
// assign name and value
tag.put("name", group.getInputName());
diff --git a/wicket/src/main/java/org/apache/wicket/markup/html/form/RadioChoice.java b/wicket/src/main/java/org/apache/wicket/markup/html/form/RadioChoice.java
index 2b762e2..cf1d867 100644
--- a/wicket/src/main/java/org/apache/wicket/markup/html/form/RadioChoice.java
+++ b/wicket/src/main/java/org/apache/wicket/markup/html/form/RadioChoice.java
@@ -450,7 +450,7 @@ public class RadioChoice<T> extends AbstractSingleSelectChoice<T> implements IOn
buffer.append(getPrefix());
String id = getChoiceRenderer().getIdValue(choice, index);
- final String idAttr = getMarkupId() + "_" + id;
+ final String idAttr = getMarkupId() + "-" + id;
boolean enabled = isEnabledInHierarchy() && !isDisabled(choice, index, selected);
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-1677_01a3dd66.diff |
bugs-dot-jar_data_WICKET-5497_724066f4 | ---
BugID: WICKET-5497
Summary: NPE in JsonUtils when the value is null
Description: |-
Most part of org.apache.wicket.ajax.json.JsonUtils.asArray(Map<String, Object> map) is trying carefully avoid null value. But there is following line
else if (value.getClass().isArray())
which cause NPE in case of empty value for some key.
P.S. Will provide patch.
diff --git a/wicket-core/src/main/java/org/apache/wicket/ajax/json/JsonUtils.java b/wicket-core/src/main/java/org/apache/wicket/ajax/json/JsonUtils.java
index f4b8a9b..ece4997 100644
--- a/wicket-core/src/main/java/org/apache/wicket/ajax/json/JsonUtils.java
+++ b/wicket-core/src/main/java/org/apache/wicket/ajax/json/JsonUtils.java
@@ -58,23 +58,23 @@ public final class JsonUtils
}
}
}
- else if (value.getClass().isArray())
+ else if (value != null)
{
- Object[] array = (Object[]) value;
- for (Object v : array)
+ if (value.getClass().isArray())
{
- if (v != null)
+ Object[] array = (Object[]) value;
+ for (Object v : array)
{
- JSONObject object = new JSONObject();
- object.put("name", name);
- object.put("value", v);
- jsonArray.put(object);
+ if (v != null)
+ {
+ JSONObject object = new JSONObject();
+ object.put("name", name);
+ object.put("value", v);
+ jsonArray.put(object);
+ }
}
}
- }
- else
- {
- if (value != null)
+ else
{
JSONObject object = new JSONObject();
object.put("name", name);
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5497_724066f4.diff |
bugs-dot-jar_data_WICKET-3428_ffc0cae9 | ---
BugID: WICKET-3428
Summary: 'IRequestCycleListener: RequestCycle.get() is null inside onBeginRequest'
Description: |-
I expect the request cycle that is supplied as an argument to onBeginRequest to be the same as RequestCycle.get.
== == == CODE == == ==
@Override
public void onBeginRequest(RequestCycle cycle) {
Session session = Session.get(); // throws IllegalArgumentException
if (session.getMetaData(REDIRECTED_JSESSIONID) == null) {
logger.debug("first application request - redirecting to loading page");
session.setMetaData(REDIRECTED_JSESSIONID, Boolean.TRUE);
String url = getServletRequestContextPath() + "/" + cycle.getRequest().getUrl();
throw new RestartResponseException(newLoadingPage(url));
}
}
== == == == == == == ==
== == == STACK TRACE == == ==
java.lang.IllegalArgumentException: Argument 'requestCycle' may not be null.
at org.apache.wicket.util.lang.Args.notNull(Args.java:37)
at org.apache.wicket.Application.fetchCreateAndSetSession(Application.java:1436)
at org.apache.wicket.Session.get(Session.java:154)
at com.joynit.tuv.common.view.request.SessionIdRemoveListener.onBeginRequest(SessionIdRemoveListener.java:30)
... [snipped -other part is not relevant]
== == == == == == == == == == ==
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 81923b6..4c93370 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
@@ -199,6 +199,8 @@ public class RequestCycle extends RequestHandlerStack implements IRequestCycle,
try
{
set(this);
+ listeners.onBeginRequest(this);
+ onBeginRequest();
IRequestHandler handler = resolveRequestHandler();
if (handler != null)
{
@@ -242,8 +244,6 @@ public class RequestCycle extends RequestHandlerStack implements IRequestCycle,
boolean result;
try
{
- listeners.onBeginRequest(this);
- onBeginRequest();
result = processRequest();
}
finally
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-3428_ffc0cae9.diff |
bugs-dot-jar_data_WICKET-4511_4ee5ad1f | ---
BugID: WICKET-4511
Summary: Stack overflow when render malformed html.
Description: "Stack overflow when render malformed html.\n\nPlease, note that </HEAD>
element is inserted after </body>.\n\nHTML:\n<html>\n<head>\n<body>\nMalformed HTML\n</body>\n</head>\n</html>\n\nJava:\npackage
com.mycompany;\n\nimport org.apache.wicket.markup.html.WebPage;\npublic class Test1
extends WebPage {\n\tprivate static final long serialVersionUID = -4267477971499123852L;\n\n}\n\n\nThanks."
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 5d7cd84..1b2ac8e 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
@@ -21,6 +21,8 @@ import java.text.ParseException;
import org.apache.wicket.markup.ComponentTag;
import org.apache.wicket.markup.Markup;
import org.apache.wicket.markup.MarkupElement;
+import org.apache.wicket.markup.MarkupException;
+import org.apache.wicket.markup.MarkupStream;
import org.apache.wicket.markup.parser.AbstractMarkupFilter;
import org.apache.wicket.markup.parser.XmlTag.TagType;
@@ -46,6 +48,9 @@ public final class HtmlHeaderSectionHandler extends AbstractMarkupFilter
/** True if <head> has been found already */
private boolean foundHead = false;
+ /** True if </head> has been found already */
+ private boolean foundClosingHead = false;
+
/** True if all the rest of the markup file can be ignored */
private boolean ignoreTheRest = false;
@@ -78,15 +83,20 @@ public final class HtmlHeaderSectionHandler extends AbstractMarkupFilter
if (tag.getNamespace() == null)
{
// we found <head>
- if (tag.isClose())
+ if (tag.isOpen())
{
foundHead = true;
+
+ if (tag.getId() == null)
+ {
+ tag.setId(HEADER_ID);
+ tag.setAutoComponentTag(true);
+ tag.setModified(true);
+ }
}
- else if (tag.getId() == null)
+ else if (tag.isClose())
{
- tag.setId(HEADER_ID);
- tag.setAutoComponentTag(true);
- tag.setModified(true);
+ foundClosingHead = true;
}
return tag;
@@ -95,10 +105,18 @@ public final class HtmlHeaderSectionHandler extends AbstractMarkupFilter
{
// we found <wicket:head>
foundHead = true;
+ foundClosingHead = true;
}
}
else if (BODY.equalsIgnoreCase(tag.getName()) && (tag.getNamespace() == null))
{
+ // WICKET-4511: We found <body> inside <head> tag. Markup is not valid!
+ if (foundHead && !foundClosingHead)
+ {
+ throw new MarkupException(new MarkupStream(markup),
+ "Invalid page markup. Tag <BODY> found inside <HEAD>");
+ }
+
// We found <body>
if (foundHead == false)
{
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-4511_4ee5ad1f.diff |
bugs-dot-jar_data_WICKET-4116_4624ab3d | ---
BugID: WICKET-4116
Summary: Ajax link reports weird error when session is expired
Description: "Reproducing steps:\n\n1. Put below simple page into a Wicket application
and get it mounted:\n\nTestPage.java:\n\nimport org.apache.wicket.ajax.AjaxRequestTarget;\nimport
org.apache.wicket.ajax.markup.html.AjaxLink;\nimport org.apache.wicket.markup.html.WebPage;\n\n@SuppressWarnings(\"serial\")\npublic
class TestPage extends WebPage {\n\t\n\tpublic TestPage() {\n\t\t\n\t\tadd(new AjaxLink<Void>(\"test\")
{\n\n\t\t\t@Override\n\t\t\tpublic void onClick(AjaxRequestTarget target) {\n\t\t\t}\n\t\t\t\n\t\t});\n\t\t\n\t}\n\t\n}\n\nTestPage.html:\n\n<!DOCTYPE
html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n<?xml
version=\"1.0\" encoding=\"UTF-8\"?>\n<html xmlns=\"http://www.w3.org/1999/xhtml\">\n\t<head>\n\t\t<title>Test
Page</title>\n\t</head>\n\t<body>\n\t\t<a wicket:id=\"test\">test</a>\n\t</body>\n</html>\n\n2.
Access the page in browser via mounted url, the page will display a link. \n\n3.
Wait until current session is expired (do not refresh the page or click the link
while waiting). \n\n4. Hit the link and below exception will be thrown:\nMessage:
Cannot find behavior with id: 0 on component: [ [Component id = test]]. Perhaps
the behavior did not properly implement getStatelessHint() and returned 'true' to
indicate that it is stateless instead of returning 'false' to indicate that it is
stateful.\n\n5. In wicket 1.5.0, this results in a PageExpiredException which is
more comprehensive. \n\n"
diff --git a/wicket-core/src/main/java/org/apache/wicket/request/handler/ListenerInterfaceRequestHandler.java b/wicket-core/src/main/java/org/apache/wicket/request/handler/ListenerInterfaceRequestHandler.java
index de801ef..a74d098 100644
--- a/wicket-core/src/main/java/org/apache/wicket/request/handler/ListenerInterfaceRequestHandler.java
+++ b/wicket-core/src/main/java/org/apache/wicket/request/handler/ListenerInterfaceRequestHandler.java
@@ -26,6 +26,8 @@ import org.apache.wicket.request.handler.RenderPageRequestHandler.RedirectPolicy
import org.apache.wicket.request.http.WebRequest;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.apache.wicket.util.lang.Args;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Request handler that invokes the listener interface on component and renders page afterwards.
@@ -37,6 +39,9 @@ public class ListenerInterfaceRequestHandler
IPageRequestHandler,
IComponentRequestHandler
{
+
+ private static final Logger LOG = LoggerFactory.getLogger(ListenerInterfaceRequestHandler.class);
+
private final IPageAndComponentProvider pageComponentProvider;
private final RequestListenerInterface listenerInterface;
@@ -146,19 +151,42 @@ public class ListenerInterfaceRequestHandler
*/
public void respond(final IRequestCycle requestCycle)
{
+ final boolean isNewPageInstance = pageComponentProvider.isNewPageInstance();
+ final boolean isAjax = ((WebRequest)requestCycle.getRequest()).isAjax();
final IRequestablePage page = getPage();
+ final boolean isStateless = page.isPageStateless();
+ final IPageProvider pageProvider = new PageProvider(page);
+
if (getComponent().getPage() == page)
{
- boolean isAjax = ((WebRequest)requestCycle.getRequest()).isAjax();
+ RedirectPolicy policy = isStateless ? RedirectPolicy.NEVER_REDIRECT
+ : RedirectPolicy.AUTO_REDIRECT;
+
+ if (isNewPageInstance)
+ {
+ if (LOG.isDebugEnabled())
+ {
+ LOG.debug(
+ "A ListenerInterface '{}' assigned to '{}' is executed on an expired page. "
+ + "Scheduling re-create of the page and ignoring the listener interface...",
+ listenerInterface, getComponentPath());
+ }
+
+ if (isAjax)
+ {
+ policy = RedirectPolicy.ALWAYS_REDIRECT;
+ }
+
+ requestCycle.scheduleRequestHandlerAfterCurrent(new RenderPageRequestHandler(
+ pageProvider, policy));
+ return;
+ }
+
if (isAjax == false && listenerInterface.isRenderPageAfterInvocation())
{
// schedule page render after current request handler is done. this can be
// overridden during invocation of listener
// method (i.e. by calling RequestCycle#setResponsePage)
- final IPageProvider pageProvider = new PageProvider(page);
- final RedirectPolicy policy = page.isPageStateless()
- ? RedirectPolicy.NEVER_REDIRECT : RedirectPolicy.AUTO_REDIRECT;
-
requestCycle.scheduleRequestHandlerAfterCurrent(new RenderPageRequestHandler(
pageProvider, policy));
}
diff --git a/wicket-core/src/main/java/org/apache/wicket/request/handler/PageProvider.java b/wicket-core/src/main/java/org/apache/wicket/request/handler/PageProvider.java
index f000bad..ed9af8f 100644
--- a/wicket-core/src/main/java/org/apache/wicket/request/handler/PageProvider.java
+++ b/wicket-core/src/main/java/org/apache/wicket/request/handler/PageProvider.java
@@ -59,6 +59,8 @@ public class PageProvider implements IPageProvider
private PageParameters pageParameters;
+ private Boolean isNewInstance = null;
+
/**
* Creates a new page provider object. Upon calling of {@link #getPageInstance()} this provider
* will return page instance with specified id.
@@ -198,17 +200,20 @@ public class PageProvider implements IPageProvider
*/
public boolean isNewPageInstance()
{
- boolean isNew = pageInstance == null;
- if (isNew && pageId != null)
+ if (isNewInstance == null)
{
- IRequestablePage storedPageInstance = getStoredPage(pageId);
- if (storedPageInstance != null)
+ isNewInstance = pageInstance == null;
+ if (isNewInstance && pageId != null)
{
- pageInstance = storedPageInstance;
- isNew = false;
+ IRequestablePage storedPageInstance = getStoredPage(pageId);
+ if (storedPageInstance != null)
+ {
+ pageInstance = storedPageInstance;
+ isNewInstance = false;
+ }
}
}
- return isNew;
+ return isNewInstance;
}
/**
@@ -292,6 +297,14 @@ public class PageProvider implements IPageProvider
(pageClass == null || pageClass.equals(storedPageInstance.getClass())))
{
pageInstance = storedPageInstance;
+
+ if (pageInstance != null)
+ {
+ if (renderCount != null && pageInstance.getRenderCount() != renderCount)
+ {
+ throw new StalePageException(pageInstance);
+ }
+ }
}
return storedPageInstance;
}
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-4116_4624ab3d.diff |
bugs-dot-jar_data_WICKET-3721_1858bc18 | ---
BugID: WICKET-3721
Summary: The Url's query parameters are not properly URL encoded
Description: |-
If page parameter has a value with special characters like ' then it is rendered as it is in the produced markup and is only XML encoded but never URL encoded.
This causes broken html for example in the case when a Link is attached to a non- a|area|link tag:
<html><body><span wicket:id="link" onclick="var win = this.ownerDocument.defaultView || this.ownerDocument.parentWindow; if (win == window) { window.location.href='bookmarkable/org.apache.wicket.MockPageWithLink?urlEscapeNeeded=someone's+ba+parameter'; } ;return false"></span></body></html>
Notice that ' after 'someone' closes the location.href string too early and breaks the app.
diff --git a/wicket-request/src/main/java/org/apache/wicket/request/UrlEncoder.java b/wicket-request/src/main/java/org/apache/wicket/request/UrlEncoder.java
index 3bfc78a..aadac5e 100644
--- a/wicket-request/src/main/java/org/apache/wicket/request/UrlEncoder.java
+++ b/wicket-request/src/main/java/org/apache/wicket/request/UrlEncoder.java
@@ -174,7 +174,6 @@ public class UrlEncoder
dontNeedEncoding.set('!');
dontNeedEncoding.set('$');
// "&" needs to be encoded for query stings
- dontNeedEncoding.set('\'');
// "(" and ")" probably don't need encoding, but we'll be conservative
dontNeedEncoding.set('*');
// "+" needs to be encoded for query strings (since it means =
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-3721_1858bc18.diff |
bugs-dot-jar_data_WICKET-5734_71674df5 | ---
BugID: WICKET-5734
Summary: Problem with WICKET-4441 and RestartResponseAtInterceptPageException
Description: WICKET-4441 introduced an issue when our app has an authorization strategy
and user is logged out. If user tries to access a protected url/page, RestartResponseAtInterceptPageException
is handled by DefaultExceptionMapper and leads to exception page instead of redirecting
user.
diff --git a/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/AbstractBookmarkableMapper.java b/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/AbstractBookmarkableMapper.java
index 658c98f..0a047ac 100644
--- a/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/AbstractBookmarkableMapper.java
+++ b/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/AbstractBookmarkableMapper.java
@@ -265,7 +265,12 @@ public abstract class AbstractBookmarkableMapper extends AbstractComponentMapper
}
else
{
- PageParameters constructionPageParameters = provider.getPageInstance().getPageParameters();
+ /**
+ * https://issues.apache.org/jira/browse/WICKET-5734
+ * */
+ PageParameters constructionPageParameters = provider.hasPageInstance() ?
+ provider.getPageInstance().getPageParameters() : new PageParameters();
+
if (PageParameters.equals(constructionPageParameters, pageParameters) == false)
{
// create a fresh page instance because the request page parameters are different than the ones
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5734_71674df5.diff |
bugs-dot-jar_data_WICKET-208_b224bad8 | ---
BugID: WICKET-208
Summary: Fixing AjaxTimerBehaviorTest
Description: |-
This is an attempt to fix failing testcase:
target/surefire-reports/wicket.ajax.AjaxTimerBehaviorTest.txt
-------------------------------------------------------------------------------
Test set: wicket.ajax.AjaxTimerBehaviorTest
-------------------------------------------------------------------------------
Tests run: 2, Failures: 2, Errors: 0, Skipped: 0, Time elapsed: 0.113 sec <<< FAILURE!
testAddToAjaxUpdate(wicket.ajax.AjaxTimerBehaviorTest) Time elapsed: 0.063 sec <<< FAILURE!
junit.framework.AssertionFailedError: There should be 1 and only 1 script in the markup for this behavior,but 0 were found exp
ected:<1> but was:<0>
at junit.framework.Assert.fail(Assert.java:47)
at junit.framework.Assert.failNotEquals(Assert.java:282)
at junit.framework.Assert.assertEquals(Assert.java:64)
at junit.framework.Assert.assertEquals(Assert.java:201)
at wicket.ajax.AjaxTimerBehaviorTest.validateTimerScript(AjaxTimerBehaviorTest.java:178)
at wicket.ajax.AjaxTimerBehaviorTest.validate(AjaxTimerBehaviorTest.java:143)
at wicket.ajax.AjaxTimerBehaviorTest.testAddToAjaxUpdate(AjaxTimerBehaviorTest.java:99)
testAddToWebPage(wicket.ajax.AjaxTimerBehaviorTest) Time elapsed: 0.026 sec <<< FAILURE!
junit.framework.AssertionFailedError: There should be 1 and only 1 script in the markup for this behavior,but 0 were found exp
ected:<1> but was:<0>
at junit.framework.Assert.fail(Assert.java:47)
at junit.framework.Assert.failNotEquals(Assert.java:282)
at junit.framework.Assert.assertEquals(Assert.java:64)
at junit.framework.Assert.assertEquals(Assert.java:201)
at wicket.ajax.AjaxTimerBehaviorTest.validateTimerScript(AjaxTimerBehaviorTest.java:178)
at wicket.ajax.AjaxTimerBehaviorTest.validate(AjaxTimerBehaviorTest.java:155)
at wicket.ajax.AjaxTimerBehaviorTest.testAddToWebPage(AjaxTimerBehaviorTest.java:127)
The attached patch properly handles the case when the callback script is added in body onload. Also, AbstractAjaxTimerBehavior needs to handle AjaxRequestTarget properly, because adding a body onload has no effect in an ajax request.
diff --git a/wicket/src/main/java/wicket/ajax/AbstractAjaxTimerBehavior.java b/wicket/src/main/java/wicket/ajax/AbstractAjaxTimerBehavior.java
index a297a5f..59eeabc 100644
--- a/wicket/src/main/java/wicket/ajax/AbstractAjaxTimerBehavior.java
+++ b/wicket/src/main/java/wicket/ajax/AbstractAjaxTimerBehavior.java
@@ -16,6 +16,7 @@
*/
package wicket.ajax;
+import wicket.RequestCycle;
import wicket.markup.html.IHeaderResponse;
import wicket.markup.html.WebPage;
import wicket.util.time.Duration;
@@ -66,8 +67,14 @@ public abstract class AbstractAjaxTimerBehavior extends AbstractDefaultAjaxBehav
if (this.attachedBodyOnLoadModifier == false)
{
this.attachedBodyOnLoadModifier = true;
- ((WebPage)getComponent().getPage()).getBodyContainer().addOnLoadModifier(
- getJsTimeoutCall(updateInterval), getComponent());
+ if (RequestCycle.get().getRequestTarget() instanceof AjaxRequestTarget) {
+ response.renderJavascript(getJsTimeoutCall(updateInterval), getComponent().getMarkupId());
+ }
+ else
+ {
+ ((WebPage)getComponent().getPage()).getBodyContainer().addOnLoadModifier(
+ getJsTimeoutCall(updateInterval), getComponent());
+ }
}
}
@@ -78,7 +85,8 @@ public abstract class AbstractAjaxTimerBehavior extends AbstractDefaultAjaxBehav
*/
protected final String getJsTimeoutCall(final Duration updateInterval)
{
- return "setTimeout(function() { " + getCallbackScript(false, true) + " }, "
+ // this might look strange, but it is necessary for IE not to leak :(
+ return "setTimeout(\"" + getCallbackScript(false, true) + "\", "
+ updateInterval.getMilliseconds() + ");";
}
@@ -92,11 +100,7 @@ public abstract class AbstractAjaxTimerBehavior extends AbstractDefaultAjaxBehav
if (!stopped)
{
- // this might look strange, but it is necessary for IE not to leak
- String js = "setTimeout(\"" + getCallbackScript(false, true) + "\", "
- + updateInterval.getMilliseconds() + ");";
-
- target.appendJavascript(js);
+ target.appendJavascript(getJsTimeoutCall(updateInterval));
}
}
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-208_b224bad8.diff |
bugs-dot-jar_data_WICKET-5326_ded3c583 | ---
BugID: WICKET-5326
Summary: Wicket doesn't encrypt links and Ajax URLs for mounted pages when CryptoMapper
is used
Description: |-
URL encryption does not work in Wicket links and Ajax URLs.
For links the URL appears unencrypted in the href attribute value and is only later forwarded to the encrypted URL using a 302 response.
I am uploading a quickstart.
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 05e7c30..99f7afc 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
@@ -16,6 +16,7 @@
*/
package org.apache.wicket.core.request.mapper;
+import java.util.Iterator;
import java.util.List;
import org.apache.wicket.Application;
@@ -25,25 +26,48 @@ import org.apache.wicket.request.IRequestMapper;
import org.apache.wicket.request.Request;
import org.apache.wicket.request.Url;
import org.apache.wicket.request.mapper.IRequestMapperDelegate;
+import org.apache.wicket.request.mapper.info.PageComponentInfo;
import org.apache.wicket.util.IProvider;
import org.apache.wicket.util.crypt.ICrypt;
import org.apache.wicket.util.crypt.ICryptFactory;
import org.apache.wicket.util.lang.Args;
import org.apache.wicket.util.string.Strings;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * Request mapper that encrypts urls generated by another mapper. The original URL (both segments
- * and parameters) is encrypted and is represented as URL segment. To be able to handle relative
- * URLs for images in .css file the same amount of URL segments that the original URL had are
- * appended to the encrypted URL. Each segment has a precise 5 character value, calculated using a
- * checksum. This helps in calculating the relative distance from the original URL. When a URL is
- * returned by the browser, we iterate through these checksummed placeholder URL segments. If the
- * segment matches the expected checksum, then the segment it deemed to be the corresponding segment
- * in the encrypted URL. If the segment does not match the expected checksum, then the segment is
- * deemed a plain text sibling of the corresponding segment in the encrypted URL, and all subsequent
+ * <p>
+ * A request mapper that encrypts URLs generated by another mapper. This mapper encrypts the segments
+ * and query parameters of URLs starting with {@code /wicket/}, and the just the {@link PageComponentInfo}
+ * parameter for mounted URLs.
+ * </p>
+ *
+ * <p>
+ * This mapper can be mounted before or after mounting other pages, but will only encrypt URLs for
+ * pages mounted before the {@link CryptoMapper}. If required, multiple {@link CryptoMapper}s may be
+ * installed in an {@link Application}.
+ * </p>
+ *
+ * <p>
+ * When encrypting URLs in the Wicket namespace (starting with {@code /wicket/}), the entire URL, including
+ * segments and parameters, is encrypted, with the encrypted form stored in the first segment of the encrypted URL.
+ * </p>
+ *
+ * <p>
+ * To be able to handle relative URLs, like for image URLs in a CSS file, checksum segments are appended to the
+ * encrypted URL until the encrypted URL has the same number of segments as the original URL had.
+ * Each checksum segment has a precise 5 character value, calculated using a checksum. This helps in calculating
+ * the relative distance from the original URL. When a URL is returned by the browser, we iterate through these
+ * checksummed placeholder URL segments. If the segment matches the expected checksum, then the segment it deemed
+ * to be the corresponding segment in the original URL. If the segment does not match the expected checksum, then
+ * the segment is deemed a plain text sibling of the corresponding segment in the original URL, and all subsequent
* segments are considered plain text children of the current segment.
+ * </p>
+ *
+ * <p>
+ * When encrypting mounted URLs, we look for the {@link PageComponentInfo} parameter, and encrypt only that parameter.
+ * </p>
*
* @author igor.vaynberg
* @author Jesse Long
@@ -53,6 +77,11 @@ public class CryptoMapper implements IRequestMapperDelegate
{
private static final Logger log = LoggerFactory.getLogger(CryptoMapper.class);
+ /**
+ * Name of the parameter which contains encrypted page component info.
+ */
+ private static final String ENCRYPTED_PAGE_COMPONENT_INFO_PARAMETER = "wicket";
+
private final IRequestMapper wrappedMapper;
private final IProvider<ICrypt> cryptProvider;
@@ -87,12 +116,34 @@ public class CryptoMapper implements IRequestMapperDelegate
this.cryptProvider = Args.notNull(cryptProvider, "cryptProvider");
}
+ /**
+ * {@inheritDoc}
+ * <p>
+ * This implementation decrypts the URL and passes the decrypted URL to the wrapped mapper.
+ * </p>
+ * @param request
+ * The request for which to get a compatability score.
+ *
+ * @return The compatability score.
+ */
@Override
public int getCompatibilityScore(final Request request)
{
- return wrappedMapper.getCompatibilityScore(request);
+ Url decryptedUrl = decryptUrl(request, request.getUrl());
+
+ if (decryptedUrl == null)
+ {
+ return 0;
+ }
+
+ Request decryptedRequest = request.cloneWithUrl(decryptedUrl);
+
+ return wrappedMapper.getCompatibilityScore(decryptedRequest);
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public Url mapHandler(final IRequestHandler requestHandler)
{
@@ -112,6 +163,9 @@ public class CryptoMapper implements IRequestMapperDelegate
return encryptUrl(url);
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public IRequestHandler mapRequest(final Request request)
{
@@ -119,7 +173,7 @@ public class CryptoMapper implements IRequestMapperDelegate
if (url == null)
{
- return wrappedMapper.mapRequest(request);
+ return null;
}
Request decryptedRequest = request.cloneWithUrl(url);
@@ -152,18 +206,44 @@ public class CryptoMapper implements IRequestMapperDelegate
return wrappedMapper;
}
+ /**
+ * Encrypts a URL. This method should return a new, encrypted instance of the URL. If the URL starts with {@code /wicket/},
+ * the entire URL is encrypted.
+ *
+ * @param url
+ * The URL to encrypt.
+ *
+ * @return A new, encrypted version of the URL.
+ */
protected Url encryptUrl(final Url url)
{
- if (url.getSegments().isEmpty())
+ if (url.getSegments().size() > 0
+ && url.getSegments().get(0).equals(Application.get().getMapperContext().getNamespace()))
{
- return url;
+ return encryptEntireUrl(url);
}
+ else
+ {
+ return encryptRequestListenerParameter(url);
+ }
+ }
+
+ /**
+ * Encrypts an entire URL, segments and query parameters.
+ *
+ * @param url
+ * The URL to encrypt.
+ *
+ * @return An encrypted form of the URL.
+ */
+ protected Url encryptEntireUrl(final Url url)
+ {
String encryptedUrlString = getCrypt().encryptUrlSafe(url.toString());
Url encryptedUrl = new Url(url.getCharset());
encryptedUrl.getSegments().add(encryptedUrlString);
- int numberOfSegments = url.getSegments().size();
+ int numberOfSegments = url.getSegments().size() - 1;
HashedSegmentGenerator generator = new HashedSegmentGenerator(encryptedUrlString);
for (int segNo = 0; segNo < numberOfSegments; segNo++)
{
@@ -172,86 +252,274 @@ public class CryptoMapper implements IRequestMapperDelegate
return encryptedUrl;
}
+ /**
+ * Encrypts the {@link PageComponentInfo} query parameter in the URL, if any is found.
+ *
+ * @param url
+ * The URL to encrypt.
+ *
+ * @return An encrypted form of the URL.
+ */
+ protected Url encryptRequestListenerParameter(final Url url)
+ {
+ Url encryptedUrl = new Url(url);
+
+ for (Iterator<Url.QueryParameter> it = encryptedUrl.getQueryParameters().iterator(); it.hasNext();)
+ {
+ Url.QueryParameter qp = it.next();
+
+ if (Strings.isEmpty(qp.getValue()) == true && Strings.isEmpty(qp.getName()) == false)
+ {
+ if (PageComponentInfo.parse(qp.getName()) != null)
+ {
+ it.remove();
+ String encryptedParameterValue = getCrypt().encryptUrlSafe(qp.getName());
+ Url.QueryParameter encryptedParameter
+ = new Url.QueryParameter(ENCRYPTED_PAGE_COMPONENT_INFO_PARAMETER, encryptedParameterValue);
+ encryptedUrl.getQueryParameters().add(0, encryptedParameter);
+ break;
+ }
+ }
+ }
+
+ return encryptedUrl;
+ }
+
+ /**
+ * Decrypts a {@link Url}. This method should return {@code null} if the URL is not decryptable, or if the
+ * URL should have been encrypted but was not. Returning {@code null} results in a 404 error.
+ *
+ * @param request
+ * The {@link Request}.
+ * @param encryptedUrl
+ * The encrypted {@link Url}.
+ *
+ * @return Returns a decrypted {@link Url}.
+ */
protected Url decryptUrl(final Request request, final Url encryptedUrl)
{
- /*
- * If the encrypted URL has no segments it is the home page URL, and does not need
- * decrypting.
- */
- if (encryptedUrl.getSegments().isEmpty())
+ Url url = decryptEntireUrl(request, encryptedUrl);
+
+ if (url == null)
{
- return encryptedUrl;
+ if (encryptedUrl.getSegments().size() > 0
+ && encryptedUrl.getSegments().get(0).equals(Application.get().getMapperContext().getNamespace()))
+ {
+ /*
+ * This URL should have been encrypted, but was not. We should refuse to handle this, except when
+ * there is more than one CryptoMapper installed, and the request was decrypted by some other
+ * CryptoMapper.
+ */
+ if (request.getOriginalUrl().getSegments().size() > 0
+ && request.getOriginalUrl().getSegments().get(0).equals(Application.get().getMapperContext().getNamespace()))
+ {
+ return null;
+ }
+ else
+ {
+ return encryptedUrl;
+ }
+ }
}
- List<String> encryptedSegments = encryptedUrl.getSegments();
+ if (url == null)
+ {
+ url = decryptRequestListenerParameter(request, encryptedUrl);
+ }
+
+ return url;
+ }
+ /**
+ * Decrypts an entire URL, which was previously encrypted by {@link #encryptEntireUrl(org.apache.wicket.request.Url)}.
+ * This method should return {@code null} if the URL is not decryptable.
+ *
+ * @param request
+ * The request that was made.
+ * @param encryptedUrl
+ * The encrypted URL.
+ *
+ * @return A decrypted form of the URL, or {@code null} if the URL is not decryptable.
+ */
+ protected Url decryptEntireUrl(final Request request, final Url encryptedUrl)
+ {
Url url = new Url(request.getCharset());
+
+ List<String> encryptedSegments = encryptedUrl.getSegments();
+
+ if (encryptedSegments.isEmpty())
+ {
+ return null;
+ }
+
+ /*
+ * The first encrypted segment contains an encrypted version of the entire plain text url.
+ */
+ String encryptedUrlString = encryptedSegments.get(0);
+ if (Strings.isEmpty(encryptedUrlString))
+ {
+ return null;
+ }
+
+ String decryptedUrl;
try
{
+ decryptedUrl = getCrypt().decryptUrlSafe(encryptedUrlString);
+ }
+ catch (Exception e)
+ {
+ log.error("Error decrypting URL", e);
+ return null;
+ }
+
+ if (decryptedUrl == null)
+ {
+ return null;
+ }
+
+ Url originalUrl = Url.parse(decryptedUrl, request.getCharset());
+
+ int originalNumberOfSegments = originalUrl.getSegments().size();
+ int encryptedNumberOfSegments = encryptedUrl.getSegments().size();
+
+ if (originalNumberOfSegments > 0)
+ {
/*
- * The first encrypted segment contains an encrypted version of the entire plain text
- * url.
+ * This should always be true. Home page URLs are the only ones without
+ * segments, and we dont encrypt those with this method.
+ *
+ * We always add the first segment of the URL, because we encrypt a URL like:
+ * /path/to/something
+ * to:
+ * /encrypted_full/hash/hash
+ *
+ * Notice the consistent number of segments. If we applied the following relative URL:
+ * ../../something
+ * then the resultant URL would be:
+ * /something
+ *
+ * Hence, the mere existence of the first, encrypted version of complete URL, segment
+ * tells us that the first segment of the original URL is still to be used.
*/
- String encryptedUrlString = encryptedSegments.get(0);
- if (Strings.isEmpty(encryptedUrlString))
+ url.getSegments().add(originalUrl.getSegments().get(0));
+ }
+
+ HashedSegmentGenerator generator = new HashedSegmentGenerator(encryptedUrlString);
+ int segNo = 1;
+ for (; segNo < encryptedNumberOfSegments; segNo++)
+ {
+ if (segNo > originalNumberOfSegments)
{
- return null;
+ break;
}
- String decryptedUrl = getCrypt().decryptUrlSafe(encryptedUrlString);
- if (decryptedUrl == null)
+ String next = generator.next();
+ String encryptedSegment = encryptedSegments.get(segNo);
+ if (!next.equals(encryptedSegment))
{
- return null;
+ /*
+ * This segment received from the browser is not the same as the expected segment generated
+ * by the HashSegmentGenerator. Hence it, and all subsequent segments are considered plain
+ * text siblings of the original encrypted url.
+ */
+ break;
}
- Url originalUrl = Url.parse(decryptedUrl, request.getCharset());
- int originalNumberOfSegments = originalUrl.getSegments().size();
- int encryptedNumberOfSegments = encryptedUrl.getSegments().size();
+ /*
+ * This segments matches the expected checksum, so we add the corresponding segment from the
+ * original URL.
+ */
+ url.getSegments().add(originalUrl.getSegments().get(segNo));
+ }
+ /*
+ * Add all remaining segments from the encrypted url as plain text segments.
+ */
+ for (; segNo < encryptedNumberOfSegments; segNo++)
+ {
+ // modified or additional segment
+ url.getSegments().add(encryptedUrl.getSegments().get(segNo));
+ }
- HashedSegmentGenerator generator = new HashedSegmentGenerator(encryptedUrlString);
- int segNo = 1;
- for (; segNo < encryptedNumberOfSegments; segNo++)
- {
- if (segNo > originalNumberOfSegments)
- {
- break;
- }
+ url.getQueryParameters().addAll(originalUrl.getQueryParameters());
+ // WICKET-4923 additional parameters
+ url.getQueryParameters().addAll(encryptedUrl.getQueryParameters());
+
+ return url;
+ }
+
+ /**
+ * Decrypts a URL which may contain an encrypted {@link PageComponentInfo} query parameter.
+ *
+ * @param request
+ * The request that was made.
+ * @param encryptedUrl
+ * The (potentially) encrypted URL.
+ *
+ * @return A decrypted form of the URL.
+ */
+ protected Url decryptRequestListenerParameter(final Request request, Url encryptedUrl)
+ {
+ Url url = new Url(encryptedUrl);
- String next = generator.next();
- String encryptedSegment = encryptedSegments.get(segNo);
- if (!next.equals(encryptedSegment))
+ url.getQueryParameters().clear();
+
+ for (Url.QueryParameter qp : encryptedUrl.getQueryParameters())
+ {
+ if (Strings.isEmpty(qp.getValue()) && Strings.isEmpty(qp.getName()) == false)
+ {
+ if (PageComponentInfo.parse(qp.getName()) != null)
{
/*
- * This segment received from the browser is not the same as the expected
- * segment generated by the HashSegmentGenerator. Hence it, and all subsequent
- * segments are considered plain text siblings of the original encrypted url.
+ * Plain text request listener parameter found. This should have been encrypted, so we
+ * refuse to map the request unless the original URL did not include this parameter, which
+ * case there are likely to be multiple cryptomappers installed.
*/
- break;
+ if (request.getOriginalUrl().getQueryParameter(qp.getName()) == null)
+ {
+ url.getQueryParameters().add(qp);
+ }
+ else
+ {
+ return null;
+ }
}
+ }
+ else if (ENCRYPTED_PAGE_COMPONENT_INFO_PARAMETER.equals(qp.getName()))
+ {
+ String encryptedValue = qp.getValue();
- /*
- * This segments matches the expected checksum, so we add the corresponding segment
- * from the original URL.
- */
- url.getSegments().add(originalUrl.getSegments().get(segNo - 1));
+ if (Strings.isEmpty(encryptedValue))
+ {
+ url.getQueryParameters().add(qp);
+ }
+ else
+ {
+ String decryptedValue = null;
+
+ try
+ {
+ decryptedValue = getCrypt().decryptUrlSafe(encryptedValue);
+ }
+ catch (Exception e)
+ {
+ log.error("Error decrypting encrypted request listener query parameter", e);
+ }
+
+ if (Strings.isEmpty(decryptedValue))
+ {
+ url.getQueryParameters().add(qp);
+ }
+ else
+ {
+ Url.QueryParameter decryptedParamter = new Url.QueryParameter(decryptedValue, "");
+ url.getQueryParameters().add(0, decryptedParamter);
+ }
+ }
}
- /*
- * Add all remaining segments from the encrypted url as plain text segments.
- */
- for (; segNo < encryptedNumberOfSegments; segNo++)
+ else
{
- // modified or additional segment
- url.getSegments().add(encryptedUrl.getSegments().get(segNo));
+ url.getQueryParameters().add(qp);
}
-
- url.getQueryParameters().addAll(originalUrl.getQueryParameters());
- // WICKET-4923 additional parameters
- url.getQueryParameters().addAll(encryptedUrl.getQueryParameters());
- }
- catch (Exception e)
- {
- log.error("Error decrypting URL", e);
- url = null;
}
return url;
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5326_ded3c583.diff |
bugs-dot-jar_data_WICKET-5783_7b8b6767 | ---
BugID: WICKET-5783
Summary: Multiple events in AjaxEventBehavior with prefix 'on'
Description: "if multiple events are used and one starts with \"on\", it only works
if it is the first one, because of:\n\n{code}\n\t\tif (event.startsWith(\"on\"))\n\t\t{\n\t\t\tevent
= event.substring(2);\n\t\t}\n{code}\n\nWhy are events possible to start with \"on\"
? \n\nIs this legacy? Perhaps should be removed for Wicket 7 ?\n"
diff --git a/wicket-core/src/main/java/org/apache/wicket/ajax/AjaxEventBehavior.java b/wicket-core/src/main/java/org/apache/wicket/ajax/AjaxEventBehavior.java
index b1a6f98..aba06de 100644
--- a/wicket-core/src/main/java/org/apache/wicket/ajax/AjaxEventBehavior.java
+++ b/wicket-core/src/main/java/org/apache/wicket/ajax/AjaxEventBehavior.java
@@ -16,11 +16,16 @@
*/
package org.apache.wicket.ajax;
+import java.util.ArrayList;
+import java.util.List;
+
import org.apache.wicket.Component;
import org.apache.wicket.ajax.attributes.AjaxRequestAttributes;
import org.apache.wicket.markup.head.IHeaderResponse;
import org.apache.wicket.markup.head.OnDomReadyHeaderItem;
import org.apache.wicket.util.lang.Args;
+import org.apache.wicket.util.lang.Checks;
+import org.apache.wicket.util.string.Strings;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -43,7 +48,14 @@ import org.slf4j.LoggerFactory;
* This behavior will be linked to the <em>click</em> javascript event of the div WebMarkupContainer
* represents, and so anytime a user clicks this div the {@link #onEvent(AjaxRequestTarget)} of the
* behavior is invoked.
- *
+ *
+ * <p>
+ * <strong>Note</strong>: {@link #getEvent()} method cuts any <em>on</em> prefix from the given event name(s).
+ * This is being done for easier migration of applications coming from Wicket 1.5.x where Wicket used
+ * inline attributes like 'onclick=...'. If the application needs to use custom events with names starting with
+ * <em>on</em> then {@link #getEvent()} should be overridden.
+ * </p>
+ *
* @since 1.2
*
* @author Igor Vaynberg (ivaynberg)
@@ -69,18 +81,6 @@ public abstract class AjaxEventBehavior extends AbstractDefaultAjaxBehavior
onCheckEvent(event);
- event = event.toLowerCase();
- if (event.startsWith("on"))
- {
- String shortName = event.substring(2);
- // TODO Wicket 8 Change this to throw an error in the milestone/RC versions and remove it for the final version
- LOGGER.warn("Since version 6.0.0 Wicket uses JavaScript event registration so there is no need of the leading " +
- "'on' in the event name '{}'. Please use just '{}'. Wicket 8.x won't manipulate the provided event " +
- "names so the leading 'on' may break your application."
- , event, shortName);
- event = shortName;
- }
-
this.event = event;
}
@@ -102,7 +102,9 @@ public abstract class AjaxEventBehavior extends AbstractDefaultAjaxBehavior
{
super.updateAjaxAttributes(attributes);
- attributes.setEventNames(event);
+ String evt = getEvent();
+ Checks.notEmpty(evt, "getEvent() should return non-empty event name(s)");
+ attributes.setEventNames(evt);
}
/**
@@ -115,13 +117,33 @@ public abstract class AjaxEventBehavior extends AbstractDefaultAjaxBehavior
}
/**
- *
* @return event
* the event this behavior is attached to
*/
- public final String getEvent()
+ public String getEvent()
{
- return event;
+ String events = event.toLowerCase();
+ String[] splitEvents = events.split("\\s+");
+ List<String> cleanedEvents = new ArrayList<>(splitEvents.length);
+ for (String evt : splitEvents)
+ {
+ if (Strings.isEmpty(evt) == false)
+ {
+ if (evt.startsWith("on"))
+ {
+ String shortName = evt.substring(2);
+ // TODO Wicket 8 Change this to throw an error in the milestone/RC versions and remove it for the final version
+ LOGGER.warn("Since version 6.0.0 Wicket uses JavaScript event registration so there is no need of the leading " +
+ "'on' in the event name '{}'. Please use just '{}'. Wicket 8.x won't manipulate the provided event " +
+ "names so the leading 'on' may break your application."
+ , evt, shortName);
+ evt = shortName;
+ }
+ cleanedEvents.add(evt);
+ }
+ }
+
+ return Strings.join(" ", cleanedEvents);
}
/**
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5783_7b8b6767.diff |
bugs-dot-jar_data_WICKET-5724_b92591f6 | ---
BugID: WICKET-5724
Summary: Queueing component in autocomponent
Description: "There is an exception when a component is added to queue when its parent
is an auto component\n\n<body>\n\t\t<a href=\"panier.html\">\n\t\t\t<span wicket:id=\"inlink\"></span>\n\t\t</a>\n\t</body>\n\n\nLast
cause: Unable to find component with id 'inlink' in [TransparentWebMarkupContainer
[Component id = wicket_relative_path_prefix_1]]\n\tExpected: 'wicket_relative_path_prefix_1:inlink'.\n\tFound
with similar names: ''"
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 b607b4e..1ec4f02 100644
--- a/wicket-core/src/main/java/org/apache/wicket/MarkupContainer.java
+++ b/wicket-core/src/main/java/org/apache/wicket/MarkupContainer.java
@@ -1535,7 +1535,7 @@ public abstract class MarkupContainer extends Component implements Iterable<Comp
ComponentTag.IAutoComponentFactory autoComponentFactory = tag.getAutoComponentFactory();
if (autoComponentFactory != null)
{
- queue(autoComponentFactory.newComponent(tag));
+ queue(autoComponentFactory.newComponent(this, tag));
}
}
}
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/ComponentTag.java b/wicket-core/src/main/java/org/apache/wicket/markup/ComponentTag.java
index b572677..bffde4e 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/ComponentTag.java
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/ComponentTag.java
@@ -25,6 +25,7 @@ import java.util.List;
import java.util.Map;
import org.apache.wicket.Component;
+import org.apache.wicket.MarkupContainer;
import org.apache.wicket.behavior.Behavior;
import org.apache.wicket.markup.parser.XmlTag;
import org.apache.wicket.markup.parser.XmlTag.TagType;
@@ -65,7 +66,7 @@ public class ComponentTag extends MarkupElement
/**
* Creates a new instance of auto component to be queued
*/
- Component newComponent(ComponentTag tag);
+ Component newComponent(MarkupContainer container, ComponentTag tag);
}
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/parser/filter/EnclosureHandler.java b/wicket-core/src/main/java/org/apache/wicket/markup/parser/filter/EnclosureHandler.java
index 4a47f38..098533c 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/parser/filter/EnclosureHandler.java
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/parser/filter/EnclosureHandler.java
@@ -56,7 +56,7 @@ public final class EnclosureHandler extends AbstractMarkupFilter implements ICom
private static final IAutoComponentFactory FACTORY = new IAutoComponentFactory()
{
@Override
- public Component newComponent(ComponentTag tag)
+ public Component newComponent(MarkupContainer container, ComponentTag tag)
{
return new Enclosure(tag.getId(), tag
.getAttribute(EnclosureHandler.CHILD_ATTRIBUTE));
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 0f85964..6d08c95 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
@@ -49,8 +49,8 @@ import org.apache.wicket.markup.resolver.HtmlHeaderResolver;
*/
public final class HtmlHeaderSectionHandler extends AbstractMarkupFilter
{
- private static final String BODY = "body";
- private static final String HEAD = "head";
+ public static final String BODY = "body";
+ public static final String HEAD = "head";
/** The automatically assigned wicket:id to >head< tag */
public static final String HEADER_ID = "_header_";
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/parser/filter/InlineEnclosureHandler.java b/wicket-core/src/main/java/org/apache/wicket/markup/parser/filter/InlineEnclosureHandler.java
index e3c953a..0014b92 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/parser/filter/InlineEnclosureHandler.java
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/parser/filter/InlineEnclosureHandler.java
@@ -127,7 +127,7 @@ public final class InlineEnclosureHandler extends AbstractMarkupFilter
tag.setAutoComponentFactory(new ComponentTag.IAutoComponentFactory()
{
@Override
- public Component newComponent(ComponentTag tag)
+ public Component newComponent(MarkupContainer container, ComponentTag tag)
{
String attributeName = getInlineEnclosureAttributeName(null);
String childId = tag.getAttribute(attributeName);
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/parser/filter/RelativePathPrefixHandler.java b/wicket-core/src/main/java/org/apache/wicket/markup/parser/filter/RelativePathPrefixHandler.java
index 0ae97ee..79edb52 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/parser/filter/RelativePathPrefixHandler.java
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/parser/filter/RelativePathPrefixHandler.java
@@ -86,8 +86,8 @@ public final class RelativePathPrefixHandler extends AbstractMarkupFilter
{
String attrValue = tag.getAttributes().getString(attrName);
- if ((attrValue != null) && (attrValue.startsWith("/") == false) &&
- (!attrValue.contains(":")) && !(attrValue.startsWith("#")))
+ if ((attrValue != null) && (attrValue.startsWith("/") == false)
+ && (!attrValue.contains(":")) && !(attrValue.startsWith("#")))
{
tag.getAttributes().put(attrName,
UrlUtils.rewriteToContextRelative(attrValue, RequestCycle.get()));
@@ -95,6 +95,14 @@ public final class RelativePathPrefixHandler extends AbstractMarkupFilter
}
}
};
+
+ /**
+ * https://issues.apache.org/jira/browse/WICKET-5724
+ *
+ * Says if we are inside an head tag or wicket:head tag.
+ *
+ * */
+ private boolean insideHead;
/**
* Constructor for the IComponentResolver role.
@@ -106,8 +114,9 @@ public final class RelativePathPrefixHandler extends AbstractMarkupFilter
/**
* Constructor for the IMarkupFilter role
+ *
* @param markup
- * The markup created by reading the markup file
+ * The markup created by reading the markup file
*/
public RelativePathPrefixHandler(final MarkupResourceStream markup)
{
@@ -119,30 +128,62 @@ public final class RelativePathPrefixHandler extends AbstractMarkupFilter
{
if (tag.isClose())
{
+ if (isHeadTag(tag))
+ {
+ //outside head tag
+ insideHead = false;
+ }
+
return tag;
}
+ if (isHeadTag(tag))
+ {
+ //inside head tag
+ insideHead = true;
+ }
+
String wicketIdAttr = getWicketNamespace() + ":" + "id";
// Don't touch any wicket:id component and any auto-components
- if ((tag instanceof WicketTag) || (tag.isAutolinkEnabled() == true) ||
- (tag.getAttributes().get(wicketIdAttr) != null))
+ if ((tag instanceof WicketTag) || (tag.isAutolinkEnabled() == true)
+ || (tag.getAttributes().get(wicketIdAttr) != null))
{
return tag;
}
-
+
// Work out whether we have any attributes that require us to add a
// behavior that prepends the relative path.
for (String attrName : attributeNames)
{
String attrValue = tag.getAttributes().getString(attrName);
- if ((attrValue != null) && (attrValue.startsWith("/") == false) &&
- (!attrValue.contains(":")) && !(attrValue.startsWith("#")))
+ if ((attrValue != null) && (attrValue.startsWith("/") == false)
+ && (!attrValue.contains(":")) && !(attrValue.startsWith("#")))
{
if (tag.getId() == null)
{
tag.setId(getWicketRelativePathPrefix(null));
tag.setAutoComponentTag(true);
+
+ /**
+ * https://issues.apache.org/jira/browse/WICKET-5724
+ * Transparent component inside page body must allow
+ * queued children components.
+ */
+ if(!insideHead)
+ {
+ tag.setAutoComponentFactory(new ComponentTag.IAutoComponentFactory()
+ {
+ @Override
+ public Component newComponent(MarkupContainer container, ComponentTag tag)
+ {
+ String id = tag.getId() + container.getPage().getAutoIndex();
+ tag.setId(id);
+
+ return new TransparentWebMarkupContainer(id);
+ }
+ });
+ }
}
tag.addBehavior(RELATIVE_PATH_BEHAVIOR);
tag.setModified(true);
@@ -152,7 +193,17 @@ public final class RelativePathPrefixHandler extends AbstractMarkupFilter
return tag;
}
-
+
+ private boolean isHeadTag(ComponentTag tag)
+ {
+ if (HtmlHeaderSectionHandler.HEAD.equalsIgnoreCase(tag.getName()))
+ {
+ return true;
+ }
+
+ return false;
+ }
+
@Override
public Component resolve(final MarkupContainer container, final MarkupStream markupStream,
final ComponentTag tag)
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/resolver/IComponentResolver.java b/wicket-core/src/main/java/org/apache/wicket/markup/resolver/IComponentResolver.java
index b8d1588..9e83b71 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/resolver/IComponentResolver.java
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/resolver/IComponentResolver.java
@@ -28,6 +28,8 @@ import org.apache.wicket.util.io.IClusterable;
* are first looked up in a component's hierarchy before falling back to a list of
* IComponentResolvers maintained in {@link PageSettings}.
*
+ * NOTE: implementations for this interface must be thread-safe!
+ *
* @see ComponentResolvers
*
* @author Juergen Donnerstag
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5724_b92591f6.diff |
bugs-dot-jar_data_WICKET-5226_8e518d88 | ---
BugID: WICKET-5226
Summary: CDI integration fails in Glassfish 4.0 with WELD-000070
Description: "When CDI is configured in the Application and a page has a non-static
inner class the page throws exception, regardless of whether there are any injected
fields.\n\nCaused by: org.jboss.weld.exceptions.DefinitionException: WELD-000070
Simple bean [EnhancedAnnotatedTypeImpl] private class com.inversebit.HomePage$AForm
cannot be a non-static inner class\n\tat org.jboss.weld.injection.producer.BasicInjectionTarget.checkType(BasicInjectionTarget.java:81)\n\tat
org.jboss.weld.injection.producer.BasicInjectionTarget.<init>(BasicInjectionTarget.java:69)\n\tat
org.jboss.weld.injection.producer.BeanInjectionTarget.<init>(BeanInjectionTarget.java:52)\n\tat
org.jboss.weld.manager.InjectionTargetFactoryImpl.createInjectionTarget(InjectionTargetFactoryImpl.java:95)\n\tat
org.jboss.weld.manager.InjectionTargetFactoryImpl.createInjectionTarget(InjectionTargetFactoryImpl.java:78)\n\t...
65 more\n"
diff --git a/wicket-cdi/src/main/java/org/apache/wicket/cdi/ComponentInjector.java b/wicket-cdi/src/main/java/org/apache/wicket/cdi/ComponentInjector.java
index 0316004..c921706 100644
--- a/wicket-cdi/src/main/java/org/apache/wicket/cdi/ComponentInjector.java
+++ b/wicket-cdi/src/main/java/org/apache/wicket/cdi/ComponentInjector.java
@@ -48,7 +48,8 @@ class ComponentInjector extends AbstractInjector implements IComponentInstantiat
{
Class<? extends Component> componentClass = component.getClass();
- if (componentClass.isMemberClass() && Modifier.isStatic(componentClass.getModifiers()) == false)
+ if (componentClass.isAnonymousClass() ||
+ (componentClass.isMemberClass() && Modifier.isStatic(componentClass.getModifiers()) == false))
{
LOG.debug("Skipping non-static inner class '{}' ", componentClass);
}
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5226_8e518d88.diff |
bugs-dot-jar_data_WICKET-5071_d3d42d42 | ---
BugID: WICKET-5071
Summary: 404 Error on Nested ModalWindows in IE7 and IE8
Description: |-
When opening a ModalWindow inside a ModalWindow, the inner ModalWindow generates a 404 error. Both windows use a PageCreator for content.
To replicate, you must use an actual IE 7 or IE 8 browser, as this does not replicate using developer tools and setting the document and brower to IE 7.
The problem can be seen at http://www.wicket-library.com/wicket-examples/ajax/modal-window. I will attach a Quickstart as well.
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 1fd71d6..a9fd212 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
@@ -190,6 +190,11 @@ public class BookmarkableMapper extends AbstractBookmarkableMapper
{
matches = true;
}
+ // baseUrl = 'bookmarkable/com.example.SomePage', requestUrl = 'bookmarkable/com.example.SomePage'
+ else if (baseUrl.getSegments().size() == 2 && urlStartsWith(baseUrl, bookmarkableIdentifier) && url.getSegments().size() == 2 && urlStartsWith(url, bookmarkableIdentifier))
+ {
+ matches = true;
+ }
// baseUrl = 'wicket/page[?...]', requestUrl = 'bookmarkable/com.example.SomePage'
else if (baseUrl.getSegments().size() == 2 && urlStartsWith(baseUrl, namespace, pageIdentifier) && url.getSegments().size() >= 2 && urlStartsWith(url, bookmarkableIdentifier))
{
diff --git a/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/PageInstanceMapper.java b/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/PageInstanceMapper.java
index 3789a9f..a034642 100644
--- a/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/PageInstanceMapper.java
+++ b/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/PageInstanceMapper.java
@@ -175,17 +175,19 @@ public class PageInstanceMapper extends AbstractComponentMapper
{
boolean matches = false;
Url url = request.getUrl();
+ Url baseUrl = request.getClientUrl();
String namespace = getContext().getNamespace();
String pageIdentifier = getContext().getPageIdentifier();
+
if (urlStartsWith(url, namespace, pageIdentifier))
{
matches = true;
}
- else if (urlStartsWith(request.getClientUrl(), namespace, pageIdentifier) && urlStartsWith(url, pageIdentifier))
+ else if (urlStartsWith(baseUrl, namespace, pageIdentifier) && urlStartsWith(url, pageIdentifier))
{
matches = true;
}
- else if (urlStartsWith(request.getClientUrl(), pageIdentifier) && urlStartsWith(url, pageIdentifier))
+ else if (urlStartsWith(baseUrl, pageIdentifier) && urlStartsWith(url, pageIdentifier))
{
matches = true;
}
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5071_d3d42d42.diff |
bugs-dot-jar_data_WICKET-3861_d1e0e411 | ---
BugID: WICKET-3861
Summary: AbstractTransformerBehavior sets wrong namespace
Description: "AbstractTransformerBehaviour adds a wicket namespace (http://wicket.apache.org)
to its tag which is different from that of the whole page (http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd).\n\nThis
causes (at least) XPath queries for Wicket nodes to fail when matching the contents
of components with an AbstractTransformerBehavior. "
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 ebbe98f..17f43d7 100644
--- a/wicket-core/src/main/java/org/apache/wicket/MarkupContainer.java
+++ b/wicket-core/src/main/java/org/apache/wicket/MarkupContainer.java
@@ -1811,15 +1811,12 @@ public abstract class MarkupContainer extends Component implements Iterable<Comp
protected void onAfterRenderChildren()
{
// Loop through child components
- final Iterator<? extends Component> iter = iterator();
- while (iter.hasNext())
+ for (Component child : this)
{
- // Get next child
- final Component child = iter.next();
-
// Call end request on the child
child.afterRender();
}
+
super.onAfterRenderChildren();
}
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/MarkupResourceStream.java b/wicket-core/src/main/java/org/apache/wicket/markup/MarkupResourceStream.java
index 95cd456..9e26187 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/MarkupResourceStream.java
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/MarkupResourceStream.java
@@ -45,6 +45,9 @@ public class MarkupResourceStream implements IResourceStream, IFixedLocationReso
private static final Logger log = LoggerFactory.getLogger(MarkupResourceStream.class);
+ /** */
+ public static final String WICKET_XHTML_DTD = "http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd";
+
private static final Pattern DOCTYPE_REGEX = Pattern.compile("!DOCTYPE\\s+(.*)\\s*");
/** The associated markup resource stream */
@@ -68,10 +71,7 @@ public class MarkupResourceStream implements IResourceStream, IFixedLocationReso
/** The encoding as found in <?xml ... encoding="" ?>. Null, else */
private String encoding;
- /**
- * Wicket namespace: <html
- * xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.3-strict.dtd>
- */
+ /** Wicket namespace: see WICKET_XHTML_DTD */
private String wicketNamespace;
/** == wicket namespace name + ":id" */
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/transformer/AbstractTransformerBehavior.java b/wicket-core/src/main/java/org/apache/wicket/markup/transformer/AbstractTransformerBehavior.java
index 0e82dc3..be0490b 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/transformer/AbstractTransformerBehavior.java
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/transformer/AbstractTransformerBehavior.java
@@ -19,7 +19,6 @@ package org.apache.wicket.markup.transformer;
import org.apache.wicket.Component;
import org.apache.wicket.WicketRuntimeException;
import org.apache.wicket.behavior.Behavior;
-import org.apache.wicket.markup.ComponentTag;
import org.apache.wicket.protocol.http.BufferedWebResponse;
import org.apache.wicket.request.cycle.RequestCycle;
import org.apache.wicket.request.http.WebResponse;
@@ -59,12 +58,6 @@ public abstract class AbstractTransformerBehavior extends Behavior implements IT
}
@Override
- public void onComponentTag(final Component component, final ComponentTag tag)
- {
- tag.put("xmlns:wicket", "http://wicket.apache.org");
- }
-
- @Override
public void beforeRender(Component component)
{
super.beforeRender(component);
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/transformer/XsltOutputTransformerContainer.java b/wicket-core/src/main/java/org/apache/wicket/markup/transformer/XsltOutputTransformerContainer.java
index 873c476..d09c100 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/transformer/XsltOutputTransformerContainer.java
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/transformer/XsltOutputTransformerContainer.java
@@ -18,6 +18,7 @@ package org.apache.wicket.markup.transformer;
import org.apache.wicket.AttributeModifier;
import org.apache.wicket.Component;
+import org.apache.wicket.markup.MarkupResourceStream;
import org.apache.wicket.markup.MarkupType;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
@@ -74,7 +75,7 @@ public class XsltOutputTransformerContainer extends AbstractOutputTransformerCon
// Make the XSLT processor happy and allow him to handle the wicket
// tags and attributes which are in the wicket namespace
add(AttributeModifier.replace("xmlns:wicket",
- Model.of("http://wicket.apache.org/dtds.data/wicket-xhtml1.3-strict.dtd")));
+ Model.of(MarkupResourceStream.WICKET_XHTML_DTD)));
}
/**
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/transformer/XsltTransformerBehavior.java b/wicket-core/src/main/java/org/apache/wicket/markup/transformer/XsltTransformerBehavior.java
index 97a1680..d1c3efa 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/transformer/XsltTransformerBehavior.java
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/transformer/XsltTransformerBehavior.java
@@ -20,6 +20,7 @@ import org.apache.wicket.Component;
import org.apache.wicket.Page;
import org.apache.wicket.WicketRuntimeException;
import org.apache.wicket.markup.ComponentTag;
+import org.apache.wicket.markup.MarkupResourceStream;
/**
* An IBehavior which can be added to any component except ListView. It allows to post-process
@@ -69,10 +70,10 @@ public class XsltTransformerBehavior extends AbstractTransformerBehavior
@Override
public void onComponentTag(final Component component, final ComponentTag tag)
{
- tag.put("xmlns:wicket", "http://wicket.apache.org/dtds.data/wicket-xhtml1.3-strict.dtd");
-
// Make the XSLT processor happy and allow it to handle the wicket tags
// and attributes that are in the wicket namespace
+ tag.put("xmlns:wicket", MarkupResourceStream.WICKET_XHTML_DTD);
+
super.onComponentTag(component, tag);
}
diff --git a/wicket-core/src/main/java/org/apache/wicket/protocol/http/BufferedWebResponse.java b/wicket-core/src/main/java/org/apache/wicket/protocol/http/BufferedWebResponse.java
index 6ab2ef8..1fa461c 100644
--- a/wicket-core/src/main/java/org/apache/wicket/protocol/http/BufferedWebResponse.java
+++ b/wicket-core/src/main/java/org/apache/wicket/protocol/http/BufferedWebResponse.java
@@ -132,7 +132,6 @@ public class BufferedWebResponse extends WebResponse implements IMetaDataBufferi
@Override
protected void invoke(WebResponse response)
{
-
AppendingStringBuffer responseBuffer = new AppendingStringBuffer(builder);
List<IResponseFilter> responseFilters = Application.get()
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-3861_d1e0e411.diff |
bugs-dot-jar_data_WICKET-4488_e6582c52 | ---
BugID: WICKET-4488
Summary: URL with a previous page version ignores requested page based on mount path
Description: |-
See discussion on http://mail-archives.apache.org/mod_mbox/wicket-users/201203.mbox/browser
With 2 mounts /page1 and /page2 to stateful pages and the following sequence:
1-With a new session, user visits "/page1". Displayed URL is "/page1?0"
2-Whatever, without expiring session
3-User requests URL "/page2?0" because it was bookmarked, received via email, etc.
4-Rendered page is "/page1?0" which was stored in the page map. The actual URL displayed is "/wicket/bookmarkable/com.mycompany.Page1?0"
If a requested page id exists but does not match the page class mounted on the actual requested url, Wicket should not use the old page version. This is very counter-intuitive for users having bookmarks to stateful pages or exchanging links.
diff --git a/wicket-core/src/main/java/org/apache/wicket/core/request/handler/PageProvider.java b/wicket-core/src/main/java/org/apache/wicket/core/request/handler/PageProvider.java
index f239c4d..50402f6 100644
--- a/wicket-core/src/main/java/org/apache/wicket/core/request/handler/PageProvider.java
+++ b/wicket-core/src/main/java/org/apache/wicket/core/request/handler/PageProvider.java
@@ -294,18 +294,22 @@ public class PageProvider implements IPageProvider
private IRequestablePage getStoredPage(final int pageId)
{
IRequestablePage storedPageInstance = getPageSource().getPageInstance(pageId);
- if (storedPageInstance != null &&
- (pageClass == null || pageClass.equals(storedPageInstance.getClass())))
+ if (storedPageInstance != null)
{
- pageInstance = storedPageInstance;
- pageInstanceIsFresh = false;
- if (pageInstance != null)
+ if (pageClass == null || pageClass.equals(storedPageInstance.getClass()))
{
+ pageInstance = storedPageInstance;
+ pageInstanceIsFresh = false;
if (renderCount != null && pageInstance.getRenderCount() != renderCount)
{
throw new StalePageException(pageInstance);
}
}
+ else
+ {
+ // the found page class doesn't match the requested one
+ storedPageInstance = null;
+ }
}
return storedPageInstance;
}
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-4488_e6582c52.diff |
bugs-dot-jar_data_WICKET-4789_6f0863f4 | ---
BugID: WICKET-4789
Summary: URL rendering regression
Description: |-
The way URLs are encoded was changed (WICKET-4645) and now the first request (with ;jsessionid in path) generates invalid internal links:
My page is mounted to "/Home/" and I get redirected to "/Home/;jsessionid=1234?0" (fine). There's a Link on the page and the generated URL for it is "../Home;jsessionid=1234?0-1.ILinkListener-link". Note the missing "/". This results in a 404 and breaks basically all of my system tests.
I'll attach a simple quickstart which demonstrates the problem. It's important to delete the jsessionid cookie before accessing the page.
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 364b5d3..9fb454c 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
@@ -81,8 +81,7 @@ public class Url implements Serializable
*
* @author igor
*/
- public static enum StringMode
- {
+ public static enum StringMode {
/** local urls are rendered without the host name */
LOCAL,
/**
@@ -123,13 +122,13 @@ public class Url implements Serializable
{
Args.notNull(url, "url");
- this.protocol = url.protocol;
- this.host = url.host;
- this.port = url.port;
- this.segments = new ArrayList<String>(url.segments);
- this.parameters = new ArrayList<QueryParameter>(url.parameters);
- this.charsetName = url.charsetName;
- this._charset = url._charset;
+ protocol = url.protocol;
+ host = url.host;
+ port = url.port;
+ segments = new ArrayList<String>(url.segments);
+ parameters = new ArrayList<QueryParameter>(url.parameters);
+ charsetName = url.charsetName;
+ _charset = url._charset;
}
/**
@@ -617,7 +616,7 @@ public class Url implements Serializable
return toString(getCharset());
}
- /**
+ /**
* Stringizes this url
*
* @param mode
@@ -938,12 +937,12 @@ public class Url implements Serializable
{
if (getSegments().size() > 0)
{
- // strip the first non-folder segment
+ // strip the first non-folder segment (if it is not empty)
getSegments().remove(getSegments().size() - 1);
}
- // remove leading './' (current folder) and empty segments, process any ../ segments from the
- // relative url
+ // remove leading './' (current folder) and empty segments, process any ../ segments from
+ // the relative url
while (!relative.getSegments().isEmpty())
{
if (".".equals(relative.getSegments().get(0)))
@@ -968,6 +967,11 @@ public class Url implements Serializable
}
}
+ if (!getSegments().isEmpty() && relative.getSegments().isEmpty())
+ {
+ getSegments().add("");
+ }
+
// append the remaining relative segments
getSegments().addAll(relative.getSegments());
@@ -1104,36 +1108,41 @@ public class Url implements Serializable
{
return getQueryString(getCharset());
}
-
-
+
+
/**
- * Try to reduce url by eliminating '..' and '.' from the path where appropriate
- * (this is somehow similar to {@link java.io.File#getCanonicalPath()}).
- * Either by different / unexpected browser behavior or by malicious attacks it
- * can happen that these kind of redundant urls are processed by wicket. These urls
- * can cause some trouble when mapping the request.
- * <p/>
+ * Try to reduce url by eliminating '..' and '.' from the path where appropriate (this is
+ * somehow similar to {@link java.io.File#getCanonicalPath()}). Either by different / unexpected
+ * browser behavior or by malicious attacks it can happen that these kind of redundant urls are
+ * processed by wicket. These urls can cause some trouble when mapping the request.
+ * <p/>
* <strong>example:</strong>
*
* the url
*
- * <pre> /example/..;jsessionid=234792?0</pre>
+ * <pre>
+ * /example/..;jsessionid=234792?0
+ * </pre>
*
- * will not get normalized by the browser due to the ';jsessionid' string that
- * gets appended by the servlet container. After wicket strips the
- * jsessionid part the resulting internal url will be
+ * will not get normalized by the browser due to the ';jsessionid' string that gets appended by
+ * the servlet container. After wicket strips the jsessionid part the resulting internal url
+ * will be
*
- * <pre> /example/..</pre>
+ * <pre>
+ * /example/..
+ * </pre>
*
* instead of
*
- * <pre> /</pre>
+ * <pre>
+ * /
+ * </pre>
*
* <p/>
*
- * This code correlates to
- * <a href="https://issues.apache.org/jira/browse/WICKET-4303">WICKET-4303</a>
- *
+ * This code correlates to <a
+ * href="https://issues.apache.org/jira/browse/WICKET-4303">WICKET-4303</a>
+ *
* @return canonical url
*/
public Url canonical()
@@ -1141,18 +1150,18 @@ public class Url implements Serializable
Url url = new Url(this);
url.segments.clear();
- for (int i = 0; i < this.segments.size(); i++)
+ for (int i = 0; i < segments.size(); i++)
{
- final String segment = this.segments.get(i);
+ final String segment = segments.get(i);
- // drop '.' from path
+ // drop '.' from path
if (".".equals(segment))
{
continue;
}
// skip segment if following segment is a '..'
- if ((i + 1) < this.segments.size() && "..".equals(this.segments.get(i + 1)))
+ if ((i + 1) < segments.size() && "..".equals(segments.get(i + 1)))
{
i++;
continue;
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-4789_6f0863f4.diff |
bugs-dot-jar_data_WICKET-2202_24ac1a35 | ---
BugID: WICKET-2202
Summary: Form gets submitted using AjaxSubmitBehavior when sub-form has error's
Description: |-
from http://www.nabble.com/Should-a-form-submit-when-sub-form-has-error%27s--tt22803314.html
I have a main-form where I add a panel that contains another form.
This sub-form contains a formvalidator that gives the error.
However the main-form is submitted, but the feedbackpanel does show the error message set in the sub-form's validator.
I'll attach 2 patches with testcases displaying the behavior in wicket 1.3 vs 1.4
(As a side note, I had to rename the org.apache.wicket.markup.html.form.validation.TestHomePage to org.apache.wicket.markup.html.form.validation.HomePageTest to get the test to run when building wicket)
diff --git a/wicket/src/main/java/org/apache/wicket/markup/html/form/Form.java b/wicket/src/main/java/org/apache/wicket/markup/html/form/Form.java
index 521e014..a1d958f 100644
--- a/wicket/src/main/java/org/apache/wicket/markup/html/form/Form.java
+++ b/wicket/src/main/java/org/apache/wicket/markup/html/form/Form.java
@@ -1238,11 +1238,15 @@ public class Form<T> extends WebMarkupContainer implements IFormSubmitListener
}
};
- visitChildren(FormComponent.class, new IVisitor<Component>()
+ visitChildren(Component.class, new IVisitor<Component>()
{
public Object component(final Component component)
{
- return visitor.component(component);
+ if ((component instanceof Form) || (component instanceof FormComponent))
+ {
+ return visitor.component(component);
+ }
+ return Component.IVisitor.CONTINUE_TRAVERSAL;
}
});
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-2202_24ac1a35.diff |
bugs-dot-jar_data_WICKET-428_4a6a573b | ---
BugID: WICKET-428
Summary: MiniMap.iterator().next() should throw NoSuchElementException
Description: |
The wicket.util.collections.MiniMap.iterator().next() should throw NoSuchElementException when there are no more elements to return (line 235), please add:
if(i >= size)
throw new NoSuchElementException();
diff --git a/jdk-1.4/wicket/src/main/java/wicket/util/collections/MiniMap.java b/jdk-1.4/wicket/src/main/java/wicket/util/collections/MiniMap.java
index 7581c21..d63c836 100644
--- a/jdk-1.4/wicket/src/main/java/wicket/util/collections/MiniMap.java
+++ b/jdk-1.4/wicket/src/main/java/wicket/util/collections/MiniMap.java
@@ -229,19 +229,19 @@ public final class MiniMap implements Map, Serializable
{
public boolean hasNext()
{
- return i < size;
+ return i < size - 1;
}
public Object next()
{
- // Find next key
- i = nextKey(nextIndex(i));
-
// Just in case... (WICKET-428)
if (!hasNext()) {
throw new NoSuchElementException();
}
+ // Find next key
+ i = nextKey(nextIndex(i));
+
// Get key
return keys[i];
}
@@ -273,6 +273,9 @@ public final class MiniMap implements Map, Serializable
{
public Object get(final int index)
{
+ if (index > size - 1) {
+ throw new IndexOutOfBoundsException();
+ }
int keyIndex = nextKey(0);
for (int i = 0; i < index; i++)
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-428_4a6a573b.diff |
bugs-dot-jar_data_WICKET-428_d906576c | ---
BugID: WICKET-428
Summary: MiniMap.iterator().next() should throw NoSuchElementException
Description: |
The wicket.util.collections.MiniMap.iterator().next() should throw NoSuchElementException when there are no more elements to return (line 235), please add:
if(i >= size)
throw new NoSuchElementException();
diff --git a/jdk-1.4/wicket/src/main/java/wicket/util/collections/MicroMap.java b/jdk-1.4/wicket/src/main/java/wicket/util/collections/MicroMap.java
index c708f98..1253baa 100644
--- a/jdk-1.4/wicket/src/main/java/wicket/util/collections/MicroMap.java
+++ b/jdk-1.4/wicket/src/main/java/wicket/util/collections/MicroMap.java
@@ -22,6 +22,7 @@ import java.util.AbstractSet;
import java.util.Collection;
import java.util.Iterator;
import java.util.Map;
+import java.util.NoSuchElementException;
import java.util.Set;
/**
@@ -211,6 +212,10 @@ public final class MicroMap implements Map, Serializable
public Object next()
{
+ if (!hasNext())
+ {
+ throw new NoSuchElementException();
+ }
index++;
return key;
@@ -241,6 +246,9 @@ public final class MicroMap implements Map, Serializable
{
public Object get(final int index)
{
+ if (index > size() - 1) {
+ throw new IndexOutOfBoundsException();
+ }
return value;
}
@@ -269,6 +277,10 @@ public final class MicroMap implements Map, Serializable
public Object next()
{
+ if (!hasNext())
+ {
+ throw new NoSuchElementException();
+ }
index++;
return new Map.Entry()
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-428_d906576c.diff |
bugs-dot-jar_data_WICKET-5916_def03add | ---
BugID: WICKET-5916
Summary: StackOverflowError when calling getObject() from load() in LDM
Description: The fix for WICKET-5772 caused an infinite loop when calling getObject()
from inside load() in LoadableDetachableModel. While of course unwise to do so and
nobody in their right mind would do so directly, such a cycle can be triggered through
a series of unrelated calls emanating from load().
diff --git a/wicket-core/src/main/java/org/apache/wicket/model/LoadableDetachableModel.java b/wicket-core/src/main/java/org/apache/wicket/model/LoadableDetachableModel.java
index c172678..e3a7fc0 100644
--- a/wicket-core/src/main/java/org/apache/wicket/model/LoadableDetachableModel.java
+++ b/wicket-core/src/main/java/org/apache/wicket/model/LoadableDetachableModel.java
@@ -23,8 +23,8 @@ import org.slf4j.LoggerFactory;
/**
* Model that makes working with detachable models a breeze. LoadableDetachableModel holds a
- * temporary, transient model object, that is set when {@link #getObject()} is called by
- * calling abstract method 'load', and that will be reset/ set to null on {@link #detach()}.
+ * temporary, transient model object, that is set when {@link #getObject()} is called by calling
+ * abstract method 'load', and that will be reset/ set to null on {@link #detach()}.
*
* A usage example:
*
@@ -60,8 +60,40 @@ public abstract class LoadableDetachableModel<T> implements IModel<T>
/** Logger. */
private static final Logger log = LoggerFactory.getLogger(LoadableDetachableModel.class);
+ private enum AttachingState
+ {
+ DETACHED(false, false),
+ ATTACHING(true, false),
+ ATTACHED(true, true);
+
+ private boolean attaching;
+ private boolean attached;
+
+ private AttachingState(boolean attaching, boolean attached)
+ {
+ this.attached = attached;
+ this.attaching = attaching;
+ }
+
+ public boolean isAttached()
+ {
+ return attached;
+ }
+
+ public boolean isAttaching()
+ {
+ return attaching;
+ }
+
+ @Override
+ public String toString()
+ {
+ return name().toLowerCase();
+ }
+ }
+
/** keeps track of whether this model is attached or detached */
- private transient boolean attached = false;
+ private transient AttachingState attached = AttachingState.DETACHED;
/** temporary, transient object. */
private transient T transientModelObject;
@@ -83,7 +115,7 @@ public abstract class LoadableDetachableModel<T> implements IModel<T>
public LoadableDetachableModel(T object)
{
this.transientModelObject = object;
- attached = true;
+ attached = AttachingState.ATTACHED;
}
/**
@@ -92,7 +124,7 @@ public abstract class LoadableDetachableModel<T> implements IModel<T>
@Override
public void detach()
{
- if (attached)
+ if (attached == AttachingState.ATTACHED)
{
try
{
@@ -100,7 +132,7 @@ public abstract class LoadableDetachableModel<T> implements IModel<T>
}
finally
{
- attached = false;
+ attached = AttachingState.DETACHED;
transientModelObject = null;
log.debug("removed transient object for {}, requestCycle {}", this,
@@ -115,8 +147,11 @@ public abstract class LoadableDetachableModel<T> implements IModel<T>
@Override
public final T getObject()
{
- if (!attached)
+ if (attached == AttachingState.DETACHED)
{
+ // prevent infinite attachment loops
+ attached = AttachingState.ATTACHING;
+
transientModelObject = load();
if (log.isDebugEnabled())
@@ -125,7 +160,7 @@ public abstract class LoadableDetachableModel<T> implements IModel<T>
", requestCycle " + RequestCycle.get());
}
- attached = true;
+ attached = AttachingState.ATTACHED;
onAttach();
}
return transientModelObject;
@@ -138,7 +173,7 @@ public abstract class LoadableDetachableModel<T> implements IModel<T>
*/
public final boolean isAttached()
{
- return attached;
+ return attached.isAttached();
}
/**
@@ -147,9 +182,12 @@ public abstract class LoadableDetachableModel<T> implements IModel<T>
@Override
public String toString()
{
- StringBuilder sb = new StringBuilder(super.toString());
- sb.append(":attached=").append(attached).append(":tempModelObject=[").append(
- this.transientModelObject).append("]");
+ StringBuilder sb = new StringBuilder(super.toString());
+ sb.append(":attached=")
+ .append(isAttached())
+ .append(":tempModelObject=[")
+ .append(this.transientModelObject)
+ .append("]");
return sb.toString();
}
@@ -187,8 +225,7 @@ public abstract class LoadableDetachableModel<T> implements IModel<T>
@Override
public void setObject(final T object)
{
- attached = true;
+ attached = AttachingState.ATTACHED;
transientModelObject = object;
}
-
}
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5916_def03add.diff |
bugs-dot-jar_data_WICKET-5138_e8dab4a0 | ---
BugID: WICKET-5138
Summary: Wicket does not correctly handle http OPTIONS requests
Description: |-
currently these requests cause regular processing (page rendering), when in fact they should have a special response.
rendering the page in OPTIONS causes renderCount to be incremented and this messes with the subsequent request to the same url via a GET or POST
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 eb73ee7..be577f3 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
@@ -96,8 +96,8 @@ public class WicketFilter implements Filter
private boolean isServlet = false;
/**
- * default constructor, usually invoked through the servlet
- * container by the web.xml configuration
+ * default constructor, usually invoked through the servlet container by the web.xml
+ * configuration
*/
public WicketFilter()
{
@@ -106,11 +106,11 @@ public class WicketFilter implements Filter
/**
* constructor supporting programmatic setup of the filter
* <p/>
- * this can be useful for programmatically creating and appending the
- * wicket filter to the servlet context using servlet 3 features.
+ * this can be useful for programmatically creating and appending the wicket filter to the
+ * servlet context using servlet 3 features.
*
* @param application
- * web application
+ * web application
*/
public WicketFilter(WebApplication application)
{
@@ -174,7 +174,7 @@ public class WicketFilter implements Filter
return false;
}
- if ("OPTIONS".equals(httpServletRequest.getMethod()))
+ if ("OPTIONS".equalsIgnoreCase(httpServletRequest.getMethod()))
{
// handle the OPTIONS request outside of normal request processing.
// wicket pages normally only support GET and POST methods, but resources and
@@ -198,7 +198,8 @@ public class WicketFilter implements Filter
httpServletResponse);
RequestCycle requestCycle = application.createRequestCycle(webRequest, webResponse);
- res = processRequestCycle(requestCycle, webResponse, httpServletRequest, httpServletResponse, chain);
+ res = processRequestCycle(requestCycle, webResponse, httpServletRequest,
+ httpServletResponse, chain);
}
else
{
@@ -238,7 +239,7 @@ public class WicketFilter implements Filter
/**
* Process the request cycle
- *
+ *
* @param requestCycle
* @param webResponse
* @param httpServletRequest
@@ -249,8 +250,9 @@ public class WicketFilter implements Filter
* @throws ServletException
*/
protected boolean processRequestCycle(RequestCycle requestCycle, WebResponse webResponse,
- HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse,
- final FilterChain chain) throws IOException, ServletException {
+ HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse,
+ final FilterChain chain) throws IOException, ServletException
+ {
// Assume we are able to handle the request
boolean res = true;
@@ -518,6 +520,7 @@ public class WicketFilter implements Filter
/**
* Provide a standard getter for filterPath.
+ *
* @return The configured filterPath.
*/
protected String getFilterPath()
@@ -651,7 +654,8 @@ public class WicketFilter implements Filter
if (this.filterPath != null)
{
throw new IllegalStateException(
- "Filter path is write-once. You can not change it. Current value='" + filterPath + '\'');
+ "Filter path is write-once. You can not change it. Current value='" + filterPath +
+ '\'');
}
if (filterPath != null)
{
@@ -775,7 +779,7 @@ public class WicketFilter implements Filter
* A filterPath should have all leading slashes removed and exactly one trailing slash. A
* wildcard asterisk character has no special meaning. If your intention is to mean the top
* level "/" then an empty string should be used instead.
- *
+ *
* @param filterPath
* @return
*/
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5138_e8dab4a0.diff |
bugs-dot-jar_data_WICKET-5522_5b730c0b | ---
BugID: WICKET-5522
Summary: Failing HTTPS redirect to RequireHttps annotated pages with ONE_PASS_RENDER
strategy
Description: |-
Activated JS: Start the quickstart -> Press the submit buttons -> See the secured page with https!
Deactivates JS: (NoScript Firefox Plugin): Start the quickstart -> Press the submit buttons -> See the secured page BUT with HTTP!
There was no proper https redirect.
If I change the rendering strategy to REDIRECT_TO_BUFFER everything works fine, but if I change the strategy to ONE_PASS_RENDER the https forwarding does't work anymore. But only if I deactivate all scripts...
Regards,
Dmitriy
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 1b98bed..0b5dee4 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
@@ -33,6 +33,7 @@ import org.apache.wicket.request.component.IRequestablePage;
import org.apache.wicket.request.cycle.RequestCycle;
import org.apache.wicket.request.http.WebRequest;
import org.apache.wicket.request.http.WebResponse;
+import org.apache.wicket.util.lang.Objects;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -338,11 +339,12 @@ public class WebPageRenderer extends PageRenderer
return false;
}
- return neverRedirect(getRedirectPolicy())
+ return (compatibleProtocols(currentUrl.getProtocol(), targetUrl.getProtocol())) &&
+ (neverRedirect(getRedirectPolicy())
|| ((isOnePassRender() && notForcedRedirect(getRedirectPolicy())) || (targetUrl
.equals(currentUrl) && notNewAndNotStatelessPage(isNewPageInstance(),
isPageStateless()))) || (targetUrl.equals(currentUrl) && isRedirectToRender())
- || (shouldPreserveClientUrl(cycle) && notForcedRedirect(getRedirectPolicy()));
+ || (shouldPreserveClientUrl(cycle) && notForcedRedirect(getRedirectPolicy())));
}
private static boolean notNewAndNotStatelessPage(boolean newPageInstance, boolean pageStateless)
@@ -365,4 +367,23 @@ public class WebPageRenderer extends PageRenderer
return !alwaysRedirect(redirectPolicy);
}
+ /**
+ * Compares the protocols of two {@link Url}s
+ *
+ * @param p1
+ * the first protocol
+ * @param p2
+ * the second protocol
+ * @return {@code false} if the protocols are both non-null and not equal,
+ * {@code true} - otherwise
+ */
+ protected boolean compatibleProtocols(String p1, String p2)
+ {
+ if (p1 != null && p2 != null)
+ {
+ return Objects.equal(p1, p2);
+ }
+
+ return true;
+ }
}
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5522_5b730c0b.diff |
bugs-dot-jar_data_WICKET-4398_f88721fd | ---
BugID: WICKET-4398
Summary: Any empty url-parameter will make wicket 1.5 crash
Description: "Adding an empty parameter to the query string will make wicket crash.\n\nhttp://www.example.com/?oneParam&\n\n\nHow
to reproduce in test:\n\nPageParameters params = new PageParameters();\nparams.set(\"\",\"\");\nparams.getAllNamed();\n\n\nCause:\nWicket
accepts empty parameters, but when encoding the url for a rendered page it will
call params.getAllNamed().\n\nparams.getAllNamed() instantiates new NamedPairs,
which calls Args.notEmpty() on the key during instantiation, causing the application
to crash. \n\nThe NamedPair constructor should probably allow empty string as a
key, and call Args.notNull() on the key in stead.\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 bbaf6ea..d387a13 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
@@ -298,7 +298,10 @@ public final class Url implements Serializable
String queryArray[] = Strings.split(queryString, '&');
for (String s : queryArray)
{
- result.parameters.add(parseQueryParameter(s, charset));
+ if (Strings.isEmpty(s) == false)
+ {
+ result.parameters.add(parseQueryParameter(s, charset));
+ }
}
}
@@ -315,22 +318,13 @@ public final class Url implements Serializable
{
if (qp.indexOf('=') == -1)
{
+ // name => empty value
return new QueryParameter(decodeParameter(qp, charset), "");
}
+
String parts[] = Strings.split(qp, '=');
- if (parts.length == 0)
- {
- return new QueryParameter("", "");
- }
- else if (parts.length == 1)
- {
- return new QueryParameter("", decodeParameter(parts[0], charset));
- }
- else
- {
- return new QueryParameter(decodeParameter(parts[0], charset), decodeParameter(parts[1],
- charset));
- }
+ return new QueryParameter(decodeParameter(parts[0], charset), decodeParameter(parts[1],
+ charset));
}
/**
diff --git a/wicket-request/src/main/java/org/apache/wicket/request/mapper/parameter/INamedParameters.java b/wicket-request/src/main/java/org/apache/wicket/request/mapper/parameter/INamedParameters.java
index e84ed21..bcf16be 100644
--- a/wicket-request/src/main/java/org/apache/wicket/request/mapper/parameter/INamedParameters.java
+++ b/wicket-request/src/main/java/org/apache/wicket/request/mapper/parameter/INamedParameters.java
@@ -49,9 +49,8 @@ public interface INamedParameters
*/
public NamedPair(final String key, final String value)
{
- Args.notEmpty(key, "key");
- this.key = key;
- this.value = value;
+ this.key = Args.notNull(key, "key");;
+ this.value = Args.notNull(value, "value");
}
/**
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-4398_f88721fd.diff |
bugs-dot-jar_data_WICKET-4594_5e1bf8d8 | ---
BugID: WICKET-4594
Summary: Do not use the parsed PageParameters when re-creating an expired page
Description: |-
WICKET-4014 and WICKET-4290 provided functionality to re-create an expired page if there is a mount path in the current request's url.
There is a minor problem with that because the page parameters are passed to the freshly created page. I.e. parameters for a callback behavior are now set as page construction parameters.
Since the execution of the behavior is ignored for the recreated page these parameters should be ignored too.
diff --git a/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/AbstractBookmarkableMapper.java b/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/AbstractBookmarkableMapper.java
index 668d0a4..93c22d2 100644
--- a/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/AbstractBookmarkableMapper.java
+++ b/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/AbstractBookmarkableMapper.java
@@ -246,9 +246,14 @@ public abstract class AbstractBookmarkableMapper extends AbstractComponentMapper
if (listenerInterface != null)
{
- // WICKET-4594 - ignore the parsed parameters as they have nothing to do with the page
+ if (pageInfo.getPageId() != null)
+ {
+ // WICKET-4594 - ignore the parsed parameters for stateful pages
+ pageParameters = null;
+ }
+
PageAndComponentProvider provider = new PageAndComponentProvider(pageInfo.getPageId(),
- pageClass, null, renderCount, componentInfo.getComponentPath());
+ pageClass, pageParameters, renderCount, componentInfo.getComponentPath());
provider.setPageSource(getContext());
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-4594_5e1bf8d8.diff |
bugs-dot-jar_data_WICKET-5071_faaae8d3 | ---
BugID: WICKET-5071
Summary: 404 Error on Nested ModalWindows in IE7 and IE8
Description: |-
When opening a ModalWindow inside a ModalWindow, the inner ModalWindow generates a 404 error. Both windows use a PageCreator for content.
To replicate, you must use an actual IE 7 or IE 8 browser, as this does not replicate using developer tools and setting the document and brower to IE 7.
The problem can be seen at http://www.wicket-library.com/wicket-examples/ajax/modal-window. I will attach a Quickstart as well.
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 1fd71d6..a9fd212 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
@@ -190,6 +190,11 @@ public class BookmarkableMapper extends AbstractBookmarkableMapper
{
matches = true;
}
+ // baseUrl = 'bookmarkable/com.example.SomePage', requestUrl = 'bookmarkable/com.example.SomePage'
+ else if (baseUrl.getSegments().size() == 2 && urlStartsWith(baseUrl, bookmarkableIdentifier) && url.getSegments().size() == 2 && urlStartsWith(url, bookmarkableIdentifier))
+ {
+ matches = true;
+ }
// baseUrl = 'wicket/page[?...]', requestUrl = 'bookmarkable/com.example.SomePage'
else if (baseUrl.getSegments().size() == 2 && urlStartsWith(baseUrl, namespace, pageIdentifier) && url.getSegments().size() >= 2 && urlStartsWith(url, bookmarkableIdentifier))
{
diff --git a/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/PageInstanceMapper.java b/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/PageInstanceMapper.java
index 3789a9f..a034642 100644
--- a/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/PageInstanceMapper.java
+++ b/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/PageInstanceMapper.java
@@ -175,17 +175,19 @@ public class PageInstanceMapper extends AbstractComponentMapper
{
boolean matches = false;
Url url = request.getUrl();
+ Url baseUrl = request.getClientUrl();
String namespace = getContext().getNamespace();
String pageIdentifier = getContext().getPageIdentifier();
+
if (urlStartsWith(url, namespace, pageIdentifier))
{
matches = true;
}
- else if (urlStartsWith(request.getClientUrl(), namespace, pageIdentifier) && urlStartsWith(url, pageIdentifier))
+ else if (urlStartsWith(baseUrl, namespace, pageIdentifier) && urlStartsWith(url, pageIdentifier))
{
matches = true;
}
- else if (urlStartsWith(request.getClientUrl(), pageIdentifier) && urlStartsWith(url, pageIdentifier))
+ else if (urlStartsWith(baseUrl, pageIdentifier) && urlStartsWith(url, pageIdentifier))
{
matches = true;
}
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5071_faaae8d3.diff |
bugs-dot-jar_data_WICKET-442_246d53c5 | ---
BugID: WICKET-442
Summary: adding (and querying) feedback messages at construction time fails.
Description: |-
See http://www.nabble.com/error%28...%29-No-page-found-for-component-tf3497125.html
Currently, adding (and querying) feedback messages fails whenever it is done on components that are not yet added to a page (or were removed from them due to component replacement).
There are two ways to fix this. The first fix is attached as a patch, and basically uses a thread local to temporarily store the messages and distribute them to the relevant page instances just in time or when rendering starts. The advantage of this method is that it is completely back wards compatible.
The other way to fix this is to store all messages, whether component specific or not, in the session, and pull them from there. We need to be careful about how/ when to clean these error messages up though. We can use this issue to think about it a little bit more.
diff --git a/jdk-1.4/wicket/src/main/java/wicket/Component.java b/jdk-1.4/wicket/src/main/java/wicket/Component.java
index cd19915..a360e4f 100644
--- a/jdk-1.4/wicket/src/main/java/wicket/Component.java
+++ b/jdk-1.4/wicket/src/main/java/wicket/Component.java
@@ -662,7 +662,7 @@ public abstract class Component implements IClusterable
*/
public final void debug(final String message)
{
- getPage().getFeedbackMessages().debug(this, message);
+ Session.get().getFeedbackMessages().debug(this, message);
}
/**
@@ -685,7 +685,7 @@ public abstract class Component implements IClusterable
*/
public final void error(final Serializable message)
{
- getPage().getFeedbackMessages().error(this, message);
+ Session.get().getFeedbackMessages().error(this, message);
}
/**
@@ -696,7 +696,7 @@ public abstract class Component implements IClusterable
*/
public final void fatal(final String message)
{
- getPage().getFeedbackMessages().fatal(this, message);
+ Session.get().getFeedbackMessages().fatal(this, message);
}
/**
@@ -825,7 +825,7 @@ public abstract class Component implements IClusterable
*/
public final FeedbackMessage getFeedbackMessage()
{
- return getPage().getFeedbackMessages().messageForComponent(this);
+ return Session.get().getFeedbackMessages().messageForComponent(this);
}
/**
@@ -1216,7 +1216,7 @@ public abstract class Component implements IClusterable
*/
public final boolean hasErrorMessage()
{
- return getPage().getFeedbackMessages().hasErrorMessageFor(this);
+ return Session.get().getFeedbackMessages().hasErrorMessageFor(this);
}
/**
@@ -1224,7 +1224,7 @@ public abstract class Component implements IClusterable
*/
public final boolean hasFeedbackMessage()
{
- return getPage().getFeedbackMessages().hasMessageFor(this);
+ return Session.get().getFeedbackMessages().hasMessageFor(this);
}
/**
@@ -1235,7 +1235,7 @@ public abstract class Component implements IClusterable
*/
public final void info(final String message)
{
- getPage().getFeedbackMessages().info(this, message);
+ Session.get().getFeedbackMessages().info(this, message);
}
/**
@@ -2376,7 +2376,7 @@ public abstract class Component implements IClusterable
*/
public final void warn(final String message)
{
- getPage().getFeedbackMessages().warn(this, message);
+ Session.get().getFeedbackMessages().warn(this, message);
}
/**
diff --git a/jdk-1.4/wicket/src/main/java/wicket/Page.java b/jdk-1.4/wicket/src/main/java/wicket/Page.java
index c67365c..24c9a2c 100644
--- a/jdk-1.4/wicket/src/main/java/wicket/Page.java
+++ b/jdk-1.4/wicket/src/main/java/wicket/Page.java
@@ -25,7 +25,6 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import wicket.authorization.UnauthorizedActionException;
-import wicket.feedback.FeedbackMessages;
import wicket.feedback.IFeedback;
import wicket.markup.MarkupException;
import wicket.markup.MarkupStream;
@@ -134,6 +133,12 @@ import wicket.version.undo.Change;
*/
public abstract class Page extends MarkupContainer implements IRedirectListener, IPageMapEntry
{
+ /**
+ * When passed to {@link Page#getVersion(int)} the latest page version is
+ * returned.
+ */
+ public static final int LATEST_VERSION = -1;
+
private static final long serialVersionUID = 1L;
/**
@@ -141,12 +146,6 @@ public abstract class Page extends MarkupContainer implements IRedirectListener,
*/
private static final ConcurrentHashMap pageClassToBookmarkableCache = new ConcurrentHashMap();
- /**
- * When passed to {@link Page#getVersion(int)} the latest page version is
- * returned.
- */
- public static final int LATEST_VERSION = -1;
-
/** True if this page is currently rendering. */
private static final short FLAG_IS_RENDERING = FLAG_RESERVED2;
@@ -165,9 +164,6 @@ public abstract class Page extends MarkupContainer implements IRedirectListener,
/** Used to create page-unique numbers */
private short autoIndex;
- /** Feedback messages for this page */
- private FeedbackMessages feedbackMessages;
-
/** Numeric version of this page's id */
private short numericId;
@@ -284,27 +280,57 @@ public abstract class Page extends MarkupContainer implements IRedirectListener,
/**
+ * Adds a component to the set of rendered components.
+ *
+ * @param component
+ * The component that was rendered
+ */
+ public final void componentRendered(final Component component)
+ {
+ // Inform the page that this component rendered
+ if (Application.get().getDebugSettings().getComponentUseCheck())
+ {
+ if (renderedComponents == null)
+ {
+ renderedComponents = new HashSet();
+ }
+ if (renderedComponents.add(component) == false)
+ {
+ throw new MarkupException(
+ "The component "
+ + component
+ + " has the same wicket:id as another component already added at the same level");
+ }
+ if (log.isDebugEnabled())
+ {
+ log.debug("Rendered " + component);
+ }
+ }
+ }
+
+ /**
* Detaches any attached models referenced by this page.
*/
public void detachModels()
{
-// // visit all this page's children to detach the models
-// visitChildren(new IVisitor()
-// {
-// public Object component(Component component)
-// {
-// try
-// {
-// // detach any models of the component
-// component.detachModels();
-// }
-// catch (Exception e) // catch anything; we MUST detach all models
-// {
-// log.error("detaching models of component " + component + " failed:", e);
-// }
-// return IVisitor.CONTINUE_TRAVERSAL;
-// }
-// });
+ // // visit all this page's children to detach the models
+ // visitChildren(new IVisitor()
+ // {
+ // public Object component(Component component)
+ // {
+ // try
+ // {
+ // // detach any models of the component
+ // component.detachModels();
+ // }
+ // catch (Exception e) // catch anything; we MUST detach all models
+ // {
+ // log.error("detaching models of component " + component + " failed:",
+ // e);
+ // }
+ // return IVisitor.CONTINUE_TRAVERSAL;
+ // }
+ // });
super.detachModels();
}
@@ -318,88 +344,6 @@ public abstract class Page extends MarkupContainer implements IRedirectListener,
}
/**
- * THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT CALL IT.
- */
- public final void renderPage()
- {
- // first try to check if the page can be rendered:
- if (!isActionAuthorized(RENDER))
- {
- if (log.isDebugEnabled())
- {
- log.debug("Page not allowed to render: " + this);
- }
- throw new UnauthorizedActionException(this, Component.RENDER);
- }
-
- // Make sure it is really empty
- renderedComponents = null;
-
- // Reset it to stateless so that it can be tested again
- this.stateless = null;
-
- // Set form component values from cookies
- setFormComponentValuesFromCookies();
-
- // First, give priority to IFeedback instances, as they have to
- // collect their messages before components like ListViews
- // remove any child components
- visitChildren(IFeedback.class, new IVisitor()
- {
- public Object component(Component component)
- {
- ((IFeedback)component).updateFeedback();
- component.attach();
- return IVisitor.CONTINUE_TRAVERSAL;
- }
- });
-
- if (this instanceof IFeedback)
- {
- ((IFeedback)this).updateFeedback();
- }
-
- // Now, do the initialization for the other components
- attach();
-
- // Visit all this page's children to reset markup streams and check
- // rendering authorization, as appropriate. We set any result; positive
- // or negative as a temporary boolean in the components, and when a
- // authorization exception is thrown it will block the rendering of this
- // page
-
- // first the page itself
- setRenderAllowed(isActionAuthorized(RENDER));
- // children of the page
- visitChildren(new IVisitor()
- {
- public Object component(final Component component)
- {
- // Find out if this component can be rendered
- final boolean renderAllowed = component.isActionAuthorized(RENDER);
-
- // Authorize rendering
- component.setRenderAllowed(renderAllowed);
- return IVisitor.CONTINUE_TRAVERSAL;
- }
- });
-
- // Handle request by rendering page
- render(null);
-
- // Check rendering if it happened fully
- checkRendering(this);
-
- if (!isPageStateless())
- {
- // trigger creation of the actual session in case it was deferred
- Session.get().getSessionStore().getSessionId(RequestCycle.get().getRequest(), true);
- // Add/touch the response page in the session (its pagemap).
- getSession().touch(this);
- }
- }
-
- /**
* THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT CALL.
*
* This method is called when a component was rendered standalone. If it is
@@ -432,6 +376,14 @@ public abstract class Page extends MarkupContainer implements IRedirectListener,
}
/**
+ * @return The current ajax version number of this page.
+ */
+ public final int getAjaxVersionNumber()
+ {
+ return versionManager == null ? 0 : versionManager.getAjaxVersionNumber();
+ }
+
+ /**
* THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT CALL IT.
*
* Get a page unique number, which will be increased with each call.
@@ -455,42 +407,6 @@ public abstract class Page extends MarkupContainer implements IRedirectListener,
}
/**
- * @return The current ajax version number of this page.
- */
- public final int getAjaxVersionNumber()
- {
- return versionManager == null ? 0 : versionManager.getAjaxVersionNumber();
- }
-
- /**
- * This returns a page instance that is rollbacked the number of versions
- * that is specified compared to the current page.
- *
- * This is a rollback including ajax versions.
- *
- * @param numberOfVersions to rollback
- * @return
- */
- public final Page rollbackPage(int numberOfVersions)
- {
- Page page = versionManager == null? this : versionManager.rollbackPage(numberOfVersions);
- getSession().touch(page);
- return page;
- }
- /**
- * @return Returns feedback messages from all components in this page
- * (including the page itself).
- */
- public final FeedbackMessages getFeedbackMessages()
- {
- if (feedbackMessages == null)
- {
- feedbackMessages = new FeedbackMessages();
- }
- return feedbackMessages;
- }
-
- /**
* @see wicket.Component#getId()
*/
public final String getId()
@@ -610,7 +526,8 @@ public abstract class Page extends MarkupContainer implements IRedirectListener,
}
// If we went all the way back to the original page
- if (page != null && page.getCurrentVersionNumber() == 0 && page.getAjaxVersionNumber() == 0)
+ if (page != null && page.getCurrentVersionNumber() == 0
+ && page.getAjaxVersionNumber() == 0)
{
// remove version info
page.versionManager = null;
@@ -659,6 +576,28 @@ public abstract class Page extends MarkupContainer implements IRedirectListener,
}
/**
+ * Call this method when the current (ajax) request shouldn't merge the
+ * changes that are happening to the page with the previous version.
+ *
+ * This is for example needed when you want to redirect to this page in an
+ * ajax request and then you do want to version normally..
+ *
+ * This method doesn't do anything if the getRequest().mergeVersion doesn't
+ * return true.
+ */
+ public final void ignoreVersionMerge()
+ {
+ if (getRequest().mergeVersion())
+ {
+ mayTrackChangesFor(this, null);
+ if (versionManager != null)
+ {
+ versionManager.ignoreVersionMerge();
+ }
+ }
+ }
+
+ /**
* Bookmarkable page can be instantiated using a bookmarkable URL.
*
* @return Returns true if the page is bookmarkable.
@@ -714,16 +653,6 @@ public abstract class Page extends MarkupContainer implements IRedirectListener,
}
/**
- * Set page stateless
- *
- * @param stateless
- */
- void setPageStateless(Boolean stateless)
- {
- this.stateless = stateless;
- }
-
- /**
* Gets whether the page is stateless. Components on stateless page must not
* render any statefull urls, and components on statefull page must not
* render any stateless urls. Statefull urls are urls, which refer to a
@@ -827,288 +756,117 @@ public abstract class Page extends MarkupContainer implements IRedirectListener,
}
/**
- * THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT CALL.
- *
- * Set the id for this Page. This method is called by PageMap when a Page is
- * added because the id, which is assigned by PageMap, is not known until
- * this time.
- *
- * @param id
- * The id
+ * THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT CALL IT.
*/
- public final void setNumericId(final int id)
+ public final void renderPage()
{
- this.numericId = (short)id;
- }
+ // first try to check if the page can be rendered:
+ if (!isActionAuthorized(RENDER))
+ {
+ if (log.isDebugEnabled())
+ {
+ log.debug("Page not allowed to render: " + this);
+ }
+ throw new UnauthorizedActionException(this, Component.RENDER);
+ }
- /**
- * THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT CALL.
- *
- * This method is called when a component will be rendered standalone.
- *
- * @param component
- *
- */
- public final void startComponentRender(Component component)
- {
+ // Make sure it is really empty
renderedComponents = null;
- }
- /**
- * Get the string representation of this container.
- *
- * @return String representation of this container
- */
- public String toString()
- {
- if(versionManager != null)
+ // Reset it to stateless so that it can be tested again
+ this.stateless = null;
+
+ // Set form component values from cookies
+ setFormComponentValuesFromCookies();
+
+ // First, give priority to IFeedback instances, as they have to
+ // collect their messages before components like ListViews
+ // remove any child components
+ visitChildren(IFeedback.class, new IVisitor()
{
- return "[Page class = " + getClass().getName() + ", id = " + getId() +
- ", version = " + versionManager.getCurrentVersionNumber() + ", ajax = " +
- versionManager.getAjaxVersionNumber() + "]";
- }
- else
+ public Object component(Component component)
+ {
+ ((IFeedback)component).updateFeedback();
+ component.attach();
+ return IVisitor.CONTINUE_TRAVERSAL;
+ }
+ });
+
+ if (this instanceof IFeedback)
{
- return "[Page class = " + getClass().getName() + ", id = " + getId() + ", version = " + 0 + "]";
+ ((IFeedback)this).updateFeedback();
}
- }
- /**
- * Set-up response with appropriate content type, locale and encoding. The
- * locale is set equal to the session's locale. The content type header
- * contains information about the markup type (@see #getMarkupType()) and
- * the encoding. The response (and request) encoding is determined by an
- * application setting (@see
- * ApplicationSettings#getResponseRequestEncoding()). In addition, if the
- * page's markup contains a xml declaration like <?xml ... ?> an xml
- * declaration with proper encoding information is written to the output as
- * well, provided it is not disabled by an applicaton setting (@see
- * ApplicationSettings#getStripXmlDeclarationFromOutput()).
- * <p>
- * Note: Prior to Wicket 1.1 the output encoding was determined by the
- * page's markup encoding. Because this caused uncertainties about the
- * /request/ encoding, it has been changed in favour of the new, much safer,
- * approach. Please see the Wiki for more details.
- */
- protected void configureResponse()
- {
- // Get the response and application
- final RequestCycle cycle = getRequestCycle();
- final Application application = cycle.getApplication();
- final Response response = cycle.getResponse();
-
- // Determine encoding
- final String encoding = application.getRequestCycleSettings().getResponseRequestEncoding();
-
- // Set content type based on markup type for page
- response.setContentType("text/" + getMarkupType() + "; charset=" + encoding);
-
- // Write out an xml declaration if the markup stream and settings allow
- final MarkupStream markupStream = findMarkupStream();
- if ((markupStream != null) && (markupStream.getXmlDeclaration() != null)
- && (application.getMarkupSettings().getStripXmlDeclarationFromOutput() == false))
- {
- response.write("<?xml version='1.0' encoding='");
- response.write(encoding);
- response.write("'?>");
- }
-
- // Set response locale from session locale
- response.setLocale(getSession().getLocale());
- }
-
- /**
- * @see wicket.Component#onDetach()
- */
- protected void onDetach()
- {
- if (log.isDebugEnabled())
- {
- log.debug("ending request for page " + this + ", request " + getRequest());
- }
+ // Now, do the initialization for the other components
+ attach();
- endVersion();
-
- super.onDetach();
- }
+ // Visit all this page's children to reset markup streams and check
+ // rendering authorization, as appropriate. We set any result; positive
+ // or negative as a temporary boolean in the components, and when a
+ // authorization exception is thrown it will block the rendering of this
+ // page
- /**
- * THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT CALL OR
- * OVERRIDE.
- *
- * @see wicket.Component#internalOnModelChanged()
- */
- protected final void internalOnModelChanged()
- {
- visitChildren(new Component.IVisitor()
+ // first the page itself
+ setRenderAllowed(isActionAuthorized(RENDER));
+ // children of the page
+ visitChildren(new IVisitor()
{
public Object component(final Component component)
{
- // If form component is using form model
- if (component.sameRootModel(Page.this))
- {
- component.modelChanged();
- }
+ // Find out if this component can be rendered
+ final boolean renderAllowed = component.isActionAuthorized(RENDER);
+
+ // Authorize rendering
+ component.setRenderAllowed(renderAllowed);
return IVisitor.CONTINUE_TRAVERSAL;
}
});
- }
-
- /**
- * @return Factory method that creates a version manager for this Page
- */
- protected final IPageVersionManager newVersionManager()
- {
- return null;
- }
- /**
- * Renders this container to the given response object.
- *
- * @param markupStream
- */
- protected void onRender(final MarkupStream markupStream)
- {
- // Set page's associated markup stream
- final MarkupStream associatedMarkupStream = getAssociatedMarkupStream(true);
- setMarkupStream(associatedMarkupStream);
-
- // Configure response object with locale and content type
- configureResponse();
-
- // Render all the page's markup
- setFlag(FLAG_IS_RENDERING, true);
- try
- {
- renderAll(associatedMarkupStream);
- }
- finally
- {
- setFlag(FLAG_IS_RENDERING, false);
- }
- }
+ // Handle request by rendering page
+ render(null);
- /**
- * A component was added.
- *
- * @param component
- * The component that was added
- */
- final void componentAdded(final Component component)
- {
- checkHierarchyChange(component);
+ // Check rendering if it happened fully
+ checkRendering(this);
- dirty();
- if (mayTrackChangesFor(component, component.getParent()))
+ if (!isPageStateless())
{
- versionManager.componentAdded(component);
+ // trigger creation of the actual session in case it was deferred
+ Session.get().getSessionStore().getSessionId(RequestCycle.get().getRequest(), true);
+ // Add/touch the response page in the session (its pagemap).
+ getSession().touch(this);
}
}
/**
- * A component's model changed.
+ * This returns a page instance that is rollbacked the number of versions
+ * that is specified compared to the current page.
*
- * @param component
- * The component whose model is about to change
- */
- final void componentModelChanging(final Component component)
- {
- checkHierarchyChange(component);
-
- dirty();
- if (mayTrackChangesFor(component, null))
- {
- versionManager.componentModelChanging(component);
- }
- }
-
- /**
- * A component was removed.
+ * This is a rollback including ajax versions.
*
- * @param component
- * The component that was removed
+ * @param numberOfVersions
+ * to rollback
+ * @return
*/
- final void componentRemoved(final Component component)
+ public final Page rollbackPage(int numberOfVersions)
{
- checkHierarchyChange(component);
-
- dirty();
- if (mayTrackChangesFor(component, component.getParent()))
- {
- versionManager.componentRemoved(component);
- }
+ Page page = versionManager == null ? this : versionManager.rollbackPage(numberOfVersions);
+ getSession().touch(page);
+ return page;
}
/**
- * Adds a component to the set of rendered components.
+ * THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT CALL.
*
- * @param component
- * The component that was rendered
- */
- public final void componentRendered(final Component component)
- {
- // Inform the page that this component rendered
- if (Application.get().getDebugSettings().getComponentUseCheck())
- {
- if (renderedComponents == null)
- {
- renderedComponents = new HashSet();
- }
- if (renderedComponents.add(component) == false)
- {
- throw new MarkupException(
- "The component "
- + component
- + " has the same wicket:id as another component already added at the same level");
- }
- if (log.isDebugEnabled())
- {
- log.debug("Rendered " + component);
- }
- }
- }
-
- final void componentStateChanging(final Component component, Change change)
- {
- checkHierarchyChange(component);
-
- dirty();
- if (mayTrackChangesFor(component, null))
- {
- versionManager.componentStateChanging(change);
- }
- }
-
- /**
- * Sets values for form components based on cookie values in the request.
+ * Set the id for this Page. This method is called by PageMap when a Page is
+ * added because the id, which is assigned by PageMap, is not known until
+ * this time.
*
+ * @param id
+ * The id
*/
- final void setFormComponentValuesFromCookies()
- {
- // Visit all Forms contained in the page
- visitChildren(Form.class, new Component.IVisitor()
- {
- // For each FormComponent found on the Page (not Form)
- public Object component(final Component component)
- {
- ((Form)component).loadPersistentFormComponentValues();
- return CONTINUE_TRAVERSAL;
- }
- });
- }
-
- /**
- * @param pageMap
- * Sets this page into the page map with the given name. If the
- * page map does not yet exist, it is automatically created.
- */
- final void setPageMap(final IPageMap pageMap)
+ public final void setNumericId(final int id)
{
- // Save transient reference to pagemap
- this.pageMap = pageMap;
-
- // Save name for restoring transient
- this.pageMapName = pageMap.getName();
+ this.numericId = (short)id;
}
/**
@@ -1131,21 +889,37 @@ public abstract class Page extends MarkupContainer implements IRedirectListener,
}
/**
- * THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT CALL OR
- * OVERRIDE.
+ * THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT CALL.
+ *
+ * This method is called when a component will be rendered standalone.
+ *
+ * @param component
*
- * @param map
*/
- protected final void moveToPageMap(IPageMap map)
+ public final void startComponentRender(Component component)
{
- // TODO post 1.2 shouldn't we remove this page from the pagemap/session
- // if it would be in there?
- // This should be done if the page was not cloned first, but shouldn't
- // be done if it was cloned..
- setPageMap(map);
- numericId = (short)map.nextId();
+ renderedComponents = null;
}
+ /**
+ * Get the string representation of this container.
+ *
+ * @return String representation of this container
+ */
+ public String toString()
+ {
+ if (versionManager != null)
+ {
+ return "[Page class = " + getClass().getName() + ", id = " + getId() + ", version = "
+ + versionManager.getCurrentVersionNumber() + ", ajax = "
+ + versionManager.getAjaxVersionNumber() + "]";
+ }
+ else
+ {
+ return "[Page class = " + getClass().getName() + ", id = " + getId() + ", version = "
+ + 0 + "]";
+ }
+ }
/**
* Checks whether the hierarchy may be changed at all, and throws an
@@ -1253,7 +1027,7 @@ public abstract class Page extends MarkupContainer implements IRedirectListener,
// this effectively means that change tracking begins after the
// first request to a page completes.
setFlag(FLAG_TRACK_CHANGES, true);
-
+
// If a new version was created
if (getFlag(FLAG_NEW_VERSION))
{
@@ -1362,24 +1136,238 @@ public abstract class Page extends MarkupContainer implements IRedirectListener,
}
/**
- * Call this method when the current (ajax) request shouldn't merge
- * the changes that are happening to the page with the previous version.
- *
- * This is for example needed when you want to redirect to this
- * page in an ajax request and then you do want to version normally..
+ * Set-up response with appropriate content type, locale and encoding. The
+ * locale is set equal to the session's locale. The content type header
+ * contains information about the markup type (@see #getMarkupType()) and
+ * the encoding. The response (and request) encoding is determined by an
+ * application setting (@see
+ * ApplicationSettings#getResponseRequestEncoding()). In addition, if the
+ * page's markup contains a xml declaration like <?xml ... ?> an xml
+ * declaration with proper encoding information is written to the output as
+ * well, provided it is not disabled by an applicaton setting (@see
+ * ApplicationSettings#getStripXmlDeclarationFromOutput()).
+ * <p>
+ * Note: Prior to Wicket 1.1 the output encoding was determined by the
+ * page's markup encoding. Because this caused uncertainties about the
+ * /request/ encoding, it has been changed in favour of the new, much safer,
+ * approach. Please see the Wiki for more details.
+ */
+ protected void configureResponse()
+ {
+ // Get the response and application
+ final RequestCycle cycle = getRequestCycle();
+ final Application application = cycle.getApplication();
+ final Response response = cycle.getResponse();
+
+ // Determine encoding
+ final String encoding = application.getRequestCycleSettings().getResponseRequestEncoding();
+
+ // Set content type based on markup type for page
+ response.setContentType("text/" + getMarkupType() + "; charset=" + encoding);
+
+ // Write out an xml declaration if the markup stream and settings allow
+ final MarkupStream markupStream = findMarkupStream();
+ if ((markupStream != null) && (markupStream.getXmlDeclaration() != null)
+ && (application.getMarkupSettings().getStripXmlDeclarationFromOutput() == false))
+ {
+ response.write("<?xml version='1.0' encoding='");
+ response.write(encoding);
+ response.write("'?>");
+ }
+
+ // Set response locale from session locale
+ response.setLocale(getSession().getLocale());
+ }
+
+ /**
+ * THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT CALL OR
+ * OVERRIDE.
*
- * This method doesn't do anything if the getRequest().mergeVersion
- * doesn't return true.
+ * @see wicket.Component#internalOnModelChanged()
*/
- public final void ignoreVersionMerge()
+ protected final void internalOnModelChanged()
{
- if (getRequest().mergeVersion())
+ visitChildren(new Component.IVisitor()
{
- mayTrackChangesFor(this, null);
- if (versionManager != null)
+ public Object component(final Component component)
{
- versionManager.ignoreVersionMerge();
+ // If form component is using form model
+ if (component.sameRootModel(Page.this))
+ {
+ component.modelChanged();
+ }
+ return IVisitor.CONTINUE_TRAVERSAL;
}
+ });
+ }
+
+ /**
+ * THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT CALL OR
+ * OVERRIDE.
+ *
+ * @param map
+ */
+ protected final void moveToPageMap(IPageMap map)
+ {
+ // TODO post 1.2 shouldn't we remove this page from the pagemap/session
+ // if it would be in there?
+ // This should be done if the page was not cloned first, but shouldn't
+ // be done if it was cloned..
+ setPageMap(map);
+ numericId = (short)map.nextId();
+ }
+
+ /**
+ * @return Factory method that creates a version manager for this Page
+ */
+ protected final IPageVersionManager newVersionManager()
+ {
+ return null;
+ }
+
+ /**
+ * @see wicket.Component#onDetach()
+ */
+ protected void onDetach()
+ {
+ if (log.isDebugEnabled())
+ {
+ log.debug("ending request for page " + this + ", request " + getRequest());
+ }
+
+ endVersion();
+
+ super.onDetach();
+ }
+
+ /**
+ * Renders this container to the given response object.
+ *
+ * @param markupStream
+ */
+ protected void onRender(final MarkupStream markupStream)
+ {
+ // Set page's associated markup stream
+ final MarkupStream associatedMarkupStream = getAssociatedMarkupStream(true);
+ setMarkupStream(associatedMarkupStream);
+
+ // Configure response object with locale and content type
+ configureResponse();
+
+ // Render all the page's markup
+ setFlag(FLAG_IS_RENDERING, true);
+ try
+ {
+ renderAll(associatedMarkupStream);
}
+ finally
+ {
+ setFlag(FLAG_IS_RENDERING, false);
+ }
+ }
+
+
+ /**
+ * A component was added.
+ *
+ * @param component
+ * The component that was added
+ */
+ final void componentAdded(final Component component)
+ {
+ checkHierarchyChange(component);
+
+ dirty();
+ if (mayTrackChangesFor(component, component.getParent()))
+ {
+ versionManager.componentAdded(component);
+ }
+ }
+
+ /**
+ * A component's model changed.
+ *
+ * @param component
+ * The component whose model is about to change
+ */
+ final void componentModelChanging(final Component component)
+ {
+ checkHierarchyChange(component);
+
+ dirty();
+ if (mayTrackChangesFor(component, null))
+ {
+ versionManager.componentModelChanging(component);
+ }
+ }
+
+ /**
+ * A component was removed.
+ *
+ * @param component
+ * The component that was removed
+ */
+ final void componentRemoved(final Component component)
+ {
+ checkHierarchyChange(component);
+
+ dirty();
+ if (mayTrackChangesFor(component, component.getParent()))
+ {
+ versionManager.componentRemoved(component);
+ }
+ }
+
+ final void componentStateChanging(final Component component, Change change)
+ {
+ checkHierarchyChange(component);
+
+ dirty();
+ if (mayTrackChangesFor(component, null))
+ {
+ versionManager.componentStateChanging(change);
+ }
+ }
+
+ /**
+ * Sets values for form components based on cookie values in the request.
+ *
+ */
+ final void setFormComponentValuesFromCookies()
+ {
+ // Visit all Forms contained in the page
+ visitChildren(Form.class, new Component.IVisitor()
+ {
+ // For each FormComponent found on the Page (not Form)
+ public Object component(final Component component)
+ {
+ ((Form)component).loadPersistentFormComponentValues();
+ return CONTINUE_TRAVERSAL;
+ }
+ });
+ }
+
+ /**
+ * @param pageMap
+ * Sets this page into the page map with the given name. If the
+ * page map does not yet exist, it is automatically created.
+ */
+ final void setPageMap(final IPageMap pageMap)
+ {
+ // Save transient reference to pagemap
+ this.pageMap = pageMap;
+
+ // Save name for restoring transient
+ this.pageMapName = pageMap.getName();
+ }
+
+ /**
+ * Set page stateless
+ *
+ * @param stateless
+ */
+ void setPageStateless(Boolean stateless)
+ {
+ this.stateless = stateless;
}
}
diff --git a/jdk-1.4/wicket/src/main/java/wicket/RequestCycle.java b/jdk-1.4/wicket/src/main/java/wicket/RequestCycle.java
index 9db2282..b8e00a5 100644
--- a/jdk-1.4/wicket/src/main/java/wicket/RequestCycle.java
+++ b/jdk-1.4/wicket/src/main/java/wicket/RequestCycle.java
@@ -886,7 +886,7 @@ public abstract class RequestCycle
// remove any rendered feedback messages from the session
try
{
- session.cleanupFeedbackMessages();
+ session.cleanupRenderedFeedbackMessages();
}
catch (RuntimeException re)
{
diff --git a/jdk-1.4/wicket/src/main/java/wicket/Session.java b/jdk-1.4/wicket/src/main/java/wicket/Session.java
index ae82d31..0e88aed 100644
--- a/jdk-1.4/wicket/src/main/java/wicket/Session.java
+++ b/jdk-1.4/wicket/src/main/java/wicket/Session.java
@@ -37,7 +37,6 @@ import wicket.feedback.FeedbackMessage;
import wicket.feedback.FeedbackMessages;
import wicket.request.ClientInfo;
import wicket.session.ISessionStore;
-import wicket.util.concurrent.CopyOnWriteArrayList;
import wicket.util.convert.IConverter;
import wicket.util.lang.Objects;
import wicket.util.string.Strings;
@@ -167,7 +166,7 @@ public abstract class Session implements IClusterable, IConverterLocator
/** A store for touched pages for one request */
private static final ThreadLocal touchedPages = new ThreadLocal();
-
+
/** Logging object */
private static final Log log = LogFactory.getLog(Session.class);
@@ -199,7 +198,7 @@ public abstract class Session implements IClusterable, IConverterLocator
private String style;
/** feedback messages */
- private FeedbackMessages feedbackMessages = new FeedbackMessages(new CopyOnWriteArrayList());
+ private FeedbackMessages feedbackMessages = new FeedbackMessages();
private transient Map pageMapsUsedInRequest;
@@ -827,7 +826,7 @@ public abstract class Session implements IClusterable, IConverterLocator
// to the pagemap when the session does it update/detaches.
// all the pages are then detached
List lst = (List)touchedPages.get();
- if(lst == null)
+ if (lst == null)
{
lst = new ArrayList();
touchedPages.set(lst);
@@ -910,7 +909,7 @@ public abstract class Session implements IClusterable, IConverterLocator
*
* @return the converter
*/
- public final IConverter getConverter(Class/*<?>*/ type)
+ public final IConverter getConverter(Class/* <?> */type)
{
if (converterSupplier == null)
{
@@ -1060,7 +1059,7 @@ public abstract class Session implements IClusterable, IConverterLocator
protected void update()
{
List lst = (List)touchedPages.get();
- if(lst != null)
+ if (lst != null)
{
for (int i = 0; i < lst.size(); i++)
{
@@ -1069,7 +1068,7 @@ public abstract class Session implements IClusterable, IConverterLocator
}
touchedPages.set(null);
}
-
+
// If state is dirty
if (dirty)
{
@@ -1133,7 +1132,7 @@ public abstract class Session implements IClusterable, IConverterLocator
* Removes any rendered feedback messages as well as compacts memory. This
* method is usually called at the end of the request cycle processing.
*/
- final void cleanupFeedbackMessages()
+ final void cleanupRenderedFeedbackMessages()
{
int size = feedbackMessages.size();
feedbackMessages.clearRendered();
@@ -1146,6 +1145,26 @@ public abstract class Session implements IClusterable, IConverterLocator
}
/**
+ * Cleans up any unrendered, dangling feedback messages there may be. This
+ * implementation calls {@link FeedbackMessages#clearComponentSpecific()} to
+ * aggresively ensure there won't be memory leaks. Clients can override this
+ * method to e.g. call {@link FeedbackMessages#clearPageSpecific(Page)}.
+ * <p>
+ * This method should be called from by the framework right before a even
+ * handler is called. There is no need for clients to call this method
+ * directly
+ * </p>
+ *
+ * @param page
+ * any current page (the page on which the event handler is that
+ * is about to be processed)
+ */
+ public void cleanupFeedbackMessages(Page page)
+ {
+ feedbackMessages.clearComponentSpecific();
+ }
+
+ /**
* @param page
* The page to add to dirty objects list
*/
diff --git a/jdk-1.4/wicket/src/main/java/wicket/feedback/FeedbackMessages.java b/jdk-1.4/wicket/src/main/java/wicket/feedback/FeedbackMessages.java
index 7da2662..719e177 100644
--- a/jdk-1.4/wicket/src/main/java/wicket/feedback/FeedbackMessages.java
+++ b/jdk-1.4/wicket/src/main/java/wicket/feedback/FeedbackMessages.java
@@ -27,6 +27,7 @@ import org.apache.commons.logging.LogFactory;
import wicket.Component;
import wicket.IClusterable;
+import wicket.Page;
import wicket.util.concurrent.CopyOnWriteArrayList;
import wicket.util.string.StringList;
@@ -58,24 +59,37 @@ public final class FeedbackMessages implements IClusterable
*/
public FeedbackMessages()
{
- messages = new ArrayList();
+ messages = new CopyOnWriteArrayList();
}
/**
- * Call this constructor if you want to replace the internal
- * store with another implemention then the default (ArrayList).
- * This could be a {@link CopyOnWriteArrayList} if this feedbackmessages
- * instance is used by multiply threads.
+ * Call this constructor if you want to replace the internal store with
+ * another implemention then the default (ArrayList). This could be a
+ * {@link CopyOnWriteArrayList} if this feedbackmessages instance is used by
+ * multiply threads.
*
- * @param messagesList
+ * @param messagesList
*
*/
public FeedbackMessages(List messagesList)
{
- if(messagesList == null) throw new IllegalArgumentException("messages list can't be null");
+ if (messagesList == null)
+ throw new IllegalArgumentException("messages list can't be null");
messages = messagesList;
}
-
+
+ /**
+ * Adds a message
+ *
+ * @param reporter
+ * @param message
+ * @param level
+ */
+ public final void add(Component reporter, String message, int level)
+ {
+ add(new FeedbackMessage(reporter, message, level));
+ }
+
/**
* Clears any existing messages
*/
@@ -85,13 +99,50 @@ public final class FeedbackMessages implements IClusterable
}
/**
- * Gets the number of messages
+ * Clears any messages specifically for components. This is an aggressive
+ * cleanup to ensure there won't be a memory leak in session.
+ */
+ public final void clearComponentSpecific()
+ {
+ for (int i = messages.size() - 1; i >= 0; i--)
+ {
+ final FeedbackMessage msg = (FeedbackMessage)messages.get(i);
+ Component reporter = msg.getReporter();
+ if (reporter != null)
+ {
+ messages.remove(i);
+ }
+ }
+ trimToSize();
+ }
+
+ /**
+ * Clears any messages specifically for components on the provided page.
*
- * @return the number of messages
+ * @param page
+ * The page to clear messages for
*/
- public final int size()
+ public final void clearPageSpecific(Page page)
{
- return messages.size();
+ if (page == null)
+ {
+ return;
+ }
+
+ for (int i = messages.size() - 1; i >= 0; i--)
+ {
+ final FeedbackMessage msg = (FeedbackMessage)messages.get(i);
+ Component reporter = msg.getReporter();
+ if (reporter != null)
+ {
+ Page reporterPage = (Page)reporter.findParent(Page.class);
+ if (reporterPage != null && reporterPage.equals(page))
+ {
+ messages.remove(i);
+ }
+ }
+ }
+ trimToSize();
}
/**
@@ -99,7 +150,7 @@ public final class FeedbackMessages implements IClusterable
*/
public final void clearRendered()
{
- for(int i = messages.size() - 1; i >= 0; i--)
+ for (int i = messages.size() - 1; i >= 0; i--)
{
final FeedbackMessage msg = (FeedbackMessage)messages.get(i);
if (msg.isRendered())
@@ -226,6 +277,16 @@ public final class FeedbackMessages implements IClusterable
}
/**
+ * Gets an iterator over stored messages
+ *
+ * @return iterator over stored messages
+ */
+ public final Iterator iterator()
+ {
+ return messages.iterator();
+ }
+
+ /**
* Looks up a message for the given component.
*
* @param component
@@ -275,6 +336,16 @@ public final class FeedbackMessages implements IClusterable
}
/**
+ * Gets the number of messages
+ *
+ * @return the number of messages
+ */
+ public final int size()
+ {
+ return messages.size();
+ }
+
+ /**
* @see java.lang.Object#toString()
*/
public String toString()
@@ -283,6 +354,17 @@ public final class FeedbackMessages implements IClusterable
}
/**
+ * Frees any unnecessary internal storage
+ */
+ public final void trimToSize()
+ {
+ if (messages instanceof ArrayList)
+ {
+ ((ArrayList)messages).trimToSize();
+ }
+ }
+
+ /**
* Adds a new ui message with level WARNING to the current messages.
*
* @param reporter
@@ -296,16 +378,6 @@ public final class FeedbackMessages implements IClusterable
}
/**
- * Adds a message
- * @param reporter
- * @param message
- * @param level
- */
- public final void add(Component reporter, String message, int level) {
- add(new FeedbackMessage(reporter, message, level));
- }
-
- /**
* Adds a message.
*
* @param message
@@ -319,25 +391,4 @@ public final class FeedbackMessages implements IClusterable
}
messages.add(message);
}
-
- /**
- * Gets an iterator over stored messages
- *
- * @return iterator over stored messages
- */
- public final Iterator iterator()
- {
- return messages.iterator();
- }
-
- /**
- * Frees any unnecessary internal storage
- */
- public final void trimToSize()
- {
- if(messages instanceof ArrayList)
- {
- ((ArrayList)messages).trimToSize();
- }
- }
}
\ No newline at end of file
diff --git a/jdk-1.4/wicket/src/main/java/wicket/feedback/FeedbackMessagesModel.java b/jdk-1.4/wicket/src/main/java/wicket/feedback/FeedbackMessagesModel.java
index 7b52300..82f39b2 100644
--- a/jdk-1.4/wicket/src/main/java/wicket/feedback/FeedbackMessagesModel.java
+++ b/jdk-1.4/wicket/src/main/java/wicket/feedback/FeedbackMessagesModel.java
@@ -17,13 +17,13 @@
package wicket.feedback;
import java.io.Serializable;
-import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import wicket.Component;
import wicket.Page;
+import wicket.Session;
import wicket.model.IModel;
/**
@@ -51,8 +51,9 @@ public class FeedbackMessagesModel implements IModel
* Constructor. Creates a model for all feedback messages on the page.
*
* @param component
- * The component where the page will be get from for which messages will be displayed
- * usually the same page as the one feedbackpanel is attached to
+ * The component where the page will be get from for which
+ * messages will be displayed usually the same page as the one
+ * feedbackpanel is attached to
*/
public FeedbackMessagesModel(Component component)
{
@@ -87,7 +88,7 @@ public class FeedbackMessagesModel implements IModel
{
return filter;
}
-
+
/**
* @return The current sorting comparator
*/
@@ -104,13 +105,7 @@ public class FeedbackMessagesModel implements IModel
if (messages == null)
{
// Get filtered messages from page where component lives
- List pageMessages = component.getPage().getFeedbackMessages().messages(filter);
-
- List sessionMessages = component.getSession().getFeedbackMessages().messages(filter);
-
- messages = new ArrayList(pageMessages.size() + sessionMessages.size());
- messages.addAll(pageMessages);
- messages.addAll(sessionMessages);
+ messages = Session.get().getFeedbackMessages().messages(filter);
// Sort the list before returning it
if (sortingComparator != null)
@@ -164,7 +159,7 @@ public class FeedbackMessagesModel implements IModel
{
return messages;
}
-
+
/**
*
* @see wicket.model.IModel#setObject(java.lang.Object)
@@ -172,7 +167,7 @@ public class FeedbackMessagesModel implements IModel
public void setObject(Object object)
{
}
-
+
/**
*
* @see wicket.model.IDetachable#detach()
diff --git a/jdk-1.4/wicket/src/main/java/wicket/markup/html/form/validation/FormComponentFeedbackBorder.java b/jdk-1.4/wicket/src/main/java/wicket/markup/html/form/validation/FormComponentFeedbackBorder.java
index 2198c9e..5d4f34a 100644
--- a/jdk-1.4/wicket/src/main/java/wicket/markup/html/form/validation/FormComponentFeedbackBorder.java
+++ b/jdk-1.4/wicket/src/main/java/wicket/markup/html/form/validation/FormComponentFeedbackBorder.java
@@ -16,6 +16,7 @@
*/
package wicket.markup.html.form.validation;
+import wicket.Session;
import wicket.feedback.ContainerFeedbackMessageFilter;
import wicket.feedback.IFeedback;
import wicket.feedback.IFeedbackMessageFilter;
@@ -87,7 +88,7 @@ public class FormComponentFeedbackBorder extends Border implements IFeedback
public void updateFeedback()
{
// Get the messages for the current page
- visible = getPage().getFeedbackMessages().messages(getMessagesFilter()).size() != 0;
+ visible = Session.get().getFeedbackMessages().messages(getMessagesFilter()).size() != 0;
}
/**
diff --git a/jdk-1.4/wicket/src/main/java/wicket/markup/html/form/validation/FormComponentFeedbackIndicator.java b/jdk-1.4/wicket/src/main/java/wicket/markup/html/form/validation/FormComponentFeedbackIndicator.java
index 0653181..bb76fee 100644
--- a/jdk-1.4/wicket/src/main/java/wicket/markup/html/form/validation/FormComponentFeedbackIndicator.java
+++ b/jdk-1.4/wicket/src/main/java/wicket/markup/html/form/validation/FormComponentFeedbackIndicator.java
@@ -17,6 +17,7 @@
package wicket.markup.html.form.validation;
import wicket.Component;
+import wicket.Session;
import wicket.feedback.ComponentFeedbackMessageFilter;
import wicket.feedback.IFeedback;
import wicket.feedback.IFeedbackMessageFilter;
@@ -36,7 +37,7 @@ import wicket.model.IModel;
public class FormComponentFeedbackIndicator extends Panel implements IFeedback
{
private static final long serialVersionUID = 1L;
-
+
/** The message filter for this indicator component */
private IFeedbackMessageFilter filter;
@@ -74,7 +75,7 @@ public class FormComponentFeedbackIndicator extends Panel implements IFeedback
public void updateFeedback()
{
// Get the messages for the current page
- setVisible(getPage().getFeedbackMessages().hasMessage(getFeedbackMessageFilter()));
+ setVisible(Session.get().getFeedbackMessages().hasMessage(getFeedbackMessageFilter()));
}
/**
diff --git a/jdk-1.4/wicket/src/main/java/wicket/request/target/component/listener/AbstractListenerInterfaceRequestTarget.java b/jdk-1.4/wicket/src/main/java/wicket/request/target/component/listener/AbstractListenerInterfaceRequestTarget.java
index 7d8fb92..ed88751 100644
--- a/jdk-1.4/wicket/src/main/java/wicket/request/target/component/listener/AbstractListenerInterfaceRequestTarget.java
+++ b/jdk-1.4/wicket/src/main/java/wicket/request/target/component/listener/AbstractListenerInterfaceRequestTarget.java
@@ -21,6 +21,7 @@ import wicket.Component;
import wicket.Page;
import wicket.RequestCycle;
import wicket.RequestListenerInterface;
+import wicket.Session;
import wicket.request.RequestParameters;
import wicket.request.target.IEventProcessor;
import wicket.request.target.component.PageRequestTarget;
@@ -189,7 +190,7 @@ public abstract class AbstractListenerInterfaceRequestTarget extends PageRequest
requestCycle.setUpdateSession(true);
// Clear all feedback messages if it isn't a redirect
- getPage().getFeedbackMessages().clear();
+ Session.get().cleanupFeedbackMessages(getPage());
getPage().startComponentRender(getTarget());
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-442_246d53c5.diff |
bugs-dot-jar_data_WICKET-172_99e22ce4 | ---
BugID: WICKET-172
Summary: Component reAttach and versioning
Description: "I'm reAttaching a component doing something like: \n\nMyFooPanel p1
= new MyFooPanel(this, \"panel\";); \nMyBarPanel p2 = new MyBarPanel(this, \"panel\");
\np1.reAttach(); \n\nWhen I try to restore to the initial page version I found that
the component with id \"panel\" is not a children component of the page. \n\nI have
investigated it and I think it is because when the component is reAttached the order
in which the changes are added to the ChangesList is: \n- Add p2. \n- Remove p1.
\n\nWhen the initial version is restored the undo functionality is done in reverse
mode like, \n- Add p1. \n- Remove p2. \n\nThe problem is p1 and p2 have the same
id, so when p2 is removed what is removing is p1 that has just added. \n\nOscar."
diff --git a/wicket/src/main/java/wicket/MarkupContainer.java b/wicket/src/main/java/wicket/MarkupContainer.java
index 3234316..395943c 100644
--- a/wicket/src/main/java/wicket/MarkupContainer.java
+++ b/wicket/src/main/java/wicket/MarkupContainer.java
@@ -90,7 +90,7 @@ import wicket.version.undo.Change;
* @see MarkupStream
* @author Jonathan Locke
*/
-public abstract class MarkupContainer<T> extends Component<T> implements Iterable<Component>
+public abstract class MarkupContainer<T> extends Component<T> implements Iterable<Component<?>>
{
private static final long serialVersionUID = 1L;
@@ -124,7 +124,7 @@ public abstract class MarkupContainer<T> extends Component<T> implements Iterabl
/**
* @see wicket.Component#Component(MarkupContainer,String)
*/
- public MarkupContainer(MarkupContainer parent, final String id)
+ public MarkupContainer(MarkupContainer<?> parent, final String id)
{
super(parent, id);
}
@@ -132,7 +132,7 @@ public abstract class MarkupContainer<T> extends Component<T> implements Iterabl
/**
* @see wicket.Component#Component(MarkupContainer,String, IModel)
*/
- public MarkupContainer(MarkupContainer parent, final String id, IModel<T> model)
+ public MarkupContainer(MarkupContainer<?> parent, final String id, IModel<T> model)
{
super(parent, id, model);
}
@@ -166,7 +166,7 @@ public abstract class MarkupContainer<T> extends Component<T> implements Iterabl
* operation.
* @return This
*/
- final MarkupContainer add(final Component<?> child)
+ final MarkupContainer<?> add(final Component<?> child)
{
if (child == null)
{
@@ -180,8 +180,7 @@ public abstract class MarkupContainer<T> extends Component<T> implements Iterabl
}
// Add to map
- addedComponent(child);
- Component replaced = put(child);
+ Component<?> replaced = put(child);
child.setFlag(FLAG_REMOVED_FROM_PARENT, false);
if (replaced != null)
{
@@ -195,6 +194,8 @@ public abstract class MarkupContainer<T> extends Component<T> implements Iterabl
String replacedId = (replaced.hasMarkupIdMetaData()) ? replaced.getMarkupId() : null;
child.setMarkupIdMetaData(replacedId);
}
+ // now call addedComponent (after removedComponent)
+ addedComponent(child);
return this;
}
@@ -229,7 +230,7 @@ public abstract class MarkupContainer<T> extends Component<T> implements Iterabl
* True if all descendents should be considered
* @return True if the component is contained in this container
*/
- public final boolean contains(final Component component, final boolean recurse)
+ public final boolean contains(final Component<?> component, final boolean recurse)
{
if (component == null)
{
@@ -239,10 +240,10 @@ public abstract class MarkupContainer<T> extends Component<T> implements Iterabl
if (recurse)
{
// Start at component and continue while we're not out of parents
- for (Component current = component; current != null;)
+ for (Component<?> current = component; current != null;)
{
// Get parent
- final MarkupContainer parent = current.getParent();
+ final MarkupContainer<?> parent = current.getParent();
// If this container is the parent, then the component is
// recursively contained by this container
@@ -274,7 +275,7 @@ public abstract class MarkupContainer<T> extends Component<T> implements Iterabl
* @return The component at the path
*/
@Override
- public final Component get(final String path)
+ public final Component<?> get(final String path)
{
// Reference to this container
if (path == null || path.trim().equals(""))
@@ -286,7 +287,7 @@ public abstract class MarkupContainer<T> extends Component<T> implements Iterabl
final String id = Strings.firstPathComponent(path, Component.PATH_SEPARATOR);
// Get child by id
- Component child = children_get(id);
+ Component<?> child = children_get(id);
// If the container is transparent, than ask its parent.
// ParentResolver does something quite similar, but because of <head>,
@@ -341,7 +342,7 @@ public abstract class MarkupContainer<T> extends Component<T> implements Iterabl
* Thrown if a child with the same id is replaced by the add
* operation.
*/
- public void internalAdd(final Component child)
+ public void internalAdd(final Component<?> child)
{
if (log.isDebugEnabled())
{
@@ -372,7 +373,7 @@ public abstract class MarkupContainer<T> extends Component<T> implements Iterabl
for (int i = 0; i < size; i++)
{
// Get next child
- final Component child = children_get(i);
+ final Component<?> child = children_get(i);
// Ignore feedback as that was done in Page
if (!(child instanceof IFeedback))
@@ -409,7 +410,7 @@ public abstract class MarkupContainer<T> extends Component<T> implements Iterabl
super.internalDetach();
// Loop through child components
- for (Component child : this)
+ for (Component<?> child : this)
{
// Call end request on the child
child.internalDetach();
@@ -420,9 +421,9 @@ public abstract class MarkupContainer<T> extends Component<T> implements Iterabl
* @return Iterator that iterates through children in the order they were
* added
*/
- public final Iterator<Component> iterator()
+ public final Iterator<Component<?>> iterator()
{
- return new Iterator<Component>()
+ return new Iterator<Component<?>>()
{
int index = 0;
@@ -431,7 +432,7 @@ public abstract class MarkupContainer<T> extends Component<T> implements Iterabl
return index < children_size();
}
- public Component next()
+ public Component<?> next()
{
return children_get(index++);
}
@@ -449,9 +450,9 @@ public abstract class MarkupContainer<T> extends Component<T> implements Iterabl
* @return Iterator that iterates over children in the order specified by
* comparator
*/
- public final Iterator<Component> iterator(Comparator<Component> comparator)
+ public final Iterator<Component<?>> iterator(Comparator<Component<?>> comparator)
{
- final List<Component> sorted;
+ final List<Component<?>> sorted;
if (children == null)
{
sorted = Collections.emptyList();
@@ -460,12 +461,12 @@ public abstract class MarkupContainer<T> extends Component<T> implements Iterabl
{
if (children instanceof Component)
{
- sorted = new ArrayList<Component>(1);
- sorted.add((Component)children);
+ sorted = new ArrayList<Component<?>>(1);
+ sorted.add((Component<?>)children);
}
else
{
- sorted = Arrays.asList((Component[])children);
+ sorted = Arrays.asList((Component<?>[])children);
}
}
Collections.sort(sorted, comparator);
@@ -476,7 +477,7 @@ public abstract class MarkupContainer<T> extends Component<T> implements Iterabl
* @param component
* Component to remove from this container
*/
- public void remove(final Component component)
+ public void remove(final Component<?> component)
{
if (component == null)
{
@@ -503,7 +504,7 @@ public abstract class MarkupContainer<T> extends Component<T> implements Iterabl
throw new IllegalArgumentException("argument id may not be null");
}
- final Component component = get(id);
+ final Component<?> component = get(id);
if (component != null)
{
remove(component);
@@ -685,7 +686,7 @@ public abstract class MarkupContainer<T> extends Component<T> implements Iterabl
for (int i = 0; i < size; i++)
{
// Get next child
- final Component child = children_get(i);
+ final Component<?> child = children_get(i);
if (i != 0)
{
buffer.append(' ');
@@ -709,7 +710,7 @@ public abstract class MarkupContainer<T> extends Component<T> implements Iterabl
* @return The return value from a visitor which halted the traversal, or
* null if the entire traversal occurred
*/
- public final Object visitChildren(final Class clazz, final IVisitor visitor)
+ public final Object visitChildren(final Class<?> clazz, final IVisitor visitor)
{
if (visitor == null)
{
@@ -720,7 +721,7 @@ public abstract class MarkupContainer<T> extends Component<T> implements Iterabl
for (int i = 0; i < children_size(); i++)
{
// Get next child component
- final Component child = children_get(i);
+ final Component<?> child = children_get(i);
Object value = null;
// Is the child of the correct class (or was no class specified)?
@@ -780,7 +781,7 @@ public abstract class MarkupContainer<T> extends Component<T> implements Iterabl
protected final MarkupStream findMarkupStream()
{
// Start here
- MarkupContainer c = this;
+ MarkupContainer<?> c = this;
// Walk up hierarchy until markup found
while (c.getMarkupStream() == null)
@@ -1025,7 +1026,7 @@ public abstract class MarkupContainer<T> extends Component<T> implements Iterabl
* @param child
* Child to add
*/
- private final void children_add(final Component child)
+ private final void children_add(final Component<?> child)
{
if (this.children == null)
{
@@ -1037,7 +1038,7 @@ public abstract class MarkupContainer<T> extends Component<T> implements Iterabl
final int size = children_size();
// Create array that holds size + 1 elements
- final Component[] children = new Component[size + 1];
+ final Component<?>[] children = new Component[size + 1];
// Loop through existing children copying them
for (int i = 0; i < size; i++)
@@ -1059,7 +1060,7 @@ public abstract class MarkupContainer<T> extends Component<T> implements Iterabl
{
if (children instanceof Component)
{
- return (Component)children;
+ return (Component<?>)children;
}
else
{
@@ -1072,11 +1073,11 @@ public abstract class MarkupContainer<T> extends Component<T> implements Iterabl
}
}
- private final Component children_get(final String id)
+ private final Component<?> children_get(final String id)
{
if (children instanceof Component)
{
- final Component component = (Component)children;
+ final Component<?> component = (Component<?>)children;
if (component.getId().equals(id))
{
return component;
@@ -1086,8 +1087,8 @@ public abstract class MarkupContainer<T> extends Component<T> implements Iterabl
{
if (children != null)
{
- final Component[] components = (Component[])children;
- for (Component element : components)
+ final Component<?>[] components = (Component[])children;
+ for (Component<?> element : components)
{
if (element.getId().equals(id))
{
@@ -1099,11 +1100,49 @@ public abstract class MarkupContainer<T> extends Component<T> implements Iterabl
return null;
}
+ /**
+ * Will search for this specific child instance in the current
+ * children. So it will do a identity check, it will not look if the
+ * id is already present in the children. Use indexOf(String) for that.
+ * @param child
+ * @return The index of this child.
+ */
private final int children_indexOf(Component<?> child)
{
if (children instanceof Component)
{
- if (((Component)children).getId().equals(child.getId()))
+ if (children == child)
+ {
+ return 0;
+ }
+ }
+ else
+ {
+ if (children != null)
+ {
+ final Component<?>[] components = (Component[])children;
+ for (int i = 0; i < components.length; i++)
+ {
+ if (components[i] == child)
+ {
+ return i;
+ }
+ }
+ }
+ }
+ return -1;
+ }
+
+ /**
+ * Will search for the id if it is found in the current children.
+ * @param id The id to search for.
+ * @return The index of this child.
+ */
+ private final int children_indexOf(String id)
+ {
+ if (children instanceof Component)
+ {
+ if (((Component<?>)children).getId().equals(id))
{
return 0;
}
@@ -1112,10 +1151,10 @@ public abstract class MarkupContainer<T> extends Component<T> implements Iterabl
{
if (children != null)
{
- final Component[] components = (Component[])children;
+ final Component<?>[] components = (Component[])children;
for (int i = 0; i < components.length; i++)
{
- if (components[i].getId().equals(child.getId()))
+ if (components[i].getId().equals(id))
{
return i;
}
@@ -1125,7 +1164,7 @@ public abstract class MarkupContainer<T> extends Component<T> implements Iterabl
return -1;
}
- private final Component children_remove(Component<?> component)
+ private final Component<?> children_remove(Component<?> component)
{
int index = children_indexOf(component);
if (index != -1)
@@ -1135,13 +1174,13 @@ public abstract class MarkupContainer<T> extends Component<T> implements Iterabl
return null;
}
- private final Component children_remove(int index)
+ private final Component<?> children_remove(int index)
{
if (children instanceof Component)
{
if (index == 0)
{
- final Component removed = (Component)children;
+ final Component<?> removed = (Component<?>)children;
this.children = null;
return removed;
}
@@ -1152,8 +1191,8 @@ public abstract class MarkupContainer<T> extends Component<T> implements Iterabl
}
else
{
- Component[] c = ((Component[])children);
- final Component removed = c[index];
+ Component<?>[] c = ((Component[])children);
+ final Component<?> removed = c[index];
if (c.length == 2)
{
if (index == 0)
@@ -1171,7 +1210,7 @@ public abstract class MarkupContainer<T> extends Component<T> implements Iterabl
}
else
{
- Component[] newChildren = new Component[c.length - 1];
+ Component<?>[] newChildren = new Component[c.length - 1];
int j = 0;
for (int i = 0; i < c.length; i++)
{
@@ -1186,19 +1225,19 @@ public abstract class MarkupContainer<T> extends Component<T> implements Iterabl
}
}
- private final Component children_set(int index, Component child)
+ private final Component<?> children_set(int index, Component<?> child)
{
- final Component replaced;
+ final Component<?> replaced;
if (index < children_size())
{
if (children == null || children instanceof Component)
{
- replaced = (Component)children;
+ replaced = (Component<?>)children;
children = child;
}
else
{
- final Component[] children = (Component[])this.children;
+ final Component<?>[] children = (Component[])this.children;
replaced = children[index];
children[index] = child;
}
@@ -1234,9 +1273,12 @@ public abstract class MarkupContainer<T> extends Component<T> implements Iterabl
* The child to put into the map
* @return Any component that was replaced
*/
- private final Component put(final Component<?> child)
+ private final Component<?> put(final Component<?> child)
{
- int index = children_indexOf(child);
+ // search for the child by id. So that it will
+ // find the right index for the id instead of looking
+ // if the component itself is already children.
+ int index = children_indexOf(child.getId());
if (index == -1)
{
children_add(child);
@@ -1410,7 +1452,7 @@ public abstract class MarkupContainer<T> extends Component<T> implements Iterabl
{
super.renderHead(response);
- for (Component child : this)
+ for (Component<?> child : this)
{
child.renderHead(response);
}
diff --git a/wicket/src/main/java/wicket/markup/repeater/RefreshingView.java b/wicket/src/main/java/wicket/markup/repeater/RefreshingView.java
index 87d61fe..29fe8c4 100644
--- a/wicket/src/main/java/wicket/markup/repeater/RefreshingView.java
+++ b/wicket/src/main/java/wicket/markup/repeater/RefreshingView.java
@@ -170,7 +170,7 @@ public abstract class RefreshingView<T> extends RepeatingView<T>
*/
public Iterator<Item<T>> getItems()
{
- final Iterator<Component> iterator = iterator();
+ final Iterator<Component<?>> iterator = iterator();
return new Iterator<Item<T>>()
{
public boolean hasNext()
diff --git a/wicket/src/main/java/wicket/markup/repeater/data/GridView.java b/wicket/src/main/java/wicket/markup/repeater/data/GridView.java
index 1f306fc..d1984e8 100644
--- a/wicket/src/main/java/wicket/markup/repeater/data/GridView.java
+++ b/wicket/src/main/java/wicket/markup/repeater/data/GridView.java
@@ -303,7 +303,7 @@ public abstract class GridView<T> extends DataViewBase<T>
*/
private static class ItemsIterator<T> implements Iterator<Item<T>>
{
- private Iterator<Component> rows;
+ private Iterator<Component<?>> rows;
private Iterator<Item<T>> cells;
private Item<T> next;
@@ -312,7 +312,7 @@ public abstract class GridView<T> extends DataViewBase<T>
* @param rows
* iterator over child row views
*/
- public ItemsIterator(Iterator<Component> rows)
+ public ItemsIterator(Iterator<Component<?>> rows)
{
this.rows = rows;
findNext();
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-172_99e22ce4.diff |
bugs-dot-jar_data_WICKET-5565_204849bc | ---
BugID: WICKET-5565
Summary: PackageMapper - Could not resolve class
Description: "It seems that the PackageMapper try to resolve much more than it is
supposed to do, for instance if I've 2 pages test1/TestPage1 and test2/TestPage2
then it tries to resolve test2/TestPage1 when I reach the page1... \n\nWARN - WicketObjects
\ - Could not resolve class [com.mycompany.test2.TestPage1]\njava.lang.ClassNotFoundException:
com.mycompany.test2.TestPage1\n at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)\n
\ at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)\n
\ at java.lang.Class.forName0(Native Method)\n at java.lang.Class.forName(Class.java:270)\n
\ at org.apache.wicket.application.AbstractClassResolver.resolveClass(AbstractClassResolver.java:108)\n
\ at org.apache.wicket.core.util.lang.WicketObjects.resolveClass(WicketObjects.java:71)\n
\ at org.apache.wicket.core.request.mapper.AbstractComponentMapper.getPageClass(AbstractComponentMapper.java:134)\n
\ at org.apache.wicket.core.request.mapper.PackageMapper.parseRequest(PackageMapper.java:152)\n
\ at org.apache.wicket.core.request.mapper.AbstractBookmarkableMapper.mapRequest(AbstractBookmarkableMapper.java:322)\n
\ at org.apache.wicket.request.mapper.CompoundRequestMapper.mapRequest(CompoundRequestMapper.java:152)\n
\ at org.apache.wicket.request.cycle.RequestCycle.resolveRequestHandler(RequestCycle.java:189)\n
\ at org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:219)\n
\ at org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:293)\n
\ at org.apache.wicket.protocol.http.WicketFilter.processRequestCycle(WicketFilter.java:261)\n
\ at org.apache.wicket.protocol.http.WicketFilter.processRequest(WicketFilter.java:203)\n
\ at org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:284)"
diff --git a/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/AbstractBookmarkableMapper.java b/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/AbstractBookmarkableMapper.java
index e9ad89c..e38d956 100644
--- a/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/AbstractBookmarkableMapper.java
+++ b/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/AbstractBookmarkableMapper.java
@@ -204,7 +204,25 @@ public abstract class AbstractBookmarkableMapper extends AbstractComponentMapper
* @see IRequestMapper#getCompatibilityScore(Request)
*/
@Override
- public abstract int getCompatibilityScore(Request request);
+ public int getCompatibilityScore(Request request)
+ {
+ if (urlStartsWith(request.getUrl(), mountSegments))
+ {
+ /* see WICKET-5056 - alter score with pathSegment type */
+ int countOptional = 0;
+ int fixedSegments = 0;
+ for (MountPathSegment pathSegment : pathSegments)
+ {
+ fixedSegments += pathSegment.getFixedPartSize();
+ countOptional += pathSegment.getOptionalParameters();
+ }
+ return mountSegments.length - countOptional + fixedSegments;
+ }
+ else
+ {
+ return 0;
+ }
+ }
/**
* Creates a {@code IRequestHandler} that processes a bookmarkable request.
diff --git a/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/MountedMapper.java b/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/MountedMapper.java
index da6c4c4..fdf1dc2 100644
--- a/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/MountedMapper.java
+++ b/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/MountedMapper.java
@@ -268,30 +268,6 @@ public class MountedMapper extends AbstractBookmarkableMapper
}
/**
- * @see AbstractBookmarkableMapper#getCompatibilityScore(org.apache.wicket.request.Request)
- */
- @Override
- public int getCompatibilityScore(Request request)
- {
- if (urlStartsWith(request.getUrl(), mountSegments))
- {
- /* see WICKET-5056 - alter score with pathSegment type */
- int countOptional = 0;
- int fixedSegments = 0;
- for (MountPathSegment pathSegment : pathSegments)
- {
- fixedSegments += pathSegment.getFixedPartSize();
- countOptional += pathSegment.getOptionalParameters();
- }
- return mountSegments.length - countOptional + fixedSegments;
- }
- else
- {
- return 0;
- }
- }
-
- /**
* @see AbstractBookmarkableMapper#checkPageClass(java.lang.Class)
*/
@Override
diff --git a/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/PackageMapper.java b/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/PackageMapper.java
index 2037356..ff8b81a 100644
--- a/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/PackageMapper.java
+++ b/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/PackageMapper.java
@@ -221,17 +221,4 @@ public class PackageMapper extends AbstractBookmarkableMapper
{
return false;
}
-
- @Override
- public int getCompatibilityScore(Request request)
- {
- if (urlStartsWith(request.getUrl(), mountSegments))
- {
- return mountSegments.length;
- }
- else
- {
- return 0;
- }
- }
}
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5565_204849bc.diff |
bugs-dot-jar_data_WICKET-4717_6a1b2f61 | ---
BugID: WICKET-4717
Summary: StringValidator.exactLength has wrong variable in ErrorMessage
Description: "In error message for StringValidator.exactLength is variable ${exact}
, but in StringValidator.decorate is added variable length to map and not exact.
\n\nException when is error message interpolate for show in feedback.\n\nCaused
by: java.lang.IllegalArgumentException: Value of variable [[exact]] could not be
resolved while interpolating [['${label}' is not exactly ${exact} characters long.]]\n\nproperty
from application.\nStringValidator.exact='${label}' is not exactly ${exact} characters
long.\n\nWhen I added same property in my own properties and change exact to length,
it works."
diff --git a/wicket-core/src/main/java/org/apache/wicket/validation/validator/AbstractRangeValidator.java b/wicket-core/src/main/java/org/apache/wicket/validation/validator/AbstractRangeValidator.java
index babc170..f6ba851 100644
--- a/wicket-core/src/main/java/org/apache/wicket/validation/validator/AbstractRangeValidator.java
+++ b/wicket-core/src/main/java/org/apache/wicket/validation/validator/AbstractRangeValidator.java
@@ -109,7 +109,8 @@ public abstract class AbstractRangeValidator<R extends Comparable<R> & Serializa
final R max = getMaximum();
if ((min != null && value.compareTo(min) < 0) || (max != null && value.compareTo(max) > 0))
{
- ValidationError error = new ValidationError(this, getMode().getVariation());
+ Mode mode = getMode();
+ ValidationError error = new ValidationError(this, mode.getVariation());
if (min != null)
{
error.setVariable("minimum", min);
@@ -118,6 +119,10 @@ public abstract class AbstractRangeValidator<R extends Comparable<R> & Serializa
{
error.setVariable("maximum", max);
}
+ if (mode == Mode.EXACT)
+ {
+ error.setVariable("exact", max);
+ }
validatable.error(decorate(error, validatable));
}
}
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-4717_6a1b2f61.diff |
bugs-dot-jar_data_WICKET-5569_5efb8091 | ---
BugID: WICKET-5569
Summary: Unable to find markup for children of deeply nested IComponentResolvers during
Ajax response
Description: |-
Component hierarchy: Page -> WebMarkupContainer -> IComponentResolver (that uses Page to resolve) and Page -> Panel.
Markup hierarchy: Page -> WebMarkupContainer -> IComponentResolver -> Panel.
When rendering whole page, it works, because it is markup driven. Wicket encounters ComponentTag for Panel and resolves the Panel using IComponentResolver, which retrieves the Panel from the Page.
When you add the Panel to an AjaxRequestTarget, the render is component driven. In order to render the Panel, we must retrieve the markup for the Panel from its parent MarkupContainer, which happens to be the Page.
Markup.java around line 230 skips to closing tags of ComponentTag, so when Page gets to the opening tag of the WebMarkupContainer, it skips to the closing tag of the WebMarkupContainer, and so passes over the ComponentTag for Panel without noticing it. There is actually another check, in DefaultMarkupSourcingStrategy, that tries to fetch from all the "transparent" components in the markup container, but this is not good enough, because in our example, the IComponentResolver is not actually a direct child of the Panel's parent, to it is never used to try find the markup.
One solution might be to traverse the tree, and attempt to find the markup from all IComponentResolving MarkupContainers, but we should be careful. I'm a bit concerned at how various parts of Wicket just assume that an IComponentResolver is transparent and resolves from its direct parent only.
If we do go down the route of traversing the tree to find IComponentResolvers, then try find the markup from each of them, we really should add a check in AbstractMarkupSourcingStrategy#searchMarkupInTransparentResolvers() to check that the Component that the IComponentResolver resolves for the markup id is the same component for which we are looking for markup.
This is a difficult one. I am working around it for the mean time, just recording the difficulty here. Will try make a patch when I can.
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 c7fe735..cbddd25 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
@@ -26,6 +26,8 @@ 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.
@@ -60,22 +62,37 @@ public abstract class AbstractMarkupSourcingStrategy implements IMarkupSourcingS
protected IMarkupFragment searchMarkupInTransparentResolvers(final MarkupContainer container,
final Component child)
{
- IMarkupFragment markup = null;
-
- for (Component ch : container)
+ return container.visitChildren(MarkupContainer.class, new IVisitor<MarkupContainer, IMarkupFragment>()
{
- if ((ch != child) && (ch instanceof MarkupContainer) &&
- (ch instanceof IComponentResolver))
+ @Override
+ public void component(MarkupContainer resolvingContainer, IVisit<IMarkupFragment> visit)
{
- markup = ((MarkupContainer)ch).getMarkup(child);
- if (markup != null)
+ if (resolvingContainer instanceof IComponentResolver)
{
- break;
+ IMarkupFragment childMarkup = resolvingContainer.getMarkup(child);
+
+ if (childMarkup != null && childMarkup.size() > 0)
+ {
+ 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);
+ }
+ }
}
}
- }
-
- return markup;
+ });
}
/**
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5569_5efb8091.diff |
bugs-dot-jar_data_WICKET-2057_e2d88568 | ---
BugID: WICKET-2057
Summary: AjaxPreprocessingCallDecorator calls the delegate decorator before itself
(same behavior as AjaxPostprocessingCallDecorator)
Description: AjaxPreprocessingCallDecorator calls the delegate decorator before itself
(same behavior as AjaxPostprocessingCallDecorator), when it should call itself before
the delegate.
diff --git a/wicket/src/main/java/org/apache/wicket/ajax/calldecorator/AjaxPreprocessingCallDecorator.java b/wicket/src/main/java/org/apache/wicket/ajax/calldecorator/AjaxPreprocessingCallDecorator.java
index f57a2d4..a37d6ed 100644
--- a/wicket/src/main/java/org/apache/wicket/ajax/calldecorator/AjaxPreprocessingCallDecorator.java
+++ b/wicket/src/main/java/org/apache/wicket/ajax/calldecorator/AjaxPreprocessingCallDecorator.java
@@ -49,8 +49,9 @@ public class AjaxPreprocessingCallDecorator implements IAjaxCallDecorator
*/
public CharSequence decorateScript(CharSequence script)
{
- CharSequence s = (delegate == null) ? script : delegate.decorateScript(script);
- return preDecorateScript(s);
+ CharSequence s = preDecorateScript(script);
+ return (delegate == null) ? s : delegate.decorateScript(s);
+
}
/**
@@ -58,8 +59,8 @@ public class AjaxPreprocessingCallDecorator implements IAjaxCallDecorator
*/
public CharSequence decorateOnSuccessScript(CharSequence script)
{
- CharSequence s = (delegate == null) ? script : delegate.decorateOnSuccessScript(script);
- return preDecorateOnSuccessScript(s);
+ CharSequence s = preDecorateOnSuccessScript(script);
+ return (delegate == null) ? s : delegate.decorateOnSuccessScript(s);
}
/**
@@ -67,8 +68,9 @@ public class AjaxPreprocessingCallDecorator implements IAjaxCallDecorator
*/
public CharSequence decorateOnFailureScript(CharSequence script)
{
- CharSequence s = (delegate == null) ? script : delegate.decorateOnFailureScript(script);
- return preDecorateOnFailureScript(s);
+ CharSequence s = preDecorateOnFailureScript(script);
+
+ return (delegate == null) ? s : delegate.decorateOnFailureScript(s);
}
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-2057_e2d88568.diff |
bugs-dot-jar_data_WICKET-4519_e62ded51 | ---
BugID: WICKET-4519
Summary: discrepancy between JavaDoc and code in MarkupContainer#visitChildren()
Description: |-
The JavaDoc for MarkupContainer#visitChildren() states that
"@param clazz The class of child to visit, or null to visit all children"
The parameter clazz is used to create a new ClassVisitFilter which in
its visitObject() does not check for clazz == null, leading to a NPE.
diff --git a/wicket-util/src/main/java/org/apache/wicket/util/visit/ClassVisitFilter.java b/wicket-util/src/main/java/org/apache/wicket/util/visit/ClassVisitFilter.java
index c94e069..0a7d0b1 100644
--- a/wicket-util/src/main/java/org/apache/wicket/util/visit/ClassVisitFilter.java
+++ b/wicket-util/src/main/java/org/apache/wicket/util/visit/ClassVisitFilter.java
@@ -45,6 +45,6 @@ public class ClassVisitFilter<T> implements IVisitFilter
/** {@inheritDoc} */
public boolean visitObject(final Object object)
{
- return clazz.isAssignableFrom(object.getClass());
+ return clazz == null || clazz.isAssignableFrom(object.getClass());
}
}
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-4519_e62ded51.diff |
bugs-dot-jar_data_WICKET-3420_be97d017 | ---
BugID: WICKET-3420
Summary: javascript with a less than character ("<") fails to execute when added through
a header contribution in ajax response
Description: "This is adapted from a wicket users post I made (links are to the same
thread in two archive systems):\n\nhttp://markmail.org/search/?q=wicket%20users%20wicket-ajax.js#query:wicket%20users%20wicket-ajax.js+page:1+mid:rfts3ar3upffhbbt+state:results\n\nhttp://mail-archives.apache.org/mod_mbox/wicket-users/201102.mbox/%[email protected]%3E\n\nThe
problem: I have a panel with this:\n\n <wicket:head>\n\t<script>\n\t\tif (someVariable
< 0) {\n\t\t\tsomeVariable = 0;\t\t\n\t\t}\n\t</script>\n </wicket:head>\n\nThis
script fails to execute when the panel is loaded by ajax. If I replace the less
than character \"<\" with equals \"==\", then it executes (but of course, this is
not what I need).\n\nI tested this in Firefox 4.0b10 and Chrome 8.\n\nAfter some
debugging, it seems to me that this needs to be corrected in wicket-ajax.js. The
header contribution is sent to the browser inside of a CDATA section so the \"<\"
character arrives to javascript intact. However, in parsing the script tag, the
\"<\" seems to signal the beginning of an HTML tag that then is considered malformed.\n\n\nPossible
workarounds for apps:\n\n - Invert the logic so a greater-than is used. In my example,
this would be: \"if (0 > someVariable) {\"\n - Put the code into a separate JS file
(the downside is it requires another network hop from the browser)\n - Embed the
script in <wicket:panel> rather than <wicket:head> (the disadvantage is the script
will be re-sent with the panel content when the panel is re-used on the same page)\n\n"
diff --git a/wicket-core/src/main/java/org/apache/wicket/pageStore/DefaultPageStore.java b/wicket-core/src/main/java/org/apache/wicket/pageStore/DefaultPageStore.java
index 17a812b..675f320 100644
--- a/wicket-core/src/main/java/org/apache/wicket/pageStore/DefaultPageStore.java
+++ b/wicket-core/src/main/java/org/apache/wicket/pageStore/DefaultPageStore.java
@@ -22,7 +22,6 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
-import org.apache.wicket.Page;
import org.apache.wicket.page.IManageablePage;
import org.apache.wicket.util.lang.Args;
import org.apache.wicket.util.lang.Objects;
@@ -275,7 +274,7 @@ public class DefaultPageStore implements IPageStore
{
return null;
}
- else if (!storeAfterSessionReplication() || serializable instanceof Page)
+ else if (!storeAfterSessionReplication() || serializable instanceof IManageablePage)
{
return serializable;
}
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-3420_be97d017.diff |
bugs-dot-jar_data_WICKET-2181_d79d0192 | ---
BugID: WICKET-2181
Summary: Bounds error in PageableListView#getCurrentPage()
Description: |-
In the getCurrentPage() method of class PageableListView, the following code:
while ((currentPage * rowsPerPage) > getList().size())
{
currentPage--;
}
checks if "first cell if out of range". However, the index of that first cell is (currentPage * rowsPerPage), and then the comparison with getList().size() should use a ">=" instead a ">".
diff --git a/wicket/src/main/java/org/apache/wicket/markup/html/list/PageableListView.java b/wicket/src/main/java/org/apache/wicket/markup/html/list/PageableListView.java
index 707cef4..e1b2e77 100644
--- a/wicket/src/main/java/org/apache/wicket/markup/html/list/PageableListView.java
+++ b/wicket/src/main/java/org/apache/wicket/markup/html/list/PageableListView.java
@@ -84,7 +84,7 @@ public abstract class PageableListView<T> extends ListView<T> implements IPageab
public final int getCurrentPage()
{
// If first cell is out of range, bring page back into range
- while ((currentPage * rowsPerPage) >= getList().size())
+ while ((currentPage > 0) && ((currentPage * rowsPerPage) >= getList().size()))
{
currentPage--;
}
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-2181_d79d0192.diff |
bugs-dot-jar_data_WICKET-3065_b293b75c | ---
BugID: WICKET-3065
Summary: HomePageMapper ignores request to '/' with query string parameters
Description: "Issue a request to http://host:port/contextpath/?something\nWicket will
log an error message like:\nERROR - RequestCycle - Unable to execute
request. No suitable RequestHandler found. URL=?something\n\nI think the reason
is in HomePageMapper which maps to the configured home page only if there are no
query parameters.\n\nHomePageMapper.java:\n{code}\npublic IRequestHandler mapRequest(Request
request)\n\t{\n\t\tif (request.getUrl().getSegments().size() == 0 &&\n\t\t\trequest.getUrl().getQueryParameters().size()
== 0)\n\t\t{\n\t\t\treturn new RenderPageRequestHandler(new PageProvider(getContext().getHomePageClass()));\n\t\t}\n\t\telse\n\t\t{\n\t\t\treturn
null;\n\t\t}\n\t}\n{code}"
diff --git a/wicket/src/main/java/org/apache/wicket/request/mapper/HomePageMapper.java b/wicket/src/main/java/org/apache/wicket/request/mapper/HomePageMapper.java
index e4f6c8b..b44207d 100644
--- a/wicket/src/main/java/org/apache/wicket/request/mapper/HomePageMapper.java
+++ b/wicket/src/main/java/org/apache/wicket/request/mapper/HomePageMapper.java
@@ -87,6 +87,7 @@ public class HomePageMapper extends AbstractComponentMapper
{
pageProvider = new PageProvider(homePageClass);
}
+ pageProvider.setPageSource(getContext());
return new RenderPageRequestHandler(pageProvider);
}
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-3065_b293b75c.diff |
bugs-dot-jar_data_WICKET-3222_5729ed90 | ---
BugID: WICKET-3222
Summary: AbstractMarkupParser doesn't remove Comments correctly
Description: |-
AbstractMarkupParser removeComment(...) doesn't remove Comments correctly
if two html comments stand to close together <!-- foo --> <!-- bar -->
foo will be removed but not bar.
see:
https://github.com/mafulafunk/wicketComments
[email protected]:mafulafunk/wicketComments.git
diff --git a/wicket/src/main/java/org/apache/wicket/markup/AbstractMarkupParser.java b/wicket/src/main/java/org/apache/wicket/markup/AbstractMarkupParser.java
index de976e7..51c46e6 100644
--- a/wicket/src/main/java/org/apache/wicket/markup/AbstractMarkupParser.java
+++ b/wicket/src/main/java/org/apache/wicket/markup/AbstractMarkupParser.java
@@ -30,7 +30,6 @@ import org.apache.wicket.markup.parser.filter.RootMarkupFilter;
import org.apache.wicket.settings.IMarkupSettings;
import org.apache.wicket.util.resource.ResourceStreamNotFoundException;
import org.apache.wicket.util.resource.StringResourceStream;
-import org.apache.wicket.util.string.AppendingStringBuffer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -404,9 +403,9 @@ public abstract class AbstractMarkupParser
int pos1 = rawMarkup.indexOf("<!--");
while (pos1 != -1)
{
- final int pos2 = rawMarkup.indexOf("-->", pos1 + 4);
+ int pos2 = rawMarkup.indexOf("-->", pos1 + 4);
- final AppendingStringBuffer buf = new AppendingStringBuffer(rawMarkup.length());
+ final StringBuilder buf = new StringBuilder(rawMarkup.length());
if (pos2 != -1)
{
final String comment = rawMarkup.substring(pos1 + 4, pos2);
@@ -424,8 +423,12 @@ public abstract class AbstractMarkupParser
}
rawMarkup = buf.toString();
}
+ else
+ {
+ pos1 = pos2;
+ }
}
- pos1 = rawMarkup.length() <= pos1 + 2 ? -1 : rawMarkup.indexOf("<!--", pos1 + 4);
+ pos1 = rawMarkup.indexOf("<!--", pos1);
}
return rawMarkup;
}
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-3222_5729ed90.diff |
bugs-dot-jar_data_WICKET-2609_7da4ad17 | ---
BugID: WICKET-2609
Summary: EnumChoiceRenderer misbehaves with anonymous enum classes
Description: |-
Please find attached testcase reproducing the problem.
Proper fix is to do
return object.getDeclaringClass().getSimpleName() + "." + object.name()
instead of
return object.getClass().getSimpleName() + "." + object.name()
in EnumChoiceRenderer.resourceKey
diff --git a/wicket/src/main/java/org/apache/wicket/markup/html/form/EnumChoiceRenderer.java b/wicket/src/main/java/org/apache/wicket/markup/html/form/EnumChoiceRenderer.java
index 3af4e49..9181c8e 100644
--- a/wicket/src/main/java/org/apache/wicket/markup/html/form/EnumChoiceRenderer.java
+++ b/wicket/src/main/java/org/apache/wicket/markup/html/form/EnumChoiceRenderer.java
@@ -94,7 +94,7 @@ public class EnumChoiceRenderer<T extends Enum<T>> implements IChoiceRenderer<T>
*/
protected String resourceKey(T object)
{
- return object.getClass().getSimpleName() + "." + object.name();
+ return object.getDeclaringClass().getSimpleName() + "." + object.name();
}
/**
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-2609_7da4ad17.diff |
bugs-dot-jar_data_WICKET-5662_9aec4f33 | ---
BugID: WICKET-5662
Summary: '@SpringBean(name="something", required=false) still throws org.springframework.beans.factory.NoSuchBeanDefinitionException:
No bean named ''something'' is defined'
Description: "Example:\n\n{code}\npublic class TwitterLoginLink extends StatelessLink<Void>
{\n\t\t\t\n\t@SpringBean(name=\"twitterMgr\", required=false)\n\tprivate TwitterManager
twitterMgr;\n{code}\n\nstill throws:\n\n{code}\norg.springframework.beans.factory.NoSuchBeanDefinitionException:
No bean named 'twitterMgr' is defined\nat org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:641)\nat
org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1159)\nat
org.springframework.beans.factory.support.AbstractBeanFactory.isSingleton(AbstractBeanFactory.java:418)\nat
org.springframework.context.support.AbstractApplicationContext.isSingleton(AbstractApplicationContext.java:1002)\nat
org.apache.wicket.spring.SpringBeanLocator.isSingletonBean(SpringBeanLocator.java)\nat
org.apache.wicket.spring.injection.annot.AnnotProxyFieldValueFactory.getFieldValue(AnnotProxyFieldValueFactory.java:141)\nat
org.apache.wicket.injection.Injector.inject(Injector.java:111)\nat org.apache.wicket.spring.injection.annot.SpringComponentInjector.inject(SpringComponentInjector.java:124)\nat
org.apache.wicket.spring.injection.annot.SpringComponentInjector.onInstantiation(SpringComponentInjector.java:130)\nat
org.apache.wicket.application.ComponentInstantiationListenerCollection$1.notify(ComponentInstantiationListenerCollection.java:38)\nat
org.apache.wicket.application.ComponentInstantiationListenerCollection$1.notify(ComponentInstantiationListenerCollection.java:34)\nat
org.apache.wicket.util.listener.ListenerCollection.notify(ListenerCollection.java:80)\nat
org.apache.wicket.application.ComponentInstantiationListenerCollection.onInstantiation(ComponentInstantiationListenerCollection.java:33)\nat
org.apache.wicket.Component.<init>(Component.java:686)\nat org.apache.wicket.MarkupContainer.<init>(MarkupContainer.java:121)\nat
org.apache.wicket.markup.html.WebMarkupContainer.<init>(WebMarkupContainer.java:52)\nat
org.apache.wicket.markup.html.link.AbstractLink.<init>(AbstractLink.java:57)\nat
org.apache.wicket.markup.html.link.AbstractLink.<init>(AbstractLink.java:44)\nat
org.apache.wicket.markup.html.link.Link.<init>(Link.java:105)\nat org.apache.wicket.markup.html.link.StatelessLink.<init>(StatelessLink.java:42)\nat
org.soluvas.web.login.twitter.TwitterLoginLink.<init>(TwitterLoginLink.java:40)\nat
org.soluvas.web.login.DedicatedLoginPanel$FormSignIn.<init>(DedicatedLoginPanel.java:90)\nat
org.soluvas.web.login.DedicatedLoginPanel.onInitialize(DedicatedLoginPanel.java:58)\nat
org.apache.wicket.Component.fireInitialize(Component.java:876)\nat org.apache.wicket.MarkupContainer$3.component(MarkupContainer.java:967)\nat
org.apache.wicket.MarkupContainer$3.component(MarkupContainer.java:963)\nat org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:144)\nat
org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:123)\nat org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:192)\nat
org.apache.wicket.MarkupContainer.visitChildren(MarkupContainer.java:875)\nat org.apache.wicket.MarkupContainer.internalInitialize(MarkupContainer.java:962)\nat
org.apache.wicket.Page.isPageStateless(Page.java:463)\nat org.apache.wicket.core.request.mapper.AbstractBookmarkableMapper.getPageInfo(AbstractBookmarkableMapper.java:447)\nat
org.apache.wicket.core.request.mapper.AbstractBookmarkableMapper.mapHandler(AbstractBookmarkableMapper.java:391)\nat
org.apache.wicket.core.request.mapper.MountedMapper.mapHandler(MountedMapper.java:395)\nat
org.apache.wicket.request.mapper.CompoundRequestMapper.mapHandler(CompoundRequestMapper.java:215)\nat
org.apache.wicket.request.cycle.RequestCycle.mapUrlFor(RequestCycle.java:429)\nat
org.apache.wicket.request.handler.render.WebPageRenderer.respond(WebPageRenderer.java:273)\nat
org.apache.wicket.core.request.handler.RenderPageRequestHandler.respond(RenderPageRequestHandler.java:175)\nat
org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:862)\nat
org.apache.wicket.request.RequestHandlerStack.execute(RequestHandlerStack.java:64)\nat
org.apache.wicket.request.cycle.RequestCycle.execute(RequestCycle.java:261)\nat
org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:218)\nat
org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:289)\nat
org.apache.wicket.protocol.http.WicketFilter.processRequestCycle(WicketFilter.java:259)\nat
org.apache.wicket.protocol.http.WicketFilter.processRequest(WicketFilter.java:201)\nat
org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:282)\nat
org.soluvas.web.site.SecuredWicketAtmosphereHandler$CustomFilterChain.doFilter(SecuredWicketAtmosphereHandler.java:199)\nat
org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)\nat
org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)\nat
org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)\nat
org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)\nat
org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:383)\nat
org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)\nat
org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)\nat
org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:344)\nat
org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:261)\nat
org.soluvas.web.site.SecuredWicketAtmosphereHandler$CustomFilterChain.doFilter(SecuredWicketAtmosphereHandler.java:199)\nat
org.soluvas.web.site.SecuredWicketAtmosphereHandler$CustomFilterChain.invokeFilterChain(SecuredWicketAtmosphereHandler.java:185)\nat
org.soluvas.web.site.SecuredWicketAtmosphereHandler.onRequest(SecuredWicketAtmosphereHandler.java:91)\nat
org.atmosphere.cpr.AsynchronousProcessor.action(AsynchronousProcessor.java:187)\nat
org.atmosphere.cpr.AsynchronousProcessor.suspended(AsynchronousProcessor.java:98)\nat
org.atmosphere.container.Tomcat7CometSupport.service(Tomcat7CometSupport.java:96)\nat
org.atmosphere.cpr.AtmosphereFramework.doCometSupport(AtmosphereFramework.java:1809)\nat
org.atmosphere.cpr.AtmosphereServlet.event(AtmosphereServlet.java:255)\nat org.apache.catalina.core.ApplicationFilterChain.internalDoFilterEvent(ApplicationFilterChain.java:484)\nat
org.apache.catalina.core.ApplicationFilterChain.doFilterEvent(ApplicationFilterChain.java:377)\nat
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)\nat
org.apache.catalina.core.StandardContextValve.__invoke(StandardContextValve.java:123)\nat
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java)\nat
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)\nat
org.apache.catalina.core.StandardHostValve.__invoke(StandardHostValve.java:171)\nat
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java)\nat org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)\nat
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)\nat org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)\nat
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)\nat
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023)\nat
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)\nat
org.apache.tomcat.util.net.AprEndpoint$SocketWithOptionsProcessor.run(AprEndpoint.java:1810)\nat
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)\nat
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)\nat
java.lang.Thread.run(Thread.java:745)\n{code}\n\nWorkaround:\n\n{code}\n @Autowire(required=false)\n
\ private TwitterManager twitterMgr;\n{code}\n"
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 a022792..a279126 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
@@ -19,6 +19,7 @@ package org.apache.wicket.spring;
import java.lang.ref.WeakReference;
import org.apache.wicket.proxy.IProxyTargetLocator;
+import org.apache.wicket.util.lang.Args;
import org.apache.wicket.util.lang.Objects;
import org.apache.wicket.core.util.lang.WicketObjects;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
@@ -73,14 +74,8 @@ public class SpringBeanLocator implements IProxyTargetLocator
public SpringBeanLocator(final String beanName, final Class<?> beanType,
final ISpringContextLocator locator)
{
- if (locator == null)
- {
- throw new IllegalArgumentException("[locator] argument cannot be null");
- }
- if (beanType == null)
- {
- throw new IllegalArgumentException("[beanType] argument cannot be null");
- }
+ Args.notNull(locator, "locator");
+ Args.notNull(beanType, "beanType");
beanTypeCache = new WeakReference<Class<?>>(beanType);
beanTypeName = beanType.getName();
@@ -122,9 +117,6 @@ public class SpringBeanLocator implements IProxyTargetLocator
return clazz;
}
- /**
- * @see org.apache.wicket.proxy.IProxyTargetLocator#locateProxyTarget()
- */
@Override
public Object locateProxyTarget()
{
@@ -174,11 +166,10 @@ public class SpringBeanLocator implements IProxyTargetLocator
* bean name
* @param clazz
* bean class
- * @throws IllegalStateException
+ * @throws java.lang.IllegalStateException
* @return found bean
*/
- private static Object lookupSpringBean(final ApplicationContext ctx, final String name,
- final Class<?> clazz)
+ private Object lookupSpringBean(ApplicationContext ctx, String name, Class<?> clazz)
{
try
{
@@ -194,7 +185,7 @@ public class SpringBeanLocator implements IProxyTargetLocator
catch (NoSuchBeanDefinitionException e)
{
throw new IllegalStateException("bean with name [" + name + "] and class [" +
- clazz.getName() + "] not found");
+ clazz.getName() + "] not found", e);
}
}
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 648d2c7..6b7d071 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
@@ -110,7 +110,23 @@ public class AnnotProxyFieldValueFactory implements IFieldValueFactory
{
if (supportsField(field))
{
- String beanName = getBeanName(field);
+ SpringBean annot = field.getAnnotation(SpringBean.class);
+
+ String name;
+ boolean required;
+ if (annot != null)
+ {
+ name = annot.name();
+ required = annot.required();
+ }
+ else
+ {
+ Named named = field.getAnnotation(Named.class);
+ name = named != null ? named.value() : "";
+ required = false;
+ }
+
+ String beanName = getBeanName(field, name, required);
if (beanName == null)
{
@@ -128,13 +144,26 @@ public class AnnotProxyFieldValueFactory implements IFieldValueFactory
}
Object target;
- if (wrapInProxies)
+ try
{
- target = LazyInitProxyFactory.createProxy(field.getType(), locator);
+ // check whether there is a bean with the provided properties
+ target = locator.locateProxyTarget();
}
- else
+ catch (IllegalStateException isx)
{
- target = locator.locateProxyTarget();
+ if (required)
+ {
+ throw isx;
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ if (wrapInProxies)
+ {
+ target = LazyInitProxyFactory.createProxy(field.getType(), locator);
}
// only put the proxy into the cache if the bean is a singleton
@@ -156,31 +185,20 @@ public class AnnotProxyFieldValueFactory implements IFieldValueFactory
* @param field
* @return bean name
*/
- private String getBeanName(final Field field)
+ private String getBeanName(final Field field, String name, boolean required)
{
- SpringBean annot = field.getAnnotation(SpringBean.class);
-
- String name;
- boolean required;
- if (annot != null) {
- name = annot.name();
- required = annot.required();
- } else {
- Named named = field.getAnnotation(Named.class);
- name = named != null ? named.value() : "";
- required = false;
- }
if (Strings.isEmpty(name))
{
- name = beanNameCache.get(field.getType());
+ Class<?> fieldType = field.getType();
+ name = beanNameCache.get(fieldType);
if (name == null)
{
- name = getBeanNameOfClass(contextLocator.getSpringContext(), field.getType(), required);
+ name = getBeanNameOfClass(contextLocator.getSpringContext(), fieldType, required);
if (name != null)
{
- String tmpName = beanNameCache.putIfAbsent(field.getType(), name);
+ String tmpName = beanNameCache.putIfAbsent(fieldType, name);
if (tmpName != null)
{
name = tmpName;
@@ -188,6 +206,7 @@ public class AnnotProxyFieldValueFactory implements IFieldValueFactory
}
}
}
+
return name;
}
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5662_9aec4f33.diff |
bugs-dot-jar_data_WICKET-5966_d547fcd4 | ---
BugID: WICKET-5966
Summary: ResourceUtils.getLocaleFromFilename can't handle minimized resources well
Description: |-
I think the ResourceUtils.getLocaleFromFilename(String path) has the order of locale and minimization wrong:
It currently parses: File.min_Lang_Coun_Var.ext while the typical convention is File_Lang_Coun_Var.min.ext
Surely considering the ResourceUtils.getMinifiedName() method which does work according to convention.
diff --git a/wicket-util/src/main/java/org/apache/wicket/util/resource/ResourceUtils.java b/wicket-util/src/main/java/org/apache/wicket/util/resource/ResourceUtils.java
index edcd96c..ac1d025 100644
--- a/wicket-util/src/main/java/org/apache/wicket/util/resource/ResourceUtils.java
+++ b/wicket-util/src/main/java/org/apache/wicket/util/resource/ResourceUtils.java
@@ -34,7 +34,8 @@ public class ResourceUtils
/** The default postfix for minified names (ex: /css/mystyle.min.css) **/
public static final String MIN_POSTFIX_DEFAULT = "min";
/** Regular expression patter to extract the locale from the filename (ex: de_DE) **/
- private static final Pattern LOCALE_PATTERN = Pattern.compile("_([a-z]{2})(_([A-Z]{2})(_([^_]+))?)?$");
+ private static final Pattern LOCALE_MIN_PATTERN = Pattern
+ .compile("_([a-z]{2})(_([A-Z]{2})(_([^_\\.]+))?)?(\\.min)?$");
/** Stores standard ISO country codes from {@code java.util.Locale} **/
private final static Set<String> isoCountries = new HashSet<>(
Arrays.asList(Locale.getISOCountries()));
@@ -77,7 +78,12 @@ public class ResourceUtils
}
/**
- * Extract the locale from the filename
+ * Extract the locale from the filename taking into account possible minimized resource name.
+ *
+ * E.g. {@code file_us_EN.min.js} will correctly determine a locale of {@code us_EN} by
+ * stripping the {@code .min} from the filename, the filename returned will be
+ * {@code file.min.js}, if you want the {@code .min} to be removed as well, use
+ * {@link #getLocaleFromMinifiedFilename(String)} instead.
*
* @param path
* The file path
@@ -86,7 +92,8 @@ public class ResourceUtils
public static PathLocale getLocaleFromFilename(String path)
{
String extension = "";
- int pos = path.lastIndexOf('.');
+
+ final int pos = path.lastIndexOf('.');
if (pos != -1)
{
extension = path.substring(pos);
@@ -94,12 +101,13 @@ public class ResourceUtils
}
String filename = Strings.lastPathComponent(path, '/');
- Matcher matcher = LOCALE_PATTERN.matcher(filename);
+ Matcher matcher = LOCALE_MIN_PATTERN.matcher(filename);
if (matcher.find())
{
String language = matcher.group(1);
String country = matcher.group(3);
String variant = matcher.group(5);
+ String min = matcher.group(6);
// did we find a language?
if (language != null)
@@ -124,8 +132,9 @@ public class ResourceUtils
if (language != null)
{
- pos = path.length() - filename.length() + matcher.start();
- String basePath = path.substring(0, pos) + extension;
+ int languagePos = path.length() - filename.length() + matcher.start();
+ String basePath = path.substring(0, languagePos) + (min == null ? "" : min) +
+ extension;
Locale locale = new Locale(language, country != null ? country : "",
variant != null ? variant : "");
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5966_d547fcd4.diff |
bugs-dot-jar_data_WICKET-4518_a88882f7 | ---
BugID: WICKET-4518
Summary: Wicket example 'forminput' is broken due to bad url for IOnChangeListener
Description: "http://localhost:8080/forminput (wicket-examples) doesn't change the
locale of the labels when the locale select is changed.\nThe reason seems to be
the produced url: './.?5-1.IOnChangeListener-inputForm-localeSelect' \nThis is parsed
to a Url with one empty segment and thus HomePageMapper doesn't match it and doesn't
handle it."
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 d387a13..acb4287 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
@@ -989,17 +989,28 @@ public final class Url implements Serializable
// strip the first non-folder segment
getSegments().remove(getSegments().size() - 1);
}
- // remove all './' (current folder) from the relative url
- if (!relative.getSegments().isEmpty() && ".".equals(relative.getSegments().get(0)))
- {
- relative.getSegments().remove(0);
- }
- // process any ../ segments in the relative url
- while (!relative.getSegments().isEmpty() && "..".equals(relative.getSegments().get(0)))
+ // remove leading './' (current folder) and empty segments, process any ../ segments from the
+ // relative url
+ while (!relative.getSegments().isEmpty())
{
- relative.getSegments().remove(0);
- getSegments().remove(getSegments().size() - 1);
+ if (".".equals(relative.getSegments().get(0)))
+ {
+ relative.getSegments().remove(0);
+ }
+ else if ("".equals(relative.getSegments().get(0)))
+ {
+ relative.getSegments().remove(0);
+ }
+ else if ("..".equals(relative.getSegments().get(0)))
+ {
+ relative.getSegments().remove(0);
+ getSegments().remove(getSegments().size() - 1);
+ }
+ else
+ {
+ break;
+ }
}
// append the remaining relative segments
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-4518_a88882f7.diff |
bugs-dot-jar_data_WICKET-3885_beb9086d | ---
BugID: WICKET-3885
Summary: setResponsePage in AjaxLink goes always to localhost:8080 instead to the
right host and port
Description: |-
setResponsePage in an AjaxLink in Wicket 1.4 redirects with a relative path to the response page.
Wicket 1.5 takes the absolute path "localhost:8080/path to the response page" even when the host and port are different.
(e.g. with Apache2 a virtual host is created with server name www.mycompany.com, setResponce wil go to "localhost:8080/path to page" instead of "www.mycompany.com/path to page")
diff --git a/wicket-core/src/main/java/org/apache/wicket/protocol/http/servlet/ServletWebResponse.java b/wicket-core/src/main/java/org/apache/wicket/protocol/http/servlet/ServletWebResponse.java
index a1d0312..c5bc8c7 100644
--- a/wicket-core/src/main/java/org/apache/wicket/protocol/http/servlet/ServletWebResponse.java
+++ b/wicket-core/src/main/java/org/apache/wicket/protocol/http/servlet/ServletWebResponse.java
@@ -241,7 +241,6 @@ public class ServletWebResponse extends WebResponse
try
{
redirect = true;
- url = getAbsoluteURL(url);
url = encodeRedirectURL(url);
// wicket redirects should never be cached
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-3885_beb9086d.diff |
bugs-dot-jar_data_WICKET-4578_c66cf607 | ---
BugID: WICKET-4578
Summary: Link always causes Page to become stateful, regardless of visibility
Description: "Despite the changes made in WICKET-4468 , an invisible Link still causes
a Page to become stateful. \n\nThe problem seems to be that Component#isStateless
does this before even checking the visibility: \n\n\t\tif (!getStatelessHint())\n\t\t{\n\t\t\treturn
false;\n\t\t}\n\n\n... and Link#getStatelessHint() just contains just \"return false\"
. "
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 4470dbc..b616d1b 100644
--- a/wicket-core/src/main/java/org/apache/wicket/Component.java
+++ b/wicket-core/src/main/java/org/apache/wicket/Component.java
@@ -2080,11 +2080,6 @@ public abstract class Component
*/
public final boolean isStateless()
{
- if (!getStatelessHint())
- {
- return false;
- }
-
if (
// the component is either invisible or disabled
(isVisibleInHierarchy() && isEnabledInHierarchy()) == false &&
@@ -2097,6 +2092,11 @@ public abstract class Component
return true;
}
+ if (!getStatelessHint())
+ {
+ return false;
+ }
+
for (Behavior behavior : getBehaviors())
{
if (!behavior.getStatelessHint(this))
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-4578_c66cf607.diff |
bugs-dot-jar_data_WICKET-5072_381b90fd | ---
BugID: WICKET-5072
Summary: Cookies#isEqual(Cookie, Cookie) may fail with NullPointerException
Description: |-
If c1.getPath == null but c2.getPath != null then a NPE will occur.
Same is valid for the 'domain' property.
diff --git a/wicket-core/src/main/java/org/apache/wicket/protocol/http/mock/Cookies.java b/wicket-core/src/main/java/org/apache/wicket/protocol/http/mock/Cookies.java
index 68f3083..d3a8a6e 100644
--- a/wicket-core/src/main/java/org/apache/wicket/protocol/http/mock/Cookies.java
+++ b/wicket-core/src/main/java/org/apache/wicket/protocol/http/mock/Cookies.java
@@ -19,6 +19,7 @@ package org.apache.wicket.protocol.http.mock;
import javax.servlet.http.Cookie;
import org.apache.wicket.util.lang.Args;
+import org.apache.wicket.util.lang.Objects;
/**
* A helper class for dealing with cookies
@@ -59,7 +60,7 @@ public final class Cookies
Args.notNull(c2, "c2");
return c1.getName().equals(c2.getName()) &&
- ((c1.getPath() == null && c2.getPath() == null) || (c1.getPath().equals(c2.getPath()))) &&
- ((c1.getDomain() == null && c2.getDomain() == null) || (c1.getDomain().equals(c2.getDomain())));
+ Objects.isEqual(c1.getPath(), c2.getPath()) &&
+ Objects.isEqual(c1.getDomain(), c2.getDomain());
}
}
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5072_381b90fd.diff |
bugs-dot-jar_data_WICKET-5230_9c8f658a | ---
BugID: WICKET-5230
Summary: AjaxFormChoiceComponentUpdatingBehavior fails for choices containing other
invalid FormComponents
Description: |-
If a TextField inside a RadioGroup has a ValidationError, processing of AjaxFormChoiceComponentUpdatingBehavior will erroneously update the group's model:
- RadioGroup#validate() does not convert the input, because #isValid() returns false (since the nested textfield has an error message)
- the behavior tests #hasErrorMessage() on the group, which returns false (since the group itself doesn't have an error message)
- the behavior continues processing with a null value
diff --git a/wicket-core/src/main/java/org/apache/wicket/ajax/form/AjaxFormComponentUpdatingBehavior.java b/wicket-core/src/main/java/org/apache/wicket/ajax/form/AjaxFormComponentUpdatingBehavior.java
index c5b15ec..2d6cf0e 100644
--- a/wicket-core/src/main/java/org/apache/wicket/ajax/form/AjaxFormComponentUpdatingBehavior.java
+++ b/wicket-core/src/main/java/org/apache/wicket/ajax/form/AjaxFormComponentUpdatingBehavior.java
@@ -46,7 +46,8 @@ import org.slf4j.LoggerFactory;
*/
public abstract class AjaxFormComponentUpdatingBehavior extends AjaxEventBehavior
{
- private static final Logger log = LoggerFactory.getLogger(AjaxFormComponentUpdatingBehavior.class);
+ private static final Logger log = LoggerFactory
+ .getLogger(AjaxFormComponentUpdatingBehavior.class);
/**
*
@@ -76,8 +77,8 @@ public abstract class AjaxFormComponentUpdatingBehavior extends AjaxEventBehavio
Component component = getComponent();
if (!(component instanceof FormComponent))
{
- throw new WicketRuntimeException("Behavior " + getClass().getName() +
- " can only be added to an instance of a FormComponent");
+ throw new WicketRuntimeException("Behavior " + getClass().getName()
+ + " can only be added to an instance of a FormComponent");
}
checkComponent((FormComponent<?>)component);
@@ -94,13 +95,14 @@ public abstract class AjaxFormComponentUpdatingBehavior extends AjaxEventBehavio
*/
protected void checkComponent(FormComponent<?> component)
{
- if (Application.get().usesDevelopmentConfig() &&
- AjaxFormChoiceComponentUpdatingBehavior.appliesTo(component))
+ if (Application.get().usesDevelopmentConfig()
+ && AjaxFormChoiceComponentUpdatingBehavior.appliesTo(component))
{
- log.warn(String.format(
- "AjaxFormComponentUpdatingBehavior is not supposed to be added in the form component at path: \"%s\". "
- + "Use the AjaxFormChoiceComponentUpdatingBehavior instead, that is meant for choices/groups that are not one component in the html but many",
- component.getPageRelativePath()));
+ log.warn(String
+ .format(
+ "AjaxFormComponentUpdatingBehavior is not supposed to be added in the form component at path: \"%s\". "
+ + "Use the AjaxFormChoiceComponentUpdatingBehavior instead, that is meant for choices/groups that are not one component in the html but many",
+ component.getPageRelativePath()));
}
}
@@ -139,13 +141,7 @@ public abstract class AjaxFormComponentUpdatingBehavior extends AjaxEventBehavio
{
formComponent.inputChanged();
formComponent.validate();
- if (formComponent.hasErrorMessage())
- {
- formComponent.invalid();
-
- onError(target, null);
- }
- else
+ if (formComponent.isValid())
{
formComponent.valid();
if (getUpdateModel())
@@ -155,6 +151,12 @@ public abstract class AjaxFormComponentUpdatingBehavior extends AjaxEventBehavio
onUpdate(target);
}
+ else
+ {
+ formComponent.invalid();
+
+ onError(target, null);
+ }
}
catch (RuntimeException e)
{
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5230_9c8f658a.diff |
bugs-dot-jar_data_WICKET-5071_6e794ad0 | ---
BugID: WICKET-5071
Summary: 404 Error on Nested ModalWindows in IE7 and IE8
Description: |-
When opening a ModalWindow inside a ModalWindow, the inner ModalWindow generates a 404 error. Both windows use a PageCreator for content.
To replicate, you must use an actual IE 7 or IE 8 browser, as this does not replicate using developer tools and setting the document and brower to IE 7.
The problem can be seen at http://www.wicket-library.com/wicket-examples/ajax/modal-window. I will attach a Quickstart as well.
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 b1418bf..1fd71d6 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
@@ -16,6 +16,8 @@
*/
package org.apache.wicket.core.request.mapper;
+import java.util.List;
+
import org.apache.wicket.Application;
import org.apache.wicket.core.request.handler.PageProvider;
import org.apache.wicket.core.request.handler.RenderPageRequestHandler;
@@ -93,14 +95,26 @@ public class BookmarkableMapper extends AbstractBookmarkableMapper
@Override
protected UrlInfo parseRequest(Request request)
{
- Url url = request.getUrl();
- if (matches(url))
+ if (matches(request))
{
+ Url url = request.getUrl();
+
// try to extract page and component information from URL
PageComponentInfo info = getPageComponentInfo(url);
+ List<String> segments = url.getSegments();
+
// load the page class
- String className = url.getSegments().get(2);
+ String className;
+ if (segments.size() >= 3)
+ {
+ className = segments.get(2);
+ }
+ else
+ {
+ className = segments.get(1);
+ }
+
Class<? extends IRequestablePage> pageClass = getPageClass(className);
if (pageClass != null && IRequestablePage.class.isAssignableFrom(pageClass))
@@ -111,13 +125,13 @@ public class BookmarkableMapper extends AbstractBookmarkableMapper
if (application.getSecuritySettings().getEnforceMounts())
{
- // we make an excepion if the homepage itself was mounted, see WICKET-1898
+ // we make an exception 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))
+ if (!matches(request.cloneWithUrl(reverseUrl)))
{
return null;
}
@@ -151,17 +165,37 @@ public class BookmarkableMapper extends AbstractBookmarkableMapper
public int getCompatibilityScore(Request request)
{
int score = 0;
- Url url = request.getUrl();
- if (matches(url))
+ if (matches(request))
{
score = Integer.MAX_VALUE;
}
return score;
}
- private boolean matches(final Url url)
+ private boolean matches(final Request request)
{
- return (url.getSegments().size() >= 3 && urlStartsWith(url, getContext().getNamespace(),
- getContext().getBookmarkableIdentifier()));
+ boolean matches = false;
+ Url url = request.getUrl();
+ Url baseUrl = request.getClientUrl();
+ String namespace = getContext().getNamespace();
+ String bookmarkableIdentifier = getContext().getBookmarkableIdentifier();
+ String pageIdentifier = getContext().getPageIdentifier();
+
+ if (url.getSegments().size() >= 3 && urlStartsWith(url, namespace, bookmarkableIdentifier))
+ {
+ matches = true;
+ }
+ // baseUrl = 'wicket/bookmarkable/com.example.SomePage[?...]', requestUrl = 'bookmarkable/com.example.SomePage'
+ else if (baseUrl.getSegments().size() == 3 && urlStartsWith(baseUrl, namespace, bookmarkableIdentifier) && url.getSegments().size() >= 2 && urlStartsWith(url, bookmarkableIdentifier))
+ {
+ matches = true;
+ }
+ // baseUrl = 'wicket/page[?...]', requestUrl = 'bookmarkable/com.example.SomePage'
+ else if (baseUrl.getSegments().size() == 2 && urlStartsWith(baseUrl, namespace, pageIdentifier) && url.getSegments().size() >= 2 && urlStartsWith(url, bookmarkableIdentifier))
+ {
+ matches = true;
+ }
+
+ return matches;
}
}
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5071_6e794ad0.diff |
bugs-dot-jar_data_WICKET-2079_ceac38b1 | ---
BugID: WICKET-2079
Summary: Component Use Check always fails for visible components inside an invisible
border body
Description:
diff --git a/wicket/src/main/java/org/apache/wicket/Page.java b/wicket/src/main/java/org/apache/wicket/Page.java
index eaf188d..b6f0290 100644
--- a/wicket/src/main/java/org/apache/wicket/Page.java
+++ b/wicket/src/main/java/org/apache/wicket/Page.java
@@ -33,6 +33,7 @@ import org.apache.wicket.authorization.strategies.page.SimplePageAuthorizationSt
import org.apache.wicket.markup.MarkupException;
import org.apache.wicket.markup.MarkupStream;
import org.apache.wicket.markup.html.WebPage;
+import org.apache.wicket.markup.html.border.Border;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.resolver.IComponentResolver;
import org.apache.wicket.model.IModel;
@@ -1133,6 +1134,29 @@ public abstract class Page extends MarkupContainer implements IRedirectListener,
}
}
}
+
+ // Check if this component is a child of a border whose body is invisible and if
+ // so ignore it
+ Border border = component.findParent(Border.class);
+ if (border != null && !border.getBodyContainer().isVisibleInHierarchy())
+ {
+
+ // Suppose:
+ //
+ // <div wicket:id="border"><div wicket:id="label"></div> suppose
+ // border->label and border's body is hidden.
+ //
+ // The label is added to border not to its hidden body so as far as wicket
+ // is concerned label is visible in hierarchy, but when rendering label wont
+ // be rendered because in the markup it is inside the border's hidden body.
+ // Thus component use check will fail even though it shouldnt - make sure it
+ // doesnt.
+ //
+
+ // TODO it would be more accurate to determine that this component is inside
+ // the border parent's markup not the border's itself
+ iterator.remove();
+ }
}
// if still > 0
if (unrenderedComponents.size() > 0)
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-2079_ceac38b1.diff |
bugs-dot-jar_data_WICKET-5968_8b7946d8 | ---
BugID: WICKET-5968
Summary: CachingResourceLocator lookup key doesn't take strict into account
Description: "CachingResourceLocator uses a CacheKey to store lookups for resources.
\n\nWith e.g. \n- b_nl.js\n- b.js\n\nWhen e.g. a strict resource lookup for b.js
with locale \"us\" is performed, it will store the not-found for locale \"us\" under
the cache key. The cache key consists of resource name, locale, style and variation.
However when you search non-strict for locale \"us\", the resource locator should
find the non-localized resource \"b.js\", but since a matching key for the lookup
was stored for this particular resource, it will fail.\n"
diff --git a/wicket-core/src/main/java/org/apache/wicket/core/util/resource/locator/caching/CachingResourceStreamLocator.java b/wicket-core/src/main/java/org/apache/wicket/core/util/resource/locator/caching/CachingResourceStreamLocator.java
index ceeb59f..f9b3624 100644
--- a/wicket-core/src/main/java/org/apache/wicket/core/util/resource/locator/caching/CachingResourceStreamLocator.java
+++ b/wicket-core/src/main/java/org/apache/wicket/core/util/resource/locator/caching/CachingResourceStreamLocator.java
@@ -73,7 +73,7 @@ public class CachingResourceStreamLocator implements IResourceStreamLocator
@Override
public IResourceStream locate(Class<?> clazz, String path)
{
- CacheKey key = new CacheKey(clazz.getName(), path, null, null, null, null);
+ CacheKey key = new CacheKey(clazz.getName(), path, null, null, null, null, true);
IResourceStreamReference resourceStreamReference = cache.get(key);
final IResourceStream result;
@@ -113,7 +113,7 @@ public class CachingResourceStreamLocator implements IResourceStreamLocator
public IResourceStream locate(Class<?> scope, String path, String style, String variation,
Locale locale, String extension, boolean strict)
{
- CacheKey key = new CacheKey(scope.getName(), path, extension, locale, style, variation);
+ CacheKey key = new CacheKey(scope.getName(), path, extension, locale, style, variation, strict);
IResourceStreamReference resourceStreamReference = cache.get(key);
final IResourceStream result;
@@ -154,37 +154,54 @@ public class CachingResourceStreamLocator implements IResourceStreamLocator
*/
private static class CacheKey extends Key
{
+ private static final long serialVersionUID = 1L;
+
/**
* The file extension
*/
private final String extension;
- private CacheKey(String scope, String name, String extension, Locale locale, String style, String variation)
+ /** Whether the key was looked up using a strict matching search */
+ private final boolean strict;
+
+ private CacheKey(String scope, String name, String extension, Locale locale, String style, String variation, boolean strict)
{
super(scope, name, locale, style, variation);
this.extension = extension;
+ this.strict = strict;
}
@Override
- public boolean equals(Object o)
+ public int hashCode()
{
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
- if (!super.equals(o)) return false;
-
- CacheKey cacheKey = (CacheKey) o;
-
- return !(extension != null ? !extension.equals(cacheKey.extension) : cacheKey.extension != null);
-
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + ((extension == null) ? 0 : extension.hashCode());
+ result = prime * result + (strict ? 1231 : 1237);
+ return result;
}
@Override
- public int hashCode()
+ public boolean equals(Object obj)
{
- int result = super.hashCode();
- result = 31 * result + (extension != null ? extension.hashCode() : 0);
- return result;
+ if (this == obj)
+ return true;
+ if (!super.equals(obj))
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ CacheKey other = (CacheKey)obj;
+ if (extension == null)
+ {
+ if (other.extension != null)
+ return false;
+ }
+ else if (!extension.equals(other.extension))
+ return false;
+ if (strict != other.strict)
+ return false;
+ return true;
}
}
}
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5968_8b7946d8.diff |
bugs-dot-jar_data_WICKET-5720_2fc6a395 | ---
BugID: WICKET-5720
Summary: Method Strings.join doesn't work correctly if separator is empty.
Description: |-
If we use an empty separator ("") to join strings, the first character of any fragment is truncated.
Es "foo", "bar", "baz" became "ooaraz".
diff --git a/wicket-util/src/main/java/org/apache/wicket/util/string/Strings.java b/wicket-util/src/main/java/org/apache/wicket/util/string/Strings.java
index f3ebe1b..fdb75a4 100755
--- a/wicket-util/src/main/java/org/apache/wicket/util/string/Strings.java
+++ b/wicket-util/src/main/java/org/apache/wicket/util/string/Strings.java
@@ -677,7 +677,7 @@ public final class Strings
{
boolean lhsClosed = fragments[i - 1].endsWith(separator);
boolean rhsClosed = fragment.startsWith(separator);
- if (lhsClosed && rhsClosed)
+ if (!Strings.isEmpty(separator) && lhsClosed && rhsClosed)
{
buff.append(fragment.substring(1));
}
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5720_2fc6a395.diff |
bugs-dot-jar_data_WICKET-5071_a2f848f2 | ---
BugID: WICKET-5071
Summary: 404 Error on Nested ModalWindows in IE7 and IE8
Description: |-
When opening a ModalWindow inside a ModalWindow, the inner ModalWindow generates a 404 error. Both windows use a PageCreator for content.
To replicate, you must use an actual IE 7 or IE 8 browser, as this does not replicate using developer tools and setting the document and brower to IE 7.
The problem can be seen at http://www.wicket-library.com/wicket-examples/ajax/modal-window. I will attach a Quickstart as well.
diff --git a/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/PageInstanceMapper.java b/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/PageInstanceMapper.java
index 776e546..fb9b3bd 100644
--- a/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/PageInstanceMapper.java
+++ b/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/PageInstanceMapper.java
@@ -59,9 +59,9 @@ public class PageInstanceMapper extends AbstractComponentMapper
@Override
public IRequestHandler mapRequest(Request request)
{
- Url url = request.getUrl();
- if (matches(url))
+ if (matches(request))
{
+ Url url = request.getUrl();
PageComponentInfo info = getPageComponentInfo(url);
if (info != null && info.getPageInfo().getPageId() != null)
{
@@ -153,16 +153,38 @@ public class PageInstanceMapper extends AbstractComponentMapper
public int getCompatibilityScore(final Request request)
{
int score = 0;
- Url url = request.getUrl();
- if (matches(url))
+ if (matches(request))
{
score = Integer.MAX_VALUE;
}
return score;
}
- private boolean matches(final Url url)
+ /**
+ * Matches when the request url starts with
+ * {@link org.apache.wicket.core.request.mapper.IMapperContext#getNamespace()}/{@link org.apache.wicket.core.request.mapper.IMapperContext#getPageIdentifier()}
+ * or when the base url starts with {@link org.apache.wicket.core.request.mapper.IMapperContext#getNamespace()}
+ * and the request url with {@link org.apache.wicket.core.request.mapper.IMapperContext#getPageIdentifier()}
+
+ * @param request
+ * the request to check
+ * @return {@code true} if the conditions match
+ */
+ private boolean matches(final Request request)
{
- return urlStartsWith(url, getContext().getNamespace(), getContext().getPageIdentifier());
+ boolean matches = false;
+ Url url = request.getUrl();
+ String namespace = getContext().getNamespace();
+ String pageIdentifier = getContext().getPageIdentifier();
+ if (urlStartsWith(url, namespace, pageIdentifier))
+ {
+ matches = true;
+ }
+ else if (urlStartsWith(request.getClientUrl(), namespace) && urlStartsWith(url, pageIdentifier))
+ {
+ matches = true;
+ }
+
+ return matches;
}
}
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5071_a2f848f2.diff |
bugs-dot-jar_data_WICKET-5265_0eb596df | ---
BugID: WICKET-5265
Summary: FencedFeedbackPanel is broken with RefreshingView(and it's implementations)
Description: "FencedFeedbackPanel doesn't work correctly if inner form(s) are in RefreshingView(or
it's implementations)..\nin this case outerform feedbackpanel just starts including
messages meant for inner feedbackpanel.\nwith ListView FencedFeedbackPanel works
correctly..\nactually one user(Mike Dundee) created this issue in quickview https://github.com/vineetsemwal/quickview/issues/19\n
so in that link he has described his problem and pasted the code you can use to
reproduce ...\nthere i have also explained why it's broken with RefreshingView and
it's implementations currently(it's a little complex so i am trying to avoid explaining
all again ,also english is not my first language :-) ) \n\nthank you !\n"
diff --git a/wicket-core/src/main/java/org/apache/wicket/feedback/FencedFeedbackPanel.java b/wicket-core/src/main/java/org/apache/wicket/feedback/FencedFeedbackPanel.java
index f7df59e..42e1344 100644
--- a/wicket-core/src/main/java/org/apache/wicket/feedback/FencedFeedbackPanel.java
+++ b/wicket-core/src/main/java/org/apache/wicket/feedback/FencedFeedbackPanel.java
@@ -29,13 +29,13 @@ import org.apache.wicket.markup.html.panel.FeedbackPanel;
* the nesting of these panels to work correctly without displaying the same feedback message twice.
* A constructor that does not takes a fencing component creates a catch-all panel that shows
* messages that do not come from inside any fence or from the {@link Session}.
- *
+ * <p/>
* <h2>IN DEPTH EXPLANATION</h2>
* <p>
* It is often very useful to have feedback panels that show feedback that comes from inside a
* certain container only. For example given a page with the following structure:
* </p>
- *
+ * <p/>
* <pre>
* Page
* Form1
@@ -72,7 +72,7 @@ import org.apache.wicket.markup.html.panel.FeedbackPanel;
* fencing component. There is usually one instance of such a panel at the top of the page to
* display notifications of success.
* </p>
- *
+ *
* @author igor
*/
public class FencedFeedbackPanel extends FeedbackPanel
@@ -89,7 +89,7 @@ public class FencedFeedbackPanel extends FeedbackPanel
/**
* Creates a catch-all feedback panel that will show messages not coming from any fence,
* including messages coming from {@link Session}
- *
+ *
* @param id
*/
public FencedFeedbackPanel(String id)
@@ -100,7 +100,7 @@ public class FencedFeedbackPanel extends FeedbackPanel
/**
* Creates a feedback panel that will only show messages if they original from, or inside of,
* the {@code fence} component and not from any inner fence.
- *
+ *
* @param id
* @param fence
*/
@@ -111,11 +111,10 @@ public class FencedFeedbackPanel extends FeedbackPanel
/**
* Creates a catch-all instance with a filter.
- *
- * @see #FencedFeedbackPanel(String)
- *
+ *
* @param id
* @param filter
+ * @see #FencedFeedbackPanel(String)
*/
public FencedFeedbackPanel(String id, IFeedbackMessageFilter filter)
{
@@ -124,12 +123,11 @@ public class FencedFeedbackPanel extends FeedbackPanel
/**
* Creates a fenced feedback panel with a filter.
- *
- * @see #FencedFeedbackPanel(String, Component)
- *
+ *
* @param id
* @param fence
* @param filter
+ * @see #FencedFeedbackPanel(String, Component)
*/
public FencedFeedbackPanel(String id, Component fence, IFeedbackMessageFilter filter)
{
@@ -137,12 +135,17 @@ public class FencedFeedbackPanel extends FeedbackPanel
this.fence = fence;
if (fence != null)
{
- Integer count = fence.getMetaData(FENCE_KEY);
- count = count == null ? 1 : count + 1;
- fence.setMetaData(FENCE_KEY, count);
+ incrementFenceCount();
}
}
+ private void incrementFenceCount()
+ {
+ Integer count = fence.getMetaData(FENCE_KEY);
+ count = count == null ? 1 : count + 1;
+ fence.setMetaData(FENCE_KEY, count);
+ }
+
@Override
protected void onRemove()
{
@@ -151,12 +154,17 @@ public class FencedFeedbackPanel extends FeedbackPanel
{
// decrement the fence count
- Integer count = fence.getMetaData(FENCE_KEY);
- count = (count == null || count == 1) ? null : count - 1;
- fence.setMetaData(FENCE_KEY, count);
+ decrementFenceCount();
}
}
+ private void decrementFenceCount()
+ {
+ Integer count = fence.getMetaData(FENCE_KEY);
+ count = (count == null || count == 1) ? null : count - 1;
+ fence.setMetaData(FENCE_KEY, count);
+ }
+
@Override
protected FeedbackMessagesModel newFeedbackMessagesModel()
{
@@ -166,7 +174,7 @@ public class FencedFeedbackPanel extends FeedbackPanel
@Override
protected List<FeedbackMessage> collectMessages(Component panel,
- IFeedbackMessageFilter filter)
+ IFeedbackMessageFilter filter)
{
if (fence == null)
{
@@ -177,7 +185,7 @@ public class FencedFeedbackPanel extends FeedbackPanel
@Override
protected boolean shouldRecurseInto(Component component)
{
- return component.getMetaData(FENCE_KEY) == null;
+ return !componentIsMarkedAsFence(component);
}
}.collect(filter);
}
@@ -191,12 +199,29 @@ public class FencedFeedbackPanel extends FeedbackPanel
protected boolean shouldRecurseInto(Component component)
{
// only recurse into components that are not fences
-
- return component.getMetaData(FENCE_KEY) == null;
+ return !componentIsMarkedAsFence(component);
}
}.setIncludeSession(false).collect(filter);
}
}
};
}
+
+ private boolean componentIsMarkedAsFence(Component component)
+ {
+ return component.getMetaData(FENCE_KEY) != null;
+ }
+
+ @Override
+ protected void onReAdd()
+ {
+ if (this.fence != null)
+ {
+ // The fence mark is removed when the feedback panel is removed from the hierarchy.
+ // see onRemove().
+ // when the panel is re-added, we recreate the fence mark.
+ incrementFenceCount();
+ }
+ super.onReAdd();
+ }
}
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-5265_0eb596df.diff |
bugs-dot-jar_data_WICKET-128_7e1000dd | ---
BugID: WICKET-128
Summary: Debug settings / serialize session attributes option not working
Description: |-
Session attributes are serialized even if this debug setting is turned off. I've noticed that the code that serializes attributes and logs their serialized size in HttpSessionStore#setAttribute is duplicated in Session#setAttribute - but without the debug settings condition. This code was added by the recent patch resolving WICKET-100 and only in the trunk, not in the wicket-1.x branch... why???
Regards,
Bendis
diff --git a/wicket/src/main/java/wicket/Session.java b/wicket/src/main/java/wicket/Session.java
index 0a64238..1de82b7 100644
--- a/wicket/src/main/java/wicket/Session.java
+++ b/wicket/src/main/java/wicket/Session.java
@@ -16,8 +16,6 @@
*/
package wicket;
-import java.io.ByteArrayOutputStream;
-import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
@@ -41,7 +39,6 @@ import wicket.feedback.FeedbackMessages;
import wicket.request.ClientInfo;
import wicket.session.ISessionStore;
import wicket.util.convert.IConverter;
-import wicket.util.lang.Bytes;
import wicket.util.lang.Objects;
import wicket.util.string.Strings;
import wicket.util.time.Duration;
@@ -1036,20 +1033,6 @@ public abstract class Session implements Serializable, IConverterLocator
}
}
}
- String valueTypeName = (value != null ? value.getClass().getName() : "null");
- try
- {
- final ByteArrayOutputStream out = new ByteArrayOutputStream();
- new ObjectOutputStream(out).writeObject(value);
- log.debug("Stored attribute " + name + "{ " + valueTypeName + "} with size: "
- + Bytes.bytes(out.size()));
- }
- catch (Exception e)
- {
- throw new WicketRuntimeException(
- "Internal error cloning object. Make sure all dependent objects implement Serializable. Class: "
- + valueTypeName, e);
- }
// Set the actual attribute
store.setAttribute(request, name, value);
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-128_7e1000dd.diff |
bugs-dot-jar_data_WICKET-4256_09166ea8 | ---
BugID: WICKET-4256
Summary: onBeforeRender() is called on components that are not allowed to render
Description: |-
pasted from the list:
Hi,
I ran into an odd problem this week. A model fed to a ListView was
calling service methods the current user wasn't allowed to use, and I
was wondering how that could happen. A panel far above this ListView in
the hierarchy had been secured (using Shiro annotations, but that turns
out to not matter at all) and was not supposed to be rendered for this
user. From this I had expected the ListView not to be rendered either,
but here it was trying to assemble itself in onBeforeRender and thus
calling the "forbidden" service methods.
I investigated Component and friends for a bit, and have found a
potential problem.
internalBeforeRender() checks determineVisibility() before doing
anything. So far so good. determineVisibility() then checks
isRenderAllowed() so the application's IAuthorizationStrategy can block
certain components. This is where it goes wrong though:
isRenderAllowed() only looks at FLAG_IS_RENDER_ALLOWED for performance
reasons, and that flag hasn't been set yet! internalPrepareForRender()
only calls setRenderAllowed() *after* beforeRender().
Due to this, the supposedly secure panel was going through its own
beforeRender and thus calling that ListView's beforeRender.
I think this can be a serious problem, such as in my case described
above. I'd expect that if isActionAuthorized(RENDER) is false, the
secured component should basically never get to the beforeRender phase.
My questions are now:
- Is this intentional? If yes, please explain the reasoning behind it,
because it isn't obvious to me.
- If not, can we fix it? My intuitive suggestion would be to simply
move the call to setRenderAllowed() from the end of
internalBeforeRender() (prepareForRender in 1.4) to the beginning of
that method, so beforeRender() can reliably look at that flag.
- If we can fix it, when and where do we fix it? This hit me in 1.4,
and looking at the code it's still there in 1.5. I'd *really* like it
fixed in the last 1.4 release, and certainly in 1.5, given that this
has the potential to impact security.
It's not an API break, but I'm not sure whether the implications for
application behavior are tolerable for all existing applications. On
the other hand, it seems to be a real security problem, so maybe the
change is justified. I'd like some core dev opinions please :-)
If this is in fact a bug, I'm of course willing to provide a ticket and
a patch :-)
Thanks!
Carl-Eric
www.wicketbuch.de
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 e9e5a60..1d2ccc3 100644
--- a/wicket-core/src/main/java/org/apache/wicket/Component.java
+++ b/wicket-core/src/main/java/org/apache/wicket/Component.java
@@ -971,6 +971,9 @@ public abstract class Component
{
configure();
+ // check authorization
+ setRenderAllowed();
+
if ((determineVisibility()) && !getFlag(FLAG_RENDERING) &&
!getFlag(FLAG_PREPARED_FOR_RENDER))
{
@@ -2210,11 +2213,6 @@ public abstract class Component
}
markRendering(setRenderingFlag);
-
- // check authorization
- // first the component itself
- // (after attach as otherwise list views etc wont work)
- setRenderAllowed();
}
/**
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-4256_09166ea8.diff |
bugs-dot-jar_data_WICKET-3510_292a2582 | ---
BugID: WICKET-3510
Summary: DateTimeField improperly converts time causing wrong dates when the server's
current date is different from the client's date.
Description: "The bug is in DateTimeField#convertInput().\n<code>\n// Get year, month
and day ignoring any timezone of the Date object\nCalendar cal = Calendar.getInstance();\ncal.setTime(dateFieldInput);\nint
year = cal.get(Calendar.YEAR);\nint month = cal.get(Calendar.MONTH) + 1;\nint day
= cal.get(Calendar.DAY_OF_MONTH);\nint hours = (hoursInput == null ? 0 : hoursInput
% 24);\nint minutes = (minutesInput == null ? 0 : minutesInput);\n\n// Use the input
to create a date object with proper timezone\nMutableDateTime date = new MutableDateTime(year,
month, day, hours, minutes, 0, 0,\n\tDateTimeZone.forTimeZone(getClientTimeZone()));\n</code>\nIf
the server's current date is different from the client's, this produces wrong output.
I attached a patch with a test case that simulates this condition.\n\nI don't know
why this \"casting\" of day, month, year is done.\n"
diff --git a/wicket-datetime/src/main/java/org/apache/wicket/datetime/markup/html/form/DateTextField.java b/wicket-datetime/src/main/java/org/apache/wicket/datetime/markup/html/form/DateTextField.java
index 718e7a3..ba144cf 100644
--- a/wicket-datetime/src/main/java/org/apache/wicket/datetime/markup/html/form/DateTextField.java
+++ b/wicket-datetime/src/main/java/org/apache/wicket/datetime/markup/html/form/DateTextField.java
@@ -132,7 +132,7 @@ public class DateTextField extends TextField<Date> implements ITextFormatProvide
*/
public static DateTextField forShortStyle(String id)
{
- return forShortStyle(id, null);
+ return forShortStyle(id, null, true);
}
/**
@@ -144,9 +144,10 @@ public class DateTextField extends TextField<Date> implements ITextFormatProvide
* The model
* @return DateTextField
*/
- public static DateTextField forShortStyle(String id, IModel<Date> model)
+ public static DateTextField forShortStyle(String id, IModel<Date> model,
+ boolean applyTimeZoneDifference)
{
- return new DateTextField(id, model, new StyleDateConverter(true));
+ return new DateTextField(id, model, new StyleDateConverter(applyTimeZoneDifference));
}
/**
diff --git a/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/DateTimeField.java b/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/DateTimeField.java
index ebb04e4..25f0d5c 100644
--- a/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/DateTimeField.java
+++ b/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/DateTimeField.java
@@ -377,7 +377,7 @@ public class DateTimeField extends FormComponentPanel<Date>
*/
protected DateTextField newDateTextField(String id, PropertyModel<Date> dateFieldModel)
{
- return DateTextField.forShortStyle(id, dateFieldModel);
+ return DateTextField.forShortStyle(id, dateFieldModel, false);
}
/**
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-3510_292a2582.diff |
bugs-dot-jar_data_WICKET-3272_c86b972a | ---
BugID: WICKET-3272
Summary: Set an request parameter on Wicket tester do not add it in the request URL
Description: |-
When submitting an form, the parameters set in request do not get appended to the URL query string.
Initial impression is that UrlRender should append query parameters in the base URL on relatives URL.
diff --git a/wicket-core/src/main/java/org/apache/wicket/request/mapper/AbstractComponentMapper.java b/wicket-core/src/main/java/org/apache/wicket/request/mapper/AbstractComponentMapper.java
index 0512fad..5757332 100644
--- a/wicket-core/src/main/java/org/apache/wicket/request/mapper/AbstractComponentMapper.java
+++ b/wicket-core/src/main/java/org/apache/wicket/request/mapper/AbstractComponentMapper.java
@@ -80,18 +80,24 @@ public abstract class AbstractComponentMapper extends AbstractMapper implements
*
* @return PageComponentInfo instance if one was encoded in URL, <code>null</code> otherwise.
*/
- protected PageComponentInfo getPageComponentInfo(Url url)
+ protected PageComponentInfo getPageComponentInfo(final Url url)
{
if (url == null)
{
throw new IllegalStateException("Argument 'url' may not be null.");
}
- if (url.getQueryParameters().size() > 0)
+ else
{
- QueryParameter param = url.getQueryParameters().get(0);
- if (Strings.isEmpty(param.getValue()))
+ for (QueryParameter queryParameter : url.getQueryParameters())
{
- return PageComponentInfo.parse(param.getName());
+ if (Strings.isEmpty(queryParameter.getValue()))
+ {
+ PageComponentInfo pageComponentInfo = PageComponentInfo.parse(queryParameter.getName());
+ if (pageComponentInfo != null)
+ {
+ return pageComponentInfo;
+ }
+ }
}
}
return null;
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-3272_c86b972a.diff |
bugs-dot-jar_data_WICKET-4738_a7ce7f91 | ---
BugID: WICKET-4738
Summary: DownloadLink doesn't wrap the String model used for file name nor does it
detach
Description: "Component DownloadLink doesn't call method wrap of class Component on
parameter fileNameModel. This causes models like StringResourceModel to not resolve
resource bundles correctly.\nSee the discussion here: http://stackoverflow.com/questions/12196533/how-to-use-wicket-stringresourcemodel-in-downloadlink\n\nThe
patch seems quite trivial. \n\nDetachment is also missing."
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/link/DownloadLink.java b/wicket-core/src/main/java/org/apache/wicket/markup/html/link/DownloadLink.java
index 3974b18..293a239 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/html/link/DownloadLink.java
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/link/DownloadLink.java
@@ -135,7 +135,18 @@ public class DownloadLink extends Link<File>
public DownloadLink(String id, IModel<File> fileModel, IModel<String> fileNameModel)
{
super(id, fileModel);
- this.fileNameModel = fileNameModel;
+ this.fileNameModel = wrap(fileNameModel);
+ }
+
+ @Override
+ public void detachModels()
+ {
+ super.detachModels();
+
+ if (fileNameModel != null)
+ {
+ fileNameModel.detach();
+ }
}
@Override
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-4738_a7ce7f91.diff |
bugs-dot-jar_data_WICKET-2350_cd281092 | ---
BugID: WICKET-2350
Summary: Localization messages stops working with validators since 1.4-rc2
Description: |-
With the previous 1.3.6 and 1.4-rc1 releases I was capable to restrict a localization message for a validation to only one wicket id e.g. :
in foobar.java
RequiredTextField nameTF = new RequiredTextField("name");
nameTF.add(StringValidator.lengthBetween(2, 255));
nameTF.add(new PatternValidator("[^|:]*"));
and in foobar.properties
name.Required=some text
name.StringValidator.range=some other text
name.PatternValidator=some other text again
So, like this I could have to create an another RequiredTextField named "password", and attach to it a different localization message (for example "password.Required=blabla").
But somehow with the 1.4-rc2-5 it looks like that this function is broken, it only recognizes the localization text, when I remove the "name." prefix from my property.
diff --git a/wicket/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java b/wicket/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
index 32edb5c..5673f23 100644
--- a/wicket/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
+++ b/wicket/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
@@ -159,11 +159,12 @@ public abstract class FormComponent<T> extends LabeledWebMarkupContainer
String prefix = formComponent.getValidatorKeyPrefix();
String message = null;
- // first try the full form of key [prefix].[form-component-id].[key]
- String resource = prefix(prefix, getId() + "." + key);
+ // first try the full form of key [form-component-id].[key]
+ String resource = getId() + "." + prefix(prefix, key);
message = getString(localizer, resource, formComponent);
- // if not found, try a more general form (without prefix) [form-component-id].[key]
+ // if not found, try a more general form (without prefix)
+ // [form-component-id].[prefix].[key]
if (Strings.isEmpty(message) && Strings.isEmpty(prefix))
{
resource = getId() + "." + key;
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-2350_cd281092.diff |
bugs-dot-jar_data_WICKET-4370_7ca927c1 | ---
BugID: WICKET-4370
Summary: HttpSession getSession() in MockHttpServletRequest is not compliant with
the j2ee servlet spec
Description: "The implementation of\nhttpRequest.getSession();\nfor MockHttpServletRequest
seems not correct since it can return null when\nthe servler api specs\n(http://docs.oracle.com/javaee/1.4/api/)
says:\n\npublic HttpSession getSession()\nReturns the current session associated
with this request, or if the request\ndoes not have a session, creates one.\n\nSo
as far as I understand\nhttpRequest.getSession(); and httpRequest.getSession(true);
are equivalent\n\nThe MockHttpServletRequest implementation is\n\n public HttpSession
getSession()\n {\n if (session instanceof MockHttpSession &&\n((MockHttpSession)session).isTemporary())\n
\ {\n return null;\n }\n return session;\n }\n\nI think
it should be \n public HttpSession getSession()\n {\n return getSession(true);\n
\ }\n\n"
diff --git a/wicket-core/src/main/java/org/apache/wicket/protocol/http/mock/MockHttpServletRequest.java b/wicket-core/src/main/java/org/apache/wicket/protocol/http/mock/MockHttpServletRequest.java
index a93eb7f..73dc26f 100755
--- a/wicket-core/src/main/java/org/apache/wicket/protocol/http/mock/MockHttpServletRequest.java
+++ b/wicket-core/src/main/java/org/apache/wicket/protocol/http/mock/MockHttpServletRequest.java
@@ -1068,11 +1068,7 @@ public class MockHttpServletRequest implements HttpServletRequest
@Override
public HttpSession getSession()
{
- if (session instanceof MockHttpSession && ((MockHttpSession)session).isTemporary())
- {
- return null;
- }
- return session;
+ return getSession(true);
}
/**
@@ -1085,11 +1081,21 @@ public class MockHttpServletRequest implements HttpServletRequest
@Override
public HttpSession getSession(boolean b)
{
- if (b && session instanceof MockHttpSession)
+ HttpSession sess = null;
+ if (session instanceof MockHttpSession)
{
- ((MockHttpSession)session).setTemporary(false);
+ MockHttpSession mockHttpSession = (MockHttpSession) session;
+ if (b)
+ {
+ mockHttpSession.setTemporary(false);
+ }
+
+ if (mockHttpSession.isTemporary() == false)
+ {
+ sess = session;
+ }
}
- return getSession();
+ return sess;
}
/**
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-4370_7ca927c1.diff |
bugs-dot-jar_data_WICKET-3906_aadaa4e9 | ---
BugID: WICKET-3906
Summary: PageParameters#set not follow INamedParameters#set behavior
Description: |-
Couple of problems to work with page parameters:
Major - The PageParameters#set(final String name, final Object value, final int index) used remove/add pattern instead of set parameter value by specified index.
Minor - Inposible to get the index of key in elegant way to use obtained index in #set operation
diff --git a/wicket-request/src/main/java/org/apache/wicket/request/mapper/parameter/PageParameters.java b/wicket-request/src/main/java/org/apache/wicket/request/mapper/parameter/PageParameters.java
index 03c3dc5..bb11fa4 100644
--- a/wicket-request/src/main/java/org/apache/wicket/request/mapper/parameter/PageParameters.java
+++ b/wicket-request/src/main/java/org/apache/wicket/request/mapper/parameter/PageParameters.java
@@ -483,7 +483,8 @@ public class PageParameters implements IClusterable, IIndexedParameters, INamedP
*/
public PageParameters set(final String name, final Object value)
{
- set(name, value, -1);
+ int position = getPosition(name);
+ set(name, value, position);
return this;
}
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-3906_aadaa4e9.diff |
bugs-dot-jar_data_WICKET-4441_54c86ebb | ---
BugID: WICKET-4441
Summary: PageProvider should create a new Page instance if PageParameters are changed,
even if a stored page exists.
Description: |+
The 'getStoredPage(int)' method returns a stored page instance even if user changes parameter values encoded into URL, and the PageParameters object of the stored page instance is never changed. So same page is displayed always though user changes url on browser manually.
** HOW TO REPRODUCT **
1. unpack the attached sample project 'pagebug.tar.gz'.
2. mvn jetty:run
3. access to http://localhost:8080/user/user1
You will see a form filled with information about user 1. The user's name is 'user 1', age is 30 and country is 'Japan'.
The mount path of this page is '/user/${userId}'. so 'user1' in the accessed url is a parameter value.
after accessing to the url, the url will be changed to http://localhost:8080/user/user1?0 . it contains the page id of the currently displayed page.
4. change some values and submit the form. page id will be changed on every submit.
5. change only parameter value in url to 'user2'. Never change page-id.
for example, if you now access to http://localhost:8080/user/user1?5, change the url to http://localhost:8080/user/user2?5 .
6. This program must display information about user2, because the parameter value of url is changed. But you will see the information of user 1. Wicket always display the page of page-id = 5 (even though user changed url manually).
In this sample program, I use LoadableDetachableModel for retrieving current parameter-value. But I don't get the new parameter-value because pageParameters object in a page instance is never changed after the construction. pageParameters is fixed in the constructor of Page class.
I think that there are no easy way to retrieve parameter-values encoded into mount-path. Request.getRequestParameters() does not contain parameters encoded into mount-path. So there are no work-around for this issue.
** HOW TO FIX THIS ISSUE **
We must return null from getStoredPage(int) method of PageProvider class, if current PageParameters is not same with the PageParameters of a stored page. In current code, getStoredPage(int) checks only if the class of both pages are same. We must check the PageParameters of both pages.
** PATCH **
I attached a pache for PageProvider class. try it.
diff --git a/wicket-core/src/main/java/org/apache/wicket/core/request/handler/PageProvider.java b/wicket-core/src/main/java/org/apache/wicket/core/request/handler/PageProvider.java
index 50402f6..6068e35 100644
--- a/wicket-core/src/main/java/org/apache/wicket/core/request/handler/PageProvider.java
+++ b/wicket-core/src/main/java/org/apache/wicket/core/request/handler/PageProvider.java
@@ -296,7 +296,10 @@ public class PageProvider implements IPageProvider
IRequestablePage storedPageInstance = getPageSource().getPageInstance(pageId);
if (storedPageInstance != null)
{
- if (pageClass == null || pageClass.equals(storedPageInstance.getClass()))
+ if (
+ (pageClass == null || pageClass.equals(storedPageInstance.getClass())) &&
+ (isPageParametersEmpty(pageParameters) || arePageParametersSame(storedPageInstance))
+ )
{
pageInstance = storedPageInstance;
pageInstanceIsFresh = false;
@@ -413,4 +416,23 @@ public class PageProvider implements IPageProvider
}
return pageInstanceIsFresh;
}
+
+ /**
+ * A helper method that compares the requested PageParameters with the ones in the stored
+ * page instance. {@code null} and empty PageParameters are considered equal.
+ *
+ * @param storedPageInstance
+ * the page instance with the original page parameters
+ * @return {@code true} if the indexed and named parameters are equal, {@code false} - otherwise
+ */
+ private boolean arePageParametersSame(IRequestablePage storedPageInstance) {
+ PageParameters currentCopy = new PageParameters(pageParameters);
+ PageParameters storedCopy = new PageParameters(storedPageInstance.getPageParameters());
+ return currentCopy.equals(storedCopy);
+ }
+
+ private boolean isPageParametersEmpty(PageParameters parameters)
+ {
+ return parameters == null || parameters.isEmpty();
+ }
}
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-4441_54c86ebb.diff |
bugs-dot-jar_data_WICKET-1619_b154d12f | ---
BugID: WICKET-1619
Summary: 'PagingNavigator.setEnabled(false) doesn''t work '
Description: "1. Create paging navigator PagingNavigator \n2. call PagingNavigator.setEnabled(false)\n3.
navigator will be rendered as enabled, if click on any link (\"1\", \"2\" etc) -
content of the data view will be changed.\n\nIn many cases it's necessary disable
navigator, for example, when user need to edit only single line of DataView other
controls need to be disabled. "
diff --git a/wicket/src/main/java/org/apache/wicket/markup/html/navigation/paging/PagingNavigation.java b/wicket/src/main/java/org/apache/wicket/markup/html/navigation/paging/PagingNavigation.java
index 3342762..60c5499 100644
--- a/wicket/src/main/java/org/apache/wicket/markup/html/navigation/paging/PagingNavigation.java
+++ b/wicket/src/main/java/org/apache/wicket/markup/html/navigation/paging/PagingNavigation.java
@@ -345,7 +345,8 @@ public class PagingNavigation extends Loop
@Override
public boolean isEnabled()
{
- return PagingNavigation.this.isEnabled() && PagingNavigation.this.isEnableAllowed();
+ return super.isEnabled() && PagingNavigation.this.isEnabled() &&
+ PagingNavigation.this.isEnableAllowed();
}
};
}
diff --git a/wicket/src/main/java/org/apache/wicket/markup/html/navigation/paging/PagingNavigator.java b/wicket/src/main/java/org/apache/wicket/markup/html/navigation/paging/PagingNavigator.java
index 018d165..9d9fd47 100644
--- a/wicket/src/main/java/org/apache/wicket/markup/html/navigation/paging/PagingNavigator.java
+++ b/wicket/src/main/java/org/apache/wicket/markup/html/navigation/paging/PagingNavigator.java
@@ -119,7 +119,8 @@ public class PagingNavigator extends Panel
@Override
public boolean isEnabled()
{
- return PagingNavigator.this.isEnabled() && PagingNavigator.this.isEnableAllowed();
+ return super.isEnabled() && PagingNavigator.this.isEnabled() &&
+ PagingNavigator.this.isEnableAllowed();
}
};
}
@@ -145,9 +146,11 @@ public class PagingNavigator extends Panel
@Override
public boolean isEnabled()
{
- return PagingNavigator.this.isEnabled() && PagingNavigator.this.isEnableAllowed();
+ return super.isEnabled() && PagingNavigator.this.isEnabled() &&
+ PagingNavigator.this.isEnableAllowed();
}
};
+
}
/**
@@ -169,7 +172,8 @@ public class PagingNavigator extends Panel
@Override
public boolean isEnabled()
{
- return PagingNavigator.this.isEnabled() && PagingNavigator.this.isEnableAllowed();
+ return super.isEnabled() && PagingNavigator.this.isEnabled() &&
+ PagingNavigator.this.isEnableAllowed();
}
};
}
| bugs-dot-jar/wicket_extracted_diff/developer-patch_bugs-dot-jar_WICKET-1619_b154d12f.diff |