This week's giveaway is in the EJB and other Java EE Technologies forum. We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line! See this thread for details.
With so many choices out there, why choose Struts2? Here are some of the features that may lead you to consider Struts2: Action based framework Mature with a vibrant developer and user community Annotation and XML configuration options POJO-based actions that are easy to test Spring, SiteMesh and Tiles integration OGNL expression language integration Themes based tag libraries and Ajax tags Multiple view options (JSP, Freemarker, Velocity and XSLT) Plug-ins to extend and modify framework features
Action based frameworks came onto the scene to combine the concepts of servlets and JSPs. The idea being to split the request processing for the page the user sees into processing logic and the presentation logic, letting each part do what it does the best. The implementation used a pattern from Smalltalk known as the model-view-controller pattern � or more recently known as the front controller, or in Sun parlance Model 2.
As web applications became more complex, it was realized that a page was no longer the logical separation � web applications had multiple forms per page, links for content updates and many other custom widgets � all which needed processing logic to perform their tasks.
POJO Action's ● Struts 1 � Actions in Struts1 have dependencies on the servlet API since the HttpServletRequest and HttpServletResponse objects are passed to the execute() method ● Struts 2 � Any java class with execute() method can be used as an Action class. � Actions to be neutral to the underlying framework ● ActionForms feature is no more known to the Struts 2 framework. ● Simple JavaBean flavored actions are used to put properties directly
Interceptors ● Interceptors can execute code before and after an Action is invoked. ● Most of the framework's core functionality is implemented as Interceptors. � Features like double-submit guards, type conversion, object population, validation, file upload, page preparation, and more, are all implemented with the help of Interceptors. ● Each and every Interceptor is pluggable
Defining Validation Rules ● Per Action class: � in a file named <ActionName>-validation.xml ● Per Action alias: � in a file named <ActionName-alias>-validation.xml ● Inheritance hierarchy and interfaces implemented by Action class � Searches up the inheritance tree of the action to find default validations for parent classes of the Action and interfaces implemented
struts.xml ● The core configuration file for the framework ● Should reside on the classpath of the webapp (generally /WEB-INF/classes).
Firstly, thanks for above list, very comprehensive! (do I need the book now? )
Originally posted by Nishan Patel:
POJO-based actions that are easy to test
● Struts 2 � Any java class with execute() method can be used as an Action class. � Actions to be neutral to the underlying framework
do you go into the unittesting side of things in much depth in your book? I currently still use struts 1 and find the testing of actions gets so bogged down in mocks... well, its not so easy. Do you suggest using struts 2 means you could advocate TDD for action classes too?
do you go into the unit testing side of things in much depth in your book? I currently still use struts 1 and find the testing of actions gets so bogged down in mocks... well, its not so easy. Do you suggest using struts 2 means you could advocate TDD for action classes too?
There is a chapter covering testing from several angles: simple action testing, interceptor testing, full-stack action testing, and functional testing via driving a browser from unit test code.
The architecture of Struts 2 makes testing much, much easier than in Struts 1, IMO, and makes TDD much more feasible than with Struts 1.
Joined: Jan 04, 2002
Having now read up on your book I see this is one of the main points listed!! * "Apply the best of agile development techniques and TDD techniques"
Looks really good, sorry also for answering wrong thread assuming it was you
Could you say who your target audience is? How much of the book is covering Struts 2.1 specifics as opposed to "interspersed with detours into more advanced development topics"?
The precise target audience is "people that need to get up to speed on good web development practices using S2 really quickly". More broadly, it covers a fair amount of advanced topics, but in a way that's accessible to less-experienced developers, but still useful to those that already know "everything" ;)