|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.struts2.dispatcher.mapper.DefaultActionMapper
public class DefaultActionMapper
Default action mapper implementation, using the standard *.[ext] (where ext usually "action") pattern. The extension is looked up from the Struts configuration key struts.action.exection.
To help with dealing with buttons and other related requirements, this mapper (and otherActionMappers, we hope) has the ability to name a
button with some predefined prefix and have that button name alter the
execution behaviour. The four prefixes are:
<!-- START SNIPPET: method-example -->
<a:form action="baz">
<a:textfield label="Enter your name" name="person.name"/>
<a:submit value="Create person"/>
<a:submit name="method:anotherMethod" value="Cancel"/>
</a:form>
<!-- END SNIPPET: method-example -->
Action prefix
With action-prefix, instead of executing baz action's execute() method (by
default if it isn't overriden in struts.xml to be something else), the
anotherAction action's execute() method (assuming again if it isn't overriden
with something else in struts.xml) will be executed.
<!-- START SNIPPET: action-example -->
<a:form action="baz">
<a:textfield label="Enter your name" name="person.name"/>
<a:submit value="Create person"/>
<a:submit name="action:anotherAction" value="Cancel"/>
</a:form>
<!-- END SNIPPET: action-example -->
Redirect prefix
With redirect-prefix, instead of executing baz action's execute() method (by
default it isn't overriden in struts.xml to be something else), it will get
redirected to, in this case to www.google.com. Internally it uses
ServletRedirectResult to do the task.
<!-- START SNIPPET: redirect-example -->
<a:form action="baz">
<a:textfield label="Enter your name" name="person.name"/>
<a:submit value="Create person"/>
<a:submit name="redirect:www.google.com" value="Cancel"/>
</a:form>
<!-- END SNIPPET: redirect-example -->
Redirect-action prefix
With redirect-action-prefix, instead of executing baz action's execute()
method (by default it isn't overriden in struts.xml to be something else), it
will get redirected to, in this case 'dashboard.action'. Internally it uses
ServletRedirectResult to do the task and read off the extension from the
struts.properties.
<!-- START SNIPPET: redirect-action-example -->
<a:form action="baz">
<a:textfield label="Enter your name" name="person.name"/>
<a:submit value="Create person"/>
<a:submit name="redirect-action:dashboard" value="Cancel"/>
</a:form>
<!-- END SNIPPET: redirect-action-example -->
| Nested Class Summary | |
|---|---|
(package private) static interface |
DefaultActionMapper.ParameterAction
Defines a parameter action prefix |
| Field Summary | |
|---|---|
(package private) static String |
ACTION_PREFIX
|
private boolean |
allowDynamicMethodCalls
|
private boolean |
allowSlashesInActionNames
|
private boolean |
alwaysSelectFullNamespace
|
private Container |
container
|
(package private) List |
extensions
|
(package private) static String |
METHOD_PREFIX
|
private PrefixTrie |
prefixTrie
|
(package private) static String |
REDIRECT_ACTION_PREFIX
|
(package private) static String |
REDIRECT_PREFIX
|
| Constructor Summary | |
|---|---|
DefaultActionMapper()
|
|
| Method Summary | |
|---|---|
(package private) String |
dropExtension(String name)
Drops the extension from the action name |
(package private) String |
getDefaultExtension()
Returns null if no extension is specified. |
ActionMapping |
getMapping(HttpServletRequest request,
ConfigurationManager configManager)
Expose the ActionMapping for the current request |
(package private) String |
getUri(HttpServletRequest request)
Gets the uri from the request |
String |
getUriFromActionMapping(ActionMapping mapping)
Convert an ActionMapping into a URI string |
void |
handleSpecialParameters(HttpServletRequest request,
ActionMapping mapping)
Special parameters, as described in the class-level comment, are searched for and handled. |
boolean |
isSlashesInActionNames()
|
(package private) void |
parseNameAndNamespace(String uri,
ActionMapping mapping,
ConfigurationManager configManager)
Parses the name and namespace from the uri |
void |
setAllowDynamicMethodCalls(String allow)
|
void |
setAlwaysSelectFullNamespace(String val)
|
void |
setContainer(Container container)
|
void |
setExtensions(String extensions)
|
void |
setSlashesInActionNames(String allow)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
static final String METHOD_PREFIX
static final String ACTION_PREFIX
static final String REDIRECT_PREFIX
static final String REDIRECT_ACTION_PREFIX
private boolean allowDynamicMethodCalls
private boolean allowSlashesInActionNames
private boolean alwaysSelectFullNamespace
private PrefixTrie prefixTrie
List extensions
private Container container
| Constructor Detail |
|---|
public DefaultActionMapper()
| Method Detail |
|---|
public void setAllowDynamicMethodCalls(String allow)
public void setSlashesInActionNames(String allow)
public void setAlwaysSelectFullNamespace(String val)
public void setContainer(Container container)
public ActionMapping getMapping(HttpServletRequest request,
ConfigurationManager configManager)
ActionMapper
getMapping in interface ActionMapperrequest - The servlet requestconfigManager - The current configuration manager
public void handleSpecialParameters(HttpServletRequest request,
ActionMapping mapping)
request - The requestmapping - The action mapping
void parseNameAndNamespace(String uri,
ActionMapping mapping,
ConfigurationManager configManager)
uri - The urimapping - The action mapping to populateString dropExtension(String name)
name - The action name
String getDefaultExtension()
public void setExtensions(String extensions)
String getUri(HttpServletRequest request)
request - The request
public String getUriFromActionMapping(ActionMapping mapping)
ActionMapper
getUriFromActionMapping in interface ActionMappermapping - The action mapping
public boolean isSlashesInActionNames()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||