org.hdiv.dispatcher.mapper
Class HDIVActionMapper
java.lang.Object
org.hdiv.dispatcher.mapper.HDIVActionMapper
- All Implemented Interfaces:
- org.apache.struts2.dispatcher.mapper.ActionMapper
public class HDIVActionMapper
- extends java.lang.Object
- implements org.apache.struts2.dispatcher.mapper.ActionMapper
HDIV 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 other
ActionMappers, 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:
- Method prefix - method:default
- Action prefix - action:dashboard
- Redirect prefix - redirect:cancel.jsp
- Redirect-action prefix - redirect-action:cancel
In addition to these four prefixes, this mapper also understands the action
naming pattern of foo!bar in either the extension form (eg:
foo!bar.action) or in the prefix form (eg: action:foo!bar). This syntax tells this
mapper to map to the action named foo and the method bar. Method Prefix With method-prefix, instead of calling baz action's execute() method (by
default if it isn't overriden in struts.xml to be something else), the baz
action's anotherMethod() will be called. A very elegant way determine which button
is clicked. Alternatively, one would have submit button set a particular value on
the action when clicked, and the execute() method decides on what to do with the
setted value depending on which button is clicked.
<!-- 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 -->
- Author:
- Gorka Vicente
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
HDIVActionMapper
public HDIVActionMapper()
setAllowDynamicMethodCalls
public void setAllowDynamicMethodCalls(java.lang.String allow)
setSlashesInActionNames
public void setSlashesInActionNames(java.lang.String allow)
setAlwaysSelectFullNamespace
public void setAlwaysSelectFullNamespace(java.lang.String val)
setContainer
public void setContainer(com.opensymphony.xwork2.inject.Container container)
getMapping
public org.apache.struts2.dispatcher.mapper.ActionMapping getMapping(javax.servlet.http.HttpServletRequest request,
com.opensymphony.xwork2.config.ConfigurationManager configManager)
- Specified by:
getMapping in interface org.apache.struts2.dispatcher.mapper.ActionMapper
handleSpecialParameters
public void handleSpecialParameters(javax.servlet.http.HttpServletRequest request,
org.apache.struts2.dispatcher.mapper.ActionMapping mapping)
- Special parameters, as described in the class-level comment, are searched for
and handled.
- Parameters:
request - The requestmapping - The action mapping
setExtensions
public void setExtensions(java.lang.String extensions)
getUriFromActionMapping
public java.lang.String getUriFromActionMapping(org.apache.struts2.dispatcher.mapper.ActionMapping mapping)
- Specified by:
getUriFromActionMapping in interface org.apache.struts2.dispatcher.mapper.ActionMapper
getExtensions
public java.util.List getExtensions()
- Returns:
- Returns the extensions.
Copyright © 2008 hdiv.org. All Rights Reserved.