org.mentawai.core
Class ActionConfig

java.lang.Object
  extended by org.mentawai.core.ActionConfig
Direct Known Subclasses:
ClassActionConfig, CoCActionConfig, GuiceActionConfig, RubyActionConfig, SingleInstanceActionConfig, SpringActionConfig

public class ActionConfig
extends Object

An ActionConfig links together an action implementation, an action name or alias, action results and action consequences. It makes it possible for an action implementation to be re-used in different situations with different names and consequences.

Author:
Sergio Oliveira

Field Summary
protected  Class<? extends Object> actionClass
           
 
Constructor Summary
ActionConfig(Class<? extends Object> klass)
          Creates an ActionConfig for the given action implementation.
ActionConfig(Class<? extends Object> klass, String innerAction)
          Creates an ActionConfig with the given name for the given inner action implementation.
ActionConfig(String name, Class<? extends Object> klass)
          Creates an ActionConfig with the given name for the given action implementation.
ActionConfig(String name, Class<? extends Object> klass, String innerAction)
          Creates an ActionConfig for the given action implementation.
 
Method Summary
 ActionConfig addConsequence(String result, Consequence c)
          Adds a consequence for the given result.
 ActionConfig addConsequence(String result, String innerAction, Consequence c)
          Adds a consequence for the given result of the given inner action.
 ActionConfig addFilter(Filter filter)
          Adds a filter for the action.
 ActionConfig addFilter(Filter filter, String... args)
          Adds a filter to a list of inner actions.
 ActionConfig addFilter(Filter filter, String innerAction)
          Adds a filter for this inner action.
 ActionConfig addFilter(List filters)
          Adds a list of filter for the action.
 ActionConfig addFilter(List filters, String innerAction)
          Adds a list of filter for the inner action.
 ActionConfig addFilterFirst(Filter filter)
          Adds a filter that will be executed before the global filters.
 ActionConfig addFilterFirst(Filter filter, String innerAction)
          Adds a filter that will be executed before the global filters.
 ActionConfig addFilterFirst(List filters)
          Add a list of filters that will be executed before the global filters.
 ActionConfig addFilterFirst(List filters, String innerAction)
          Adds a list of filters that will be executed before the global filters.
 ActionConfig ajaxError(AjaxRenderer renderer)
          Shorter version of a AjaxConsequence error.
 ActionConfig ajaxOk(AjaxRenderer renderer)
          Shorter version of a AjaxConsequence success.
 ActionConfig all(Consequence c)
           
 ActionConfig authorize(Enum<?>... es)
           
 ActionConfig authorize(String... groups)
           
 ActionConfig bypassAuthentication()
          Indicate that this action should NOT be authenticated.
 ActionConfig catchAll(Consequence c)
           
 ActionConfig chainError(ActionConfig actionConfig)
          Shorter version of chain on error
 ActionConfig chainOk(ActionConfig actionConfig)
          Shorter version of chain on success
 ActionConfig comeBackAfterLogin()
          Indicate that this action redirects after login.
 ActionConfig fileUpload()
           
 ActionConfig fileUpload(int maxInMemorySize)
           
 ActionConfig fileUpload(int maxInMemorySize, int maxSizeToThrowError)
           
 ActionConfig fileUpload(int maxInMemorySize, int maxSizeToThrowError, String tempDirInsideWebInf)
           
 ActionConfig fileUpload(int maxInMemorySize, String tempDirInsideWebInf)
           
 ActionConfig filter(Filter filter)
          Shorter version of addFilter.
 ActionConfig filter(Filter filter, String... args)
          Shorter version.
 ActionConfig filter(Filter filter, String innerAction)
          Shorter version of addFilter.
 ActionConfig filter(List filters)
          Shorter version of addFilter.
 ActionConfig filter(List filters, String innerAction)
          Shorter version of addFilter.
 ActionConfig filterFirst(Filter filter)
          Add a list of filters that will be executed before the global filters.
 ActionConfig filterFirst(Filter filter, String innerAction)
          Add a list of filters that will be executed before the global filters.
 ActionConfig filterFirst(List filters)
          Add a list of filters that will be executed before the global filters.
 ActionConfig filterFirst(List filters, String innerAction)
          Add a list of filters that will be executed before the global filters.
 ActionConfig fwdError(String page)
          Shorter version of a forward on error.
 ActionConfig fwdOk(String page)
          Shorter version of a forward on success.
 Action getAction()
          Returns an action instance to be used with this request.
 Class<? extends Object> getActionClass()
          Returns the action class for this action config.
 Consequence getAutoConsequence(String result, String innerAction)
           
 Consequence getCatchAll()
           
 Consequence getConsequence(String result)
          Gets the consequence for the given result.
 Consequence getConsequence(String result, String innerAction)
          Gets the consequence for the given result of the given inner action.
