Strecks uses annotations to implement pluggable navigation and view rendering in the action bean. Two navigation-related annotations are currently supported.
@NavigateForward
is used to handle various
mechanisms for ActionForward-based navigation.@SpringView
enables Spring MVC's view
rendering mechanisms, particularly useful for
localized views and accessing alternative view rendering technologies.The BasicAction
interface shown below is coupled with navigation, because
the result returned from execute()
is used to locate an ActionForward
using ActionMapping.findForward(String)
. @NavigateForward
provides a mechanism
for decoupling request processing execution methods from navigation.
An example is shown below:
@Controller(name = NavigableController.class) public class ExampleNavigableAction implements NavigableAction { public void execute() { //omitted } @NavigateForward public String getResult() { return "success"; } }
This allows different styles of navigation to be used without changing the
request processing interface. @NavigateForward
supports three styles of navigation
by default. In each case, the supported style depends on the return value of the
method annotated using @NavigateForward
.
String |
Functionally identical to the BasicController 's behaviour: the returned String
is used to find an ActionForward using ActionMapping.findForward(String)
|
ActionForward |
The ActionForward returned is wrapped using an ActionForwardViewAdapter
and propagated to the Struts navigation handler.
|
Page |
The Page bean is a Java representation of a JSP, used to control access to the
page's data as well as implement formatting logic on behalf of the page.
In this case, @NavigateForward will return a PageForward instance.
PageForward extends
ActionForward and wraps the Page instance.
|
ViewAdapter |
The @NavigateForward can return a ViewAdapter .
This will simply be propagated by the action controller.
|
Location | Method returning navigation information |
Purpose | Identify the controller implementation |
Usage |
In action beans which use NavigableControllerAction controllers
|
The @SpringView
annotation is used to enable Spring MVC based view rendering.
Spring MVC supports a number of different view rendering mechanisms, including
JSP with JSTL, Tiles, XSLT, Excel, PDF and Jasper Reports. Spring Views can
either be created programmatically, accessed from the Spring ApplicationContext
or accessed via a Spring ViewResolver
. More details on each of these mechanisms
as well as examples are found in the
Spring Integration section.
Location |
Method returning navigation information. This method must return a Spring
ModelAndView instance.
|
Purpose |
Enable view rendering using Spring's View.render() method.
|
Usage |
In action beans which use NavigableControllerAction controllers.
|