|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
public interface CommandContext
Defines the interface for an object instance passed to the execute() method of a Command instance. Thw CommandContext not only provides access to context information such as the request and response, but also provides some handy convenience methods for performing common actions such as seting scoped variables and dispatching to other resources.
| 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 context)
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. |
| Method Detail |
|---|
CommandBroker getCommandBroker()
javax.servlet.http.HttpServletRequest getRequest()
javax.servlet.http.HttpServletResponse getResponse()
javax.servlet.http.HttpSession getSession()
javax.servlet.ServletContext getServletContext()
java.lang.String getPathInfo()
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 improved semantics. The name can be provided as any object whose string value is used as the name.
name - 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
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. The name can be provided as any object whose string value is used as the name.
name - the name of the scoped variablevalue - the value of the scoped variable
javax.servlet.ServletException - if the specified scope is not a valid value
java.lang.NullPointerException - if name is null
java.lang.Object getScopedVariable(java.lang.Object name,
ScopedContext context)
throws javax.servlet.ServletException
name - the name of the scoped variablecontext - the scoped context in which to look
javax.servlet.ServletException - if anything goes awryjava.lang.Object findScopedVariable(java.lang.Object name)
name - the name of the scoped variable
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.
path - 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
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.
location - 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
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.
location - 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
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.
statusCode - 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
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.
verb - the verb for the forward command
java.io.IOException - see forward(String)
javax.servlet.ServletException - see forward(String)
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.
viewName - the name for the forward view
java.io.IOException - see forward(String)
javax.servlet.ServletException - see forward(String)
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.
verb - the verb for the redirect command
java.io.IOException - see redirect(String)
javax.servlet.ServletException - see redirect(String)
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.
verb - 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)
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.
viewName - the name for the redirect view
java.io.IOException - see redirect(String)
javax.servlet.ServletException - see redirect(String)
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.
viewName - 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 | ||||||||