protected  String getDirFromClass(Class klass)
          This method will imply a directory name from the action class name.
 List<Filter> getFilters()
          Returns the filters for this action.
 List<Filter> getFilters(String innerAction)
          Returns the filters for this inner action.
 List<Filter> getFirstFilters(String innerAction)
          Returns the filters for this inner action, that will be executed before the global filters.
 String getInnerAction()
          Gets the inner action that this action config represents.
 String getName()
          Gets the name or alias of this ActionConfig.
 ActionConfig internalOnly()
           
 boolean isInternalOnly()
           
 ActionConfig methodParams(String... params)
           
 ActionConfig on(String result, Consequence c)
          Shorter version of addConsequence.
 ActionConfig on(String result, String jsp)
          Shorter verions of addConsequence that will assume a forward.
 ActionConfig on(String result, String innerAction, Consequence c)
          Shorter version of addConsequence.
 ActionConfig prettyURLParams(String... params)
           
 ActionConfig redirError()
          Shorter version of a redir on error.
 ActionConfig redirError(String page)
          Shorter version of a redir on error.
 ActionConfig redirError(String page, boolean flag)
          Shorter version of a redir on error.
 ActionConfig redirOk()
          Shorter version of a redir on success.
 ActionConfig redirOk(String page)
          Shorter version of a redir on success.
 ActionConfig redirOk(String page, boolean flag)
          Shorter version of a redir on success.
 boolean shouldBypassAuthentication()
           
 boolean shouldRedirectAfterLogin()
           
 String toString()
          Returns the name of this ActionConfig.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

actionClass

protected final Class<? extends Object> actionClass
Constructor Detail

ActionConfig

public ActionConfig(Class<? extends Object> klass)
Creates an ActionConfig for the given action implementation. This action config will use the name of the action to derive its name. This can and should also be used with chain consequence! org.myapp.blablabla.MyAction The name will be: /MyAction

Parameters:
klass - The action implementation to use

ActionConfig

public ActionConfig(String name,
                    Class<? extends Object> klass)
Creates an ActionConfig with the given name for the given action implementation.

Parameters:
name - The name or alias of this ActionConfig
klass - The action implementation to use

ActionConfig

public ActionConfig(String name,
                    Class<? extends Object> klass,
                    String innerAction)
Creates an ActionConfig for the given action implementation. This action config will use the name of the action to derive its name. This can and should also be used with chain consequence! Notice that this action config is specific to an inner action. org.myapp.blablabla.MyAction The name will be: /MyAction

Parameters:
name - The name or alias of this ActionConfig
klass - The action implementation to use
innerAction - The inner action to use

ActionConfig

public ActionConfig(Class<? extends Object> klass,
                    String innerAction)
Creates an ActionConfig with the given name for the given inner action implementation. Notice that this action config is specific to an inner action.

Parameters:
klass - The action implementation to use
innerAction - The inner action to use
Method Detail

getDirFromClass

protected String getDirFromClass(Class klass)
This method will imply a directory name from the action class name. The action can then use this directory to look for JSPs in case of automatically page discovery. Ex: Action = examples.helloworld.HelloWorldAction Directory = /helloworld

Parameters:
klass - The action class name
Returns:
a directory where to look for JSPs

addConsequence

public ActionConfig addConsequence(String result,
                                   Consequence c)
Adds a consequence for the given result. An action must have a consequence for each of its possible results.

Parameters:
result - A possible result of this ActionConfig
c - The consequence for this result
Returns:
this action config for method chaining. Ex: addConsequence().addConsequence();

internalOnly

public ActionConfig internalOnly()

isInternalOnly

public boolean isInternalOnly()

bypassAuthentication

public ActionConfig bypassAuthentication()
Indicate that this action should NOT be authenticated. (For registration, login, etc.)

Returns:
this action config
Since:
2.4.0

fileUpload

public ActionConfig fileUpload()

fileUpload

public ActionConfig fileUpload(int maxInMemorySize)

fileUpload

public ActionConfig fileUpload(int maxInMemorySize,
                               int maxSizeToThrowError)

fileUpload

public ActionConfig fileUpload(int maxInMemorySize,
                               String tempDirInsideWebInf)

fileUpload

public ActionConfig fileUpload(int maxInMemorySize,
                               int maxSizeToThrowError,
                               String tempDirInsideWebInf)

shouldBypassAuthentication

public boolean shouldBypassAuthentication()

prettyURLParams

public ActionConfig prettyURLParams(String... params)

methodParams

public ActionConfig methodParams(String... params)

comeBackAfterLogin

public ActionConfig comeBackAfterLogin()
Indicate that this action redirects after login.

Returns:
this action config
Since:
2.4.0

shouldRedirectAfterLogin

public boolean shouldRedirectAfterLogin()

on

public ActionConfig on(String result,
                       Consequence c)
Shorter version of addConsequence.

Parameters:
result -
c -
Returns:
this action config
Since:
1.2

on

public ActionConfig on(String result,
                       String jsp)
Shorter verions of addConsequence that will assume a forward.

Parameters:
result -
jsp -
Returns:
this action config
Since:
1.9

addConsequence

public ActionConfig addConsequence(String result,
                                   String innerAction,
                                   Consequence c)
Adds a consequence for the given result of the given inner action. An inner action can have a consequence for each of its possible results. If you don't define consequences for an inner action, the consequences of the main action (execute() method) is used instead.

Parameters:
result - A possible result of this ActionConfig
innerAction - The inner action that can return this result.
c - The consequence for this result
Returns:
this action config for method chaining Ex: addConsequence().addConsequence();
Throws:
IllegalStateException - If this method is called for a action config specific to an inner action

on

public ActionConfig on(String result,
                       String innerAction,
                       Consequence c)
Shorter version of addConsequence.

Parameters:
result -
innerAction -
c -
Returns:
this action config
Since:
1.2

addFilter

public ActionConfig addFilter(Filter filter)
Adds a filter for the action.

Parameters:
filter - The filter to add for this action.
Returns:
this action config for method chaining Ex: addConsequence().addFilter();

authorize

public ActionConfig authorize(Enum<?>... es)

authorize

public ActionConfig authorize(String... groups)

filter

public ActionConfig filter(Filter filter)
Shorter version of addFilter.

Parameters:
filter -
Returns:
this action config
Since:
1.2

getCatchAll

public Consequence getCatchAll()

catchAll

public ActionConfig catchAll(Consequence c)

all

public ActionConfig all(Consequence c)

addFilter

public ActionConfig addFilter(Filter filter,
                              String innerAction)
Adds a filter for this inner action.

Parameters:
filter - The filter to add for this inner action.
innerAction - the inner action
Returns:
this action config for method chaining Ex: addConsequence().addFilter();
Since:
1.1.1

filterFirst

public ActionConfig filterFirst(List filters)
Add a list of filters that will be executed before the global filters.

Parameters:
filters -
Returns:
this
Since:
1.9

filterFirst

public ActionConfig filterFirst(List filters,
                                String innerAction)
Add a list of filters that will be executed before the global filters.

Parameters:
filters -
innerAction -
Returns:
this
Since:
1.9

filterFirst

public ActionConfig filterFirst(Filter filter)
Add a list of filters that will be executed before the global filters.

Parameters:
filter -
Returns:
this
Since:
1.9

filterFirst

public ActionConfig filterFirst(Filter filter,
                                String innerAction)
Add a list of filters that will be executed before the global filters.

Parameters:
filter -
innerAction -
Returns:
this
Since:
1.9

addFilterFirst

public ActionConfig addFilterFirst(List filters)
Add a list of filters that will be executed before the global filters.

Parameters:
filters -
Returns:
this
Since:
1.9

addFilterFirst

public ActionConfig addFilterFirst(List filters,
                                   String innerAction)
Adds a list of filters that will be executed before the global filters.

Parameters:
filters -
innerAction -
Returns:
this
Since:
1.9

addFilterFirst

public ActionConfig addFilterFirst(Filter filter)
Adds a filter that will be executed before the global filters.

Parameters:
filter -
Returns:
this
Since:
1.9

addFilterFirst

public ActionConfig addFilterFirst(Filter filter,
                                   String innerAction)
Adds a filter that will be executed before the global filters.

Parameters:
filter -
innerAction -
Returns:
this
Since:
1.9

filter

public ActionConfig filter(Filter filter,
                           String innerAction)
Shorter version of addFilter.

Parameters:
filter -
innerAction -
Returns:
this action config
Since:
1.2

addFilter

public ActionConfig addFilter(List filters)
Adds a list of filter for the action.

Parameters:
filters - A list of filters.
Returns:
this action config for method chaining Ex: addConsequence().addFilter();

filter

public ActionConfig filter(List filters)
Shorter version of addFilter.

Parameters:
filters -
Returns:
this action config
Since:
1.2

fwdOk

public ActionConfig fwdOk(String page)
Shorter version of a forward on success.

Parameters:
page -
Returns:
this
Since:
1.3

fwdError

public ActionConfig fwdError(String page)
Shorter version of a forward on error.

Parameters:
page -
Returns:
this
Since:
1.3

ajaxOk

public ActionConfig ajaxOk(AjaxRenderer renderer)
Shorter version of a AjaxConsequence success.

Parameters:
renderer -
Returns:
this
Since:
1.10.1

ajaxError

public ActionConfig ajaxError(AjaxRenderer renderer)
Shorter version of a AjaxConsequence error.

Parameters:
renderer -
Returns:
this
Since:
1.10.1

redirOk

public ActionConfig redirOk(String page)
Shorter version of a redir on success.

Parameters:
page -
Returns:
this
Since:
1.3

redirError

public ActionConfig redirError(String page)
Shorter version of a redir on error.

Parameters:
page -
Returns:
this
Since:
1.3

redirOk

public ActionConfig redirOk()
Shorter version of a redir on success.

Returns:
this
Since:
1.3

redirError

public ActionConfig redirError()
Shorter version of a redir on error.

Returns:
this
Since:
1.3

redirOk

public ActionConfig redirOk(String page,
                            boolean flag)
Shorter version of a redir on success.

Parameters:
page -
flag -
Returns:
this
Since:
1.3

redirError

public ActionConfig redirError(String page,
                               boolean flag)
Shorter version of a redir on error.

Parameters:
page -
flag -
Returns:
this
Since:
1.3

chainOk

public ActionConfig chainOk(ActionConfig actionConfig)
Shorter version of chain on success

Parameters:
actionConfig -
Returns:
this
Since:
2.0.1

chainError

public ActionConfig chainError(ActionConfig actionConfig)
Shorter version of chain on error

Parameters:
actionConfig -
Returns:
this
Since:
2.0.1

addFilter

public ActionConfig addFilter(List filters,
                              String innerAction)
Adds a list of filter for the inner action.

Parameters:
filters - A list of filters
innerAction - the inner action
Returns:
this action config for method chaining Ex: addConsequence().addFilter();
Since:
1.1.1

addFilter

public ActionConfig addFilter(Filter filter,
                              String... args)
Adds a filter to a list of inner actions.

Parameters:
filter - The filter to add
args - The list of inner actions
Returns:
this
Since:
1.11

filter

public ActionConfig filter(Filter filter,
                           String... args)
Shorter version.

Parameters:
filter -
args -
Returns:
this action config
Since:
1.11

filter

public ActionConfig filter(List filters,
                           String innerAction)
Shorter version of addFilter.

Parameters:
filters -
innerAction -
Returns:
this action config
Since:
1.2

getFilters

public List<Filter> getFilters()
Returns the filters for this action.

Returns:
The filters for this action.

getFilters

public List<Filter> getFilters(String innerAction)
Returns the filters for this inner action.

Parameters:
innerAction - the inner action.
Returns:
The filters for this action.
Since:
1.1.1

getFirstFilters

public List<Filter> getFirstFilters(String innerAction)
Returns the filters for this inner action, that will be executed before the global filters.

Parameters:
innerAction - the inner action.
Returns:
The filters for this action.
Since:
1.9

getName

public String getName()
Gets the name or alias of this ActionConfig.

Returns:
The name or alias of this ActionConfig.

getInnerAction

public String getInnerAction()
Gets the inner action that this action config represents.

Returns:
The inner action name that his action represents.

getConsequence

public Consequence getConsequence(String result)
Gets the consequence for the given result.

Parameters:
result - The result for what to get the consequence
Returns:
The consequence associated with the result.

getConsequence

public Consequence getConsequence(String result,
                                  String innerAction)
Gets the consequence for the given result of the given inner action.

Parameters:
result - The result for what to get the consequence
innerAction - The innerAction from where to get the consequence.
Returns:
The consequence associated with the result and the inner action.

getAutoConsequence

public Consequence getAutoConsequence(String result,
                                      String innerAction)

getAction

public Action getAction()
Returns an action instance to be used with this request. Mentawai creates a new action instance for each request. You can extend ActionConfig and override this class to integrate Mentawai with other IoC containers, that may want to create the action themselves.

Returns:
The action instance to use for the request.

getActionClass

public Class<? extends Object> getActionClass()
Returns the action class for this action config.

Returns:
The action class for this action config.
Since:
1.2.1

toString

public String toString()
Returns the name of this ActionConfig. Ex: /HelloWorld, /customers/add, etc.

Overrides:
toString in class Object
Returns:
The name of this action.


Copyright © 2013. All Rights Reserved.