|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.chwf.servlet.InvocationContext
Invocation context that allows the controller to specify view urls and
perform error handling. A new context is created for each invocation of
a controller. As a rule, developers should not directly manipulate the
InvocationContext
; its methods are public only to facilitate
out-of-container testing for view redirection.
Constructor Summary | |
InvocationContext()
|
Method Summary | |
void |
addViewParameter(java.lang.String parameter,
java.lang.Object value)
Sets a parameter for the view redirection. |
java.lang.Throwable |
getError()
The exception thrown by the invoked method or null if
the method was successful. |
java.lang.String |
getErrorPage()
The error page, a URL without the context path. |
java.lang.String |
getRedirectURL()
The redirection URL with parameter values appended. |
java.lang.Object |
getResult()
The invoked method's result. |
java.lang.String |
getView()
The view, a URL without the context path. |
void |
handleError(java.lang.String errorPage,
java.lang.Throwable error)
Specifies that the system redirect to the error page and pass it the specified error. |
void |
handleError(java.lang.Throwable error)
Specifies that the system redirect to the default error page and pass it the specified error. |
boolean |
hasError()
True if the invoked method threw an exception. |
void |
setDefaultErrorPage(java.lang.String url)
Specify the default error page. |
void |
setDefaultView(java.lang.String url)
Specify the default view. |
void |
setResult(java.lang.Object result)
Set the invoked method's result. |
void |
setView(java.lang.String url)
Set the view for the controller. |
void |
setView(java.lang.String url,
java.lang.String parameter,
java.lang.Object value)
Set the view and a single parameter value for the controller. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public InvocationContext()
Method Detail |
public void setView(java.lang.String url)
url
- The URL to redirect to after processing is complete.public void setView(java.lang.String url, java.lang.String parameter, java.lang.Object value)
setView("/showItem.jsp", "itemId", item.getItemId());This results in the redirection URL:
/{context-path}/showProject.jsp?itemId={itemId}
url
- The URL to redirect to after processing is complete.parameter
- The parameter name.value
- The parameter value. This will be converted to a string.public void addViewParameter(java.lang.String parameter, java.lang.Object value)
addViewParameter("id", productId); addViewParameter("showSpecials", "true");
parameter
- The parameter name.value
- The parameter value. This will be converted to a string.public void handleError(java.lang.Throwable error)
error
- The error.public void handleError(java.lang.String errorPage, java.lang.Throwable error)
errorPage
- The error page.error
- The error.public java.lang.Object getResult()
public void setResult(java.lang.Object result)
result
- The invoked method's result.public java.lang.String getView()
public java.lang.String getErrorPage()
public java.lang.Throwable getError()
null
if
the method was successful. It is forwarded to the error page.public boolean hasError()
public java.lang.String getRedirectURL()
public void setDefaultView(java.lang.String url)
url
- The default view.public void setDefaultErrorPage(java.lang.String url)
url
- The default error page.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |