Author: dashorst Date: Sun Dec 2 13:19:25 2007 New Revision: 600375 URL: http://svn.apache.org/viewvc?rev=600375&view=rev Log: WICKET-1198
Added: wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/request/target/coding/IndexedHybridUrlCodingStrategyTest$TestPage.html (with props) wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/request/target/coding/IndexedHybridUrlCodingStrategyTest.java (with props) Modified: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/request/target/coding/HybridUrlCodingStrategy.java Modified: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/request/target/coding/HybridUrlCodingStrategy.java URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/request/target/coding/HybridUrlCodingStrategy.java?rev=600375&r1=600374&r2=600375&view=diff ============================================================================== --- wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/request/target/coding/HybridUrlCodingStrategy.java (original) +++ wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/request/target/coding/HybridUrlCodingStrategy.java Sun Dec 2 13:19:25 2007 @@ -152,8 +152,8 @@ Integer pageId = pageInfo != null ? pageInfo.getPageId() : null; // decode parameters - PageParameters parameters = new PageParameters(decodeParameters(extraction - .getUrlAfterExtraction(), requestParameters.getParameters())); + PageParameters parameters = new PageParameters(decodeParameters( + extraction.getUrlAfterExtraction(), requestParameters.getParameters())); if (requestParameters.getPageMapName() == null) { @@ -167,13 +167,11 @@ // do some extra work for checking whether this is a normal request to a // bookmarkable page, or a request to a stateless page (in which case a // wicket:interface parameter should be available - final String interfaceParameter = (String)parameters - .remove(WebRequestCodingStrategy.INTERFACE_PARAMETER_NAME); + final String interfaceParameter = (String)parameters.remove(WebRequestCodingStrategy.INTERFACE_PARAMETER_NAME); // we need to remember the amount of trailing slashes after the redirect // (otherwise we'll break relative urls) - int originalUrlTrailingSlashesCount = getTrailingSlashesCount(extraction - .getUrlAfterExtraction()); + int originalUrlTrailingSlashesCount = getTrailingSlashesCount(extraction.getUrlAfterExtraction()); boolean redirect = isRedirectOnBookmarkableRequest(); if (Strings.isEmpty(pageMapName) != true && alwaysRedirectWhenPageMapIsSpecified()) @@ -185,9 +183,9 @@ { // stateless listener interface WebRequestCodingStrategy.addInterfaceParameters(interfaceParameter, requestParameters); - return new BookmarkableListenerInterfaceRequestTarget(pageMapName, (Class)pageClassRef - .get(), parameters, requestParameters.getComponentPath(), requestParameters - .getInterfaceName(), requestParameters.getVersionNumber()); + return new BookmarkableListenerInterfaceRequestTarget(pageMapName, + (Class)pageClassRef.get(), parameters, requestParameters.getComponentPath(), + requestParameters.getInterfaceName(), requestParameters.getVersionNumber()); } else if (pageId == null) { @@ -223,8 +221,9 @@ { // we didn't find the page, act as bookmarkable page request - // create new instance - return new HybridBookmarkablePageRequestTarget(pageMapName, (Class)pageClassRef - .get(), parameters, originalUrlTrailingSlashesCount, redirect); + return new HybridBookmarkablePageRequestTarget(pageMapName, + (Class)pageClassRef.get(), parameters, originalUrlTrailingSlashesCount, + redirect); } } @@ -297,8 +296,8 @@ { ListenerInterfaceRequestTarget target = (ListenerInterfaceRequestTarget)requestTarget; Page page = target.getPage(); - return new PageInfo(new Integer(page.getNumericId()), new Integer(page - .getCurrentVersionNumber()), page.getPageMapName()); + return new PageInfo(new Integer(page.getNumericId()), new Integer( + page.getCurrentVersionNumber()), page.getPageMapName()); } else { @@ -406,7 +405,12 @@ final AppendingStringBuffer url = new AppendingStringBuffer(40); url.append(getMountPath()); - appendParameters(url, parameters); + + // there are cases where the parameters are null + if (parameters != null) + { + appendParameters(url, parameters); + } // check whether we know if the initial URL ended with slash Integer trailingSlashesCount = getOriginalOriginalTrailingSlashesCount(requestTarget); Added: wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/request/target/coding/IndexedHybridUrlCodingStrategyTest$TestPage.html URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/request/target/coding/IndexedHybridUrlCodingStrategyTest%24TestPage.html?rev=600375&view=auto ============================================================================== --- wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/request/target/coding/IndexedHybridUrlCodingStrategyTest$TestPage.html (added) +++ wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/request/target/coding/IndexedHybridUrlCodingStrategyTest$TestPage.html Sun Dec 2 13:19:25 2007 @@ -0,0 +1,6 @@ +<html> +<body> +<a href="#" wicket:id="ajax">ajax</a> +<a href="#" wicket:id="link">link</a> +</body> +</html> Propchange: wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/request/target/coding/IndexedHybridUrlCodingStrategyTest$TestPage.html ------------------------------------------------------------------------------ svn:eol-style = native Added: wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/request/target/coding/IndexedHybridUrlCodingStrategyTest.java URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/request/target/coding/IndexedHybridUrlCodingStrategyTest.java?rev=600375&view=auto ============================================================================== --- wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/request/target/coding/IndexedHybridUrlCodingStrategyTest.java (added) +++ wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/request/target/coding/IndexedHybridUrlCodingStrategyTest.java Sun Dec 2 13:19:25 2007 @@ -0,0 +1,87 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.wicket.request.target.coding; + +import junit.framework.TestCase; + +import org.apache.wicket.IRedirectListener; +import org.apache.wicket.IRequestTarget; +import org.apache.wicket.PageParameters; +import org.apache.wicket.ajax.AjaxRequestTarget; +import org.apache.wicket.ajax.markup.html.AjaxLink; +import org.apache.wicket.markup.html.WebPage; +import org.apache.wicket.markup.html.link.Link; +import org.apache.wicket.request.target.component.listener.ListenerInterfaceRequestTarget; +import org.apache.wicket.util.tester.WicketTester; + +/** + * + */ +public class IndexedHybridUrlCodingStrategyTest extends TestCase +{ + /** + * + */ + public static class TestPage extends WebPage + { + private static final long serialVersionUID = 1L; + + /** + * Construct. + * + * @param pars + */ + public TestPage(PageParameters pars) + { + add(new AjaxLink("ajax") + { + private static final long serialVersionUID = 1L; + + public void onClick(AjaxRequestTarget target) + { + getSession().bind(); + target.addComponent(this); + } + }.setOutputMarkupId(true)); + add(new Link("link") + { + private static final long serialVersionUID = 1L; + + public void onClick() + { + getSession().invalidate(); + } + }); + } + } + + /** + * Test for a NPE in a page mounted through a [EMAIL PROTECTED] IndexedHybridUrlCodingStrategy}. + */ + public void testJiraXXXX() + { + IRequestTargetUrlCodingStrategy strategy = new IndexedHybridUrlCodingStrategy("/foo", + TestPage.class); + + WicketTester tester = new WicketTester(); + tester.setupRequestAndResponse(); + TestPage page = new TestPage(null); + IRequestTarget requestTarget = new ListenerInterfaceRequestTarget(page, page, + IRedirectListener.INTERFACE); + strategy.encode(requestTarget); + } +} Propchange: wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/request/target/coding/IndexedHybridUrlCodingStrategyTest.java ------------------------------------------------------------------------------ svn:eol-style = native