001 /*
002 * Databinder: a simple bridge from Wicket to Hibernate
003 * Copyright (C) 2006 Nathan Hamblen nathan@technically.us
004 *
005 * This library is free software; you can redistribute it and/or
006 * modify it under the terms of the GNU Lesser General Public
007 * License as published by the Free Software Foundation; either
008 * version 2.1 of the License, or (at your option) any later version.
009 *
010 * This library is distributed in the hope that it will be useful,
011 * but WITHOUT ANY WARRANTY; without even the implied warranty of
012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
013 * Lesser General Public License for more details.
014 *
015 * You should have received a copy of the GNU Lesser General Public
016 * License along with this library; if not, write to the Free Software
017 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
018 */
019 package net.databinder.web;
020
021 import javax.servlet.http.HttpServletResponse;
022
023 import org.apache.wicket.Application;
024 import org.apache.wicket.protocol.http.BufferedWebResponse;
025 import org.apache.wicket.protocol.http.WebResponse;
026
027 /**
028 * Creates web response objects that do not rewrite URLs for cookieless support. Buffered or
029 * basic responses are created according to the application configuration. This factory is
030 * used by DataApplicationBase when cookieless support is off, but may also be used independently.
031 * @see net.databinder.DataApplicationBase
032 * @author Nathan Hamblen
033 */
034 public class NorewriteWebResponse {
035
036 public static WebResponse getNew(Application app, final HttpServletResponse servletResponse) {
037 return app.getRequestCycleSettings().getBufferResponse() ?
038 new Buffered(servletResponse) : new Unbuffered(servletResponse);
039 }
040
041 static class Buffered extends BufferedWebResponse {
042 public Buffered(final HttpServletResponse httpServletResponse)
043 {
044 super(httpServletResponse);
045 }
046 @Override
047 public CharSequence encodeURL(CharSequence url) {
048 return url;
049 }
050 }
051
052 static class Unbuffered extends WebResponse {
053 public Unbuffered(final HttpServletResponse httpServletResponse)
054 {
055 super(httpServletResponse);
056 }
057 @Override
058 public CharSequence encodeURL(CharSequence url) {
059 return url;
060 }
061 }
062 }