public class Controller extends ActionServlet
| Modifier and Type | Class and Description |
|---|---|
static interface |
Controller.Dto<T>
Defines a Data Transfer Object
|
| Modifier and Type | Field and Description |
|---|---|
static String |
CSRF_HEADER
Name of the header used to send/retrieve a CSRF token.
|
static String |
METHOD_NAME_MAPPING |
static String |
SESSION_ATTR_CSRF_TOKEN
Name of the default session attribute used to store CSRF token.
|
static String |
SESSION_ATTR_USER
Name of the session attribute used to store current user.
|
| Constructor and Description |
|---|
Controller() |
| Modifier and Type | Method and Description |
|---|---|
protected User |
getUser(ActionRequest request)
This method instructs the controller how to retrieve the user associated with given HTTP exchange.
|
protected boolean |
onControllerError(ActionRequest request,
ActionResponse response,
Throwable uncaughtError)
Called upon controller uncaught error.
|
protected void |
onControllerInit()
Called during controller initialization.
|
protected void |
onInit()
Called during servlet initialization.
|
protected boolean |
onUncaughtError(ActionRequest request,
ActionResponse response,
RuntimeException uncaughtError)
Called when an uncaught error happened while processing the request.
|
protected void |
sendObject(ActionRequest request,
ActionResponse response,
Object obj)
This method instructs the controller how to send an object to the client.
|
protected void |
setUser(ActionRequest request,
ActionResponse response,
User user)
This method instructs the controller how to associate an user with a HTTP exchange.
|
afterAction, beforeAction, isInitialized, onClientError, registerAction, servicedoDelete, doGet, doHead, doOptions, doPost, doPut, doTrace, getLastModified, servicepublic static final String METHOD_NAME_MAPPING
public static final String SESSION_ATTR_USER
public static final String SESSION_ATTR_CSRF_TOKEN
public static final String CSRF_HEADER
protected final void onInit()
ActionServletonInit in class ActionServletprotected void onControllerInit()
protected boolean onControllerError(ActionRequest request, ActionResponse response, Throwable uncaughtError) throws javax.servlet.ServletException, IOException
request - HTTP request.response - HTTP response.uncaughtError - uncaught error.javax.servlet.ServletException - if the HTTP request cannot be handled.IOException - if an input or output error occurs while the servlet is handling the HTTP request.protected User getUser(ActionRequest request) throws javax.servlet.ServletException, IOException
request - HTTP request.javax.servlet.ServletException - if the HTTP request cannot be handled.IOException - if an input or output error occurs while the servlet is handling the HTTP request.protected void setUser(ActionRequest request, ActionResponse response, User user) throws javax.servlet.ServletException, IOException
request - HTTP request.response - HTTP response.user - user to be registered with given HTTP exchange. Passing null unregisters the user. Passing non-null user instance will generate a CSRF token header which will be sent in associated response.javax.servlet.ServletException - if the HTTP request cannot be handled.IOException - if an input or output error occurs while the servlet is handling the HTTP request.protected void sendObject(ActionRequest request, ActionResponse response, Object obj) throws javax.servlet.ServletException, IOException
request - HTTP request.response - HTTP response.obj - object to be sent to the client.javax.servlet.ServletException - if the HTTP request cannot be handled.IOException - if an input or output error occurs while the servlet is handling the HTTP request.protected final boolean onUncaughtError(ActionRequest request, ActionResponse response, RuntimeException uncaughtError) throws javax.servlet.ServletException, IOException
ActionServletonUncaughtError in class ActionServletrequest - HTTP request.response - HTTP response.uncaughtError - uncaught error.javax.servlet.ServletException - if the HTTP request cannot be handled.IOException - if an input or output error occurs while the servlet is handling the HTTP request.Copyright © 2017 Agapsys Tecnologia Ltda-ME. All rights reserved.