com.fruitioninc.jwc
Class ControllerServlet

java.lang.Object
  |
  +--javax.servlet.GenericServlet
        |
        +--javax.servlet.http.HttpServlet
              |
              +--com.fruitioninc.jwc.ControllerServlet
All Implemented Interfaces:
java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig
Direct Known Subclasses:
SerializedControllerServlet

public class ControllerServlet
extends javax.servlet.http.HttpServlet

This is the singleton servlet that acts as the controller for all the components in the application. It is responsible for the following:

See Also:
Serialized Form

Field Summary
static java.lang.String PARAMETER_EVENT_NAME
           
static java.lang.String PARAMETER_EVENT_SOURCE_PATH_NAME
           
 
Constructor Summary
ControllerServlet()
           
 
Method Summary
protected  void applyApplicationState(Application application, javax.servlet.http.HttpServletRequest request)
          Applys request parameters to the state of the application.
protected  void dispatchRequest(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Handles HTTP GET and POST requests.
 void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          This is called by the servlet container when it receives a HTTP GET request.
 void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          This is called by the servlet container when it receives a HTTP POST request.
protected  boolean handleMouseClick(Application application, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Handle mouse click event if there was one.
 void init()
           This is called by the servlet container when the servlet is loaded.
protected  void logRequest(javax.servlet.http.HttpServletRequest request)
          This is called for each incoming request.
protected  void redirect(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Application application)
          Redirects to another page within the application.
protected  void sendResponse(Application application, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Send HTTP response.
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, service
 
Methods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PARAMETER_EVENT_SOURCE_PATH_NAME

public static final java.lang.String PARAMETER_EVENT_SOURCE_PATH_NAME
See Also:
Constant Field Values

PARAMETER_EVENT_NAME

public static final java.lang.String PARAMETER_EVENT_NAME
See Also:
Constant Field Values
Constructor Detail

ControllerServlet

public ControllerServlet()
Method Detail

init

public void init()
          throws javax.servlet.ServletException

This is called by the servlet container when the servlet is loaded. Its job is to perform application initialization. In the future more things will happen here, but currently the only thing that happens is that calls are made to the Configuration class to get instances various factories.

If you override this method in order to perform your own application initialization, make sure to call super.init().

Currently, you must override this method in order to configure JWebComponents to use a specialized ApplicationFactory that creates instances of your Application class. In the future this configuration will done via a XML configuration file.

FIXME: implement the XML configuration file.

Overrides:
init in class javax.servlet.GenericServlet
javax.servlet.ServletException

doGet

public void doGet(javax.servlet.http.HttpServletRequest request,
                  javax.servlet.http.HttpServletResponse response)
           throws javax.servlet.ServletException,
                  java.io.IOException
This is called by the servlet container when it receives a HTTP GET request. All it does is call dispatchRequest.

Overrides:
doGet in class javax.servlet.http.HttpServlet
javax.servlet.ServletException
java.io.IOException

doPost

public void doPost(javax.servlet.http.HttpServletRequest request,
                   javax.servlet.http.HttpServletResponse response)
            throws javax.servlet.ServletException,
                   java.io.IOException
This is called by the servlet container when it receives a HTTP POST request. All it does is call dispatchRequest.

Overrides:
doPost in class javax.servlet.http.HttpServlet
javax.servlet.ServletException
java.io.IOException

dispatchRequest

protected void dispatchRequest(javax.servlet.http.HttpServletRequest request,
                               javax.servlet.http.HttpServletResponse response)
                        throws javax.servlet.ServletException,
                               java.io.IOException
Handles HTTP GET and POST requests.

javax.servlet.ServletException
java.io.IOException

logRequest

protected void logRequest(javax.servlet.http.HttpServletRequest request)
This is called for each incoming request. Its job is to log the request.


applyApplicationState

protected void applyApplicationState(Application application,
                                     javax.servlet.http.HttpServletRequest request)
                              throws javax.servlet.ServletException,
                                     java.io.IOException
Applys request parameters to the state of the application.

javax.servlet.ServletException
java.io.IOException

sendResponse

protected void sendResponse(Application application,
                            javax.servlet.http.HttpServletRequest request,
                            javax.servlet.http.HttpServletResponse response)
                     throws javax.servlet.ServletException,
                            java.io.IOException
Send HTTP response.

javax.servlet.ServletException
java.io.IOException

handleMouseClick

protected boolean handleMouseClick(Application application,
                                   javax.servlet.http.HttpServletRequest request,
                                   javax.servlet.http.HttpServletResponse response)
                            throws javax.servlet.ServletException,
                                   java.io.IOException
Handle mouse click event if there was one. This default implementation redirects to the next page in order to clear out transient request parameters (those from the mouse click). We don't want them sent to the next page. FIXME: an alternative might be to attach a unique ID to all mouse events and then ignore duplicates.

Returns:
true if a HTTP response was sent, false othwerwise.
javax.servlet.ServletException
java.io.IOException

redirect

protected void redirect(javax.servlet.http.HttpServletRequest request,
                        javax.servlet.http.HttpServletResponse response,
                        Application application)
                 throws javax.servlet.ServletException,
                        java.io.IOException
Redirects to another page within the application.

javax.servlet.ServletException
java.io.IOException