Struts2.0

How to configure the plugins for struts2 in netbeans IDE. Some basic components in brief. Reference. 20/02/2009. 2. Avishek Arang :: avishekarang@gmail.com.
展开查看详情

1. Struts2.0 1 REVOLUTION TO NEXT GENERATION Avishek Arang :: avishekarang@gmail.com 20/02/2009

2. 2 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 Avishek Arang :: avishekarang@gmail.com 20/02/2009

3. Features 3 P a g e - b a s e d N a v i g a t i o n B u i l t - i n A j a x S u p p o r t : D W R a n d D o j o S p r i n g a s d e f a u l t i n v e r s i o n o f c o n t r o l c o n t a i n e r C h a n g e d f r o m f r o n t - c o n t r o l l e r s e r v l e t t o f i l t e r M u c h b e t t e r c l i e n t - s i d e v a l i d a t i o n s u p p o r t Q u i c k S t a r t a n d A n n o t a t i o n s J S F S u p p o r t B u i l t - i n s u p p o r t f o r t e s t i n g w i t h S t r u t s T e s t C a s e Avishek Arang :: avishekarang@gmail.com 20/02/2009

4. Comparison 4 Struts2.0 Struts1.1  Action  Action or POJO  Result  struts.xml  Action  FilterDispatcher  ActionForm  Interceptors  ActionForward  Action-validation.xml  struts-config.xml  ActionServlet  RequestProcessor  validation.xml Avishek Arang :: avishekarang@gmail.com 20/02/2009

5.Architecture 5 Avishek Arang :: avishekarang@gmail.com 20/02/2009

6. Flow of Struts 2 based Application 6 U s e r S e n d s r e q u e s t . F i l t e r D i s p a t c h e r d e t e r m i n e s t h e a p p r o p r i a t e action. I n t e r c e p t o r s a r e a p p l i e d .     E x e c u t i o n o f A c t i o n .     O u t p u t r e n d e r i n g .     R e t u r n o f R e q u e s t ( r e v e r s e o r d e r ) .     D i s p l a y t h e r e s u l t t o u s e r . Avishek Arang :: avishekarang@gmail.com 20/02/2009

7. 7 Select Tools > Plugins: To configure struts plugins to netbeans IDE. Avishek Arang :: avishekarang@gmail.com 20/02/2009

8. 8 Configure Plugins: org-netbeans-modules- web-frameworks- struts2.nbm org-netbeans-modules- web-frameworks- struts2lib20011.nbm Avishek Arang :: avishekarang@gmail.com 20/02/2009

9. Struts 2 Core components 9 S t r u t s 2 Core components are Action handler, Result Handler and Custom Tags.  A c t i o n h a n d l e r Action handler interacts with other layers. R e s u l t H a n d l e r Result handler actually dispatches the request to view. C u s t o m T a g s Custom Tags are used render the dynamic content. I n t e r c e p t o r s The Interceptors are used to specify the "request-processing lifecycle" for an action. Interceptors are configured to apply the common functionalities like workflow, validation etc.. to the request. Interceptors code is executed before and after an Action is invoked E x p r e s s i o n L a n g u a g e ( O N G L - O b j e c t G r a p h N o t a t i o n L a n g u a g e ) Avishek Arang :: avishekarang@gmail.com 20/02/2009

10. struts.xml 10 <struts> <include file="struts-default.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> </struts> Avishek Arang :: avishekarang@gmail.com 20/02/2009

11. <include> 11 U s e d t o m o d u l a r i z e a p p l i c a t i o n . A l w a y s a c h i l d o f < s t r u t s > t a g . O n l y a t t r i b u t e “ f i l e ” i m p l i e s t h e c o n f i g file. < i n c l u d e f i l e = “ m o d u l e 1 - c o n f i g . x m l ” > O r d e r o f i n c l u d i n g f i l e s a r e i m p o r t a n t . e x p l i c i t l y i n c l u d e : “ s t r u t s - d e f a u l t . x m l ” a n d the “struts-plugin.xml” files Avishek Arang :: avishekarang@gmail.com 20/02/2009

12. <package> 12 n a m e - u n i q u e . e x t e n d s - “ s t r u t s - d e f a u l t ” . n a m e s p a c e - a d m i n , k n o w l e d g e c e n t e r , t e s t . A b s t r a c t - i f “ t r u e ” a c t i o n s c o n f i g u r e d w i l l not be accessible via the package name. Avishek Arang :: avishekarang@gmail.com 20/02/2009

13. Interceptor 13 T h e y p r o v i d e a w a y t o s u p p l y p r e - p r o c e s s i n g a n d p o s t - processing around the action. e x a m p l e s i n c l u d e e x c e p t i o n h a n d l i n g , f i l e u p l o a d i n g , l i f e c y c l e callbacks and validation. <interceptors> <interceptor name="autowiring“ class="interceptor.ActionAutowiringInterceptor"/> </interceptors> <action name="my" class="com.fdar.infoq.MyAction" > <result>view.jsp</result> <interceptor-ref name="autowiring"/> </action> Avishek Arang :: avishekarang@gmail.com 20/02/2009

14. com.opensymphony.xwork2 Interface Action 14 F i e l d Summary s t a t i c   S t r i n g E R R O R T h e a c t i o n e x e c u t i o n w a s a f a i l u r e . s t a t i c   S t r i n g I N P U T The action execution require more input in order to succeed. s t a t i c   S t r i n g L O G I N           The action could not execute, since the user most was not logged in. s t a t i c   S t r i n g N O N E           The action execution was successful but do not show a view. s t a t i c   S t r i n g S U C C E S S           The action execution was successful.   M e t h o d S u m m a r y   S t r i n g e x e c u t e( )           Where the logic of the action is executed. Avishek Arang :: avishekarang@gmail.com 20/02/2009

15. Bibliography 15 - www.roseindia.com - Starting Struts2 by Ian Roughley [free ebook]. - Struts 2 Design and Programming: A Tutorial by Budi Kurniawan. Avishek Arang :: avishekarang@gmail.com 20/02/2009