|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.bibeault.frontman.CommandContextImplementation
public final class CommandContextImplementation
A context object that maintains the state information for the invocation of a command, as well as making various useful methods available to Command implementations.
The state information includes the current request and response instances, as well as a reference back to the invoking broker.
A CommandContext is considered valid only for the duration of an invocation of the execute() method of the
Command interface. A reference to the CommandContext should never be retained beyond the scope of that
method, for example, by storing it in a scoped variable.
| Constructor Summary | |
|---|---|
CommandContextImplementation(CommandBroker commandBroker,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
|
|
| Method Summary | |
|---|---|
java.lang.Object |
findScopedVariable(java.lang.Object name)
Finds a scoped variable. |
void |
forward(java.lang.String path)
Forwards the current request to the resource at the specified path. |
void |
forwardToCommand(java.lang.String verb)
Convenience wrapper around the forward(String) method that forwards to the command specified by the passed
command verb. |
void |
forwardToView(java.lang.String viewName)
Convenience wrapper around the forward(String) method that forwards to the view specified by the passed
view name. |
CommandBroker |
getCommandBroker()
|
java.lang.String |
getPathInfo()
Returns the path info for the current request. |
javax.servlet.http.HttpServletRequest |
getRequest()
|
javax.servlet.http.HttpServletResponse |
getResponse()
|
java.lang.Object |
getScopedVariable(java.lang.Object name,
ScopedContext scope)
Gets a scoped variable from the specified context. |
javax.servlet.ServletContext |
getServletContext()
|
javax.servlet.http.HttpSession |
getSession()
|
void |
redirect(java.lang.String location)
Sends a temporary redirect response to the client using the specified redirect location URL. |
void |
redirect(java.lang.String location,
java.util.Map<java.lang.String,java.lang.String[]> parameters)
Sends a temporary redirect response to the client using the specified redirect location URL. |
void |
redirectToCommand(java.lang.String verb)
Convenience wrapper around the redirect(String) method that redirects to the command specified by the
passed command verb. |
void |
redirectToCommand(java.lang.String verb,
java.util.Map<java.lang.String,java.lang.String[]> parameters)
Convenience wrapper around the redirect(String) method that redirects to the command specified by the
passed command verb, with one or more request parameters. |
void |
redirectToView(java.lang.String viewName)
Convenience wrapper around the redirect(String) method that redirects to the view specified by the
passed view name. |
void |
redirectToView(java.lang.String viewName,
java.util.Map<java.lang.String,java.lang.String[]> parameters)
Convenience wrapper around the redirect(String) method that redirects to the view specified by the
passed view name, with one or more request parameters. |
void |
sendError(int statusCode)
Sends an error response to the client with the specified status code. |
void |
setScopedVariable(java.lang.Object name,
java.lang.Object value)
Sets a scoped variable into the request context. |
void |
setScopedVariable(java.lang.Object name,
java.lang.Object value,
ScopedContext scope)
Sets a scoped variable into the specified context. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public CommandContextImplementation(CommandBroker commandBroker,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
| Method Detail |
|---|
public CommandBroker getCommandBroker()
getCommandBroker in interface CommandContextpublic javax.servlet.http.HttpServletRequest getRequest()
getRequest in interface CommandContextpublic javax.servlet.http.HttpServletResponse getResponse()
getResponse in interface CommandContextpublic javax.servlet.http.HttpSession getSession()
getSession in interface CommandContextpublic javax.servlet.ServletContext getServletContext()
getServletContext in interface CommandContextpublic java.lang.String getPathInfo()
getPathInfo in interface CommandContext
public void setScopedVariable(java.lang.Object name,
java.lang.Object value,
ScopedContext scope)
throws javax.servlet.ServletException,
java.lang.NullPointerException
This is a convenience method that shortens the syntax of setting scoped variables into their contexts as well as providing imporoved semantics.
setScopedVariable in interface CommandContextname - the name of the scoped variablevalue - the value of the scoped variablescope - one of SCOPE_REQUEST, SCOPE_SESSION or SCOPE_APPLICATION
javax.servlet.ServletException - if the specified scope is not a valid value
java.lang.NullPointerException - if name is null
public void setScopedVariable(java.lang.Object name,
java.lang.Object value)
throws javax.servlet.ServletException
This is a convenience method that shortens the syntax of setting scoped variables into request context.
setScopedVariable in interface CommandContextname - the name of the scoped variablevalue - the value of the scoped variable
java.lang.NullPointerException - if name is null
javax.servlet.ServletException - if anything else fails
public java.lang.Object getScopedVariable(java.lang.Object name,
ScopedContext scope)
throws javax.servlet.ServletException
getScopedVariable in interface CommandContextname - the name of the scoped variablescope - the scoped context in which to look
javax.servlet.ServletException - if anything goes awrypublic java.lang.Object findScopedVariable(java.lang.Object name)
findScopedVariable in interface CommandContextname - the name of the scoped variable
public void forward(java.lang.String path)
throws java.io.IOException,
javax.servlet.ServletException,
java.lang.IllegalStateException
The semantics of path are the same as that required by the javax.servlet.RequestDispatcher.forward()
method.
forward in interface CommandContextpath - the path of the resource to whcih the request is to be forwarded
java.io.IOException - if the request dispatcher throws this exception
javax.servlet.ServletException - if the request dispatcher throws this exception
java.lang.IllegalStateException - if the response is already committedRequestDispatcher
public void redirect(java.lang.String location)
throws java.io.IOException,
java.lang.IllegalStateException
The semantics of location are the same as that required by the
javax.servlet.http.HttpServletResponse.sendRedirect() method.
This method automatically ensures that the redirect is properly encoded to ensure that the session id is included in the URL if necessary.
redirect in interface CommandContextlocation - the location of the redirect resource
java.io.IOException - If an input or output exception occurs
java.lang.IllegalStateException - if the response is already committed, or the location cannot be made into a valid URLHttpServletResponse
public void redirect(java.lang.String location,
java.util.Map<java.lang.String,java.lang.String[]> parameters)
throws java.io.IOException,
java.lang.IllegalStateException
The semantics of location are the same as that required by the
javax.servlet.http.HttpServletResponse.sendRedirect() method.
This method automatically ensures that the redirect is properly encoded to ensure that the session id is included in the URL if necessary.
redirect in interface CommandContextlocation - the location of the redirect resourceparameters - a Map of the request parameters to add the URL as a query string
java.io.IOException - If an input or output exception occurs
java.lang.IllegalStateException - if the response is already committed, or the location cannot be made into a valid URLHttpServletResponse
public void sendError(int statusCode)
throws java.io.IOException,
java.lang.IllegalStateException
This method is a thin wrapper around the
javax.servlet.http.HttpServletResponse.sendError() method.
sendError in interface CommandContextstatusCode - one of the SC_ codes defined by javax.servlet.http.HttpServletResponse
java.io.IOException - If an input or output exception occurs
java.lang.IllegalStateException - if the response is already committed
public void forwardToCommand(java.lang.String verb)
throws java.io.IOException,
javax.servlet.ServletException
forward(String) method that forwards to the command specified by the passed
command verb.
forwardToCommand in interface CommandContextverb - the verb for the forward command
java.io.IOException - see forward(String)
javax.servlet.ServletException - see forward(String)
public void forwardToView(java.lang.String viewName)
throws java.io.IOException,
javax.servlet.ServletException
forward(String) method that forwards to the view specified by the passed
view name.
forwardToView in interface CommandContextviewName - the name for the forward view
java.io.IOException - see forward(String)
javax.servlet.ServletException - see forward(String)
public void redirectToCommand(java.lang.String verb)
throws java.io.IOException,
javax.servlet.ServletException
redirect(String) method that redirects to the command specified by the
passed command verb.
redirectToCommand in interface CommandContextverb - the verb for the redirect command
java.io.IOException - see redirect(String)
javax.servlet.ServletException - see redirect(String)
public void redirectToCommand(java.lang.String verb,
java.util.Map<java.lang.String,java.lang.String[]> parameters)
throws java.io.IOException,
javax.servlet.ServletException
redirect(String) method that redirects to the command specified by the
passed command verb, with one or more request parameters.
redirectToCommand in interface CommandContextverb - the verb for the redirect commandparameters - a Map of the request parameters to add the URL as a query string
java.io.IOException - see redirect(String)
javax.servlet.ServletException - see redirect(String)
public void redirectToView(java.lang.String viewName)
throws java.io.IOException,
javax.servlet.ServletException
redirect(String) method that redirects to the view specified by the
passed view name.
redirectToView in interface CommandContextviewName - the name for the redirect view
java.io.IOException - see redirect(String)
javax.servlet.ServletException - see redirect(String)
public void redirectToView(java.lang.String viewName,
java.util.Map<java.lang.String,java.lang.String[]> parameters)
throws java.io.IOException,
javax.servlet.ServletException
redirect(String) method that redirects to the view specified by the
passed view name, with one or more request parameters.
redirectToView in interface CommandContextviewName - the name for the redirect viewparameters - a Map of the request parameters to add the URL as a query string
java.io.IOException - see redirect(String)
javax.servlet.ServletException - see redirect(String)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||