org.scopemvc.controller.servlet
Class ServletContext

java.lang.Object
  |
  +--org.scopemvc.controller.basic.ViewContext
        |
        +--org.scopemvc.controller.servlet.ServletContext
Direct Known Subclasses:
JSPContext, XSLServletContext

public abstract class ServletContext
extends ViewContext

A ViewContext that handles showView(), hideView() and showError() for servlet implementations.

The showView() expects a ServletView that is asked to stream the currently visible Page to the HTTP Response's OutputStream.

Two interesting behaviours can be customized with a ServletContext subclass:

Custom ServletContexts can be used for requests by overriding ScopeServlet.createServletContext(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, java.util.HashMap) in the application's ScopeServlet subclass to return an instance of the custom ServletContext.

Version:
$Revision: 1.11 $ $Date: 2002/09/05 15:41:51 $
Author:
Steve Meyfroidt
See Also:
JSPContext, XSLServletContext

Field Summary
protected  java.util.HashMap formParameters
          TODO: describe of the Field
protected  javax.servlet.http.HttpServletRequest request
          TODO: describe of the Field
protected  javax.servlet.http.HttpServletResponse response
          The HttpServletResponse to use on showView.
protected  ScopeServlet servlet
          TODO: describe of the Field
 
Constructor Summary
ServletContext(ScopeServlet inServlet, javax.servlet.http.HttpServletRequest inRequest, javax.servlet.http.HttpServletResponse inResponse, java.util.HashMap inFormParameters)
          Create with an HttpServletResponse to use on a showView during initialisation, and a HttpServletRequest accessible to application code.
 
Method Summary
 void exit()
          Used by default BasicController's handler for the EXIT Control.
protected  java.lang.String formatMessageToHTML(java.lang.String inMessage)
          Replace all low ASCII chars (<32) in the message with <BR />.
 java.util.HashMap getFormParameters()
           
 javax.servlet.http.HttpServletRequest getHttpRequest()
          Allow access to the request object.
 javax.servlet.http.HttpServletResponse getHttpResponse()
          Allow access to the response object.
 ScopeServlet getServlet()
          Return the ScopeServlet that handled this context's request.
protected  void handleInternalError(java.lang.Throwable t)
          Got an error while streaming the view into the response OutputStream.
 boolean hasShownView()
          TODO: document the method
 void hideView(View inView)
          Don't do anything in this impl.
protected  void setHttpResponse(javax.servlet.http.HttpServletResponse inResponse)
          The response to use for showView.
 void showError(java.lang.String inErrorTitle, java.lang.String inErrorMessage)
          This is a very simple default error handler.
abstract  void showView(View inView)
          Show the ServletView passed.
 void startProgress()
          TODO: document the method
 void stopProgress()
          TODO: document the method
 
Methods inherited from class org.scopemvc.controller.basic.ViewContext
addProperty, clearProperties, clearThreadContext, getProperty, getViewContext, removeProperty, setGlobalContext, setThreadContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

response

protected javax.servlet.http.HttpServletResponse response
The HttpServletResponse to use on showView. Set on creation then nulled after showView/showError.


request

protected javax.servlet.http.HttpServletRequest request
TODO: describe of the Field


formParameters

protected java.util.HashMap formParameters
TODO: describe of the Field


servlet

protected ScopeServlet servlet
TODO: describe of the Field

Constructor Detail

ServletContext

public ServletContext(ScopeServlet inServlet,
                      javax.servlet.http.HttpServletRequest inRequest,
                      javax.servlet.http.HttpServletResponse inResponse,
                      java.util.HashMap inFormParameters)
Create with an HttpServletResponse to use on a showView during initialisation, and a HttpServletRequest accessible to application code.

Parameters:
inServlet - TODO: Describe the Parameter
inRequest - TODO: Describe the Parameter
inResponse - TODO: Describe the Parameter
inFormParameters - TODO: Describe the Parameter
Method Detail

getHttpResponse

public final javax.servlet.http.HttpServletResponse getHttpResponse()
Allow access to the response object. Should rarely be used.

Returns:
The httpResponse value

getHttpRequest

public final javax.servlet.http.HttpServletRequest getHttpRequest()
Allow access to the request object. Can be used to get access to cookies, session etc.

Returns:
The httpRequest value

getServlet

public final ScopeServlet getServlet()
Return the ScopeServlet that handled this context's request.

Returns:
The servlet value

getFormParameters

public final java.util.HashMap getFormParameters()
Returns:
the form parameters for the current request.

hasShownView

public final boolean hasShownView()
TODO: document the method

Returns:
TODO: Describe the Return Value

showView

public abstract void showView(View inView)
Show the ServletView passed.

Specified by:
showView in class ViewContext
Parameters:
inView - TODO: Describe the Parameter

hideView

public void hideView(View inView)
Don't do anything in this impl.

***** A nicer impl of this view manager would maintain a "stack" of shown views and implement "doHideView" to step back through the stack if available. Could be tied to some rudimentary state management in ScopeServlet.

Specified by:
hideView in class ViewContext
Parameters:
inView - TODO: Describe the Parameter

showError

public void showError(java.lang.String inErrorTitle,
                      java.lang.String inErrorMessage)
This is a very simple default error handler. To implement your own error handler, override this method and also override ScopeServlet.createServletContext(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, java.util.HashMap) to return an instance of your custom ServletContext that will handle servlet requests.

Specified by:
showError in class ViewContext
Parameters:
inErrorTitle - TODO: Describe the Parameter
inErrorMessage - TODO: Describe the Parameter

exit

public void exit()
Used by default BasicController's handler for the EXIT Control. Doesn't do anything in a servlet context.

Specified by:
exit in class ViewContext

startProgress

public void startProgress()
TODO: document the method

Specified by:
startProgress in class ViewContext

stopProgress

public void stopProgress()
TODO: document the method

Specified by:
stopProgress in class ViewContext

setHttpResponse

protected final void setHttpResponse(javax.servlet.http.HttpServletResponse inResponse)
The response to use for showView. Set in ctor and then nulled after showing a view.

Parameters:
inResponse - The new httpResponse value

handleInternalError

protected void handleInternalError(java.lang.Throwable t)
                            throws java.io.IOException
Got an error while streaming the view into the response OutputStream. The stream could be corrupt by this point, but it hasn't been closed so do the best you can.

Parameters:
t - TODO: Describe the Parameter
Throws:
java.io.IOException - TODO: Describe the Exception

formatMessageToHTML

protected java.lang.String formatMessageToHTML(java.lang.String inMessage)
Replace all low ASCII chars (<32) in the message with <BR />.

Parameters:
inMessage - TODO: Describe the Parameter
Returns:
TODO: Describe the Return Value


Copyright © 2000-2002 The Scope Team. All Rights Reserved.