|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.easyweb4j.controller.Controller
public abstract class Controller
Parent Controller which should be extended by all application controllers. It provides several convenience methods for the sub-classes to use.
Field Summary | |
---|---|
protected static String |
DELETE
|
protected static String |
GET
|
protected static String |
HEAD
|
protected static String |
POST
|
protected static String |
PUT
|
Constructor Summary | |
---|---|
Controller()
|
Method Summary | ||
---|---|---|
void |
filterRequest()
This method is invoked at the beginning of each request. |
|
protected
|
getActionAnnotation(Class<T> annotationClass)
Returns action method's annotation for the specified type if such an annotation is present, else null. |
|
protected Annotation[] |
getActionAnnotations()
Returns all the annotations on the action method used in the current request. |
|
protected String |
getActionInvoked()
Returns the name of the action invoked by the current request. |
|
ActionResult |
getActionResult()
Returns the ActionResult instance for the current request. |
|
protected String |
getControllerName()
Returns the name of the controller handling the current request. |
|
org.apache.commons.fileupload.FileItem |
getFileItem(String paramName)
Gets the FileItem with the given parameter name. |
|
Map<String,org.apache.commons.fileupload.FileItem[]> |
getFileItemMap()
Returns a map of the FileItems in the current request. |
|
org.apache.commons.fileupload.FileItem[] |
getFileItems(String paramName)
Gets all the FileItems with the given parameter name. |
|
String |
getMethod()
Returns the HTTP method of the current request. |
|
String |
getParameter(String paramName)
Gets the value of the specified request parameter. |
|
Map<String,String[]> |
getParameterMap()
Returns a map of the parameters in the current request. |
|
String[] |
getParameterValues(String paramName)
Gets the values of the specified multi-valued request parameter. |
|
javax.servlet.http.HttpServletRequest |
getRequest()
Returns the current HttpServletRequest. |
|
Object |
getRequestAttribute(String attributeName)
Retrieves the value of a request attribute. |
|
javax.servlet.http.HttpServletResponse |
getResponse()
Returns the current HttpServletResponse. |
|
javax.servlet.ServletContext |
getServletContext()
Returns the current ServletContext. |
|
Object |
getSessionAttribute(String attributeName)
Retrieves the value of a session attribute. |
|
void |
handleActionException(Exception e)
Callback to handle exceptions which occurred during execution of the action for the request, but were not handled within the action. |
|
void |
invalidateSession()
Invalidates the current HTTP session. |
|
boolean |
isNavigationInitiated()
Determines whether navigation has been initialized for the current request or not. |
|
void |
redirect(String action)
Redirects to the specified action within the same controller. |
|
void |
redirect(String controller,
String action)
Redirects to the specified controller and action. |
|
void |
redirect(String controller,
String action,
String id)
Redirects to the specified controller, action and id combination. |
|
void |
removeRequestAttribute(String attributeName)
Removes the specified request attribute. |
|
void |
removeSessionAttribute(String attributeName)
Removes the specified session attribute. |
|
void |
render(ResponseHandler responseHandler)
Sets a ResponseHandler which deals with the view rendering. |
|
void |
render(String view)
Changes the view to be rendered for the action to the given view. |
|
void |
renderWithoutLayout()
Ensure that the default view of the action is rendered without any layout at the end of the action. |
|
void |
renderWithoutLayout(String view)
Renders the specified view at the end of the action without any layout. |
|
void |
setFlash(String key,
Serializable value)
Sets a flash entry. |
|
void |
setRequestAttribute(String attributeName,
Object attributeValue)
Sets the value of a request attribute. |
|
void |
setSessionAttribute(String attributeName,
Serializable attributeValue)
Sets the value of a session attribute. |
|
protected
|
updateModel(T model,
String objectParameter)
Same as updateModel(model, objectParameter, null); |
|
protected
|
updateModel(T model,
String objectParameter,
AssociationsProvider associationsProvider)
Updates the given model with the values specified by the object parameter and validates the model. |
|
void |
uploadProgress(long read,
long length,
int item)
This callback is notified of progress in file uploads as the multi-part request is being parsed. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final String GET
protected static final String POST
protected static final String PUT
protected static final String DELETE
protected static final String HEAD
Constructor Detail |
---|
public Controller()
Method Detail |
---|
public void filterRequest() throws Exception
Exception
- If the filter doesn't want to handle exceptions.public void handleActionException(Exception e) throws Exception
e
- The exception which occured within the action or during the
action's transaction.
Exception
- May throw an exception back to the servlet container.public void uploadProgress(long read, long length, int item)
Note: The argument descriptions are taken from commons FileUpload's JavaDocs.
read
- The total number of bytes, which have been read so far.length
- The total number of bytes, which are being read. May be -1, if
this number is unknown.item
- The number of the field, which is currently being read. (0 =
no item so far, 1 = first item is being read, ...)public String getParameter(String paramName)
paramName
- The name of the parameter, whose value is to be retrieved.
public String[] getParameterValues(String paramName)
paramName
- The name of the parameter, whose values are to be retrieved.
public Map<String,String[]> getParameterMap()
public Map<String,org.apache.commons.fileupload.FileItem[]> getFileItemMap()
public org.apache.commons.fileupload.FileItem getFileItem(String paramName)
paramName
- The name of the FileItem parameter.
public org.apache.commons.fileupload.FileItem[] getFileItems(String paramName)
paramName
- The name of the FileItem parameter.
protected <T extends Model> T updateModel(T model, String objectParameter)
updateModel(model, objectParameter, null);
updateModel(Model, String, AssociationsProvider)
protected <T extends Model> T updateModel(T model, String objectParameter, AssociationsProvider associationsProvider)
T
- The type of the model.model
- The model to be updated.objectParameter
- the object parameter's name.associationsProvider
- An implementation of AssociationsProvider
.
public void setRequestAttribute(String attributeName, Object attributeValue)
attributeName
- The name of the attribute to be set.attributeValue
- The value to set for the attribute.public Object getRequestAttribute(String attributeName)
attributeName
- The name of the attribute to be retrieved.
public void removeRequestAttribute(String attributeName)
attributeName
- The name of the attribute to be removed.public void setSessionAttribute(String attributeName, Serializable attributeValue)
attributeName
- The name of the attribute to be set.attributeValue
- The value to set for the attribute.public Object getSessionAttribute(String attributeName)
attributeName
- The name of the attribute to be retrieved.
public void removeSessionAttribute(String attributeName)
attributeName
- The name of the attribute to be removed.public void invalidateSession()
public void render(String view)
Note: This method does not commit the servlet's response
view
- The view to be rendered at the end of the action.public void render(ResponseHandler responseHandler)
ResponseHandler
which deals with the view rendering.
Note: This method does not commit the servlet's response
responseHandler
- The ResponseHandler
to be used for rendering the view.public void renderWithoutLayout()
Note: This method does not commit the servlet's response
public void renderWithoutLayout(String view)
Note: This method does not commit the servlet's response
view
- The view to be rendered at the end of the action.public void redirect(String action)
Note: This method does not commit the servlet's response
action
- The action/controller to redirect to.public void redirect(String controller, String action)
Note: This method does not commit the servlet's response
controller
- The controller to whose action response should be redirected.action
- The action in the controller to which the response should be
redirected.public void redirect(String controller, String action, String id)
Note: This method does not commit the servlet's response
controller
- The controller to whose action response should be redirected.action
- The action in the controller to which the response should be
redirected.id
- The object id to be appended to the redirection URL.public String getMethod()
public void setFlash(String key, Serializable value)
key
- The key to identify the entry.value
- The value for the entry.public javax.servlet.http.HttpServletRequest getRequest()
public javax.servlet.http.HttpServletResponse getResponse()
public javax.servlet.ServletContext getServletContext()
public ActionResult getActionResult()
ActionResult
instance for the current request.
ActionResult
of current request.public boolean isNavigationInitiated()
protected String getActionInvoked()
protected Annotation[] getActionAnnotations()
AccessibleObject.getAnnotations()
protected <T extends Annotation> T getActionAnnotation(Class<T> annotationClass)
annotationClass
- the Class object corresponding to the annotation type
protected String getControllerName()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |