org.mentawai.core
Class Redirect

java.lang.Object
  extended by org.mentawai.core.Redirect
All Implemented Interfaces:
Consequence

public class Redirect
extends Object
implements Consequence

A redirect consequence that has the following features:

  1. Paths starting with "//" are relative to the webserver root.
  2. Paths containing "://" are absolute paths.
  3. All other paths (starting with "/" or not) are related to the context path.
  4. Supports dynamic URLs and dynamic parameters, with the dynamic values will come from action output.
  5. Dynamic parameters will be encoded. Static parameters (hardcoded in the URL) are assumed to be encoded.

Author:
Sergio Oliveira Jr., Alan Burlison Alan.Burlison@sun.com

Field Summary
static String REDIRURL_PARAM
          The parameter's name in the output containing the URL to redirect to.
 
Constructor Summary
Redirect()
          Creates a redirect with a dynamic url.
Redirect(ActionConfig ac)
           
Redirect(ActionConfig ac, boolean appendOutput)
           
Redirect(boolean appendOutput)
          Creates a redirect with a dynamic URL and dynamic parameters.
Redirect(String url)
          Creates a normal redirect for the given url.
Redirect(String url, boolean appendOutput)
          Creates a redirect for the given url with dynamic parameters.
 
Method Summary
 void execute(Action act, String result, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
          Execute the redirect consequence.
 String toString()
          Return a string representation of the redirect.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

REDIRURL_PARAM

public static final String REDIRURL_PARAM
The parameter's name in the output containing the URL to redirect to.

See Also:
Constant Field Values
Constructor Detail

Redirect

public Redirect(String url)
Creates a normal redirect for the given url. The supplied URL fully specifies the target of the redirect.

Parameters:
url - is the url for this redirect.

Redirect

public Redirect(ActionConfig ac)

Redirect

public Redirect(String url,
                boolean appendOutput)
Creates a redirect for the given url with dynamic parameters. The URL query parameters are obtained from the Output object for the Action. All the parameters are appended to the URL query string.

Parameters:
url - is the url for this redirect.
appendOutput - is true if this redirect is to use dynamic parameters.

Redirect

public Redirect(ActionConfig ac,
                boolean appendOutput)

Redirect

public Redirect()
Creates a redirect with a dynamic url. The redirect url is obtained from the action output through the key REDIRURL_PARAM.


Redirect

public Redirect(boolean appendOutput)
Creates a redirect with a dynamic URL and dynamic parameters. The redirect url is obtained from the action output. The URL query parameters are obtained from the Output object for the Action. All the parameters are appended to the URL query string.

Parameters:
appendOutput - is true if this redirect is to use dynamic parameters.
Method Detail

execute

public void execute(Action act,
                    String result,
                    javax.servlet.http.HttpServletRequest req,
                    javax.servlet.http.HttpServletResponse res)
             throws ConsequenceException
Execute the redirect consequence. The URL to redirect to is built up as necessary, depending on the type of redirection that is required - see the constructirs for this class for the various flavours of redirections that are supported.

Specified by:
execute in interface Consequence
Parameters:
act - action to be redirected.
req - request object.
res - response object
result - The result generated by the action.
Throws:
ConsequenceException - if an error is detected during construction of the redirection URL.

toString

public String toString()
Return a string representation of the redirect.

Overrides:
toString in class Object
Returns:
a string representation of the redirect.


Copyright © 2013. All Rights Reserved.