SourceForge.net Logo

de.mindmatters.faces.spring.context.servlet
Class RedirectView

java.lang.Object
  extended byde.mindmatters.faces.spring.context.servlet.RedirectView
All Implemented Interfaces:
View

public class RedirectView
extends java.lang.Object
implements View

View that redirects to an absolute, context relative, or current request relative URL, exposing all model attributes as HTTP query parameters.

A URL for this view is supposed to be a HTTP redirect URL, i.e. suitable for HttpServletResponse's sendRedirect method, which is what actually does the redirect if the HTTP 1.0 flag is on, or via sending back an HTTP 303 code - if the HTTP 1.0 compatibility flag is off.

Note that while the default value for the "contextRelative" flag is off, you will probably want to almost always set it to true. With the flag off, URLs starting with "/" are considered relative to the web server root, while with the flag on, they are considered relative to the web application root. Since most web apps will never know or care what their context path actually is, they are much better off setting this flag to true, and submitting paths which are to be considered relative to the web application root.

Note that in a Servlet 2.2 environment, i.e. a servlet container which is only compliant to the limits of this spec, this class will probably fail when feeding in URLs which are not fully absolute, or relative to the current request (no leading "/"), as these are the only two types of URL that sendRedirect supports in a Servlet 2.2 environment.

Note: javaDoc copied from RedirectView

Author:
Andreas Kuhrwahl

Constructor Summary
RedirectView(RedirectView redirectView)
          Constructor for use as a bean.
RedirectView(java.lang.String url)
          Creates a new RedirectView with the given URL.
RedirectView(java.lang.String url, boolean contextRelative)
          Creates a new RedirectView with the given URL.
RedirectView(java.lang.String url, boolean contextRelative, boolean http10Compatible)
          Creates a new RedirectView with the given URL.
 
Method Summary
 void render(java.util.Map model, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RedirectView

public RedirectView(RedirectView redirectView)
Constructor for use as a bean.

Parameters:
redirectView - the delegate

RedirectView

public RedirectView(java.lang.String url)
Creates a new RedirectView with the given URL.

The given URL will be considered as relative to the web server, not as relative to the current ServletContext.

Parameters:
url - the URL to redirect to
See Also:
RedirectView(String, boolean)

RedirectView

public RedirectView(java.lang.String url,
                    boolean contextRelative)
Creates a new RedirectView with the given URL.

Parameters:
url - the URL to redirect to
contextRelative - whether to interpret the given URL as relative to the current ServletContext

RedirectView

public RedirectView(java.lang.String url,
                    boolean contextRelative,
                    boolean http10Compatible)
Creates a new RedirectView with the given URL.

Parameters:
url - the URL to redirect to
contextRelative - whether to interpret the given URL as relative to the current ServletContext
http10Compatible - whether to stay compatible with HTTP 1.0 clients
Method Detail

render

public final void render(java.util.Map model,
                         javax.servlet.http.HttpServletRequest request,
                         javax.servlet.http.HttpServletResponse response)
                  throws java.lang.Exception

Specified by:
render in interface View
Throws:
java.lang.Exception

SourceForge.net Logo

Copyright © 2002 mindmatters GmbH & Co. KG