Name | Codebehind Plugin |
---|---|
Publisher | Apache Software Foundation |
Quality Grade | Experimental - WW-1515 |
License | Open Source (ASL2) |
Version | Bundled with Struts 2 |
Homepage | |
Download |
Overview
The Codebehind Plugin
Excerpt |
---|
reduces mundane configuration by adding |
"Page Controller" conventions |
to the framework for the purpose of reducing the amount of mundane configuration. There are two common situations where the plugin applies convention over configuration:
...
To see the plugin in action, review the "Person Manager" example in the Showcase application.
Features
- Provides default mappings for pages that don't have Actions
- Provides default results by auto-discovering pages
Usage
To use this plugin, simply copy its jar into your application. The plugin can be used to find default mappings and results.
Default Mappings
To better facilitate a code-behind development approach, the plugin will detect the case where the request has no defined Struts action mapping, yet there exists a corresonding corresponding page. It will then create a dummy action mapping referencing the default Action class (usually ActionSupport), allowing the page to be displayed normally. Additionally, the default interceptor stack for the configured package will be applied, bringing the workflow benefits of interceptor stacks to simple pages.
...
If any of those pages are found, the plugin will construct an ActionConfig object on the fly, using the ActionSupport class for the Action and a single Result that points to the discovered page. The ActionConfig will be put in the configured package, meaning that it will inherit the default Interceptor stack for that package. The default package is codebehind-default
, however, it can be configured in any configuration file via the struts.codebehind.defaultPackage
constant.
Default Results
In many applications, a majority of Results could have the same root name as the action mapping. To reduce this unnecessary configuration, the Struts plugin will try to guess the appropriate Result, if none is explicitly configured. This technique works for any result code, including success
. When combined with the Zero Configuration style, the amount of configuration in an application dwindles to next to nothing.
...
If any of those pages are found, the appropriate Result will be constructed and processed.
Settings
The following settings can be customized. See the developer guide.
Setting | Description | Default | Possible Values |
---|---|---|---|
| The default package to use for created Action mappings |
| Any existing package name |
Installation
This plugin can be installed by copying the plugin jar into your application's /WEB-INF/lib
directory. No other files need to be copied or created.