• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What are the features of Struts 2 which prompts someone to opt it as a framework?

 
sumeet gupta
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
When we decide framework for our application , what are the features of Struts 2 which prompts someone to opt it as a framework for their Application.

Thanks,
Sumeet Gupta
 
Nishan Patel
Ranch Hand
Posts: 689
Eclipse IDE Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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

Struts 1
● Action
● ActionForm
● ActionForward
● struts-config.xml
● ActionServlet
● RequestProcessor
● validation.xml

vs. Struts 2

● Action
● Action or POJO
● Result
● struts.xml
● FilterDispatcher
● Interceptors
● Action-validation.xml

Wildcard Default
● Using wildcards is another approach to
default actions.
● A wildcard action at the end of the
configuration can be used to catch
unmatched references.

<action name="*" >
<result>/{1}.jsp</result>
</action>

Pre-defined result names (tokens)
String SUCCESS = "success";
● String NONE = "none";
● String ERROR = "error";
● String INPUT = "input";
● String LOGIN = "login";

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).


Bundled Plug-in's
JSF plug-in
● REST plug-in
● Spring plug-in
● Tiles plug-in
● SiteGraph plug-in
● Sitemesh plug-in
● JasperReports plug-in
● JFreeChart plug-in
● Config Browser plug-in
● Struts 1 plug-in


Thanks,
Nishan Patel.
 
sumeet gupta
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Nishan for such a detailed response.Now I am very much clear with the features of Struts2.

Thanks,
Sumeet Gupta
 
Marcus Howarth
Ranch Hand
Posts: 38
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Nishan,

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 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?

thanks
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Dave
 
Marcus Howarth
Ranch Hand
Posts: 38
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Dave,

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"


It also says its a beginners guide and you need no javascript or css. 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"?

Looks really good, sorry also for answering wrong thread assuming it was you
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It also says its a beginners guide and you need no javascript or css.

Personally, I think knowing some JavaScript basics is important for the book--I cover some of the current JavaScript "best practices" but don't introduce JavaScript itself.
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 first half of the book is largely Struts 2 and agile development methodology in parallel. The second half covers more web-oriented topics like JavaScript, some CSS, comprehensive testing, documentation, and so on.

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" ;)

Dave
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic