Author: ate Date: Wed Sep 12 07:57:42 2007 New Revision: 574981 URL: http://svn.apache.org/viewvc?rev=574981&view=rev Log: WICKET-649: New Wicket Portlet support: fix appending query parameters - Fixing AbstractAjaxBehavior.getCallbackUrl(boolean onlyTargetActivePage) See: https://issues.apache.org/jira/browse/WICKET-649#action_12526813
Added: wicket/branches/wicket-1.3.0-beta3-portlet-support/jdk-1.4/wicket/src/main/java/org/apache/wicket/behavior/IActivePageBehaviorListener.java (with props) Modified: wicket/branches/wicket-1.3.0-beta3-portlet-support/jdk-1.4/wicket/src/main/java/org/apache/wicket/behavior/AbstractAjaxBehavior.java wicket/branches/wicket-1.3.0-beta3-portlet-support/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/request/WebRequestCodingStrategy.java Modified: wicket/branches/wicket-1.3.0-beta3-portlet-support/jdk-1.4/wicket/src/main/java/org/apache/wicket/behavior/AbstractAjaxBehavior.java URL: http://svn.apache.org/viewvc/wicket/branches/wicket-1.3.0-beta3-portlet-support/jdk-1.4/wicket/src/main/java/org/apache/wicket/behavior/AbstractAjaxBehavior.java?rev=574981&r1=574980&r2=574981&view=diff ============================================================================== --- wicket/branches/wicket-1.3.0-beta3-portlet-support/jdk-1.4/wicket/src/main/java/org/apache/wicket/behavior/AbstractAjaxBehavior.java (original) +++ wicket/branches/wicket-1.3.0-beta3-portlet-support/jdk-1.4/wicket/src/main/java/org/apache/wicket/behavior/AbstractAjaxBehavior.java Wed Sep 12 07:57:42 2007 @@ -22,8 +22,6 @@ import org.apache.wicket.markup.ComponentTag; import org.apache.wicket.markup.html.IHeaderContributor; import org.apache.wicket.markup.html.IHeaderResponse; -import org.apache.wicket.protocol.http.request.WebRequestCodingStrategy; -import org.apache.wicket.util.string.AppendingStringBuffer; /** * Abstract class for handling Ajax roundtrips. This class serves as a base for @@ -105,16 +103,16 @@ final RequestListenerInterface rli; - rli = IBehaviorListener.INTERFACE; - - AppendingStringBuffer url = new AppendingStringBuffer(getComponent().urlFor(this, rli)); - if (onlyTargetActivePage) { - url.append(url.indexOf("?") > -1 ? "&" : "?").append(WebRequestCodingStrategy.IGNORE_IF_NOT_ACTIVE_PARAMETER_NAME).append("=true"); + rli = IActivePageBehaviorListener.INTERFACE; } - - return url; + else + { + rli = IBehaviorListener.INTERFACE; + } + + return getComponent().urlFor(this, rli); } /** Added: wicket/branches/wicket-1.3.0-beta3-portlet-support/jdk-1.4/wicket/src/main/java/org/apache/wicket/behavior/IActivePageBehaviorListener.java URL: http://svn.apache.org/viewvc/wicket/branches/wicket-1.3.0-beta3-portlet-support/jdk-1.4/wicket/src/main/java/org/apache/wicket/behavior/IActivePageBehaviorListener.java?rev=574981&view=auto ============================================================================== --- wicket/branches/wicket-1.3.0-beta3-portlet-support/jdk-1.4/wicket/src/main/java/org/apache/wicket/behavior/IActivePageBehaviorListener.java (added) +++ wicket/branches/wicket-1.3.0-beta3-portlet-support/jdk-1.4/wicket/src/main/java/org/apache/wicket/behavior/IActivePageBehaviorListener.java Wed Sep 12 07:57:42 2007 @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.wicket.behavior; + +import org.apache.wicket.Component; +import org.apache.wicket.IRequestTarget; +import org.apache.wicket.Page; +import org.apache.wicket.RequestListenerInterface; +import org.apache.wicket.request.RequestParameters; +import org.apache.wicket.request.target.component.listener.BehaviorRequestTarget; + +/** + * An extended [EMAIL PROTECTED] IBehaviorListener} which will be ignored if the page is not the last one the user accessed. + * @see AbstractAjaxBehavior#getCallbackUrl(boolean) + * + * @author Ate Douma + */ +public interface IActivePageBehaviorListener extends IBehaviorListener +{ + public static final RequestListenerInterface INTERFACE = new RequestListenerInterface( + IActivePageBehaviorListener.class) + { + public IRequestTarget newRequestTarget(Page page, Component component, + RequestListenerInterface listener, RequestParameters requestParameters) + { + return new BehaviorRequestTarget(page, component, listener, requestParameters); + } + }; +} Propchange: wicket/branches/wicket-1.3.0-beta3-portlet-support/jdk-1.4/wicket/src/main/java/org/apache/wicket/behavior/IActivePageBehaviorListener.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: wicket/branches/wicket-1.3.0-beta3-portlet-support/jdk-1.4/wicket/src/main/java/org/apache/wicket/behavior/IActivePageBehaviorListener.java ------------------------------------------------------------------------------ svn:keywords = Id Propchange: wicket/branches/wicket-1.3.0-beta3-portlet-support/jdk-1.4/wicket/src/main/java/org/apache/wicket/behavior/IActivePageBehaviorListener.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Modified: wicket/branches/wicket-1.3.0-beta3-portlet-support/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/request/WebRequestCodingStrategy.java URL: http://svn.apache.org/viewvc/wicket/branches/wicket-1.3.0-beta3-portlet-support/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/request/WebRequestCodingStrategy.java?rev=574981&r1=574980&r2=574981&view=diff ============================================================================== --- wicket/branches/wicket-1.3.0-beta3-portlet-support/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/request/WebRequestCodingStrategy.java (original) +++ wicket/branches/wicket-1.3.0-beta3-portlet-support/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/request/WebRequestCodingStrategy.java Wed Sep 12 07:57:42 2007 @@ -39,6 +39,7 @@ import org.apache.wicket.RequestListenerInterface; import org.apache.wicket.Session; import org.apache.wicket.WicketRuntimeException; +import org.apache.wicket.behavior.IActivePageBehaviorListener; import org.apache.wicket.behavior.IBehaviorListener; import org.apache.wicket.protocol.http.UnitTestSettings; import org.apache.wicket.request.IRequestCodingStrategy; @@ -853,6 +854,10 @@ url.append(params.getUrlDepth()); } + if (IActivePageBehaviorListener.INTERFACE.getName().equals(listenerName)) + { + url.append(url.indexOf("?") > -1 ? "&" : "?").append(IGNORE_IF_NOT_ACTIVE_PARAMETER_NAME).append("=true"); + } return url; }