com.scooterframework.web.controller
Class ActionControl

java.lang.Object
  extended by com.scooterframework.web.controller.ActionControl

public class ActionControl
extends java.lang.Object

ActionControl class serves as a helper class for all controller classes.


Constructor Summary
ActionControl()
           
 
Method Summary
static java.lang.String applicationPath()
          Returns root path to the application.
static void cleanupValidationResults()
          Cleans up cached ValidationResults.
static ValidationResults currentValidationResults()
          Returns controller validation results.
static void doForward(java.lang.String uri, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Do a forward to specified URI using a RequestDispatcher.
static java.lang.String error(java.lang.String content)
          Returns an error-tagged content string for error output.
static FilterManager filterManagerFor(java.lang.Class<?> clazz)
          Returns the FilterManager for a class type.
static void flash(java.lang.String type, Message message)
          Records a flash message of a specific type.
static void flash(java.lang.String type, java.lang.String message)
          Records a flash message of a specific type.
static void flash(java.lang.String type, java.lang.String message, java.lang.Object value)
          Records a flash message of a specific type.
static void flash(java.lang.String type, java.lang.String message, java.lang.Object value0, java.lang.Object value1)
          Records a flash message of a specific type.
static void flash(java.lang.String type, java.lang.String message, java.lang.Object value0, java.lang.Object value1, java.lang.Object value2)
          Records a flash message of a specific type.
static void flashError(Message message)
          Records a flash message of error type.
static void flashError(java.lang.String message)
          Records a flash message of error type.
static void flashError(java.lang.String message, java.lang.Object value)
          Records a flash message of error type.
static void flashError(java.lang.String message, java.lang.Object value0, java.lang.Object value1)
          Records a flash message of error type.
static void flashError(java.lang.String message, java.lang.Object value0, java.lang.Object value1, java.lang.Object value2)
          Records a flash message of error type.
static void flashNotice(Message message)
          Records a flash message of notice type.
static void flashNotice(java.lang.String message)
          Records a flash message of notice type.
static void flashNotice(java.lang.String message, java.lang.Object value)
          Records a flash message of notice type.
static void flashNotice(java.lang.String message, java.lang.Object value0, java.lang.Object value1)
          Records a flash message of notice type.
static void flashNotice(java.lang.String message, java.lang.Object value0, java.lang.Object value1, java.lang.Object value2)
          Records a flash message of notice type.
static java.lang.String format()
           Returns request extension which is linked to key Constants.FORMAT.
static java.lang.String forwardTo(java.lang.String uri)
          Returns a forward-tagged URI string.
static java.lang.String forwardTo(java.lang.String uri, ActiveRecord record)
          Returns a forward-tagged URI string with a query string.
static java.lang.String forwardTo(java.lang.String uri, java.util.Map<java.lang.String,java.lang.Object> nameValuePairs)
          Returns a forward-tagged URI string with a query string.
static java.lang.String forwardTo(java.lang.String uri, java.lang.String nameValuePairs)
          Returns a forward-tagged URI string with a query string.
static java.lang.String getAction()
          Returns action name which handles the request.
static java.lang.String getController()
          Returns controller name which handles the request.
static java.lang.String getFileExtension(java.io.File file)
          Returns the file extension.
static java.lang.Object getFromContextData(java.lang.String key)
           
static java.lang.Object getFromGlobalData(java.lang.String key)
           
static java.lang.Object getFromParameterData(java.lang.String key)
           
static java.lang.Object getFromRequestData(java.lang.String key)
           
static java.lang.Object getFromSessionData(java.lang.String key)
           
static java.lang.Object getFromThreadData(java.lang.String key)
           
static java.lang.String getHttpRequestContentType()
          Returns content type of HTTP request.
static javax.servlet.http.HttpServletRequest getHttpServletRequest()
          Returns the current HTTP Servlet request instance.
static javax.servlet.http.HttpServletResponse getHttpServletResponse()
          Returns the current HTTP Servlet response instance.
static java.lang.String getModel()
          Returns model name.
static java.lang.String getModelClassName(java.lang.Class<?> controllerClass)
          Returns model class name related to the underlying controller class name based on naming convention.
static java.lang.String getResource()
          Returns resource name which is linked to key Constants.RESOURCE.
static javax.servlet.ServletContext getServletContext()
          Returns the HTTP ServletContext instance.
static UploadFile getUploadFile(java.lang.String key)
          Returns an upload file which is an instance of UploadFile.
static java.util.List<UploadFile> getUploadFiles()
          Returns a list of upload files.
static java.util.List<java.io.File> getUploadFilesAsFiles(java.lang.String fileRepository)
          Returns a list of upload files.
static java.util.Map<java.lang.String,UploadFile> getUploadFilesMap()
          Returns a map of upload files.
static java.util.Map<java.lang.String,java.lang.Object> getViewDataMap()
          Returns all view data as a map.
static java.lang.String html(java.lang.String content)
          Returns a html-tagged content string for html output.
static boolean isAjaxRequest()
          Checks if this is an AJAX request.
static boolean isFileUploadRequest()
          Checks if this is a file-upload request or multipart request.
static boolean isTextFile(java.io.File file)
          Checks whether a file is a text file.
static Paginator jdbcPaginator(java.lang.Class<? extends ActiveRecord> modelClass)
          Returns a paginator for the underlying model.
static Paginator jdbcPaginator(java.lang.Class<? extends ActiveRecord> modelClass, java.util.Map<java.lang.String,?> pagingOptions)
          Returns a paginator for the underlying model.
static Paginator jdbcPaginator(java.lang.Class<? extends ActiveRecord> modelClass, java.util.Map<java.lang.String,java.lang.String> pagingOptions, java.util.Map<java.lang.String,java.lang.String> sqlOptions)
          Returns a paginator for the underlying model.
static Paginator jdbcPaginator(java.lang.Class<? extends ActiveRecord> modelClass, java.util.Map<java.lang.String,java.lang.String> pagingOptions, java.lang.String sqlOptions)
          Returns a paginator for the underlying model.
static Paginator jdbcPaginator(java.lang.Class<? extends ActiveRecord> modelClass, java.lang.String pagingOptions)
          Returns a paginator for the underlying model.
static Paginator jdbcPaginator(java.lang.Class<? extends ActiveRecord> modelClass, java.lang.String pagingOptions, java.util.Map<java.lang.String,java.lang.String> sqlOptions)
          Returns a paginator for the underlying model.
static Paginator jdbcPaginator(java.lang.Class<? extends ActiveRecord> modelClass, java.lang.String pagingOptions, java.lang.String sqlOptions)
          Returns a paginator for the underlying model.
static java.lang.String p(java.lang.String key)
          Alias of method params(String key).
static java.util.Map<java.lang.String,java.lang.Object> params()
          Returns all request parameters as a map.
static java.lang.String params(java.lang.String key)
          Returns a value corresponding to a key in request parameters or request attributes.
static UploadFile paramsFile(java.lang.String key)
          Alias of method getUploadedFile(String key).
static java.util.List<UploadFile> paramsFiles()
          Alias of method getUploadFiles().
static java.util.Map<java.lang.String,UploadFile> paramsFilesMap()
          Alias of method getUploadFilesMap().
static java.lang.String paramsIgnoreCase(java.lang.String key)
          Returns a value corresponding to a key in the request parameters.
static java.util.Map<java.lang.String,java.lang.Object> paramsWithPrefix(java.lang.String keyPrefix)
          Returns all request parameters as a map for those keys that have a prefix.
static java.lang.String[] pArray(java.lang.String key)
          Returns a string array corresponding to a key in request parameters or request attributes.
static java.lang.Boolean pBoolean(java.lang.String key)
          Returns true or false corresponding to a key in request parameters or request attributes.
static java.util.Date pDate(java.lang.String key)
          Returns a date instance corresponding to a key in request parameters or request attributes.
static java.util.Date pDate(java.lang.String key, java.lang.String pattern)
          Returns a date instance corresponding to a key in request parameters or request attributes.
static UploadFile pFile(java.lang.String key)
          Alias of method paramsFile(String key).
static java.util.List<UploadFile> pFiles()
          Alias of method paramsFiles().
static java.util.Map<java.lang.String,UploadFile> pFilesMap()
          Alias of method paramsFilesMap().
static void publishFile(java.io.File file)
          Publishes a file for display.
static void publishFile(java.io.File file, java.lang.String mimeType)
          Publishes a file for display.
static void publishFile(java.io.File file, java.lang.String displayableName, boolean forDownload)
          Publishes a file.
static void publishFile(java.io.File file, java.lang.String displayableName, java.lang.String mimeType, boolean forDownload)
          Publishes a file.
static java.lang.String redirectTo(java.lang.String uri)
          Returns a redirect-tagged URI string.
static java.lang.String redirectTo(java.lang.String uri, ActiveRecord record)
          Returns a redirect-tagged URI string with a query string.
static java.lang.String redirectTo(java.lang.String uri, java.util.Map<java.lang.String,java.lang.Object> nameValuePairs)
          Returns a redirect-tagged URI string with a query string.
static java.lang.String redirectTo(java.lang.String uri, java.lang.String nameValuePairs)
          Returns a redirect-tagged URI string with a query string.
static void remove(java.lang.String key)
           
static void removeAllSessionData()
           
static void removeFromContextData(java.lang.String key)
           
static void removeFromGlobalData(java.lang.String key)
           
static void removeFromRequestData(java.lang.String key)
           
static void removeFromSessionData(java.lang.String key)
           
static void removeFromThreadData(java.lang.String key)
           
static java.lang.String render(java.lang.Object content)
          Renders content.
static java.lang.String render(java.lang.Object content, java.lang.String format)
          Renders content associated with a specific request format.
static java.lang.String renderView(java.lang.String view)
          Renders a view template file with all properties in the container.
static java.lang.String renderView(java.lang.String view, java.util.Map<java.lang.String,java.lang.Object> viewDataMap)
          Renders a view template file with view data in viewDataMap.
static java.lang.String renderView(java.lang.String view, java.lang.String format)
          Renders a view template file with all properties in the container.
static java.lang.String renderView(java.lang.String view, java.lang.String format, java.util.Map<java.lang.String,java.lang.Object> viewDataMap)
          Renders a view template file with view data in viewDataMap.
static java.lang.String routeFieldValue(java.lang.String field)
          Returns value of a field for route.
static java.util.Map<java.lang.String,java.lang.String> routeFieldValues()
          Returns field values of a route.
static void setViewData(java.lang.String key, java.lang.Object data)
          Binds data to view attribute for view rendering.
static void storeToContext(java.lang.String key, java.lang.Object obj)
           
static void storeToGlobal(java.lang.String key, java.lang.Object obj)
           
static void storeToRequest(java.lang.String key, java.lang.Object obj)
           
static void storeToSession(java.lang.String key, java.lang.Object obj)
           
static void storeToThread(java.lang.String key, java.lang.Object obj)
           
static java.lang.String text(java.lang.String content)
          Returns a text-tagged content string for plain-text output.
static boolean validationFailed()
          Checks if validation failed.
static ActionValidators validators()
          Returns an instance of Validators.
static java.lang.String viewPath(java.lang.String action)
          Returns URI path to a view template of the current controller's action.
static java.lang.String viewPath(java.lang.String controller, java.lang.String action)
          Returns URI path to a view template of a controller's action.
static java.lang.String xml(java.lang.String content)
          Returns a xml-tagged content string for xml output.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ActionControl

public ActionControl()
Method Detail

getController

public static java.lang.String getController()
Returns controller name which handles the request. The controller name is linked to key Constants.CONTROLLER.


getAction

public static java.lang.String getAction()
Returns action name which handles the request. The action name is linked to key Constants.ACTION.


getModel

public static java.lang.String getModel()
Returns model name.

Model name must be set in current thread cache before this method is called.

Returns:
model name

getResource

public static java.lang.String getResource()
Returns resource name which is linked to key Constants.RESOURCE.


format

public static java.lang.String format()

Returns request extension which is linked to key Constants.FORMAT.

This is obtained from the request path. For example, if the request path is /blog/posts/1.xml, then the format is xml, which means the client wants the response be sent in xml format.

The value of format() is what is used as a default format for response.


viewPath

public static java.lang.String viewPath(java.lang.String action)
Returns URI path to a view template of the current controller's action.
 Examples:
   viewPath("show") : /WEB-INF/views/posts/show.jsp
   viewPath("index"): /WEB-INF/views/posts/index.jsp
 

Parameters:
action - action name
Returns:
path to a view file

viewPath

public static java.lang.String viewPath(java.lang.String controller,
                                        java.lang.String action)
Returns URI path to a view template of a controller's action.
 Examples:
   viewPath("posts", "show") : /WEB-INF/views/posts/show.jsp
   viewPath("posts", "index"): /WEB-INF/views/posts/index.jsp
 

Parameters:
controller - controller name
action - action name
Returns:
path to a view file

getModelClassName

public static java.lang.String getModelClassName(java.lang.Class<?> controllerClass)
Returns model class name related to the underlying controller class name based on naming convention.

Returns:
string model class name

jdbcPaginator

public static Paginator jdbcPaginator(java.lang.Class<? extends ActiveRecord> modelClass)
Returns a paginator for the underlying model.

Paging control options are constructed based on URL parameters. Therefore in URL, there must be parameters like limit, offset, npage, etc.

For a complete list of paging options, see description of Paginator class.

Parameters:
modelClass - the model class
Returns:
Paginator instance

jdbcPaginator

public static Paginator jdbcPaginator(java.lang.Class<? extends ActiveRecord> modelClass,
                                      java.lang.String pagingOptions)
Returns a paginator for the underlying model.

For a complete list of paging options, see description of Paginator class.

Parameters:
modelClass - the model class
pagingOptions - paging control options string
Returns:
Paginator instance

jdbcPaginator

public static Paginator jdbcPaginator(java.lang.Class<? extends ActiveRecord> modelClass,
                                      java.lang.String pagingOptions,
                                      java.lang.String sqlOptions)
Returns a paginator for the underlying model.

For a complete list of paging options, see description of Paginator class.

For a complete list of SQL options, see description of options in ActiveRecord class.

Parameters:
modelClass - the model class
pagingOptions - paging control options string
sqlOptions - SQL options string
Returns:
Paginator instance

jdbcPaginator

public static Paginator jdbcPaginator(java.lang.Class<? extends ActiveRecord> modelClass,
                                      java.lang.String pagingOptions,
                                      java.util.Map<java.lang.String,java.lang.String> sqlOptions)
Returns a paginator for the underlying model.

For a complete list of paging options, see description of Paginator class.

For a complete list of SQL options, see description of options in ActiveRecord class.

Parameters:
modelClass - the model class
pagingOptions - paging control options string
sqlOptions - SQL options Map
Returns:
Paginator instance

jdbcPaginator

public static Paginator jdbcPaginator(java.lang.Class<? extends ActiveRecord> modelClass,
                                      java.util.Map<java.lang.String,?> pagingOptions)
Returns a paginator for the underlying model.

For a complete list of paging options, see description of Paginator class.

Parameters:
modelClass - the model class
pagingOptions - paging control options Map
Returns:
Paginator instance

jdbcPaginator

public static Paginator jdbcPaginator(java.lang.Class<? extends ActiveRecord> modelClass,
                                      java.util.Map<java.lang.String,java.lang.String> pagingOptions,
                                      java.lang.String sqlOptions)
Returns a paginator for the underlying model.

For a complete list of paging options, see description of Paginator class.

For a complete list of SQL options, see description of options in ActiveRecord class.

Parameters:
modelClass - the model class
pagingOptions - paging control options Map
sqlOptions - SQL options string
Returns:
Paginator instance

jdbcPaginator

public static Paginator jdbcPaginator(java.lang.Class<? extends ActiveRecord> modelClass,
                                      java.util.Map<java.lang.String,java.lang.String> pagingOptions,
                                      java.util.Map<java.lang.String,java.lang.String> sqlOptions)
Returns a paginator for the underlying model.

For a complete list of paging options, see description of Paginator class.

For a complete list of SQL options, see description of options in ActiveRecord class.

Parameters:
modelClass - the model class
pagingOptions - paging control options Map
sqlOptions - SQL options Map
Returns:
Paginator instance

params

public static java.util.Map<java.lang.String,java.lang.Object> params()
Returns all request parameters as a map. This includes data in both parameter scope and request scope.

Returns:
a map of all request parameters

paramsWithPrefix

public static java.util.Map<java.lang.String,java.lang.Object> paramsWithPrefix(java.lang.String keyPrefix)
Returns all request parameters as a map for those keys that have a prefix.

Parameters:
keyPrefix -
Returns:
a map of request parameters

params

public static java.lang.String params(java.lang.String key)
Returns a value corresponding to a key in request parameters or request attributes.

Parameters:
key - name of a key in the request parameters
Returns:
a value corresponding to a key in the request parameters

p

public static java.lang.String p(java.lang.String key)
Alias of method params(String key). Returns a value corresponding to a key in request parameters or request attributes.

Parameters:
key - name of a key in the request parameters
Returns:
a value corresponding to a key in the request parameters

pArray

public static java.lang.String[] pArray(java.lang.String key)
Returns a string array corresponding to a key in request parameters or request attributes.

Parameters:
key - name of a key in the request parameters
Returns:
a string array corresponding to a key in the request parameters

pDate

public static java.util.Date pDate(java.lang.String key)
Returns a date instance corresponding to a key in request parameters or request attributes.

Parameters:
key - name of a key in the request parameters
Returns:
a date instance corresponding to a key in the request parameters

pDate

public static java.util.Date pDate(java.lang.String key,
                                   java.lang.String pattern)
Returns a date instance corresponding to a key in request parameters or request attributes.

Parameters:
key - name of a key in the request parameters
pattern - the pattern describing the date and time format
Returns:
a date instance corresponding to a key in the request parameters

pBoolean

public static java.lang.Boolean pBoolean(java.lang.String key)
Returns true or false corresponding to a key in request parameters or request attributes. Only string of "true"--regardless of case--would return true.

Parameters:
key - name of a key in the request parameters
Returns:
true or false corresponding to a key in the request parameters

isAjaxRequest

public static boolean isAjaxRequest()
Checks if this is an AJAX request.

Returns:
true if this is an AJAX request.

isFileUploadRequest

public static boolean isFileUploadRequest()
Checks if this is a file-upload request or multipart request.

Returns:
true if this is a file-upload request or multipart request.

paramsFile

public static UploadFile paramsFile(java.lang.String key)
                             throws java.lang.Exception
Alias of method getUploadedFile(String key). Returns an upload file which is an instance of UploadFile.

Returns:
an instance of UploadFile
Throws:
java.lang.Exception

paramsFiles

public static java.util.List<UploadFile> paramsFiles()
                                              throws java.lang.Exception
Alias of method getUploadFiles(). Returns a list of upload files.

Returns:
a list of UploadFile instances
Throws:
java.lang.Exception

paramsFilesMap

public static java.util.Map<java.lang.String,UploadFile> paramsFilesMap()
                                                                 throws java.lang.Exception
Alias of method getUploadFilesMap(). Returns a map of upload files. In each key/value pair, the key is the field name in the HTTP form, and the value is a UploadFile instance.

Returns:
a map of field/upload file (UploadFile) pairs
Throws:
java.lang.Exception

pFile

public static UploadFile pFile(java.lang.String key)
                        throws java.lang.Exception
Alias of method paramsFile(String key). Returns an upload file which is an instance of UploadFile.

Returns:
an instance of UploadFile
Throws:
java.lang.Exception

pFiles

public static java.util.List<UploadFile> pFiles()
                                         throws java.lang.Exception
Alias of method paramsFiles(). Returns a list of upload files.

Returns:
a list of UploadFile instances
Throws:
java.lang.Exception

pFilesMap

public static java.util.Map<java.lang.String,UploadFile> pFilesMap()
                                                            throws java.lang.Exception
Alias of method paramsFilesMap(). Returns a map of upload files. In each key/value pair, the key is the field name in the HTTP form, and the value is a UploadFile instance.

Returns:
a map of field/upload file (UploadFile) pairs
Throws:
java.lang.Exception

paramsIgnoreCase

public static java.lang.String paramsIgnoreCase(java.lang.String key)
Returns a value corresponding to a key in the request parameters. The case of the key string is ignored.

Parameters:
key - name of a key in the request parameters
Returns:
a value corresponding to a key in the request parameters

routeFieldValues

public static java.util.Map<java.lang.String,java.lang.String> routeFieldValues()
Returns field values of a route.

Returns:
field values of a route.

routeFieldValue

public static java.lang.String routeFieldValue(java.lang.String field)
Returns value of a field for route.

Parameters:
field - the field
Returns:
value of a field for route.

getFromThreadData

public static java.lang.Object getFromThreadData(java.lang.String key)

getFromParameterData

public static java.lang.Object getFromParameterData(java.lang.String key)

getFromRequestData

public static java.lang.Object getFromRequestData(java.lang.String key)

getFromSessionData

public static java.lang.Object getFromSessionData(java.lang.String key)

getFromContextData

public static java.lang.Object getFromContextData(java.lang.String key)

getFromGlobalData

public static java.lang.Object getFromGlobalData(java.lang.String key)

storeToThread

public static void storeToThread(java.lang.String key,
                                 java.lang.Object obj)

storeToRequest

public static void storeToRequest(java.lang.String key,
                                  java.lang.Object obj)

storeToSession

public static void storeToSession(java.lang.String key,
                                  java.lang.Object obj)

storeToContext

public static void storeToContext(java.lang.String key,
                                  java.lang.Object obj)

storeToGlobal

public static void storeToGlobal(java.lang.String key,
                                 java.lang.Object obj)

removeFromThreadData

public static void removeFromThreadData(java.lang.String key)

removeFromRequestData

public static void removeFromRequestData(java.lang.String key)

removeFromSessionData

public static void removeFromSessionData(java.lang.String key)

removeFromContextData

public static void removeFromContextData(java.lang.String key)

removeFromGlobalData

public static void removeFromGlobalData(java.lang.String key)

remove

public static void remove(java.lang.String key)

removeAllSessionData

public static void removeAllSessionData()

setViewData

public static void setViewData(java.lang.String key,
                               java.lang.Object data)
Binds data to view attribute for view rendering.

Parameters:
key - a string representing a place holder on view
data - the data value to be filled in the view

getHttpServletRequest

public static javax.servlet.http.HttpServletRequest getHttpServletRequest()
Returns the current HTTP Servlet request instance.


getHttpServletResponse

public static javax.servlet.http.HttpServletResponse getHttpServletResponse()
Returns the current HTTP Servlet response instance.


getServletContext

public static javax.servlet.ServletContext getServletContext()
Returns the HTTP ServletContext instance.


getHttpRequestContentType

public static java.lang.String getHttpRequestContentType()
Returns content type of HTTP request.


flash

public static void flash(java.lang.String type,
                         java.lang.String message)
Records a flash message of a specific type. The message can be either a sentence or a message key in a messages.properties file.

Parameters:
type - flash message type
message - the message or message key

flash

public static void flash(java.lang.String type,
                         java.lang.String message,
                         java.lang.Object value)
Records a flash message of a specific type. The message can be either a sentence or a message key in a messages.properties file.

Parameters:
type - flash message type
message - the message or message key
value - a value that can be used in the message

flash

public static void flash(java.lang.String type,
                         java.lang.String message,
                         java.lang.Object value0,
                         java.lang.Object value1)
Records a flash message of a specific type. The message can be either a sentence or a message key in a messages.properties file.

Parameters:
type - flash message type
message - the message or message key
value0 - a value that can be used in the message
value1 - a value that can be used in the message

flash

public static void flash(java.lang.String type,
                         java.lang.String message,
                         java.lang.Object value0,
                         java.lang.Object value1,
                         java.lang.Object value2)
Records a flash message of a specific type. The message can be either a sentence or a message key in a messages.properties file.

Parameters:
type - flash message type
message - the message or message key
value0 - a value that can be used in the message
value1 - a value that can be used in the message
value2 - a value that can be used in the message

flash

public static void flash(java.lang.String type,
                         Message message)
Records a flash message of a specific type. The message is of type Message or its subclass.

Parameters:
type - flash message type
message - a Message object

flashError

public static void flashError(java.lang.String message)
Records a flash message of error type. The message can be either a sentence or a message key in a messages.properties file.

Parameters:
message - the message or message key

flashError

public static void flashError(java.lang.String message,
                              java.lang.Object value)
Records a flash message of error type. The message can be either a sentence or a message key in a messages.properties file.

Parameters:
message - the message or message key
value - a value that can be used in the message

flashError

public static void flashError(java.lang.String message,
                              java.lang.Object value0,
                              java.lang.Object value1)
Records a flash message of error type. The message can be either a sentence or a message key in a messages.properties file.

Parameters:
message - the message or message key
value0 - a value that can be used in the message
value1 - a value that can be used in the message

flashError

public static void flashError(java.lang.String message,
                              java.lang.Object value0,
                              java.lang.Object value1,
                              java.lang.Object value2)
Records a flash message of error type. The message can be either a sentence or a message key in a messages.properties file.

Parameters:
message - the message or message key
value0 - a value that can be used in the message
value1 - a value that can be used in the message
value2 - a value that can be used in the message

flashError

public static void flashError(Message message)
Records a flash message of error type. The message is of type Message or its subclass.

Parameters:
message - a Message object

flashNotice

public static void flashNotice(java.lang.String message)
Records a flash message of notice type. The message can be either a sentence or a message key in a messages.properties file.

Parameters:
message - the message or message key

flashNotice

public static void flashNotice(java.lang.String message,
                               java.lang.Object value)
Records a flash message of notice type. The message can be either a sentence or a message key in a messages.properties file.

Parameters:
message - the message or message key
value - a value that can be used in the message

flashNotice

public static void flashNotice(java.lang.String message,
                               java.lang.Object value0,
                               java.lang.Object value1)
Records a flash message of notice type. The message can be either a sentence or a message key in a messages.properties file.

Parameters:
message - the message or message key
value0 - a value that can be used in the message
value1 - a value that can be used in the message

flashNotice

public static void flashNotice(java.lang.String message,
                               java.lang.Object value0,
                               java.lang.Object value1,
                               java.lang.Object value2)
Records a flash message of notice type. The message can be either a sentence or a message key in a messages.properties file.

Parameters:
message - the message or message key
value0 - a value that can be used in the message
value1 - a value that can be used in the message
value2 - a value that can be used in the message

flashNotice

public static void flashNotice(Message message)
Records a flash message of notice type. The message is of type Message or its subclass.

Parameters:
message - a Message object

validators

public static ActionValidators validators()
Returns an instance of Validators.

Subclass must override this method if a different validator is used.

Returns:
Validators object

currentValidationResults

public static ValidationResults currentValidationResults()
Returns controller validation results.


cleanupValidationResults

public static void cleanupValidationResults()
Cleans up cached ValidationResults.


validationFailed

public static boolean validationFailed()
Checks if validation failed.

Returns:
true if validation is failed, false otherwise.

error

public static java.lang.String error(java.lang.String content)
Returns an error-tagged content string for error output.

Parameters:
content - the error content
Returns:
a error-tagged content string

html

public static java.lang.String html(java.lang.String content)
Returns a html-tagged content string for html output.

Parameters:
content - the html content
Returns:
a html-tagged content string

text

public static java.lang.String text(java.lang.String content)
Returns a text-tagged content string for plain-text output.

Parameters:
content - the text content
Returns:
a text-tagged content string

xml

public static java.lang.String xml(java.lang.String content)
Returns a xml-tagged content string for xml output.

Parameters:
content - the xml content
Returns:
a xml-tagged content string

forwardTo

public static java.lang.String forwardTo(java.lang.String uri,
                                         ActiveRecord record)
Returns a forward-tagged URI string with a query string. The query string is formed by listing all primary key and value pairs of the record instance.

Parameters:
uri - an URI string
record - an ActiveRecord instance
Returns:
a formatted forward-tagged URI string

forwardTo

public static java.lang.String forwardTo(java.lang.String uri,
                                         java.util.Map<java.lang.String,java.lang.Object> nameValuePairs)
Returns a forward-tagged URI string with a query string.

Parameters:
uri - an URI string
nameValuePairs - a map of name and value pairs as HTTP query string
Returns:
a formatted forward-tagged URI string

forwardTo

public static java.lang.String forwardTo(java.lang.String uri,
                                         java.lang.String nameValuePairs)
Returns a forward-tagged URI string with a query string.

Parameters:
uri - an URI string
nameValuePairs - a string of name and value pairs as HTTP query string
Returns:
a formatted forward-tagged URI string

forwardTo

public static java.lang.String forwardTo(java.lang.String uri)
Returns a forward-tagged URI string.

Parameters:
uri - an URI string
Returns:
a formatted forward-tagged URI string

redirectTo

public static java.lang.String redirectTo(java.lang.String uri,
                                          ActiveRecord record)
Returns a redirect-tagged URI string with a query string. The query string is formed by listing all primary key and value pairs of the record instance.

Parameters:
uri - an URI string
record - an ActiveRecord instance
Returns:
a formatted redirect-tagged URI string

redirectTo

public static java.lang.String redirectTo(java.lang.String uri,
                                          java.util.Map<java.lang.String,java.lang.Object> nameValuePairs)
Returns a redirect-tagged URI string with a query string.

Parameters:
uri - an URI string
nameValuePairs - a map of name and value pairs as HTTP query string
Returns:
a formatted redirect-tagged URI string

redirectTo

public static java.lang.String redirectTo(java.lang.String uri,
                                          java.lang.String nameValuePairs)
Returns a redirect-tagged URI string with a query string.

Parameters:
uri - an URI string
nameValuePairs - a string of name and value pairs as HTTP query string
Returns:
a formatted redirect-tagged URI string

redirectTo

public static java.lang.String redirectTo(java.lang.String uri)
Returns a redirect-tagged URI string.

Parameters:
uri - an URI string
Returns:
a formatted redirect-tagged URI string

applicationPath

public static java.lang.String applicationPath()
Returns root path to the application.


getUploadFilesAsFiles

public static java.util.List<java.io.File> getUploadFilesAsFiles(java.lang.String fileRepository)
                                                          throws java.lang.Exception
Returns a list of upload files. Each item in the list is an instance of java.io.File instance.

Parameters:
fileRepository -
Returns:
a list of upload files (File)
Throws:
java.lang.Exception

getUploadFiles

public static java.util.List<UploadFile> getUploadFiles()
                                                 throws java.lang.Exception
Returns a list of upload files. Each item in the list is an instance of UploadFile instance.

Returns:
a list of upload files (UploadFile)
Throws:
java.lang.Exception

getUploadFilesMap

public static java.util.Map<java.lang.String,UploadFile> getUploadFilesMap()
                                                                    throws java.lang.Exception
Returns a map of upload files. In each key/value pair, the key is the field name in the HTTP form, and the value is a UploadFile instance.

Returns:
a map of field/upload file (UploadFile) pairs
Throws:
java.lang.Exception

getUploadFile

public static UploadFile getUploadFile(java.lang.String key)
                                throws java.lang.Exception
Returns an upload file which is an instance of UploadFile.

Returns:
an instance of UploadFile
Throws:
java.lang.Exception

render

public static java.lang.String render(java.lang.Object content)
Renders content. The format of the response is derived from request extension. The default format is html which is defined by Constants.DEFAULT_RESPONSE_FORMAT.

Parameters:
content - The content to be sent.
Returns:
a token of render

render

public static java.lang.String render(java.lang.Object content,
                                      java.lang.String format)
Renders content associated with a specific request format. The default format is html which is defined by Constants.DEFAULT_RESPONSE_FORMAT.

Parameters:
content - The content to be sent.
format - The request format.
Returns:
a token of render

publishFile

public static void publishFile(java.io.File file)
Publishes a file for display.

Parameters:
file - The file to be published.

publishFile

public static void publishFile(java.io.File file,
                               java.lang.String mimeType)
Publishes a file for display.

Parameters:
file - The file to be published.
mimeType - The content MIME type.

publishFile

public static void publishFile(java.io.File file,
                               java.lang.String displayableName,
                               boolean forDownload)
Publishes a file. Its MIME type is detected from the file extension.

The file extension detection rule is as follows: 1. If the file input has an extension, use it. Otherwise, 2. If the displayableName input has an extension, use it.

Parameters:
file - The file to be published.
displayableName - The display name of the file in the download dialog.
forDownload - indicates whether this is for file download or display.

publishFile

public static void publishFile(java.io.File file,
                               java.lang.String displayableName,
                               java.lang.String mimeType,
                               boolean forDownload)
Publishes a file. If the mimeType is empty, it is default to application/octet-stream.

Parameters:
file - The file to be published.
displayableName - The display name of the file in the download dialog.
mimeType - The content MIME type.
forDownload - indicates whether this is for file download or display.

isTextFile

public static boolean isTextFile(java.io.File file)
Checks whether a file is a text file.

Parameters:
file - the file to check
Returns:
true if it is a text file.

getFileExtension

public static java.lang.String getFileExtension(java.io.File file)
Returns the file extension.

Parameters:
file - the file to check
Returns:
file extension or null

getViewDataMap

public static java.util.Map<java.lang.String,java.lang.Object> getViewDataMap()
Returns all view data as a map. This includes data in both parameter scope and request scope.

Returns:
a map of all view data

renderView

public static java.lang.String renderView(java.lang.String view)
Renders a view template file with all properties in the container. The file extension of the view template is used to look up related template engine. If the view does not have an extension specified, the default extension is defined by view.extension property in the environment.properties file.

Examples:

   //render view file show.jsp
   renderView("show");
   
   //render view .../WEB-INF/views/products/show.jsp
   renderView("products/show");
   
   //render view file /home/foo/templates/show.st with StringTemplate engine
   renderView("/home/foo/templates/show.st");
   
   //render view file show.jsp and return result in text format
   renderView("show", "text");
 

Parameters:
view - The render template file
Returns:
rendered content

renderView

public static java.lang.String renderView(java.lang.String view,
                                          java.lang.String format)
Renders a view template file with all properties in the container. The file extension of the view template is used to look up related template engine. If the view does not have an extension specified, the default extension is defined by view.extension property in the environment.properties file.

Examples:

   //render view file show.jsp
   renderView("show");
   
   //render view .../WEB-INF/views/products/show.jsp
   renderView("products/show");
   
   //render view file /home/foo/templates/show.st with StringTemplate engine
   renderView("/home/foo/templates/show.st");
   
   //render view file show.jsp and return result in text format
   renderView("show", "text");
 

The response format does not apply to jsp views.

Parameters:
view - The render template file
format - the response format
Returns:
rendered content

renderView

public static java.lang.String renderView(java.lang.String view,
                                          java.util.Map<java.lang.String,java.lang.Object> viewDataMap)
Renders a view template file with view data in viewDataMap. The file extension of the view template is used to look up related template engine. If the view does not have an extension specified, the default extension is defined by view.extension property in the environment.properties file.

Parameters:
view - the render template file
viewDataMap - data (name/value pairs) to be passed to the view
Returns:
rendered content

renderView

public static java.lang.String renderView(java.lang.String view,
                                          java.lang.String format,
                                          java.util.Map<java.lang.String,java.lang.Object> viewDataMap)
Renders a view template file with view data in viewDataMap. The file extension of the view template is used to look up related template engine. If the view does not have an extension specified, the default extension is defined by view.extension property in the environment.properties file.

Examples:

 //return a view coded in String Template as html
 return renderView("paged_list.st", "html", map);
 
 //return a view coded in FreeMarker Template as text
 return renderView("paged_list.ftl", "text", map);
 

Parameters:
view - the render template file
format - response format of the render template file
viewDataMap - data (name/value pairs) to be passed to the view
Returns:
rendered content

doForward

public static void doForward(java.lang.String uri,
                             javax.servlet.http.HttpServletRequest request,
                             javax.servlet.http.HttpServletResponse response)
                      throws java.io.IOException,
                             javax.servlet.ServletException

Do a forward to specified URI using a RequestDispatcher. This method is used by all methods needing to do a forward.

Parameters:
uri - Context-relative URI to forward to
request - HTTP servlet request
response - HTTP servlet response
Throws:
java.io.IOException
javax.servlet.ServletException

filterManagerFor

public static FilterManager filterManagerFor(java.lang.Class<?> clazz)
Returns the FilterManager for a class type.