REVOLUTION TO NEXT GENERATION Struts2.0 20/02/2009 1 Avishek Arang :: [email protected].
-
Upload
darren-eugene-thornton -
Category
Documents
-
view
217 -
download
3
Transcript of REVOLUTION TO NEXT GENERATION Struts2.0 20/02/2009 1 Avishek Arang :: [email protected].
2
Avishek Arang :: [email protected]
Topics discussed …
Basic features of struts2.0.Struts2 vs struts1.1. Architecture of struts2.0.Basic flow of struts2.0.How to configure the plugins
for struts2 in netbeans IDE.Some basic components in
brief.Reference
20/02/2009
Avishek Arang :: [email protected]
3
Page-based NavigationBuilt-in Ajax Support: DWR and DojoSpring as default inversion of control containerChanged from front-controller servlet to fi lterMuch better client-side validation supportQuickStart and AnnotationsJSF SupportBuilt-in support for testing with StrutsTestCase
Features
20/02/2009
Avishek Arang :: [email protected]
4
Struts2.0 Struts1.1
ActionAction or POJOResultstruts.xmlFilterDispatcherInterceptorsAction-
validation.xml
ActionActionFormActionForwardstruts-config.xmlActionServletRequestProcessorvalidation.xml
Comparison
20/02/2009
Avishek Arang :: [email protected]
6
User Sends request.FilterDispatcher determines the appropriate action.Interceptors are applied . Execution of Action . Output rendering . Return of Request(reverse order) . Display the result to user .
20/02/2009
Flow of Struts 2 based Application
7
Avishek Arang :: [email protected]
Select Tools > Plugins:
To configure struts plugins to netbeans IDE.
20/02/2009
8
Avishek Arang :: [email protected]
Configure Plugins:
org-netbeans-modules-web-frameworks-struts2.nbm
org-netbeans-modules-web-frameworks-struts2lib20011.nbm
20/02/2009
Avishek Arang :: [email protected]
9
St ru t s 2 Core components a re Ac t ion hand le r, Resu l t Hand le r and Cus tom Tags . Act ion hand le r
A c t i o n h a n d l e r i n t e r a c t s w i t h o t h e r l a y e r s .Resu l t Hand le r
R e s u l t h a n d l e r a c t u a l l y d i s p a t c h e s t h e r e q u e s t t o v i e w.Custom Tags
C u s t o m Ta g s a r e u s e d r e n d e r t h e d y n a m i c c o n t e n t .In te rcep tor sT h e I n t e r c e p t o r s a r e u s e d t o s p e c i f y t h e " r e q u e s t - p r o c e s s i n g l i f e c y c l e " f o r a n a c t i o n . I n t e r c e p t o r s a r e c o n fi g u r e d t o a p p l y t h e c o m m o n f u n c t i o n a l i t i e s l i k e w o r k fl o w, v a l i d a t i o n e t c . . t o t h e r e q u e s t . I n t e r c e p t o r s c o d e i s e x e c u t e d b e f o r e a n d a f t e r a n A c t i o n i s i n v o k e dExpress ion Language(ONGL- Ob jec t Graph Nota t i on Language)
20/02/2009
Struts 2 Core components
Avishek Arang :: [email protected]
10
<st ru t s> < inc lud e fi l e="s t r u t s -d e fau l t . xml " />
<constant name="struts.custom.i18n.resources" value="MessageResources" />
<package name="default" extends="struts-default"> <action name="list" class="web.DefectsList">
<result>/pages/defects.jsp</result> </action> <action name="action_*" method="{1}" class="web.DefectsAction">
<result name="input">/pages/editDefect.jsp</result> <result type="redirect">list.action</result>
</action> </package>
< / s t r u t s>
20/02/2009
struts.xml
Avishek Arang :: [email protected]
11
Used to modularize application.Always a child of <struts> tag.Only attribute “fi le” implies the confi g fi le.<include fi le=“module1-confi g.xml”>Order of including fi les are important.explicitly include: “struts-default.xml” and the “struts-plugin.xml” fi les
20/02/2009
<include>
Avishek Arang :: [email protected]
12
name - unique.extends - “struts-default”.namespace- admin, knowledgecenter, test.Abstract-if “true” actions confi gured will not be accessible via the package name.
20/02/2009
<package>
Avishek Arang :: [email protected]
13
They prov ide a way to supp l y p re -process ing and pos t -p rocess ing a round the ac t i on .examples i nc lude excep t i on hand l i ng , fi l e up load ing , l i f e cyc l e ca l l backs and va l i da t i on .
<interceptors><interceptor name="autowir ing“ c lass=" interceptor.Act ionAutowir ingInterceptor" /></ interceptors><act ion name="my" c lass="com. fdar. in foq .MyAct ion" >
<result>view.jsp</result><interceptor-ref name="autowiring"/>
</action>
20/02/2009
Interceptor
Avishek Arang :: [email protected]
14
Fie ld Summary s ta t i c S t r ing ERROR The ac t ion execut ion was a fa i lure . s ta t i c S t r ing INPUT The ac t ion execut ion requ i re more input in order to succeed . s ta t i c S t r ing LOGIN The ac t ion cou ld not execute , s ince the user most was not logged in . s ta t i c S t r ing NONE The ac t ion execut ion was success fu l but do not show a v iew.s ta t i c S t r ing SUCCESS The ac t ion execut ion was success fu l . Method Summary S t r ing execute( ) Where the log ic o f the ac t ion i s executed .
20/02/2009
com.opensymphony.xwork2 Interface Action
Avishek Arang :: [email protected]
15
- www.rose india .com- Star t ing Struts2 by Ian Roughley [ f ree ebook] .- Struts 2 Des ign and Programming: A Tutor ia l by Budi Kurniawan.
20/02/2009
Bibliography