Author: jdonnerstag Date: Tue Feb 17 12:56:04 2009 New Revision: 745030 URL: http://svn.apache.org/viewvc?rev=745030&view=rev Log: fixed wicket-2061: interceptContinuationURL with umlauts not encoded
fixed MockHttpServletRequest as well, which didn't properly support it neither. Added: wicket/trunk/wicket/src/test/java/org/apache/wicket/redirect/encodingtest/ wicket/trunk/wicket/src/test/java/org/apache/wicket/redirect/encodingtest/A.html wicket/trunk/wicket/src/test/java/org/apache/wicket/redirect/encodingtest/A.java wicket/trunk/wicket/src/test/java/org/apache/wicket/redirect/encodingtest/B.html wicket/trunk/wicket/src/test/java/org/apache/wicket/redirect/encodingtest/B.java wicket/trunk/wicket/src/test/java/org/apache/wicket/redirect/encodingtest/HomePage.html wicket/trunk/wicket/src/test/java/org/apache/wicket/redirect/encodingtest/HomePage.java wicket/trunk/wicket/src/test/java/org/apache/wicket/redirect/encodingtest/RequestEncodingTest.java wicket/trunk/wicket/src/test/java/org/apache/wicket/redirect/encodingtest/WicketApplication.java Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/PageMap.java wicket/trunk/wicket/src/main/java/org/apache/wicket/protocol/http/MockHttpServletRequest.java wicket/trunk/wicket/src/main/java/org/apache/wicket/protocol/http/WicketURLDecoder.java wicket/trunk/wicket/src/main/java/org/apache/wicket/protocol/http/WicketURLEncoder.java Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/PageMap.java URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/PageMap.java?rev=745030&r1=745029&r2=745030&view=diff ============================================================================== --- wicket/trunk/wicket/src/main/java/org/apache/wicket/PageMap.java (original) +++ wicket/trunk/wicket/src/main/java/org/apache/wicket/PageMap.java Tue Feb 17 12:56:04 2009 @@ -22,9 +22,12 @@ import java.util.List; import org.apache.wicket.protocol.http.WebRequest; +import org.apache.wicket.protocol.http.WicketURLEncoder; import org.apache.wicket.request.target.basic.RedirectRequestTarget; import org.apache.wicket.session.pagemap.IPageMapEntry; import org.apache.wicket.util.lang.Objects; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * FIXME javadoc @@ -34,6 +37,9 @@ */ public abstract class PageMap implements IClusterable, IPageMap { + /** Log. */ + private static final Logger log = LoggerFactory.getLogger(PageMap.class); + /** * Visitor interface for visiting entries in this map * @@ -269,7 +275,10 @@ } else { + // wicket-2061: getURL() returns a properly <b>decoded</b> URL. But we need is a + // properly <b>encoded</b> URL. interceptContinuationURL = "/" + cycle.getRequest().getURL(); + interceptContinuationURL = WicketURLEncoder.FULL_PATH_INSTANCE.encode(interceptContinuationURL); } // Page map is dirty Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/protocol/http/MockHttpServletRequest.java URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/protocol/http/MockHttpServletRequest.java?rev=745030&r1=745029&r2=745030&view=diff ============================================================================== --- wicket/trunk/wicket/src/main/java/org/apache/wicket/protocol/http/MockHttpServletRequest.java (original) +++ wicket/trunk/wicket/src/main/java/org/apache/wicket/protocol/http/MockHttpServletRequest.java Tue Feb 17 12:56:04 2009 @@ -1117,7 +1117,7 @@ */ public void setPath(final String path) { - this.path = path; + this.path = WicketURLDecoder.PATH_INSTANCE.decode(path); } /** @@ -1145,11 +1145,11 @@ int index = url.indexOf("?"); if (index == -1) { - path = url; + setPath(url); } else { - path = url.substring(0, index); + setPath(url.substring(0, index)); String queryString = url.substring(index + 1); Map<String, String[]> params = new HashMap<String, String[]>(); @@ -1340,7 +1340,7 @@ // We need to absolutize the redirect URL as we are not as smart as a web-browser // (WICKET-702) url = redirect; - if (url.charAt(0) != '/') + if ((url.length() == 0) || (url.charAt(0) != '/')) { url = getContextPath() + getServletPath() + "/" + redirect; } Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/protocol/http/WicketURLDecoder.java URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/protocol/http/WicketURLDecoder.java?rev=745030&r1=745029&r2=745030&view=diff ============================================================================== --- wicket/trunk/wicket/src/main/java/org/apache/wicket/protocol/http/WicketURLDecoder.java (original) +++ wicket/trunk/wicket/src/main/java/org/apache/wicket/protocol/http/WicketURLDecoder.java Tue Feb 17 12:56:04 2009 @@ -25,9 +25,10 @@ /** * Adapted from java.net.URLDecoder, but defines instances for query string decoding versus URL path - * component decoding. <p/> The difference is important because a space is encoded as a + in a query - * string, but this is a valid value in a path component (and is therefore not decode back to a - * space). + * component decoding. + * <p/> + * The difference is important because a space is encoded as a + in a query string, but this is a + * valid value in a path component (and is therefore not decode back to a space). * * @author Doug Donohoe * @see java.net.URLDecoder @@ -40,14 +41,16 @@ private final boolean decodePlus; /** - * Encoder used to decode name or value components of a query string.<br/><br/> + * Encoder used to decode name or value components of a query string.<br/> + * <br/> * * For example: http://org.acme/notthis/northis/oreventhis?buthis=isokay&asis=thispart */ public static final WicketURLDecoder QUERY_INSTANCE = new WicketURLDecoder(true); /** - * Encoder used to decode components of a path.<br/><br/> + * Encoder used to decode components of a path.<br/> + * <br/> * * For example: http://org.acme/foo/thispart/orthispart?butnot=thispart */ @@ -56,8 +59,8 @@ /** * Create decoder * - * @param decodePlus - - * whether to decode + to space + * @param decodePlus + * - whether to decode + to space */ private WicketURLDecoder(boolean decodePlus) { @@ -98,6 +101,11 @@ */ public String decode(String s, String enc) { + if (s == null) + { + return null; + } + boolean needToChange = false; int numChars = s.length(); StringBuffer sb = new StringBuffer(numChars > 500 ? numChars / 2 : numChars); Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/protocol/http/WicketURLEncoder.java URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/protocol/http/WicketURLEncoder.java?rev=745030&r1=745029&r2=745030&view=diff ============================================================================== --- wicket/trunk/wicket/src/main/java/org/apache/wicket/protocol/http/WicketURLEncoder.java (original) +++ wicket/trunk/wicket/src/main/java/org/apache/wicket/protocol/http/WicketURLEncoder.java Tue Feb 17 12:56:04 2009 @@ -30,9 +30,10 @@ /** * Adapted from java.net.URLEncoder, but defines instances for query string encoding versus URL path - * component encoding. <p/> The difference is important because a space is encoded as a + in a query - * string, but this is a valid value in a path component (and is therefore not decode back to a - * space). + * component encoding. + * <p/> + * The difference is important because a space is encoded as a + in a query string, but this is a + * valid value in a path component (and is therefore not decode back to a space). * * @author Doug Donohoe * @see java.net.URLEncoder @@ -49,40 +50,63 @@ /** * query type */ - QUERY, /** + QUERY, + /** * path type */ - PATH; + PATH, + /** + * full path type + */ + FULL_PATH; } // list of what not to decode protected BitSet dontNeedEncoding; + // E.g. "?" for FULL_PATH encoding when querystring has already been encoded. + private final char stopChar; + // used in decoding protected static final int caseDiff = ('a' - 'A'); /** - * Encoder used to encode name or value components of a query string.<br/><br/> + * Encoder used to encode name or value components of a query string.<br/> + * <br/> * * For example: http://org.acme/notthis/northis/oreventhis?buthis=isokay&asis=thispart */ - public static final WicketURLEncoder QUERY_INSTANCE = new WicketURLEncoder(Type.QUERY); + public static final WicketURLEncoder QUERY_INSTANCE = new WicketURLEncoder(Type.QUERY, '\0'); /** - * Encoder used to encode components of a path.<br/><br/> + * Encoder used to encode components of a path.<br/> + * <br/> * * For example: http://org.acme/foo/thispart/orthispart?butnot=thispart */ - public static final WicketURLEncoder PATH_INSTANCE = new WicketURLEncoder(Type.PATH); + public static final WicketURLEncoder PATH_INSTANCE = new WicketURLEncoder(Type.PATH, '\0'); + + /** + * Encoder used to encode all path segments. Querystring will be excluded.<br/> + * <br/> + * + * For example: http://org.acme/foo/thispart/orthispart?butnot=thispart + */ + public static final WicketURLEncoder FULL_PATH_INSTANCE = new WicketURLEncoder(Type.FULL_PATH, + '?'); /** * Allow subclass to call constructor. * * @param type * encoder type + * @param stopChar + * stop encoding when stopChar found */ - protected WicketURLEncoder(Type type) + protected WicketURLEncoder(Type type, char stopChar) { + this.stopChar = stopChar; + /* * This note from java.net.URLEncoder ================================== * @@ -125,10 +149,10 @@ * sub-delims = "!" / "$" / "&" / "'" / "(" / ")" / "*" / "+" / "," / ";" / "=" // -- PATH * COMPONENT -- // * - * path = (see RFC for all variations) path-abempty = *( "/" segment ) segment = *pchar - * pchar = unreserved / pct-encoded / sub-delims / ":" / "@" // -- QUERY COMPONENT -- // + * path = (see RFC for all variations) path-abempty =( "/" segment ) segment =pchar pchar = + * unreserved / pct-encoded / sub-delims / ":" / "@" // -- QUERY COMPONENT -- // * - * query = *( pchar / "/" / "?" ) + * query =( pchar / "/" / "?" ) */ // unreserved @@ -174,9 +198,9 @@ // this code consistent with java.net.URLEncoder version case QUERY : dontNeedEncoding.set(' '); /* - * encoding a space to a + is done in the encode() - * method - */ + * encoding a space to a + is done in the encode() + * method + */ dontNeedEncoding.set('/'); // to allow direct passing of URL in query dontNeedEncoding.set('?'); // to allow direct passing of URL in query break; @@ -190,6 +214,18 @@ dontNeedEncoding.set('='); dontNeedEncoding.set('+'); break; + + // same as path, but '/' will not be encoded + case FULL_PATH : + // encode ' ' with a % instead of + in path portion + + // path component sub-delim values we do not need to escape + dontNeedEncoding.set('&'); + dontNeedEncoding.set('='); + dontNeedEncoding.set('+'); + + dontNeedEncoding.set('/'); + break; } } @@ -233,7 +269,9 @@ CharArrayWriter charArrayWriter = new CharArrayWriter(); if (enc == null) + { throw new NullPointerException("charsetName"); + } try { @@ -248,11 +286,18 @@ throw new WicketRuntimeException(new UnsupportedEncodingException(enc)); } + boolean stopEncoding = false; for (int i = 0; i < s.length();) { int c = s.charAt(i); + + if ((stopEncoding == false) && (c == stopChar)) + { + stopEncoding = true; + } + // System.out.println("Examining character: " + c); - if (dontNeedEncoding.get(c)) + if ((stopEncoding == true) || dontNeedEncoding.get(c)) { if (c == ' ') { Added: wicket/trunk/wicket/src/test/java/org/apache/wicket/redirect/encodingtest/A.html URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/redirect/encodingtest/A.html?rev=745030&view=auto ============================================================================== --- wicket/trunk/wicket/src/test/java/org/apache/wicket/redirect/encodingtest/A.html (added) +++ wicket/trunk/wicket/src/test/java/org/apache/wicket/redirect/encodingtest/A.html Tue Feb 17 12:56:04 2009 @@ -0,0 +1,15 @@ +<html> + <head> + <title>encodingtest</title> + </head> + <body> + <p> + The file is correct if sent as query parameter, as part of the path it is wrong: + </p> + + <h1 wicket:id="file">FILE</h1> + + <a href="/">Try again ...</a> + </body> +</html> + Added: wicket/trunk/wicket/src/test/java/org/apache/wicket/redirect/encodingtest/A.java URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/redirect/encodingtest/A.java?rev=745030&view=auto ============================================================================== --- wicket/trunk/wicket/src/test/java/org/apache/wicket/redirect/encodingtest/A.java (added) +++ wicket/trunk/wicket/src/test/java/org/apache/wicket/redirect/encodingtest/A.java Tue Feb 17 12:56:04 2009 @@ -0,0 +1,55 @@ +/* + * 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.redirect.encodingtest; + +import org.apache.wicket.PageParameters; +import org.apache.wicket.markup.html.WebPage; +import org.apache.wicket.markup.html.basic.Label; +import org.apache.wicket.protocol.http.WebApplication; + +/** + * Homepage + */ +public class A extends WebPage +{ + private static final long serialVersionUID = 1L; + + private final String file; + + /** + * Construct. + * + * @param parameters + */ + public A(final PageParameters parameters) + { + ((WicketApplication)WebApplication.get()).intercept(); + + file = parameters.getString("file"); + + add(new Label("file", file)); + } + + /** + * + * @return interceptContinuationURL + */ + public String getFileParameter() + { + return file; + } +} Added: wicket/trunk/wicket/src/test/java/org/apache/wicket/redirect/encodingtest/B.html URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/redirect/encodingtest/B.html?rev=745030&view=auto ============================================================================== --- wicket/trunk/wicket/src/test/java/org/apache/wicket/redirect/encodingtest/B.html (added) +++ wicket/trunk/wicket/src/test/java/org/apache/wicket/redirect/encodingtest/B.html Tue Feb 17 12:56:04 2009 @@ -0,0 +1,11 @@ +<html> + <head> + <title>encodingtest</title> + </head> + <body> + <p wicket:id="interceptContinuationURL">interceptContinuationURL</p> + + <a wicket:id="link">Continue to original destination</a> + </body> +</html> + Added: wicket/trunk/wicket/src/test/java/org/apache/wicket/redirect/encodingtest/B.java URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/redirect/encodingtest/B.java?rev=745030&view=auto ============================================================================== --- wicket/trunk/wicket/src/test/java/org/apache/wicket/redirect/encodingtest/B.java (added) +++ wicket/trunk/wicket/src/test/java/org/apache/wicket/redirect/encodingtest/B.java Tue Feb 17 12:56:04 2009 @@ -0,0 +1,59 @@ +/* + * 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.redirect.encodingtest; + +import org.apache.wicket.markup.html.WebPage; +import org.apache.wicket.markup.html.basic.Label; +import org.apache.wicket.markup.html.link.Link; +import org.apache.wicket.model.PropertyModel; + +/** + * Homepage + */ +public class B extends WebPage +{ + private static final long serialVersionUID = 1L; + + /** + * Construct. + */ + public B() + { + add(new Label("interceptContinuationURL", new PropertyModel<String>(getPageMap(), + "interceptContinuationURL"))); + + add(new Link<Void>("link") + { + private static final long serialVersionUID = 1L; + + @Override + public void onClick() + { + continueToOriginalDestination(); + } + }); + } + + /** + * + * @return interceptContinuationURL + */ + public String getInterceptContinuationURL() + { + return get("interceptContinuationURL").getDefaultModelObjectAsString(); + } +} Added: wicket/trunk/wicket/src/test/java/org/apache/wicket/redirect/encodingtest/HomePage.html URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/redirect/encodingtest/HomePage.html?rev=745030&view=auto ============================================================================== --- wicket/trunk/wicket/src/test/java/org/apache/wicket/redirect/encodingtest/HomePage.html (added) +++ wicket/trunk/wicket/src/test/java/org/apache/wicket/redirect/encodingtest/HomePage.html Tue Feb 17 12:56:04 2009 @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<html> + <head> + <title>encodingtest</title> + </head> + <body> + <ul> + <li> + <a href="/Aparameter?file=umlaut-%C3%A4-%C3%B6-%C3%BC">A with file "umlaut-ä-ö-ü" as query parameter</a> + </li> + <li> + <a href="/Apath/umlaut-%C3%A4-%C3%B6-%C3%BC">A with file "umlaut-ä-ö-ü" in path</a> + </li> + </ul> + </body> +</html> + Added: wicket/trunk/wicket/src/test/java/org/apache/wicket/redirect/encodingtest/HomePage.java URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/redirect/encodingtest/HomePage.java?rev=745030&view=auto ============================================================================== --- wicket/trunk/wicket/src/test/java/org/apache/wicket/redirect/encodingtest/HomePage.java (added) +++ wicket/trunk/wicket/src/test/java/org/apache/wicket/redirect/encodingtest/HomePage.java Tue Feb 17 12:56:04 2009 @@ -0,0 +1,38 @@ +/* + * 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.redirect.encodingtest; + +import org.apache.wicket.PageParameters; +import org.apache.wicket.markup.html.WebPage; + +/** + * Homepage + */ +public class HomePage extends WebPage +{ + + private static final long serialVersionUID = 1L; + + /** + * Construct. + * + * @param parameters + */ + public HomePage(final PageParameters parameters) + { + } +} Added: wicket/trunk/wicket/src/test/java/org/apache/wicket/redirect/encodingtest/RequestEncodingTest.java URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/redirect/encodingtest/RequestEncodingTest.java?rev=745030&view=auto ============================================================================== --- wicket/trunk/wicket/src/test/java/org/apache/wicket/redirect/encodingtest/RequestEncodingTest.java (added) +++ wicket/trunk/wicket/src/test/java/org/apache/wicket/redirect/encodingtest/RequestEncodingTest.java Tue Feb 17 12:56:04 2009 @@ -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.redirect.encodingtest; + +import org.apache.wicket.PageParameters; +import org.apache.wicket.WicketTestCase; +import org.apache.wicket.request.target.coding.MixedParamUrlCodingStrategy; +import org.apache.wicket.util.tester.WicketTester; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * + */ +public class RequestEncodingTest extends WicketTestCase +{ + /** Log. */ + private static final Logger log = LoggerFactory.getLogger(RequestEncodingTest.class); + + private WicketApplication application; + + /** + * @see org.apache.wicket.WicketTestCase#setUp() + */ + @Override + protected void setUp() throws Exception + { + application = new WicketApplication(); + tester = new WicketTester(application); + tester.startPage(HomePage.class); + tester.assertRenderedPage(HomePage.class); + // String document = tester.getServletResponse().getDocument(); + } + + /** + * + */ + public void testDefault() + { + tester.startPage(A.class, new PageParameters("file=umlaut-ä-ö-ü")); + tester.assertRenderedPage(B.class); + + String url2 = ((B)tester.getLastRenderedPage()).getInterceptContinuationURL(); + assertTrue(url2.contains("umlaut-%C3%A4-%C3%B6-%C3%BC")); + + tester.clickLink("link"); + tester.assertRenderedPage(A.class); + + String file = ((A)tester.getLastRenderedPage()).getFileParameter(); + assertEquals("umlaut-ä-ö-ü", file); + + String document = tester.getServletResponse().getDocument(); + assertTrue(document.contains("ä-ö-ü")); + } + + /** + * + */ + public void testUmlautsInQueryParameter() + { + application.mount(new MixedParamUrlCodingStrategy("Apath", A.class, new String[] { "file" })); + testDefault(); + } + + /** + * + */ + public void testUmlautsInRequestUri() + { + application.mountBookmarkablePage("Aparameter", A.class); + testDefault(); + } +} Added: wicket/trunk/wicket/src/test/java/org/apache/wicket/redirect/encodingtest/WicketApplication.java URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/redirect/encodingtest/WicketApplication.java?rev=745030&view=auto ============================================================================== --- wicket/trunk/wicket/src/test/java/org/apache/wicket/redirect/encodingtest/WicketApplication.java (added) +++ wicket/trunk/wicket/src/test/java/org/apache/wicket/redirect/encodingtest/WicketApplication.java Tue Feb 17 12:56:04 2009 @@ -0,0 +1,60 @@ +/* + * 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.redirect.encodingtest; + +import org.apache.wicket.Page; +import org.apache.wicket.RestartResponseAtInterceptPageException; +import org.apache.wicket.protocol.http.WebApplication; + +/** + * Application object for your web application. If you want to run this application without + * deploying, run the Start class. + * + * @see wicket.myproject.Start#main(String[]) + */ +public class WicketApplication extends WebApplication +{ + private boolean showIntercept = false; + + /** + * Constructor + */ + public WicketApplication() + { + } + + /** + * @see wicket.Application#getHomePage() + */ + @Override + public Class<? extends Page> getHomePage() + { + return HomePage.class; + } + + /** + * + */ + public void intercept() + { + showIntercept = !showIntercept; + if (showIntercept) + { + throw new RestartResponseAtInterceptPageException(B.class); + } + } +}