From 459d0160ef6416e08a40d2d3def8b52de1fec449 Mon Sep 17 00:00:00 2001 From: Georg Felbinger Date: Mon, 20 Jan 2020 15:19:41 +0100 Subject: [PATCH] apply changes of source jar --- .../java/org/apache/wicket/Application.java | 2 +- .../java/org/apache/wicket/Component.java | 14 +- .../org/apache/wicket/MarkupContainer.java | 667 ++++-------------- ...startResponseAtInterceptPageException.java | 2 +- .../ajax/AbstractDefaultAjaxBehavior.java | 70 +- .../apache/wicket/ajax/AjaxEventBehavior.java | 3 +- .../ajax/attributes/AjaxAttributeName.java | 14 - .../ajax/attributes/AjaxCallListener.java | 70 -- .../apache/wicket/ajax/json/JSONObject.java | 5 +- .../wicket/ajax/res/js/wicket-ajax-jquery.js | 160 ++--- .../wicket/ajax/res/js/wicket-event-jquery.js | 6 +- .../DefaultAuthenticationStrategy.java | 82 +-- .../core/request/mapper/CryptoMapper.java | 11 +- .../caching/CachingResourceStreamLocator.java | 49 +- .../core/util/string/ComponentRenderer.java | 21 +- .../feedback/IFeedbackMessageFilter.java | 6 +- .../wicket/markup/AbstractMarkupFragment.java | 3 +- .../wicket/markup/head/IHeaderResponse.java | 10 +- .../markup/html/PackageResourceGuard.java | 3 +- .../html/SecurePackageResourceGuard.java | 1 - .../html/TransparentWebMarkupContainer.java | 94 --- .../apache/wicket/markup/html/WebPage.java | 58 +- .../apache/wicket/markup/html/form/Form.java | 70 +- .../markup/html/form/FormComponent.java | 38 +- .../markup/html/internal/Enclosure.java | 13 +- .../html/internal/HtmlHeaderContainer.java | 5 +- .../paging/PagingNavigationIncrementLink.java | 19 - .../panel/AbstractMarkupSourcingStrategy.java | 9 +- .../markup/resolver/ComponentResolvers.java | 4 +- .../apache/wicket/mock/MockPageManager.java | 5 - .../apache/wicket/model/IModelComparator.java | 12 - .../wicket/model/StringResourceModel.java | 12 +- .../wicket/page/AbstractPageManager.java | 5 - .../wicket/page/PageManagerDecorator.java | 9 +- .../apache/wicket/page/RequestAdapter.java | 25 +- .../protocol/http/BufferedWebResponse.java | 14 - .../http/HeaderBufferingWebResponse.java | 5 - .../wicket/protocol/http/WicketFilter.java | 15 +- .../request/resource/AbstractResource.java | 5 +- .../request/resource/CssPackageResource.java | 20 +- .../resource/JavaScriptPackageResource.java | 28 +- .../DynamicJQueryResourceReference.java | 2 +- .../resource/JQueryResourceReference.java | 2 +- .../wicket/util/cookies/CookieUtils.java | 9 +- .../wicket/util/tester/BaseWicketTester.java | 116 +-- .../apache/wicket/util/tester/TagTester.java | 4 - .../wicket/util/tester/WicketTester.java | 28 - .../validator/CreditCardValidator.java | 2 +- 48 files changed, 420 insertions(+), 1407 deletions(-) diff --git a/wicket-core/src/main/java/org/apache/wicket/Application.java b/wicket-core/src/main/java/org/apache/wicket/Application.java index 5c53d63e92b..ed7f0ec883f 100644 --- a/wicket-core/src/main/java/org/apache/wicket/Application.java +++ b/wicket-core/src/main/java/org/apache/wicket/Application.java @@ -785,7 +785,7 @@ public final ICompoundRequestMapper getRootRequestMapperAsCompound() IRequestMapper root = getRootRequestMapper(); if (!(root instanceof ICompoundRequestMapper)) { - root = new SystemMapper(this).add(root); + root = new CompoundRequestMapper().add(root); setRootRequestMapper(root); } return (ICompoundRequestMapper)root; 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 16b1b279c06..4795b0a7e68 100644 --- a/wicket-core/src/main/java/org/apache/wicket/Component.java +++ b/wicket-core/src/main/java/org/apache/wicket/Component.java @@ -928,7 +928,7 @@ public final void afterRender() finally { // this flag must always be set to false. - markRendering(false); + setFlag(FLAG_RENDERING, false); } } @@ -3503,7 +3503,7 @@ private void notifyBehaviorsComponentRendered() * * Adds state change to page. */ - protected final void addStateChange() + protected void addStateChange() { checkHierarchyChange(this); final Page page = findPage(); @@ -4377,16 +4377,6 @@ public final boolean isEnabledInHierarchy() setRequestFlag(RFLAG_ENABLED_IN_HIERARCHY_VALUE, state); return state; } - - /** - * Says if the component is rendering or not checking the corresponding flag. - * - * @return true if this component is rendering, false otherwise. - */ - public final boolean isRendering() - { - return getFlag(FLAG_RENDERING); - } /** * Checks whether or not a listener method can be invoked on this component. Usually components 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 d15368d6c31..bec1da0d7c8 100644 --- a/wicket-core/src/main/java/org/apache/wicket/MarkupContainer.java +++ b/wicket-core/src/main/java/org/apache/wicket/MarkupContainer.java @@ -16,12 +16,14 @@ */ package org.apache.wicket; -import java.util.AbstractList; import java.util.ArrayList; +import java.util.Collection; import java.util.Collections; import java.util.Comparator; import java.util.Iterator; +import java.util.LinkedHashMap; import java.util.List; +import java.util.Map; import org.apache.wicket.core.util.string.ComponentStrings; import org.apache.wicket.markup.ComponentTag; @@ -41,7 +43,6 @@ import org.apache.wicket.model.IModel; import org.apache.wicket.model.IWrapModel; import org.apache.wicket.settings.IDebugSettings; -import org.apache.wicket.util.io.IClusterable; import org.apache.wicket.util.iterator.ComponentHierarchyIterator; import org.apache.wicket.util.lang.Args; import org.apache.wicket.util.lang.Classes; @@ -99,11 +100,16 @@ public abstract class MarkupContainer extends Component implements Iterable childrenMap; + + /** Optimization for first child */ + private Component firstChild; /** * @see org.apache.wicket.Component#Component(String) @@ -172,7 +178,7 @@ public MarkupContainer add(final Component... childs) // Add to map addedComponent(child); - if (put(child) != null) + if (children_add(child) != null) { throw new IllegalArgumentException(exceptionMessage("A child with id '" + child.getId() + "' already exists")); @@ -250,11 +256,7 @@ public final boolean autoAdd(final Component component, MarkupStream markupStrea // that's all what most auto-components need. Unfortunately child.onDetach() will not / can // not be invoked, since the parent doesn't known its one of his children. Hence we need to // properly add it. - int index = children_indexOf(component); - if (index >= 0) - { - children_remove(index); - } + children_remove( component ); add(component); return true; @@ -490,7 +492,7 @@ public void internalAdd(final Component child) // Add to map addedComponent(child); - put(child); + children_add(child); } /** @@ -532,29 +534,11 @@ public void remove() */ public final Iterator iterator(Comparator comparator) { - final List sorted; - if (children == null) + if (children_empty()) { - sorted = Collections.emptyList(); - } - else - { - if (children instanceof Component) - { - sorted = new ArrayList(1); - sorted.add((Component)children); - } - else - { - int size = children_size(); - sorted = new ArrayList(size); - for (int i = 0; i < size; i++) - { - sorted.add(children_get(i)); - } - - } + return Collections. emptyList().iterator(); } + final List sorted = children_copylist(); Collections.sort(sorted, comparator); return sorted.iterator(); } @@ -611,29 +595,31 @@ public MarkupContainer remove(final String id) */ public MarkupContainer removeAll() { - if (children != null) + if (firstChild != null) + { + addStateChange(); + + firstChild.internalOnRemove(); + firstChild.detach(); + firstChild.setParent( null ); + firstChild = null; + } + else if (childrenMap!=null) { addStateChange(); // Loop through child components - int size = children_size(); - for (int i = 0; i < size; i++) + for (Component child : childrenMap.values()) { - Object childObject = children_get(i, false); - if (childObject instanceof Component) - { // Get next child - final Component child = (Component)childObject; - // Do not call remove() because the state change would than be // recorded twice. child.internalOnRemove(); child.detach(); child.setParent(null); - } } - children = null; + childrenMap = null; } return this; @@ -726,7 +712,7 @@ public MarkupContainer replace(final Component child) if (child.getParent() != this) { // Add to map - final Component replaced = put(child); + final Component replaced = children_add(child); // Look up to make sure it was already in the map if (replaced == null) @@ -820,16 +806,9 @@ public String toString(final boolean detailed) buffer.append(", children = "); // Loop through child components - final int size = children_size(); - for (int i = 0; i < size; i++) + for (final Component child : children_list()) { - // Get next child - final Component child = children_get(i); - if (i != 0) - { - buffer.append(' '); - } - buffer.append(child.toString()); + buffer.append(child.toString()).append( ' ' ); } } @@ -973,21 +952,20 @@ public void component(final Component component, final IVisit visit) * @param child * Child to add */ - private void children_add(final Component child) + private Component children_add(final Component child) { - if (children == null) + if (children_empty()) { - children = child; + firstChild = child; + return null; } - else + if (children_one()) { - if (!(children instanceof ChildList)) - { - // Save new children - children = new ChildList(children); - } - ((ChildList)children).add(child); + childrenMap = new LinkedHashMap(HASHMAP_INITIAL_CAPACITY); + childrenMap.put( firstChild.getId(), firstChild ); + firstChild = null; } + return childrenMap.put(child.getId(), child); } /** @@ -1009,7 +987,7 @@ public final Component get(int index) */ private Component children_get(int index) { - return (Component)children_get(index, true); + return children_get(index, true); } /** @@ -1018,144 +996,49 @@ private Component children_get(int index) * @param reconstruct * @return the child component */ - private Object children_get(int index, boolean reconstruct) + private Component children_get(int index, boolean reconstruct) { - Object component = null; - if (children != null) + if (children_empty()) { - if (children instanceof Object[] == false && children instanceof ChildList == false) - { - if (index != 0) - { - throw new ArrayIndexOutOfBoundsException("index " + index + - " is greater then 0"); - } - component = children; - } - else - { - Object[] children; - if (this.children instanceof ChildList) - { - // we have a list - children = ((ChildList)this.children).childs; - } - else - { - // we have a object array - children = (Object[])this.children; - } - component = children[index]; - } + return null; } - return component; - } - - /** - * Returns the wicket:id of the given object if it is a {@link Component} - * - * @param object - * @return The id of the object (object can be component) - */ - private String getId(Object object) - { - if (object instanceof Component) + if (children_one() && index == 0) { - return ((Component)object).getId(); + return firstChild; } - else + int size = children_size(); + if (index < 0 || index >= size) { - throw new IllegalArgumentException("Unknown type of object " + object); + throw new ArrayIndexOutOfBoundsException("index " + index + " is smaller than 0 or beyond " + size); + } + // dreckig, aber effizienter: values().toArray() würde erst ein neues Array erzeugen und dabei über _alle_ Einträge iterieren. + final Iterator iter = children_list().iterator(); + for (int i=0; i= 0 && index < children_size()) - { - if (children instanceof Component) - { - replaced = children; - children = child; - } - else - { - if (children instanceof ChildList) - { - replaced = ((ChildList)children).set(index, child); - } - else - { - final Object[] children = (Object[])this.children; - replaced = children[index]; - children[index] = child; - } - } + if (children_one()) { + if (component.getId().equals( firstChild.getId() )) + { + final Component removed = firstChild; + firstChild = null; + return removed; + } + return null; } - else + final Component removed = childrenMap.remove( component.getId() ); + if (childrenMap.size() == 0) { - throw new IndexOutOfBoundsException(); + childrenMap = null; } - return replaced; + return removed; } /** * * @param index - * @param child - * @return The component that is replaced + * @return The component that is removed */ - private Component children_set(int index, Component child) + private Component children_remove(int index) { - return (Component)children_set(index, child, true); + return children_remove(children_get(index)); + } + + private boolean children_empty() { + return firstChild == null && childrenMap == null; + } + + private boolean children_one() { + return firstChild !=null; // && childrenMap == null; } /** @@ -1288,44 +1097,17 @@ private Component children_set(int index, Component child) */ private int children_size() { - if (children == null) + if (children_empty()) { return 0; } - else + if (children_one()) { - if (children instanceof Component) - { - return 1; - } - else if (children instanceof ChildList) - { - return ((ChildList)children).size; - } - return ((Object[])children).length; + return 1; } + return childrenMap.size(); } - /** - * Ensure that there is space in childForId map for a new entry before adding it. - * - * @param child - * The child to put into the map - * @return Any component that was replaced - */ - private Component put(final Component child) - { - int index = children_indexOf(child); - if (index == -1) - { - children_add(child); - return null; - } - else - { - return children_set(index, child); - } - } /** * @param component @@ -1539,7 +1321,7 @@ private void renderComponentTagBody(final MarkupStream markupStream, final Compo * @param markupStream * @param openTag */ - protected final void renderAll(final MarkupStream markupStream, final ComponentTag openTag) + protected void renderAll(final MarkupStream markupStream, final ComponentTag openTag) { while (markupStream.hasMore()) { @@ -1584,14 +1366,9 @@ void removeChildren() { super.removeChildren(); - for (int i = children_size(); i-- > 0;) + for (final Component child : children_copylist_reverse()) { - Object child = children_get(i, false); - if (child instanceof Component) - { - Component component = (Component)child; - component.internalOnRemove(); - } + child.internalOnRemove(); } } @@ -1600,31 +1377,17 @@ void detachChildren() { super.detachChildren(); - for (int i = children_size(); i-- > 0;) + for (final Component child : children_copylist_reverse()) { - Object child = children_get(i, false); - if (child instanceof Component) - { - Component component = (Component)child; - component.detach(); - + child.detach(); // We need to keep InlineEnclosures for Ajax request handling. // TODO this is really ugly. Feature request for 1.5: change auto-component that // they don't need to be removed anymore. - if (!(component instanceof InlineEnclosure) && component.isAuto()) - { - children_remove(i); - } + if (!(child instanceof InlineEnclosure) && child.isAuto()) + { + children_remove(child); } } - - if (children instanceof ChildList) - { - ChildList lst = (ChildList)children; - Object[] tmp = new Object[lst.size]; - System.arraycopy(lst.childs, 0, tmp, 0, lst.size); - children = tmp; - } } /** @@ -1635,26 +1398,38 @@ void detachChildren() void internalMarkRendering(boolean setRenderingFlag) { super.internalMarkRendering(setRenderingFlag); - final int size = children_size(); - for (int i = 0; i < size; i++) - { - final Component child = children_get(i); + + for (final Component child : children_list()) child.internalMarkRendering(setRenderingFlag); + } + + private Collection children_list() + { + if (children_empty()) + { + return Collections.emptyList(); } + if (children_one()) + { + return Collections.singletonList( firstChild ); + } + return childrenMap.values(); } - /** - * @return a copy of the children array. - */ - private Component[] copyChildren() + private List children_copylist() { - int size = children_size(); - Component result[] = new Component[size]; - for (int i = 0; i < size; ++i) + return new ArrayList( children_list() ); + } + + private List children_copylist_reverse() + { + if (children_empty()) { - result[i] = children_get(i); + return Collections.emptyList(); } - return result; + final List reverse = children_copylist(); + Collections.reverse(reverse); + return reverse; } /** @@ -1668,7 +1443,7 @@ void onBeforeRenderChildren() // We need to copy the children list because the children components can // modify the hierarchy in their onBeforeRender. - Component[] children = copyChildren(); + final List children = children_copylist(); try { // Loop through child components @@ -1738,121 +1513,6 @@ protected void onAfterRenderChildren() super.onAfterRenderChildren(); } - /** - * - */ - private static class ChildList extends AbstractList implements IClusterable - { - private static final long serialVersionUID = -7861580911447631127L; - private int size; - private Object[] childs; - - /** - * Construct. - * - * @param children - */ - public ChildList(Object children) - { - if (children instanceof Object[]) - { - childs = (Object[])children; - size = childs.length; - } - else - { - childs = new Object[3]; - add(children); - } - } - - @Override - public Object get(int index) - { - return childs[index]; - } - - @Override - public int size() - { - return size; - } - - @Override - public boolean add(Object o) - { - ensureCapacity(size + 1); - childs[size++] = o; - return true; - } - - @Override - public void add(int index, Object element) - { - if (index > size || index < 0) - { - throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + size); - } - - ensureCapacity(size + 1); - System.arraycopy(childs, index, childs, index + 1, size - index); - childs[index] = element; - size++; - } - - @Override - public Object set(int index, Object element) - { - if (index >= size) - { - throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + size); - } - - Object oldValue = childs[index]; - childs[index] = element; - return oldValue; - } - - @Override - public Object remove(int index) - { - if (index >= size) - { - throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + size); - } - - Object oldValue = childs[index]; - - int numMoved = size - index - 1; - if (numMoved > 0) - { - System.arraycopy(childs, index + 1, childs, index, numMoved); - } - childs[--size] = null; // Let gc do its work - - return oldValue; - } - - /** - * @param minCapacity - */ - public void ensureCapacity(int minCapacity) - { - int oldCapacity = childs.length; - if (minCapacity > oldCapacity) - { - Object oldData[] = childs; - int newCapacity = oldCapacity * 2; - if (newCapacity < minCapacity) - { - newCapacity = minCapacity; - } - childs = new Object[newCapacity]; - System.arraycopy(oldData, 0, childs, 0, size); - } - } - } - /** * Swaps position of children. This method is particularly useful for adjusting positions of * repeater's items without rebuilding the component hierarchy @@ -1867,14 +1527,12 @@ public final void swap(int idx1, int idx2) int size = children_size(); if (idx1 < 0 || idx1 >= size) { - throw new IndexOutOfBoundsException("Argument idx is out of bounds: " + idx1 + "<>[0," + - size + ")"); + throw new IndexOutOfBoundsException("Argument idx is out of bounds: " + idx1 + "<>[0," + size + ")"); } if (idx2 < 0 || idx2 >= size) { - throw new IndexOutOfBoundsException("Argument idx is out of bounds: " + idx2 + "<>[0," + - size + ")"); + throw new IndexOutOfBoundsException("Argument idx is out of bounds: " + idx2 + "<>[0," + size + ")"); } if (idx1 == idx2) @@ -1882,68 +1540,13 @@ public final void swap(int idx1, int idx2) return; } - if (children instanceof Object[]) - { - final Object[] array = (Object[])children; - Object tmp = array[idx1]; - array[idx1] = array[idx2]; - array[idx2] = tmp; - } - else - { - ChildList list = (ChildList)children; - Object tmp = list.childs[idx1]; - list.childs[idx1] = list.childs[idx2]; - list.childs[idx2] = tmp; + final List children = children_copylist(); + Collections.swap( children, idx1, idx2 ); + + childrenMap = new LinkedHashMap(children.size()); + for (final Component child : children) { + childrenMap.put( child.getId(), child ); } } - /** - * Automatically create components for tag. - */ - // to use it call it from #onInitialize() - private void createAndAddComponentsForWicketTags() - { - // Markup must be available - IMarkupFragment markup = getMarkup(); - if ((markup != null) && (markup.size() > 1)) - { - MarkupStream stream = new MarkupStream(markup); - - // Skip the first component tag which already belongs to 'this' container - if (stream.skipUntil(ComponentTag.class)) - { - stream.next(); - } - - // Search for in the remaining markup and try to resolve the component - while (stream.skipUntil(ComponentTag.class)) - { - ComponentTag tag = stream.getTag(); - if (tag.isOpen() || tag.isOpenClose()) - { - if (tag instanceof WicketTag) - { - Component component = ComponentResolvers.resolve(this, stream, tag, null); - if ((component != null) && (component.getParent() == null)) - { - if (component.getId().equals(tag.getId()) == false) - { - // make sure we are able to get() the component during rendering - tag.setId(component.getId()); - tag.setModified(true); - } - add(component); - } - } - - if (tag.isOpen()) - { - stream.skipToMatchingCloseTag(tag); - } - } - stream.next(); - } - } - } } 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 73e1dd949b8..da8b2449c37 100644 --- a/wicket-core/src/main/java/org/apache/wicket/RestartResponseAtInterceptPageException.java +++ b/wicket-core/src/main/java/org/apache/wicket/RestartResponseAtInterceptPageException.java @@ -198,7 +198,7 @@ static void continueToOriginalDestination() if (data != null) { String url = RequestCycle.get().getUrlRenderer().renderUrl(data.originalUrl); - throw new NonResettingRestartException(url); + RequestCycle.get().replaceAllRequestHandlers(new RedirectRequestHandler(url)); } } diff --git a/wicket-core/src/main/java/org/apache/wicket/ajax/AbstractDefaultAjaxBehavior.java b/wicket-core/src/main/java/org/apache/wicket/ajax/AbstractDefaultAjaxBehavior.java index 06d52cd6931..43a15259a4f 100644 --- a/wicket-core/src/main/java/org/apache/wicket/ajax/AbstractDefaultAjaxBehavior.java +++ b/wicket-core/src/main/java/org/apache/wicket/ajax/AbstractDefaultAjaxBehavior.java @@ -71,8 +71,6 @@ public abstract class AbstractDefaultAjaxBehavior extends AbstractAjaxBehavior private static final String AFTER_HANDLER_FUNCTION_TEMPLATE = "function(attrs){%s}"; private static final String BEFORE_SEND_HANDLER_FUNCTION_TEMPLATE = "function(attrs, jqXHR, settings){%s}"; private static final String BEFORE_HANDLER_FUNCTION_TEMPLATE = "function(attrs){%s}"; - private static final String INIT_HANDLER_FUNCTION_TEMPLATE = "function(attrs){%s}"; - private static final String DONE_HANDLER_FUNCTION_TEMPLATE = "function(attrs){%s}"; /** * Subclasses should call super.onBind() @@ -222,24 +220,11 @@ protected final CharSequence renderAjaxAttributes(final Component component, try { - String formId = attributes.getFormId(); - if (Strings.isEmpty(formId) == false) - { - attributesJson.put(AjaxAttributeName.FORM_ID.jsonName(), formId); - } attributesJson.put(AjaxAttributeName.URL.jsonName(), getCallbackUrl()); - - String[] eventNames = attributes.getEventNames(); - if (eventNames.length == 1) - { - attributesJson.put(AjaxAttributeName.EVENT_NAME.jsonName(), eventNames[0]); - } - else + Method method = attributes.getMethod(); + if (Method.POST == method) { - for (String eventName : eventNames) - { - attributesJson.append(AjaxAttributeName.EVENT_NAME.jsonName(), eventName); - } + attributesJson.put(AjaxAttributeName.METHOD.jsonName(), method); } if (component instanceof Page == false) @@ -248,6 +233,12 @@ protected final CharSequence renderAjaxAttributes(final Component component, attributesJson.put(AjaxAttributeName.MARKUP_ID.jsonName(), componentId); } + String formId = attributes.getFormId(); + if (Strings.isEmpty(formId) == false) + { + attributesJson.put(AjaxAttributeName.FORM_ID.jsonName(), formId); + } + if (attributes.isMultipart()) { attributesJson.put(AjaxAttributeName.IS_MULTIPART.jsonName(), true); @@ -263,7 +254,8 @@ protected final CharSequence renderAjaxAttributes(final Component component, CharSequence childSelector = attributes.getChildSelector(); if (Strings.isEmpty(childSelector) == false) { - attributesJson.put(AjaxAttributeName.CHILD_SELECTOR.jsonName(), childSelector); + attributesJson.put(AjaxAttributeName.CHILD_SELECTOR.jsonName(), + childSelector); } String indicatorId = findIndicatorId(); @@ -276,12 +268,6 @@ protected final CharSequence renderAjaxAttributes(final Component component, { if (ajaxCallListener != null) { - if (ajaxCallListener instanceof AjaxCallListener) { - CharSequence initHandler = ((AjaxCallListener) ajaxCallListener).getInitHandler(component); - appendListenerHandler(initHandler, attributesJson, - AjaxAttributeName.INIT_HANDLER.jsonName(), - INIT_HANDLER_FUNCTION_TEMPLATE); - } CharSequence beforeHandler = ajaxCallListener.getBeforeHandler(component); appendListenerHandler(beforeHandler, attributesJson, AjaxAttributeName.BEFORE_HANDLER.jsonName(), @@ -314,13 +300,6 @@ protected final CharSequence renderAjaxAttributes(final Component component, CharSequence precondition = ajaxCallListener.getPrecondition(component); appendListenerHandler(precondition, attributesJson, AjaxAttributeName.PRECONDITION.jsonName(), PRECONDITION_FUNCTION_TEMPLATE); - - if (ajaxCallListener instanceof AjaxCallListener) { - CharSequence doneHandler = ((AjaxCallListener) ajaxCallListener).getDoneHandler(component); - appendListenerHandler(doneHandler, attributesJson, - AjaxAttributeName.DONE_HANDLER.jsonName(), - DONE_HANDLER_FUNCTION_TEMPLATE); - } } } @@ -349,6 +328,19 @@ protected final CharSequence renderAjaxAttributes(final Component component, attributesJson.put(AjaxAttributeName.IS_ASYNC.jsonName(), false); } + String[] eventNames = attributes.getEventNames(); + if (eventNames.length == 1) + { + attributesJson.put(AjaxAttributeName.EVENT_NAME.jsonName(), eventNames[0]); + } + else + { + for (String eventName : eventNames) + { + attributesJson.append(AjaxAttributeName.EVENT_NAME.jsonName(), eventName); + } + } + AjaxChannel channel = attributes.getChannel(); if (channel != null && channel.equals(AjaxChannel.DEFAULT) == false) { @@ -360,12 +352,6 @@ protected final CharSequence renderAjaxAttributes(final Component component, attributesJson.put(AjaxAttributeName.IS_ALLOW_DEFAULT.jsonName(), true); } - Method method = attributes.getMethod(); - if (Method.POST == method) - { - attributesJson.put(AjaxAttributeName.METHOD.jsonName(), method); - } - if (AjaxRequestAttributes.EventPropagation.BUBBLE.equals(attributes.getEventPropagation())) { attributesJson.put(AjaxAttributeName.EVENT_PROPAGATION.jsonName(), "bubble"); @@ -554,11 +540,9 @@ public CharSequence getCallbackFunctionBody(CallbackParameter... extraParameters } } sb.append("var params = ").append(jsonArray).append(";\n"); - sb.append("attrs.") - .append(AjaxAttributeName.EXTRA_PARAMETERS) - .append(" = params.concat(attrs.") - .append(AjaxAttributeName.EXTRA_PARAMETERS) - .append(" || []);\n"); + sb.append("attrs.").append(AjaxAttributeName.EXTRA_PARAMETERS) + .append(" = params.concat(attrs.") + .append(AjaxAttributeName.EXTRA_PARAMETERS).append(" || []);\n"); sb.append("Wicket.Ajax.ajax(attrs);\n"); return sb; } 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 9b4eead5315..d605d3005cf 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 @@ -118,7 +118,8 @@ protected void onCheckEvent(final String event) */ public String getEvent() { - String[] splitEvents = event.split("\\s+"); + String events = event.toLowerCase(); + String[] splitEvents = events.split("\\s+"); List cleanedEvents = new ArrayList(splitEvents.length); for (String evt : splitEvents) { diff --git a/wicket-core/src/main/java/org/apache/wicket/ajax/attributes/AjaxAttributeName.java b/wicket-core/src/main/java/org/apache/wicket/ajax/attributes/AjaxAttributeName.java index bea715da552..6f0508da09b 100644 --- a/wicket-core/src/main/java/org/apache/wicket/ajax/attributes/AjaxAttributeName.java +++ b/wicket-core/src/main/java/org/apache/wicket/ajax/attributes/AjaxAttributeName.java @@ -173,20 +173,6 @@ public enum AjaxAttributeName { */ BEFORE_HANDLER("bh"), - /** - * init handler (ih) - * - * @see AjaxCallListener#getInitHandler(org.apache.wicket.Component) - */ - INIT_HANDLER("ih"), - - /** - * done handler (dh) - * - * @see AjaxCallListener#getDoneHandler(org.apache.wicket.Component) - */ - DONE_HANDLER("dh"), - /** * the indicator id, if any found (i) * diff --git a/wicket-core/src/main/java/org/apache/wicket/ajax/attributes/AjaxCallListener.java b/wicket-core/src/main/java/org/apache/wicket/ajax/attributes/AjaxCallListener.java index 3ba3fa7e6bf..b0e6be2d808 100644 --- a/wicket-core/src/main/java/org/apache/wicket/ajax/attributes/AjaxCallListener.java +++ b/wicket-core/src/main/java/org/apache/wicket/ajax/attributes/AjaxCallListener.java @@ -28,7 +28,6 @@ */ public class AjaxCallListener implements IAjaxCallListener, IComponentAwareHeaderContributor { - private StringBuilder init; private StringBuilder success; private StringBuilder failure; private StringBuilder before; @@ -36,49 +35,6 @@ public class AjaxCallListener implements IAjaxCallListener, IComponentAwareHeade private StringBuilder after; private StringBuilder complete; private StringBuilder precondition; - private StringBuilder done; - - /** - * Sets the JavaScript code that will be returned by {@link #getInitHandler(Component)}. - * If this code was already set, the new one will be appended to the existing one. - * - * @param init - * the JavaScript code for the corresponding handler - * @return This - */ - public AjaxCallListener onInit(final CharSequence init) - { - if (Strings.isEmpty(init) == false) - { - if (this.init == null) - { - this.init = new StringBuilder(); - } - this.init.append(init); - } - return this; - } - - /** - * Sets the JavaScript code that will be returned by {@link #getDoneHandler(Component)}. - * If this code was already set, the new one will be appended to the existing one. - * - * @param init - * the JavaScript code for the corresponding handler - * @return This - */ - public AjaxCallListener onDone(final CharSequence done) - { - if (Strings.isEmpty(done) == false) - { - if (this.done == null) - { - this.done = new StringBuilder(); - } - this.done.append(done); - } - return this; - } /** * Sets the JavaScript code that will be returned by {@link #getBeforeHandler(Component)}. @@ -239,14 +195,6 @@ public CharSequence getFailureHandler(Component component) return failure; } - /** - * TODO Wicket 7: pull up into IAjaxCallListener - */ - public CharSequence getInitHandler(Component component) - { - return init; - } - @Override public CharSequence getBeforeHandler(Component component) { @@ -277,24 +225,6 @@ public CharSequence getPrecondition(Component component) return precondition; } - - /** - * The JavaScript that will be executed after the Ajax call is done, regardless whether it was - * sent or not. The script will be executed in a function that receives the following - * parameters: - *
    - *
  1. attrs - the AjaxRequestAttributes as JSON
  2. - *
- * TODO Wicket 7: pull up into IAjaxCallListener - * - * @param component - * the Component with the Ajax behavior - * @return the JavaScript that will be executed after the Ajax call is done. - */ - public CharSequence getDoneHandler(Component component) { - return done; - } - @Override public void renderHead(Component component, IHeaderResponse response) { diff --git a/wicket-core/src/main/java/org/apache/wicket/ajax/json/JSONObject.java b/wicket-core/src/main/java/org/apache/wicket/ajax/json/JSONObject.java index 76fdc25a0f0..4aabe0c1498 100755 --- a/wicket-core/src/main/java/org/apache/wicket/ajax/json/JSONObject.java +++ b/wicket-core/src/main/java/org/apache/wicket/ajax/json/JSONObject.java @@ -34,7 +34,6 @@ of this software and associated documentation files (the "Software"), to deal import java.util.Enumeration; import java.util.HashMap; import java.util.Iterator; -import java.util.LinkedHashMap; import java.util.Locale; import java.util.Map; import java.util.ResourceBundle; @@ -150,7 +149,7 @@ public String toString() { * Construct an empty JSONObject. */ public JSONObject() { - this.map = new LinkedHashMap(); + this.map = new HashMap(); } @@ -239,7 +238,7 @@ public JSONObject(JSONTokener x) throws JSONException { * @throws JSONException */ public JSONObject(Map map) { - this.map = new LinkedHashMap(); + this.map = new HashMap(); if (map != null) { Iterator i = map.entrySet().iterator(); while (i.hasNext()) { diff --git a/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-ajax-jquery.js b/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-ajax-jquery.js index 916cd257df5..2dc6192a0fb 100644 --- a/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-ajax-jquery.js +++ b/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-ajax-jquery.js @@ -49,8 +49,7 @@ getAjaxBaseUrl, isUndef, replaceAll, - htmlToDomDocument, - nodeListToArray; + htmlToDomDocument; isUndef = function (target) { return (typeof(target) === 'undefined' || target === null); @@ -98,23 +97,6 @@ return xmldoc; }; - /** - * Converts a NodeList to an Array - * - * @param nodeList The NodeList to convert - * @returns {Array} The array with document nodes - */ - nodeListToArray = function (nodeList) { - var arr = [], - nodeId; - if (nodeList && nodeList.length) { - for (nodeId = 0; nodeId < nodeList.length; nodeId++) { - arr.push(nodeList.item(nodeId)); - } - } - return arr; - }; - /** * Functions executer takes array of functions and executes them. * The functions are executed one by one as far as the return value is FunctionsExecuter.DONE. @@ -568,6 +550,9 @@ */ doAjax: function (attrs) { + // keep channel for done() + this.channel = attrs.ch; + var // the headers to use for each Ajax request headers = { @@ -626,7 +611,7 @@ } if (result === false) { Wicket.Log.info("Ajax request stopped because of precondition check, url: " + attrs.u); - self.done(attrs); + self.done(); return false; } } @@ -710,14 +695,14 @@ complete: function (jqXHR, textStatus) { context.steps.push(jQuery.proxy(function (notify) { - if (attrs.i && context.isRedirecting !== true) { + if (attrs.i) { Wicket.DOM.hideIncrementally(attrs.i); } self._executeHandlers(attrs.coh, attrs, jqXHR, textStatus); we.publish(topic.AJAX_CALL_COMPLETE, attrs, jqXHR, textStatus); - self.done(attrs); + self.done(); return FunctionsExecuter.DONE; }, self)); @@ -774,15 +759,14 @@ // In case the page isn't really redirected. For example say the redirect is to an octet-stream. // A file download popup will appear but the page in the browser won't change. this.success(context); - this.done(context.attrs); + this.done(); var rhttp = /^http:\/\//, // checks whether the string starts with http:// rhttps = /^https:\/\//; // checks whether the string starts with https:// // support/check for non-relative redirectUrl like as provided and needed in a portlet context if (redirectUrl.charAt(0) === '/' || rhttp.test(redirectUrl) || rhttps.test(redirectUrl)) { - context.isRedirecting = true; - Wicket.Ajax.redirect(redirectUrl); + window.location = redirectUrl; } else { var urlDepth = 0; @@ -806,8 +790,7 @@ calculatedRedirect = window.location.protocol + "//" + window.location.host + calculatedRedirect; } - context.isRedirecting = true; - Wicket.Ajax.redirect(calculatedRedirect); + window.location = calculatedRedirect; } } else { @@ -928,46 +911,10 @@ this._executeHandlers(attrs.ah, attrs); we.publish(topic.AJAX_CALL_AFTER, attrs); - // a step to execute in both successful and erroneous completion - context.endStep = jQuery.proxy(function(notify) { - // remove the iframe and button elements - setTimeout(function() { - jQuery('#'+iframe.id + '-btn').remove(); - jQuery(iframe).remove(); - }, 0); - - var attrs = context.attrs; - if (attrs.i && context.isRedirecting !== true) { - // hide the indicator - Wicket.DOM.hideIncrementally(attrs.i); - } - - this._executeHandlers(attrs.coh, attrs, null, null); - Wicket.Event.publish(Wicket.Event.Topic.AJAX_CALL_COMPLETE, attrs, null, null); - - this.done(attrs); - return FunctionsExecuter.DONE; - }, this); - - // an error handler that is used when the connection to the server fails for any reason - if (attrs.rt) { - context.errorHandle = setTimeout(jQuery.proxy(function () { - this.failure(context, null, "No XML response in the IFrame document", "Failure"); - - context.steps.push(context.endStep); - var executer = new FunctionsExecuter(context.steps); - executer.start(); - }, this), attrs.rt); - } else { - Wicket.Log.info("Submitting a multipart form without a timeout. " + - "Use AjaxRequestAttributes.setRequestTimeout(duration) if need to handle connection timeouts."); - } - // install handler to deal with the ajax response // ... we add the onload event after form submit because chrome fires it prematurely we.add(iframe, "load.handleMultipartComplete", jQuery.proxy(this.handleMultipartComplete, this), context); - // handled, restore state and return true form.action = originalFormAction; form.target = originalFormTarget; @@ -988,10 +935,6 @@ iframe = event.target, envelope; - if (!isUndef(context.errorHandle)) { - clearTimeout(context.errorHandle); - } - // stop the event event.stopPropagation(); @@ -1016,7 +959,26 @@ this.loadedCallback(envelope, context); } - context.steps.push(context.endStep); + context.steps.push(jQuery.proxy(function(notify) { + // remove the iframe and button elements + setTimeout(function() { + jQuery('#'+iframe.id + '-btn').remove(); + jQuery(iframe).remove(); + }, 0); + + var attrs = context.attrs; + if (attrs.i) { + // hide the indicator + Wicket.DOM.hideIncrementally(attrs.i); + } + + this._executeHandlers(attrs.coh, attrs, null, null); + Wicket.Event.publish(Wicket.Event.Topic.AJAX_CALL_COMPLETE, attrs, null, null); + + this.done(); + return FunctionsExecuter.DONE; + }, this)); + var executer = new FunctionsExecuter(context.steps); executer.start(); }, @@ -1127,11 +1089,8 @@ }, this)); }, - done: function (attrs) { - this._executeHandlers(attrs.dh, attrs); - Wicket.Event.publish(Wicket.Event.Topic.AJAX_CALL_DONE, attrs); - - Wicket.channelManager.done(attrs.ch); + done: function () { + Wicket.channelManager.done(this.channel); }, // Adds a closure that replaces a component @@ -1262,8 +1221,7 @@ processRedirect: function (context, node) { var text = Wicket.DOM.text(node); Wicket.Log.info("Redirecting to: " + text); - context.isRedirecting = true; - Wicket.Ajax.redirect(text); + window.location = text; }, // mark the focused component so that we know if it has been replaced by response @@ -1549,24 +1507,25 @@ } else if (tag === "input" || tag === "textarea") { return Wicket.Form.serializeInput(element); } else { - var elements = nodeListToArray(element.getElementsByTagName("input")); - elements = elements.concat(nodeListToArray(element.getElementsByTagName("select"))); - elements = elements.concat(nodeListToArray(element.getElementsByTagName("textarea"))); - - var result = []; - for (var i = 0; i < elements.length; ++i) { - var el = elements[i]; - if (el.name && el.name !== "") { - result = result.concat(Wicket.Form.serializeElement(el)); - } - } - return result; + return []; } }, serializeForm: function (form) { var result = [], - elements; + elements, + nodeListToArray, + nodeId; + + nodeListToArray = function (nodeList) { + var arr = []; + if (nodeList && nodeList.length) { + for (nodeId = 0; nodeId < nodeList.length; nodeId++) { + arr.push(nodeList.item(nodeId)); + } + } + return arr; + }; if (form) { if (form.tagName.toLowerCase() === 'form') { @@ -1970,9 +1929,6 @@ attributes.event.extraData = data; } - call._executeHandlers(attributes.ih, attributes); - Wicket.Event.publish(Wicket.Event.Topic.AJAX_CALL_INIT, attributes); - var throttlingSettings = attributes.tr; if (throttlingSettings) { var postponeTimerOnUpdate = throttlingSettings.p || false; @@ -1993,15 +1949,6 @@ process: function(data) { var call = new Wicket.Ajax.Call(); call.process(data); - }, - - /** - * An abstraction over native window.location.replace() to be able to suppress it for unit tests - * - * @param url The url to redirect to - */ - redirect: function(url) { - window.location = url; } }, @@ -2702,15 +2649,14 @@ Wicket.Log.info("Calling focus on " + WF.lastFocusId); try { if (WF.focusSetFromServer) { - // WICKET-5858 - window.setTimeout(function () { toFocus.focus(); }, 0); + toFocus.focus(); } else { // avoid loops like - onfocus triggering an event the modifies the tag => refocus => the event is triggered again var temp = toFocus.onfocus; toFocus.onfocus = null; - + toFocus.focus(); // IE needs setTimeout (it seems not to call onfocus sync. when focus() is called - window.setTimeout(function () {toFocus.focus(); toFocus.onfocus = temp; }, 0); + window.setTimeout(function () {toFocus.onfocus = temp; }, 0); } } catch (ignore) { } @@ -2815,9 +2761,7 @@ setup: function () { - if (Wicket.Browser.isIE()) { - // WICKET-5959: IE >= 11 supports "input" events, but triggers too often - // to be reliable + if (Wicket.Browser.isIELessThan11()) { jQuery(this).on('keydown', function (event) { jQuery.event.special.inputchange.keyDownPressed = true; @@ -2883,7 +2827,7 @@ /** * Clear any scheduled Ajax timers when leaving the current page */ - Wicket.Event.add(window, "unload", function() { + Wicket.Event.add(window, "beforeunload", function() { var WTH = Wicket.TimerHandles; if (WTH) { for (var th in WTH) { diff --git a/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-event-jquery.js b/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-event-jquery.js index 1a83c4c59e1..41fca04c594 100644 --- a/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-event-jquery.js +++ b/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-event-jquery.js @@ -138,8 +138,8 @@ var wb = Wicket.Browser; if (wb._isIE11 === null) { var userAgent = window.navigator.userAgent; - var isTrident = userAgent.indexOf("Trident") > -1; - var is11 = userAgent.indexOf("rv:11") > -1; + var isTrident = userAgent.indexOf("Trident"); + var is11 = userAgent.indexOf("rv:11"); wb._isIE11 = isTrident && is11; } return wb._isIE11; @@ -315,7 +315,6 @@ Topic: { DOM_NODE_REMOVING : '/dom/node/removing', DOM_NODE_ADDED : '/dom/node/added', - AJAX_CALL_INIT : '/ajax/call/init', AJAX_CALL_BEFORE : '/ajax/call/before', AJAX_CALL_PRECONDITION : '/ajax/call/precondition', AJAX_CALL_BEFORE_SEND : '/ajax/call/beforeSend', @@ -323,7 +322,6 @@ AJAX_CALL_COMPLETE : '/ajax/call/complete', AJAX_CALL_AFTER : '/ajax/call/after', AJAX_CALL_FAILURE : '/ajax/call/failure', - AJAX_CALL_DONE : '/ajax/call/done', AJAX_HANDLERS_BOUND : '/ajax/handlers/bound' } } diff --git a/wicket-core/src/main/java/org/apache/wicket/authentication/strategy/DefaultAuthenticationStrategy.java b/wicket-core/src/main/java/org/apache/wicket/authentication/strategy/DefaultAuthenticationStrategy.java index 21a4e7d8fc8..a497ba028c9 100644 --- a/wicket-core/src/main/java/org/apache/wicket/authentication/strategy/DefaultAuthenticationStrategy.java +++ b/wicket-core/src/main/java/org/apache/wicket/authentication/strategy/DefaultAuthenticationStrategy.java @@ -18,9 +18,7 @@ import org.apache.wicket.Application; import org.apache.wicket.authentication.IAuthenticationStrategy; -import org.apache.wicket.util.cookies.CookieDefaults; import org.apache.wicket.util.cookies.CookieUtils; -import org.apache.wicket.util.crypt.CachingSunJceCryptFactory; import org.apache.wicket.util.crypt.ICrypt; import org.apache.wicket.util.lang.Args; import org.apache.wicket.util.string.Strings; @@ -38,13 +36,10 @@ public class DefaultAuthenticationStrategy implements IAuthenticationStrategy private static final Logger logger = LoggerFactory.getLogger(DefaultAuthenticationStrategy.class); /** The cookie name to store the username and password */ - protected final String cookieKey; - - /** The key to use for encrypting/decrypting the cookie value */ - protected final String encryptionKey; + private final String cookieKey; /** The separator used to concatenate the username and password */ - protected final String VALUE_SEPARATOR = "-sep-"; + private final String VALUE_SEPARATOR = "-sep-"; /** Cookie utils with default settings */ private CookieUtils cookieUtils; @@ -52,6 +47,7 @@ public class DefaultAuthenticationStrategy implements IAuthenticationStrategy /** Use to encrypt cookie values for username and password. */ private ICrypt crypt; + /** * Constructor * @@ -59,23 +55,8 @@ public class DefaultAuthenticationStrategy implements IAuthenticationStrategy * The name of the cookie */ public DefaultAuthenticationStrategy(final String cookieKey) - { - this(cookieKey, defaultEncryptionKey(cookieKey)); - } - - private static String defaultEncryptionKey(String cookieKey) - { - if (Application.exists()) - { - return Application.get().getName(); - } - return cookieKey; - } - - public DefaultAuthenticationStrategy(final String cookieKey, final String encryptionKey) { this.cookieKey = Args.notEmpty(cookieKey, "cookieKey"); - this.encryptionKey = Args.notEmpty(encryptionKey, "encryptionKey"); } /** @@ -87,8 +68,7 @@ protected CookieUtils getCookieUtils() { if (cookieUtils == null) { - CookieDefaults settings = new CookieDefaults(); - cookieUtils = new CookieUtils(settings); + cookieUtils = new CookieUtils(); } return cookieUtils; } @@ -100,12 +80,14 @@ protected ICrypt getCrypt() { if (crypt == null) { - CachingSunJceCryptFactory cryptFactory = new CachingSunJceCryptFactory(encryptionKey); - crypt = cryptFactory.newCrypt(); + crypt = Application.get().getSecuritySettings().getCryptFactory().newCrypt(); } return crypt; } + /** + * @see org.apache.wicket.authentication.IAuthenticationStrategy#load() + */ @Override public String[] load() { @@ -124,39 +106,32 @@ public String[] load() getCookieUtils().remove(cookieKey); value = null; } - return decode(value); + if (Strings.isEmpty(value) == false) + { + String username = null; + String password = null; + + String[] values = value.split(VALUE_SEPARATOR); + if ((values.length > 0) && (Strings.isEmpty(values[0]) == false)) + { + username = values[0]; + } + if ((values.length > 1) && (Strings.isEmpty(values[1]) == false)) + { + password = values[1]; + } + + return new String[] { username, password }; + } } return null; } /** - * This method will decode decrypted cookie value based on application needs - * - * @param value decrypted cookie value - * @return decomposed values array, or null in case cookie value was empty. + * @see org.apache.wicket.authentication.IAuthenticationStrategy#save(java.lang.String, + * java.lang.String) */ - protected String[] decode(String value) { - if (Strings.isEmpty(value) == false) - { - String username = null; - String password = null; - - String[] values = value.split(VALUE_SEPARATOR); - if ((values.length > 0) && (Strings.isEmpty(values[0]) == false)) - { - username = values[0]; - } - if ((values.length > 1) && (Strings.isEmpty(values[1]) == false)) - { - password = values[1]; - } - - return new String[] { username, password }; - } - return null; - } - @Override public void save(final String username, final String password) { @@ -167,6 +142,9 @@ public void save(final String username, final String password) getCookieUtils().save(cookieKey, encryptedValue); } + /** + * @see org.apache.wicket.authentication.IAuthenticationStrategy#remove() + */ @Override public void remove() { 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 4d6a89f0293..0cc2d68f3d3 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 @@ -343,7 +343,6 @@ protected Url encryptEntireUrl(final Url url) protected Url encryptRequestListenerParameter(final Url url) { Url encryptedUrl = new Url(url); - boolean encrypted = false; for (Iterator it = encryptedUrl.getQueryParameters().iterator(); it.hasNext();) { @@ -356,19 +355,11 @@ protected Url encryptRequestListenerParameter(final Url url) Url.QueryParameter encryptedParameter = new Url.QueryParameter(ENCRYPTED_PAGE_COMPONENT_INFO_PARAMETER, encryptedParameterValue); encryptedUrl.getQueryParameters().add(0, encryptedParameter); - encrypted = true; break; } } - if (encrypted) - { - return encryptedUrl; - } - else - { - return url; - } + return encryptedUrl; } /** 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 9e2a57bc53c..de2ec65c9a9 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 CachingResourceStreamLocator(final IResourceStreamLocator resourceStreamL @Override public IResourceStream locate(Class clazz, String path) { - CacheKey key = new CacheKey(clazz.getName(), path, null, null, null, null, true); + CacheKey key = new CacheKey(clazz.getName(), path, null, null, null, null); IResourceStreamReference resourceStreamReference = cache.get(key); final IResourceStream result; @@ -113,7 +113,7 @@ else if (stream instanceof UrlResourceStream) 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, strict); + CacheKey key = new CacheKey(scope.getName(), path, extension, locale, style, variation); IResourceStreamReference resourceStreamReference = cache.get(key); final IResourceStream result; @@ -149,54 +149,37 @@ public void clearCache() */ private static class CacheKey extends Key { - private static final long serialVersionUID = 1L; - /** * The file extension */ private final String extension; - /** 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) + private CacheKey(String scope, String name, String extension, Locale locale, String style, String variation) { super(scope, name, locale, style, variation); this.extension = extension; - this.strict = strict; } @Override - public int hashCode() + public boolean equals(Object o) { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ((extension == null) ? 0 : extension.hashCode()); - result = prime * result + (strict ? 1231 : 1237); - return result; + 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); + } @Override - public boolean equals(Object obj) + public int hashCode() { - 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; + int result = super.hashCode(); + result = 31 * result + (extension != null ? extension.hashCode() : 0); + return result; } } } diff --git a/wicket-core/src/main/java/org/apache/wicket/core/util/string/ComponentRenderer.java b/wicket-core/src/main/java/org/apache/wicket/core/util/string/ComponentRenderer.java index c86e0c981d2..b2e84dc2137 100644 --- a/wicket-core/src/main/java/org/apache/wicket/core/util/string/ComponentRenderer.java +++ b/wicket-core/src/main/java/org/apache/wicket/core/util/string/ComponentRenderer.java @@ -30,23 +30,19 @@ import org.apache.wicket.request.cycle.RequestCycle; import org.apache.wicket.util.resource.IResourceStream; import org.apache.wicket.util.resource.StringResourceStream; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * A helper class for rendering components and pages */ public class ComponentRenderer { - private static final Logger LOGGER = LoggerFactory.getLogger(ComponentRenderer.class); - /** * The id to use when rendering a component * @deprecated Not used since WICKET-5232 (6.9.0) */ @Deprecated public static final String COMP_ID = "compId"; - + /** * Collects the html generated by the rendering of a page. * @@ -77,15 +73,10 @@ public static CharSequence renderPage(final PageProvider pageProvider) return tempResponse.getText(); } + /** * Collects the html generated by the rendering of a component. * - *

- * NOTE: this method is meant to render fresh component instances that are disposed after the - * html has been generate. To avoid unwanted side effects do not use it with components that - * are from an existing hierarchy. - *

- * * @param component * the component to render. * @return the html rendered by the component @@ -99,14 +90,6 @@ public static CharSequence renderComponent(final Component component) MarkupContainer oldParent = component.getParent(); - if (oldParent != null && LOGGER.isWarnEnabled()) - { - LOGGER.warn("Component '{}' with a parent '{}' is passed for standalone rendering. " + - "It is recommended to render only orphan components because they are not cleaned up/detached" + - " after the rendering.", - component, oldParent); - } - try { requestCycle.setResponse(tempResponse); diff --git a/wicket-core/src/main/java/org/apache/wicket/feedback/IFeedbackMessageFilter.java b/wicket-core/src/main/java/org/apache/wicket/feedback/IFeedbackMessageFilter.java index fdd305737ab..83706e56243 100644 --- a/wicket-core/src/main/java/org/apache/wicket/feedback/IFeedbackMessageFilter.java +++ b/wicket-core/src/main/java/org/apache/wicket/feedback/IFeedbackMessageFilter.java @@ -28,7 +28,7 @@ public interface IFeedbackMessageFilter extends IClusterable /** * Filter that returns simply all available messages. */ - IFeedbackMessageFilter ALL = new IFeedbackMessageFilter() + public static final IFeedbackMessageFilter ALL = new IFeedbackMessageFilter() { private static final long serialVersionUID = 1L; @@ -42,7 +42,7 @@ public boolean accept(FeedbackMessage message) /** * Filter that does not match any message */ - IFeedbackMessageFilter NONE = new IFeedbackMessageFilter() + public static final IFeedbackMessageFilter NONE = new IFeedbackMessageFilter() { private static final long serialVersionUID = 1L; @@ -59,4 +59,4 @@ public boolean accept(FeedbackMessage message) * @return True if the message should be included, false to exclude it */ boolean accept(FeedbackMessage message); -} +} \ No newline at end of file diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/AbstractMarkupFragment.java b/wicket-core/src/main/java/org/apache/wicket/markup/AbstractMarkupFragment.java index b9de2a93b6f..d990db25500 100644 --- a/wicket-core/src/main/java/org/apache/wicket/markup/AbstractMarkupFragment.java +++ b/wicket-core/src/main/java/org/apache/wicket/markup/AbstractMarkupFragment.java @@ -18,7 +18,6 @@ import java.util.Deque; import java.util.LinkedList; - import org.apache.wicket.util.lang.Args; /** @@ -74,7 +73,7 @@ else if (tag.isOpen() && !tag.hasNoCloseTag()) { canFind = true; } - else if (wtag.isFragementTag() || wtag.isContainerTag()) + else if (wtag.isFragementTag()) { canFind = false; } diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/head/IHeaderResponse.java b/wicket-core/src/main/java/org/apache/wicket/markup/head/IHeaderResponse.java index a297f87954e..e5f9c15c879 100644 --- a/wicket-core/src/main/java/org/apache/wicket/markup/head/IHeaderResponse.java +++ b/wicket-core/src/main/java/org/apache/wicket/markup/head/IHeaderResponse.java @@ -38,7 +38,7 @@ public interface IHeaderResponse extends Closeable * @param item * The item to render. */ - void render(HeaderItem item); + public void render(HeaderItem item); /** * Marks the given object as rendered. The object can be anything (string, resource reference, @@ -48,7 +48,7 @@ public interface IHeaderResponse extends Closeable * @param object * object to be marked as rendered. */ - void markRendered(Object object); + public void markRendered(Object object); /** * Returns whether the given object has been marked as rendered. @@ -65,7 +65,7 @@ public interface IHeaderResponse extends Closeable * Object that is queried to be rendered * @return Whether the object has been marked as rendered during the request */ - boolean wasRendered(Object object); + public boolean wasRendered(Object object); /** * Returns the response that can be used to write arbitrary text to the head section. @@ -75,14 +75,14 @@ public interface IHeaderResponse extends Closeable * * @return Response */ - Response getResponse(); + public Response getResponse(); /** * Mark Header rendering is completed and subsequent usage will be ignored. If some kind of * buffering is used internally, this action will mark that the contents has to be flushed out. */ @Override - void close(); + public void close(); /** * @return if header rendering is completed and subsequent usage will be ignored diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/PackageResourceGuard.java b/wicket-core/src/main/java/org/apache/wicket/markup/html/PackageResourceGuard.java index db1aeb613de..be9bb439ee5 100644 --- a/wicket-core/src/main/java/org/apache/wicket/markup/html/PackageResourceGuard.java +++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/PackageResourceGuard.java @@ -85,8 +85,7 @@ protected boolean acceptAbsolutePath(String path) int len = path.length(); final String ext; if (ixExtension <= 0 || ixExtension == len || - (path.lastIndexOf('/') + 1) == ixExtension || - (path.lastIndexOf('\\') + 1) == ixExtension) + (path.lastIndexOf(File.separator) + 1) == ixExtension) { ext = null; } diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/SecurePackageResourceGuard.java b/wicket-core/src/main/java/org/apache/wicket/markup/html/SecurePackageResourceGuard.java index 11469c3376e..03cf6067fa8 100644 --- a/wicket-core/src/main/java/org/apache/wicket/markup/html/SecurePackageResourceGuard.java +++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/SecurePackageResourceGuard.java @@ -126,7 +126,6 @@ public SecurePackageResourceGuard(final ConcurrentMap cache) addPattern("+*.eot"); addPattern("+*.ttf"); addPattern("+*.woff"); - addPattern("+*.woff2"); } diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/TransparentWebMarkupContainer.java b/wicket-core/src/main/java/org/apache/wicket/markup/html/TransparentWebMarkupContainer.java index 912552899db..a53415d0955 100644 --- a/wicket-core/src/main/java/org/apache/wicket/markup/html/TransparentWebMarkupContainer.java +++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/TransparentWebMarkupContainer.java @@ -19,14 +19,8 @@ import org.apache.wicket.Component; import org.apache.wicket.MarkupContainer; import org.apache.wicket.markup.ComponentTag; -import org.apache.wicket.markup.MarkupElement; import org.apache.wicket.markup.MarkupStream; -import org.apache.wicket.markup.html.internal.HtmlHeaderContainer; -import org.apache.wicket.markup.resolver.ComponentResolvers; import org.apache.wicket.markup.resolver.IComponentResolver; -import org.apache.wicket.request.Request; -import org.apache.wicket.request.cycle.RequestCycle; -import org.apache.wicket.request.http.WebRequest; /** * A simple "transparent" markup container. @@ -66,92 +60,4 @@ public Component resolve(MarkupContainer container, MarkupStream markupStream, C } return resolvedComponent; } - - @Override - public void renderHead(HtmlHeaderContainer container) - { - /* - * https://issues.apache.org/jira/browse/WICKET-5941 - * - * if this component is updated via AJAX and is the root - * one, then render head also for embedded components. - */ - if(isAjaxRequest() && !isParentRendering()) - { - renderHeadForInnerSiblings(container); - } - - super.renderHead(container); - } - - /** - * Says if parent container is rendering or not. - * - * @return true if parent is rendering, false otherwise. - */ - private boolean isParentRendering() - { - MarkupContainer parent = getParent(); - - return parent != null && parent.isRendering(); - } - - /** - * Says if the current request is an AJAX one. - * - * @return true if the current request is an AJAX one, false otherwise. - */ - private boolean isAjaxRequest() - { - Request request = RequestCycle.get().getRequest(); - - if (request instanceof WebRequest) - { - WebRequest webRequest = (WebRequest)request; - return webRequest.isAjax(); - } - - return false; - } - - /** - * Renders head for embedded component, i.e. those who are not added - * directly to this container but have the markup inside it. - * - * @param container - * The HtmlHeaderContainer - */ - private void renderHeadForInnerSiblings(HtmlHeaderContainer container) - { - MarkupStream stream = new MarkupStream(getMarkup()); - - while (stream.hasMore()) - { - MarkupElement childOpenTag = stream.nextOpenTag(); - - if ((childOpenTag instanceof ComponentTag) && !stream.atCloseTag()) - { - // Get element as tag - final ComponentTag tag = (ComponentTag)childOpenTag; - - // Get component id - final String id = tag.getId(); - - Component component = null; - - if (get(id) == null) - { - component = ComponentResolvers.resolveByComponentHierarchy(this, stream, tag); - } - - if (component != null) - { - component.renderHead(container); - } - - //consider just direct children - stream.skipToMatchingCloseTag(tag); - } - } - } } \ No newline at end of file diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/WebPage.java b/wicket-core/src/main/java/org/apache/wicket/markup/html/WebPage.java index 065a9c5fbd6..743e327e3ef 100644 --- a/wicket-core/src/main/java/org/apache/wicket/markup/html/WebPage.java +++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/WebPage.java @@ -19,16 +19,17 @@ import org.apache.wicket.Component; import org.apache.wicket.Page; import org.apache.wicket.markup.MarkupType; -import org.apache.wicket.markup.head.IHeaderResponse; import org.apache.wicket.markup.html.internal.HtmlHeaderContainer; import org.apache.wicket.markup.html.link.BookmarkablePageLink; import org.apache.wicket.markup.parser.filter.HtmlHeaderSectionHandler; import org.apache.wicket.markup.renderStrategy.AbstractHeaderRenderStrategy; import org.apache.wicket.model.IModel; import org.apache.wicket.protocol.http.WebApplication; +import org.apache.wicket.request.IRequestHandler; import org.apache.wicket.request.Request; import org.apache.wicket.request.Response; import org.apache.wicket.request.cycle.RequestCycle; +import org.apache.wicket.core.request.handler.IPageRequestHandler; import org.apache.wicket.request.http.WebRequest; import org.apache.wicket.request.http.WebResponse; import org.apache.wicket.request.mapper.parameter.PageParameters; @@ -211,17 +212,23 @@ protected void setHeaders(WebResponse response) @Override protected void onAfterRender() { + super.onAfterRender(); + // only in development mode validate the headers if (getApplication().usesDevelopmentConfig()) { - // check headers only when page was completely rendered - if (wasRendered(this)) + // Ignore if an exception and a redirect happened in between (e.g. + // RestartResponseAtInterceptPageException) + IRequestHandler activeHandler = getRequestCycle().getActiveRequestHandler(); + if (activeHandler instanceof IPageRequestHandler) { - validateHeaders(); + IPageRequestHandler h = (IPageRequestHandler)activeHandler; + if (h.getPage() == this) + { + validateHeaders(); + } } } - - super.onAfterRender(); } /** @@ -257,22 +264,24 @@ else if (component instanceof TransparentWebMarkupContainer == false) header = new HtmlHeaderContainer(HtmlHeaderSectionHandler.HEADER_ID); add(header); - RequestCycle requestCycle = getRequestCycle(); - Response orgResponse = requestCycle.getResponse(); + Response orgResponse = getRequestCycle().getResponse(); try { - StringResponse tempResponse = new StringResponse(); - requestCycle.setResponse(tempResponse); + final StringResponse response = new StringResponse(); + getRequestCycle().setResponse(response); // Render all header sections of all components on the page AbstractHeaderRenderStrategy.get().renderHeader(header, null, getPage()); + response.close(); - IHeaderResponse headerResponse = header.getHeaderResponse(); - headerResponse.close(); - CharSequence collectedHeaderOutput = tempResponse.getBuffer(); - if (collectedHeaderOutput.length() > 0) + if (response.getBuffer().length() > 0) { - reportMissingHead(collectedHeaderOutput); + // @TODO it is not yet working properly. JDo to fix it + log.error("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"); + log.error("You probably forgot to add a or tag to your markup since no Header Container was \n" + + "found but components were found which want to write to the section.\n" + + response.getBuffer()); + log.error("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"); } } catch (Exception e) @@ -283,28 +292,11 @@ else if (component instanceof TransparentWebMarkupContainer == false) finally { this.remove(header); - requestCycle.setResponse(orgResponse); + getRequestCycle().setResponse(orgResponse); } } } - /** - * Reports an error that there is no <head> and/or <body> in the page and - * there is no where to write the header response. - * - * @param collectedHeaderOutput - * The collected response that should have been written to the <head> - * @see #validateHeaders() - */ - protected void reportMissingHead(final CharSequence collectedHeaderOutput) - { - log.error("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"); - log.error("You probably forgot to add a or tag to your markup since no Header Container was \n" + - "found but components were found which want to write to the section.\n" + - collectedHeaderOutput); - log.error("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"); - } - /** * Creates and returns a bookmarkable link to this application's home page. * diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/Form.java b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/Form.java index 4c5227be335..789a8047ccd 100644 --- a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/Form.java +++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/Form.java @@ -145,10 +145,8 @@ * @param * The model object type */ -public class Form extends WebMarkupContainer - implements - IFormSubmitListener, - IGenericComponent +public class Form extends WebMarkupContainer implements IFormSubmitListener, + IGenericComponent { private static final String HIDDEN_DIV_START = "
"; @@ -600,11 +598,9 @@ public void component(Form component, IVisit visit) /** * Gets maximum size for each file of an upload. - * * @return */ - public Bytes getFileMaxSize() - { + public Bytes getFileMaxSize() { return fileMaxSize; } @@ -893,17 +889,6 @@ public boolean wantSubmitOnNestedFormSubmit() return false; } - /** - * Whether this *nested* form wants to be submitted when parent form is submitted. By default, - * this is true, so when a parent form is submitted, the nested form is also submitted. If this - * method is overridden to return false, it will not be validated, processed nor submitted. - * - * @return {@code true} by default - */ - public boolean wantSubmitOnParentFormSubmit() - { - return true; - } /** * Process the form. Though you can override this method to provide your own algorithm, it is @@ -915,7 +900,8 @@ public boolean wantSubmitOnParentFormSubmit() * * @param submittingComponent * component responsible for submitting the form, or null if none (eg - * the form has been submitted via the enter key or javascript calling form.submit()) + * the form has been submitted via the enter key or javascript calling + * form.submit()) * * @see #delegateSubmit(IFormSubmitter) for an easy way to process submitting component in the * default manner @@ -1015,8 +1001,7 @@ private void markFormsSubmitted() public void component(final Component component, final IVisit visit) { Form form = (Form)component; - if (form.isEnabledInHierarchy() && form.isVisibleInHierarchy() && - form.wantSubmitOnParentFormSubmit()) + if (form.isEnabledInHierarchy() && isVisibleInHierarchy()) { form.setFlag(FLAG_SUBMITTED, true); return; @@ -1068,11 +1053,9 @@ public void setMaxSize(final Bytes maxSize) /** * Sets maximum size of each file in upload request. - * * @param fileMaxSize */ - public void setFileMaxSize(Bytes fileMaxSize) - { + public void setFileMaxSize(Bytes fileMaxSize) { this.fileMaxSize = fileMaxSize; } @@ -1158,8 +1141,7 @@ private boolean anyFormComponentError() @Override public void component(final Component component, final IVisit visit) { - if (component.isVisibleInHierarchy() && component.isEnabledInHierarchy() && - component.hasErrorMessage()) + if (component.hasErrorMessage()) { visit.stop(true); } @@ -1229,6 +1211,7 @@ public void component(final FormComponent formComponent, IVisit visit) protected void appendDefaultButtonField(final MarkupStream markupStream, final ComponentTag openTag) { + AppendingStringBuffer buffer = new AppendingStringBuffer(); // div that is not visible (but not display:none either) @@ -1291,7 +1274,7 @@ protected void delegateSubmit(IFormSubmitter submittingComponent) @Override public void component(Form form, IVisit visit) { - if (form.isSubmitted()) + if (form.isEnabledInHierarchy() && form.isVisibleInHierarchy()) { forms.add(form); } @@ -1420,8 +1403,7 @@ protected boolean handleMultiPart() try { ServletWebRequest request = (ServletWebRequest)getRequest(); - final MultipartServletWebRequest multipartWebRequest = request.newMultipartWebRequest( - getMaxSize(), getPage().getId()); + final MultipartServletWebRequest multipartWebRequest = request.newMultipartWebRequest(getMaxSize(), getPage().getId()); multipartWebRequest.setFileMaxSize(getFileMaxSize()); multipartWebRequest.parseFileParts(); @@ -1462,8 +1444,7 @@ protected void onFileUploadException(final FileUploadException e, { // Resource key should be .uploadTooLarge to // override default message - String msg = getString(getId() + '.' + UPLOAD_TOO_LARGE_RESOURCE_KEY, - Model.ofMap(model)); + String msg = getString(getId() + '.' + UPLOAD_TOO_LARGE_RESOURCE_KEY, Model.ofMap(model)); error(msg); } else if (e instanceof FileUploadBase.FileSizeLimitExceededException) @@ -1543,7 +1524,7 @@ private void markNestedFormComponentsValid() @Override public void component(final Form form, final IVisit visit) { - if (form.isSubmitted()) + if (form.isEnabledInHierarchy() && form.isVisibleInHierarchy()) { form.internalMarkFormComponentsValid(); } @@ -1838,9 +1819,10 @@ private final void updateNestedFormComponentModels() @Override public void component(final Form form, final IVisit visit) { - if (form.isSubmitted()) + if (form.isEnabledInHierarchy() && form.isVisibleInHierarchy()) { form.internalUpdateFormComponentModels(); + } else { @@ -1890,8 +1872,8 @@ protected void onValidate() } /** - * Calls {@linkplain #onValidateModelObjects()} on this form and all nested forms that are - * visible and enabled + * Calls {@linkplain #onValidateModelObjects()} on this form and all + * nested forms that are visible and enabled */ private void internalOnValidateModelObjects() { @@ -1899,11 +1881,11 @@ private void internalOnValidateModelObjects() visitChildren(Form.class, new IVisitor, Void>() { @Override - public void component(Form form, IVisit visit) + public void component(Form nestedForm, IVisit visit) { - if (form.isSubmitted()) + if (nestedForm.isEnabledInHierarchy() && nestedForm.isVisibleInHierarchy()) { - form.onValidateModelObjects(); + nestedForm.onValidateModelObjects(); } else { @@ -2045,7 +2027,7 @@ public void component(final Form form, final IVisit visit) return; } - if (form.isSubmitted()) + if (form.isEnabledInHierarchy() && form.isVisibleInHierarchy()) { form.validateComponents(); form.validateFormValidators(); @@ -2055,6 +2037,7 @@ public void component(final Form form, final IVisit visit) }, new ClassVisitFilter(Form.class)); } + /** * Allows to customize input names of form components inside this form. * @@ -2153,9 +2136,9 @@ public static String getRootFormRelativeId(Component component) /* * Certain input names causes problems with JavaScript. If the input name would cause a - * problem, we create a replacement unique name by prefixing the name with a path that would - * otherwise never be used (blank id in path). - * + * problem, we create a replacement unique name by prefixing the name with a path that + * would otherwise never be used (blank id in path). + * * Input names must start with [A-Za-z] according to HTML 4.01 spec. HTML 5 allows almost * anything. */ @@ -2175,7 +2158,8 @@ public static String getRootFormRelativeId(Component component) * * @author igor */ - public static enum MethodMismatchResponse { + public static enum MethodMismatchResponse + { /** * Continue processing. */ 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 eaadc276e9c..54f144a4352 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 @@ -216,21 +216,27 @@ private String substitute(String string, final Map vars) protected String getValue(String variableName) { Object value = vars.get(variableName); - - if (value == null ||value instanceof String) + if (value == null) { - return String.valueOf(value); + return null; } - - IConverter converter = getConverter(value.getClass()); - - if (converter == null) + else if (value instanceof String) { - return Strings.toString(value); + // small optimization - no need to bother with conversion + // for String vars, e.g. {label} + return (String)value; } else { - return converter.convertToString(value, getLocale()); + IConverter converter = getConverter(value.getClass()); + if (converter == null) + { + return Strings.toString(value); + } + else + { + return converter.convertToString(value, getLocale()); + } } } }.toString(); @@ -1502,11 +1508,6 @@ protected final void validateValidators() { for (Behavior behavior : getBehaviors()) { - if (isBehaviorAccepted(behavior) == false) - { - continue; - } - validator = null; if (behavior instanceof ValidatorAdapter) { @@ -1621,9 +1622,6 @@ public final void updateAutoLabels(AjaxRequestTarget target) public static void updateCollectionModel(FormComponent> formComponent) { Collection convertedInput = formComponent.getConvertedInput(); - if (convertedInput == null) { - convertedInput = Collections.emptyList(); - } Collection collection = formComponent.getModelObject(); if (collection == null) @@ -1640,7 +1638,10 @@ public static void updateCollectionModel(FormComponent> formCo try { collection.clear(); - collection.addAll(convertedInput); + if (convertedInput != null) + { + collection.addAll(convertedInput); + } modified = true; } catch (UnsupportedOperationException unmodifiable) @@ -1650,6 +1651,7 @@ public static void updateCollectionModel(FormComponent> formCo logger.debug("An error occurred while trying to modify the collection attached to " + formComponent, unmodifiable); } + collection = new ArrayList(convertedInput); } 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 61cb29da70c..8a3c8e50b49 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 @@ -142,18 +142,7 @@ public boolean isVisible() { return childComponent.determineVisibility() && super.isVisible(); } - - @Override - protected void onConfigure() - { - super.onConfigure(); - final Component child = getChild(); - - child.configure(); - boolean childVisible = child.determineVisibility(); - - setVisible(childVisible); - } + /** * Get the real parent container * diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/internal/HtmlHeaderContainer.java b/wicket-core/src/main/java/org/apache/wicket/markup/html/internal/HtmlHeaderContainer.java index c32131c4c72..17e9c5e2af0 100644 --- a/wicket-core/src/main/java/org/apache/wicket/markup/html/internal/HtmlHeaderContainer.java +++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/internal/HtmlHeaderContainer.java @@ -313,8 +313,9 @@ public boolean okToRenderComponent(final String scope, final String id) } @Override - protected void onAfterRender() { - super.onAfterRender(); + protected void onDetach() + { + super.onDetach(); renderedComponentsPerScope = null; headerResponse = null; diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/navigation/paging/PagingNavigationIncrementLink.java b/wicket-core/src/main/java/org/apache/wicket/markup/html/navigation/paging/PagingNavigationIncrementLink.java index 3a72dc8af75..78cf7be3657 100644 --- a/wicket-core/src/main/java/org/apache/wicket/markup/html/navigation/paging/PagingNavigationIncrementLink.java +++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/navigation/paging/PagingNavigationIncrementLink.java @@ -17,7 +17,6 @@ package org.apache.wicket.markup.html.navigation.paging; import org.apache.wicket.Page; -import org.apache.wicket.markup.ComponentTag; import org.apache.wicket.markup.html.link.Link; /** @@ -126,22 +125,4 @@ public boolean linksTo(final Page page) pageable.getCurrentPage(); return ((increment < 0) && isFirst()) || ((increment > 0) && isLast()); } - - @Override - protected void onComponentTag(ComponentTag tag) - { - super.onComponentTag(tag); - - if (!isEnabledInHierarchy()) - { - // if the tag is an anchor proper - String tagName = tag.getName(); - - if (!(tagName.equalsIgnoreCase("a") || tagName.equalsIgnoreCase("link") || - tagName.equalsIgnoreCase("area"))) - { - tag.remove("rel"); - } - } - } } \ No newline at end of file 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 27407cf7738..e60eaa3f352 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 @@ -67,13 +67,6 @@ protected IMarkupFragment searchMarkupInTransparentResolvers(final MarkupContain @Override public void component(MarkupContainer resolvingContainer, IVisit visit) { - //prevents possible searching loops - if (child == resolvingContainer) - { - visit.dontGoDeeper(); - return; - } - if (resolvingContainer instanceof IComponentResolver) { visit.dontGoDeeper(); @@ -99,7 +92,7 @@ public void component(MarkupContainer resolvingContainer, IVisit iterator = touchedPages.iterator(); - while (iterator.hasNext()) - { - IManageablePage touchedPage = iterator.next(); - if (touchedPage.getPageId() == page.getPageId()) - { - iterator.remove(); - break; - } - } - } - /** * */ 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 2310635206d..852eac25616 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 @@ -367,15 +367,6 @@ protected void invoke(WebResponse response) } } - private static class DisableCachingAction extends MetaDataAction - { - @Override - protected void invoke(WebResponse response) - { - response.disableCaching();; - } - } - private static class SendErrorAction extends Action { private final int sc; @@ -474,11 +465,6 @@ public void addHeader(String name, String value) actions.add(new AddHeaderAction(name, value)); } - @Override - public void disableCaching() { - actions.add(new DisableCachingAction()); - } - @Override public void write(CharSequence sequence) { diff --git a/wicket-core/src/main/java/org/apache/wicket/protocol/http/HeaderBufferingWebResponse.java b/wicket-core/src/main/java/org/apache/wicket/protocol/http/HeaderBufferingWebResponse.java index ac116d92a23..8771dcaf5b9 100644 --- a/wicket-core/src/main/java/org/apache/wicket/protocol/http/HeaderBufferingWebResponse.java +++ b/wicket-core/src/main/java/org/apache/wicket/protocol/http/HeaderBufferingWebResponse.java @@ -154,11 +154,6 @@ public void setStatus(int sc) getMetaResponse().setStatus(sc); } - @Override - public void disableCaching() { - getMetaResponse().disableCaching(); - } - @Override public String encodeURL(CharSequence url) { 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 b47b841429f..1c87f0e5634 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 @@ -256,11 +256,7 @@ protected boolean processRequestCycle(RequestCycle requestCycle, WebResponse web // Assume we are able to handle the request boolean res = true; - if (requestCycle.processRequestAndDetach()) - { - webResponse.flush(); - } - else + if (!requestCycle.processRequestAndDetach()) { if (chain != null) { @@ -268,6 +264,10 @@ protected boolean processRequestCycle(RequestCycle requestCycle, WebResponse web } res = false; } + else + { + webResponse.flush(); + } return res; } @@ -385,10 +385,7 @@ public void init(final boolean isServlet, final FilterConfig filterConfig) application = applicationFactory.createApplication(this); } - if (application.getName() == null) - { - application.setName(filterConfig.getFilterName()); - } + application.setName(filterConfig.getFilterName()); application.setWicketFilter(this); // Allow the filterPath to be preset via setFilterPath() diff --git a/wicket-core/src/main/java/org/apache/wicket/request/resource/AbstractResource.java b/wicket-core/src/main/java/org/apache/wicket/request/resource/AbstractResource.java index dadb978e062..3ec5a7f436d 100644 --- a/wicket-core/src/main/java/org/apache/wicket/request/resource/AbstractResource.java +++ b/wicket-core/src/main/java/org/apache/wicket/request/resource/AbstractResource.java @@ -656,6 +656,9 @@ else if (ContentDisposition.INLINE == disposition) webResponse.addHeader(name, value); } } + + // 6. Flush the response + flushResponseAfterHeaders(webResponse); } } @@ -696,9 +699,7 @@ public abstract static class WriteCallback * request attributes * @param stream * input stream - * @deprecated Not used since 6.20.0. Removed in 7.0.0 */ - @Deprecated protected final void writeStream(Attributes attributes, InputStream stream) throws IOException { final Response response = attributes.getResponse(); diff --git a/wicket-core/src/main/java/org/apache/wicket/request/resource/CssPackageResource.java b/wicket-core/src/main/java/org/apache/wicket/request/resource/CssPackageResource.java index df4a12da6d5..f6cf010e1bd 100644 --- a/wicket-core/src/main/java/org/apache/wicket/request/resource/CssPackageResource.java +++ b/wicket-core/src/main/java/org/apache/wicket/request/resource/CssPackageResource.java @@ -20,7 +20,6 @@ import org.apache.wicket.Application; import org.apache.wicket.css.ICssCompressor; -import org.apache.wicket.resource.IScopeAwareTextResourceProcessor; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -33,8 +32,6 @@ public class CssPackageResource extends PackageResource private static final Logger log = LoggerFactory.getLogger(CssPackageResource.class); - private final String name; - /** * Construct. * @@ -49,8 +46,6 @@ public CssPackageResource(Class scope, String name, Locale locale, String sty { super(scope, name, locale, style, variation); - this.name = name; - // CSS resources can be compressed if there is configured ICssCompressor setCompress(true); } @@ -66,19 +61,8 @@ protected byte[] processResponse(final Attributes attributes, final byte[] bytes { try { - String charsetName = "UTF-8"; - String nonCompressed = new String(processedResponse, charsetName); - String output; - if (compressor instanceof IScopeAwareTextResourceProcessor) - { - IScopeAwareTextResourceProcessor scopeAwareProcessor = (IScopeAwareTextResourceProcessor)compressor; - output = scopeAwareProcessor.process(nonCompressed, getScope(), name); - } - else - { - output = compressor.compress(nonCompressed); - } - return output.getBytes(charsetName); + String nonCompressed = new String(processedResponse, "UTF-8"); + return compressor.compress(nonCompressed).getBytes(); } catch (Exception e) { diff --git a/wicket-core/src/main/java/org/apache/wicket/request/resource/JavaScriptPackageResource.java b/wicket-core/src/main/java/org/apache/wicket/request/resource/JavaScriptPackageResource.java index b2577ab2594..210fee14633 100644 --- a/wicket-core/src/main/java/org/apache/wicket/request/resource/JavaScriptPackageResource.java +++ b/wicket-core/src/main/java/org/apache/wicket/request/resource/JavaScriptPackageResource.java @@ -20,12 +20,11 @@ import org.apache.wicket.Application; import org.apache.wicket.javascript.IJavaScriptCompressor; -import org.apache.wicket.resource.IScopeAwareTextResourceProcessor; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * Package resource for javascript files. + * Package resource for javascript files. It strips comments and whitespace from javascript. */ public class JavaScriptPackageResource extends PackageResource { @@ -33,18 +32,20 @@ public class JavaScriptPackageResource extends PackageResource private static final Logger log = LoggerFactory.getLogger(JavaScriptPackageResource.class); - private final String name; - /** * Construct. + * + * @param scope + * @param name + * @param locale + * @param style + * @param variation */ public JavaScriptPackageResource(Class scope, String name, Locale locale, String style, String variation) { super(scope, name, locale, style, variation); - this.name = name; - // JS resources can be compressed if there is configured IJavaScriptCompressor setCompress(true); } @@ -60,19 +61,8 @@ protected byte[] processResponse(final Attributes attributes, byte[] bytes) { try { - String charsetName = "UTF-8"; - String nonCompressed = new String(processedResponse, charsetName); - String output; - if (compressor instanceof IScopeAwareTextResourceProcessor) - { - IScopeAwareTextResourceProcessor scopeAwareProcessor = (IScopeAwareTextResourceProcessor)compressor; - output = scopeAwareProcessor.process(nonCompressed, getScope(), name); - } - else - { - output = compressor.compress(nonCompressed); - } - return output.getBytes(charsetName); + String nonCompressed = new String(processedResponse, "UTF-8"); + return compressor.compress(nonCompressed).getBytes("UTF-8"); } catch (Exception e) { diff --git a/wicket-core/src/main/java/org/apache/wicket/resource/DynamicJQueryResourceReference.java b/wicket-core/src/main/java/org/apache/wicket/resource/DynamicJQueryResourceReference.java index 90b8eb9b8fb..c626b179747 100644 --- a/wicket-core/src/main/java/org/apache/wicket/resource/DynamicJQueryResourceReference.java +++ b/wicket-core/src/main/java/org/apache/wicket/resource/DynamicJQueryResourceReference.java @@ -50,7 +50,7 @@ public class DynamicJQueryResourceReference extends JQueryResourceReference /** * jQuery ver. 2.x - works only on modern browsers */ - public static final String VERSION_2 = "jquery/jquery-2.1.4.js"; + public static final String VERSION_2 = "jquery/jquery-2.1.3.js"; public DynamicJQueryResourceReference() { diff --git a/wicket-core/src/main/java/org/apache/wicket/resource/JQueryResourceReference.java b/wicket-core/src/main/java/org/apache/wicket/resource/JQueryResourceReference.java index deb2885c1b0..0cdf012f170 100644 --- a/wicket-core/src/main/java/org/apache/wicket/resource/JQueryResourceReference.java +++ b/wicket-core/src/main/java/org/apache/wicket/resource/JQueryResourceReference.java @@ -34,7 +34,7 @@ public class JQueryResourceReference extends JavaScriptResourceReference /** * jQuery ver. 1.x - works on modern browsers and IE 6/7/8 */ - public static final String VERSION_1 = "jquery/jquery-1.11.3.js"; + public static final String VERSION_1 = "jquery/jquery-1.11.2.js"; private static final JQueryResourceReference INSTANCE = new JQueryResourceReference(); diff --git a/wicket-core/src/main/java/org/apache/wicket/util/cookies/CookieUtils.java b/wicket-core/src/main/java/org/apache/wicket/util/cookies/CookieUtils.java index c4a9fcd4f5d..1859d963793 100644 --- a/wicket-core/src/main/java/org/apache/wicket/util/cookies/CookieUtils.java +++ b/wicket-core/src/main/java/org/apache/wicket/util/cookies/CookieUtils.java @@ -20,7 +20,6 @@ import org.apache.wicket.markup.html.form.FormComponent; import org.apache.wicket.protocol.http.servlet.ServletWebRequest; -import org.apache.wicket.request.Response; import org.apache.wicket.request.cycle.RequestCycle; import org.apache.wicket.request.http.WebRequest; import org.apache.wicket.request.http.WebResponse; @@ -360,13 +359,7 @@ private WebRequest getWebRequest() */ private WebResponse getWebResponse() { - RequestCycle cycle = RequestCycle.get(); - Response response = cycle.getResponse(); - if (!(response instanceof WebResponse)) - { - response = cycle.getOriginalResponse(); - } - return (WebResponse)response; + return (WebResponse)RequestCycle.get().getResponse(); } /** diff --git a/wicket-core/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java b/wicket-core/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java index 2661c87b24d..4661607a954 100644 --- a/wicket-core/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java +++ b/wicket-core/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java @@ -59,7 +59,6 @@ import org.apache.wicket.ajax.form.AjaxFormSubmitBehavior; import org.apache.wicket.ajax.markup.html.AjaxFallbackLink; import org.apache.wicket.ajax.markup.html.AjaxLink; -import org.apache.wicket.ajax.markup.html.IAjaxLink; import org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink; import org.apache.wicket.behavior.AbstractAjaxBehavior; import org.apache.wicket.core.request.handler.BookmarkablePageRequestHandler; @@ -84,7 +83,6 @@ import org.apache.wicket.markup.html.form.SubmitLink; import org.apache.wicket.markup.html.link.AbstractLink; import org.apache.wicket.markup.html.link.BookmarkablePageLink; -import org.apache.wicket.markup.html.link.ExternalLink; import org.apache.wicket.markup.html.link.ILinkListener; import org.apache.wicket.markup.html.link.Link; import org.apache.wicket.markup.html.link.ResourceLink; @@ -123,7 +121,6 @@ import org.apache.wicket.request.resource.IResource; import org.apache.wicket.request.resource.ResourceReference; import org.apache.wicket.session.ISessionStore.UnboundListener; -import org.apache.wicket.settings.IApplicationSettings; import org.apache.wicket.settings.IRequestCycleSettings.RenderStrategy; import org.apache.wicket.util.lang.Args; import org.apache.wicket.util.lang.Classes; @@ -259,58 +256,20 @@ public BaseWicketTester(final WebApplication application, String servletContextB */ public BaseWicketTester(final WebApplication application, final ServletContext servletCtx) { - this(application, servletCtx, true); - } - - /** - * Creates a WicketTester. - * - * @param application - * a WicketTester WebApplication object - * @param init - * force the application to be initialized (default = true) - */ - public BaseWicketTester(final WebApplication application, boolean init) - { - this(application, null, init); - } - - /** - * Creates a WicketTester. - * - * @param application - * a WicketTester WebApplication object - * @param servletCtx - * the servlet context used as backend - * @param init - * force the application to be initialized (default = true) - */ - public BaseWicketTester(final WebApplication application, final ServletContext servletCtx, boolean init) - { - if (!init) - { - Args.notNull(application, "application"); - } - servletContext = servletCtx != null ? servletCtx - // If it's provided from the container it's not necessary to mock. - : !init && application.getServletContext() != null ? application.getServletContext() - : new MockServletContext(application, null); + : new MockServletContext(application, null); - // If using Arquillian and it's configured in a web.xml it'll be provided. If not, mock it. - if(application.getWicketFilter() == null) + final FilterConfig filterConfig = new TestFilterConfig(); + WicketFilter filter = new WicketFilter() { - final FilterConfig filterConfig = new TestFilterConfig(); - WicketFilter filter = new WicketFilter() + @Override + public FilterConfig getFilterConfig() { - @Override - public FilterConfig getFilterConfig() - { - return filterConfig; - } - }; - application.setWicketFilter(filter); - } + return filterConfig; + } + }; + + application.setWicketFilter(filter); httpSession = new MockHttpSession(servletContext); @@ -318,22 +277,15 @@ public FilterConfig getFilterConfig() this.application = application; - // If it's provided from the container it's not necessary to set again. - if (init) - { - // FIXME some tests are leaking applications by not calling destroy on them or overriding - // teardown() without calling super, for now we work around by making each name unique - application.setName("WicketTesterApplication-" + UUID.randomUUID()); - } + // FIXME some tests are leaking applications by not calling destroy on them or overriding + // teardown() without calling super, for now we work around by making each name unique + application.setName("WicketTesterApplication-" + UUID.randomUUID()); ThreadContext.setApplication(application); - // If it's provided from the container it's not necessary to set again and init. - if (init) - { - application.setServletContext(servletContext); - // initialize the application - application.initApplication(); - } + application.setServletContext(servletContext); + + // initialize the application + application.initApplication(); // We don't expect any changes during testing. In addition we avoid creating // ModificationWatcher threads tests. @@ -502,14 +454,13 @@ public void clearFeedbackMessages() * @param filter * filter used to cleanup messages, accepted messages will be removed */ - protected void cleanupFeedbackMessages(IFeedbackMessageFilter filter) + private void cleanupFeedbackMessages(IFeedbackMessageFilter filter) { - IApplicationSettings applicationSettings = application.getApplicationSettings(); - IFeedbackMessageFilter old = applicationSettings.getFeedbackMessageCleanupFilter(); - applicationSettings.setFeedbackMessageCleanupFilter(filter); + application.getApplicationSettings().setFeedbackMessageCleanupFilter(filter); getLastRenderedPage().detach(); getSession().detach(); - applicationSettings.setFeedbackMessageCleanupFilter(old); + application.getApplicationSettings().setFeedbackMessageCleanupFilter( + IFeedbackMessageFilter.NONE); } /** @@ -1927,16 +1878,6 @@ else if (linkComponent instanceof AjaxSubmitLink) submitAjaxFormSubmitBehavior(link, (AjaxFormSubmitBehavior)WicketTesterHelper.findAjaxEventBehavior(link, "onclick")); } - // if the link is an IAjaxLink, use it (do check if AJAX is expected) - else if (linkComponent instanceof IAjaxLink && isAjax) - { - List behaviors = WicketTesterHelper.findAjaxEventBehaviors( - linkComponent, "click"); - for (AjaxEventBehavior behavior : behaviors) - { - executeBehavior(behavior); - } - } /* * If the link is a submitlink then we pretend to have clicked it */ @@ -1950,21 +1891,6 @@ else if (linkComponent instanceof SubmitLink) serializeFormToRequest(submitLink.getForm()); submitForm(submitLink.getForm().getPageRelativePath()); } - else if (linkComponent instanceof ExternalLink) - { - ExternalLink externalLink = (ExternalLink) linkComponent; - String href = externalLink.getDefaultModelObjectAsString(); - try - { - getResponse().sendRedirect(href); - recordRequestResponse(); - setupNextRequestCycle(); - } - catch (IOException iox) - { - throw new WicketRuntimeException("An error occurred while redirecting to: " + href, iox); - } - } // if the link is a normal link (or ResourceLink) else if (linkComponent instanceof AbstractLink) { diff --git a/wicket-core/src/main/java/org/apache/wicket/util/tester/TagTester.java b/wicket-core/src/main/java/org/apache/wicket/util/tester/TagTester.java index abd10ae9a92..827aabbfa1f 100644 --- a/wicket-core/src/main/java/org/apache/wicket/util/tester/TagTester.java +++ b/wicket-core/src/main/java/org/apache/wicket/util/tester/TagTester.java @@ -540,10 +540,6 @@ else if (xmlTag.isOpenClose()) { tester = new TagTester(parser, openTag, closeTag); } - else if (openTag != null) - { - tester = new TagTester(parser, openTag, openTag); - } } catch (Exception e) { diff --git a/wicket-core/src/main/java/org/apache/wicket/util/tester/WicketTester.java b/wicket-core/src/main/java/org/apache/wicket/util/tester/WicketTester.java index bc61eea179a..b6ebcf6506d 100644 --- a/wicket-core/src/main/java/org/apache/wicket/util/tester/WicketTester.java +++ b/wicket-core/src/main/java/org/apache/wicket/util/tester/WicketTester.java @@ -227,34 +227,6 @@ public WicketTester(WebApplication application, ServletContext servletCtx) super(application, servletCtx); } - /** - * Creates a WicketTester to help unit testing. - * - * @param application - * a WicketTester WebApplication object - * @param init - * force the application to be initialized (default = true) - */ - public WicketTester(WebApplication application, boolean init) - { - super(application, init); - } - - /** - * Creates a WicketTester to help unit testing. - * - * @param application - * a WicketTester WebApplication object - * @param servletCtx - * the servlet context used as backend - * @param init - * force the application to be initialized (default = true) - */ - public WicketTester(WebApplication application, ServletContext servletCtx, boolean init) - { - super(application, servletCtx, init); - } - /** * Asserts that the Ajax location header is present. */ diff --git a/wicket-core/src/main/java/org/apache/wicket/validation/validator/CreditCardValidator.java b/wicket-core/src/main/java/org/apache/wicket/validation/validator/CreditCardValidator.java index fac28ad7094..97e66f24f31 100644 --- a/wicket-core/src/main/java/org/apache/wicket/validation/validator/CreditCardValidator.java +++ b/wicket-core/src/main/java/org/apache/wicket/validation/validator/CreditCardValidator.java @@ -321,7 +321,7 @@ private CreditCard isChinaUnionPay(String creditCardNumber) if ((creditCardNumber.length() >= 16 && creditCardNumber.length() <= 19) && (creditCardNumber.startsWith("622"))) { - int firstDigits = Integer.parseInt(creditCardNumber.substring(0, 6)); + int firstDigits = Integer.parseInt(creditCardNumber.substring(0, 5)); if (firstDigits >= 622126 && firstDigits <= 622925) { return CreditCard.CHINA_UNIONPAY;