|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.struts2.convention.ConventionUnknownHandler
public class ConventionUnknownHandler
This class is the default unknown handler for all of the Convention plugin integration with XWork. This handles instances when a URL doesn't have an action associated with it but does a viable result and also the instance where an action returns a result code that isn't already configured but there is a viable result for the code.
This class also handles all of the index actions using redirects and actions in nested packages. For example, if there is an action /foo/index and the URL /foo is used, this will render the index action in the /foo namespace.
Nested Class Summary | |
---|---|
static class |
ConventionUnknownHandler.Resource
|
Field Summary | |
---|---|
protected Configuration |
configuration
|
protected String |
defaultParentPackageName
|
protected com.opensymphony.xwork2.ObjectFactory |
objectFactory
|
protected com.opensymphony.xwork2.config.entities.PackageConfig |
parentPackage
|
protected ResultMapBuilder |
resultMapBuilder
|
protected javax.servlet.ServletContext |
servletContext
|
Constructor Summary | |
---|---|
ConventionUnknownHandler(Configuration configuration,
com.opensymphony.xwork2.ObjectFactory objectFactory,
javax.servlet.ServletContext servletContext,
com.opensymphony.xwork2.inject.Container container,
String defaultParentPackageName,
String redirectToSlash,
String nameSeparator)
Constructs the unknown handler. |
Method Summary | |
---|---|
protected com.opensymphony.xwork2.config.entities.ActionConfig |
buildActionConfig(String path,
com.opensymphony.xwork2.config.entities.ResultTypeConfig resultTypeConfig)
|
protected com.opensymphony.xwork2.Result |
buildResult(String path,
String resultCode,
com.opensymphony.xwork2.config.entities.ResultTypeConfig config,
com.opensymphony.xwork2.ActionContext invocationContext)
|
protected String |
canonicalize(String path)
|
protected String |
determinePath(com.opensymphony.xwork2.config.entities.ActionConfig actionConfig,
String namespace)
Determines the result path prefix that the request URL is for, minus the action name. |
protected ConventionUnknownHandler.Resource |
findResource(Map<String,com.opensymphony.xwork2.config.entities.ResultTypeConfig> resultsByExtension,
String... parts)
Finds a resource using the given path parts and all of the extensions in the map. |
protected com.opensymphony.xwork2.Result |
findResult(String path,
String resultCode,
String ext,
com.opensymphony.xwork2.ActionContext actionContext,
Map<String,com.opensymphony.xwork2.config.entities.ResultTypeConfig> resultsByExtension)
|
com.opensymphony.xwork2.config.entities.ActionConfig |
handleUnknownAction(String namespace,
String actionName)
|
Object |
handleUnknownActionMethod(Object action,
String methodName)
Not used |
com.opensymphony.xwork2.Result |
handleUnknownResult(com.opensymphony.xwork2.ActionContext actionContext,
String actionName,
com.opensymphony.xwork2.config.entities.ActionConfig actionConfig,
String resultCode)
|
protected String |
string(String... parts)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected Configuration configuration
protected com.opensymphony.xwork2.ObjectFactory objectFactory
protected javax.servlet.ServletContext servletContext
protected ResultMapBuilder resultMapBuilder
protected String defaultParentPackageName
protected com.opensymphony.xwork2.config.entities.PackageConfig parentPackage
Constructor Detail |
---|
public ConventionUnknownHandler(Configuration configuration, com.opensymphony.xwork2.ObjectFactory objectFactory, javax.servlet.ServletContext servletContext, com.opensymphony.xwork2.inject.Container container, String defaultParentPackageName, String redirectToSlash, String nameSeparator)
configuration
- The XWork configuration.objectFactory
- The XWork object factory used to create result instances.servletContext
- The servlet context used to help build the action configurations.container
- The Xwork containerdefaultParentPackageName
- The default XWork package that the unknown handler will use as
the parent package for new actions and results.redirectToSlash
- A boolean parameter that controls whether or not this will handle
unknown actions in the same manner as Apache, Tomcat and other web servers. This
handling will send back a redirect for URLs such as /foo to /foo/ if there doesn't
exist an action that responds to /foo.nameSeparator
- The character used as word separator in the action names. "-" by defaultMethod Detail |
---|
public com.opensymphony.xwork2.config.entities.ActionConfig handleUnknownAction(String namespace, String actionName) throws com.opensymphony.xwork2.XWorkException
handleUnknownAction
in interface com.opensymphony.xwork2.UnknownHandler
com.opensymphony.xwork2.XWorkException
protected ConventionUnknownHandler.Resource findResource(Map<String,com.opensymphony.xwork2.config.entities.ResultTypeConfig> resultsByExtension, String... parts)
resultsByExtension
- Map of extension to result type config objects.parts
- The parts of the resource.
protected String canonicalize(String path)
protected com.opensymphony.xwork2.config.entities.ActionConfig buildActionConfig(String path, com.opensymphony.xwork2.config.entities.ResultTypeConfig resultTypeConfig)
public com.opensymphony.xwork2.Result handleUnknownResult(com.opensymphony.xwork2.ActionContext actionContext, String actionName, com.opensymphony.xwork2.config.entities.ActionConfig actionConfig, String resultCode) throws com.opensymphony.xwork2.XWorkException
handleUnknownResult
in interface com.opensymphony.xwork2.UnknownHandler
com.opensymphony.xwork2.XWorkException
protected com.opensymphony.xwork2.Result findResult(String path, String resultCode, String ext, com.opensymphony.xwork2.ActionContext actionContext, Map<String,com.opensymphony.xwork2.config.entities.ResultTypeConfig> resultsByExtension)
protected com.opensymphony.xwork2.Result buildResult(String path, String resultCode, com.opensymphony.xwork2.config.entities.ResultTypeConfig config, com.opensymphony.xwork2.ActionContext invocationContext)
protected String string(String... parts)
protected String determinePath(com.opensymphony.xwork2.config.entities.ActionConfig actionConfig, String namespace)
actionConfig
- (Optional) The might be a ConventionActionConfig, from which we can get the
default base result location of that specific action.namespace
- The current URL namespace.
public Object handleUnknownActionMethod(Object action, String methodName) throws NoSuchMethodException
handleUnknownActionMethod
in interface com.opensymphony.xwork2.UnknownHandler
NoSuchMethodException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |