Struts 2 0 1 REVOLUTION TO NEXT GENERATION

  • Slides: 15
Download presentation
Struts 2. 0 1 REVOLUTION TO NEXT GENERATION Avishek Arang : : avishekarang@gmail. com

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

2 Topics discussed … q Basic features of struts 2. 0. q Struts 2

2 Topics discussed … q Basic features of struts 2. 0. q Struts 2 vs struts 1. 1. q Architecture of struts 2. 0. q Basic flow of struts 2. 0. q How to configure the plugins for struts 2 in netbeans IDE. q Some basic components in brief. q Reference Avishek Arang : : avishekarang@gmail. com 20/02/2009

Features 3 q. Page-based Navigation q. Built-in Ajax Support: DWR and Dojo q. Spring

Features 3 q. Page-based Navigation q. Built-in Ajax Support: DWR and Dojo q. Spring as default inversion of control container q. Changed from front-controller servlet to filter q. Much better client-side validation support q. Quick. Start and Annotations q. JSF Support q. Built-in support for testing with Struts. Test. Case Avishek Arang : : avishekarang@gmail. com 20/02/2009

Comparison 4 Struts 2. 0 Struts 1. 1 q Action or POJO q Action.

Comparison 4 Struts 2. 0 Struts 1. 1 q Action or POJO q Action. Form q Result q Action. Forward q struts. xml q struts-config. xml q Filter. Dispatcher q Action. Servlet q Interceptors q Request. Processor q Action-validation. xml q validation. xml Avishek Arang : : avishekarang@gmail. com 20/02/2009

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

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

Flow of Struts 2 based Application 6 q. User Sends request. q. Filter. Dispatcher

Flow of Struts 2 based Application 6 q. User Sends request. q. Filter. Dispatcher determines the appropriate action. q. Interceptors are applied. q. Execution of Action. q. Output rendering. q. Return of Request(reverse order). q. Display the result to user. Avishek Arang : : avishekarang@gmail. com 20/02/2009

7 Select Tools > Plugins: To configure struts plugins to netbeans IDE. Avishek Arang

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

8 Configure Plugins: org-netbeans-modulesweb-frameworksstruts 2. nbm org-netbeans-modulesweb-frameworksstruts 2 lib 20011. nbm Avishek Arang :

8 Configure Plugins: org-netbeans-modulesweb-frameworksstruts 2. nbm org-netbeans-modulesweb-frameworksstruts 2 lib 20011. nbm Avishek Arang : : avishekarang@gmail. com 20/02/2009

Struts 2 Core components 9 q. Struts 2 Core components are Action handler, Result

Struts 2 Core components 9 q. Struts 2 Core components are Action handler, Result Handler and Custom Tags. q. Action handler interacts with other layers. q. Result Handler Result handler actually dispatches the request to view. q. Custom Tags are used render the dynamic content. q. Interceptors 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 q. Expression Language(ONGL- Object Graph Notation Language) Avishek Arang : : avishekarang@gmail. com 20/02/2009

struts. xml 10 <struts> <include file="struts-default. xml"/> <constant name="struts. custom. i 18 n. resources"

struts. xml 10 <struts> <include file="struts-default. xml"/> <constant name="struts. custom. i 18 n. resources" value="Message. Resources" /> <package name="default" extends="struts-default"> <action name="list" class="web. Defects. List"> <result>/pages/defects. jsp</result> </action> <action name="action_*" method="{1}" class="web. Defects. Action"> <result name="input">/pages/edit. Defect. jsp</result> <result type="redirect">list. action</result> </action> </package> </struts> Avishek Arang : : avishekarang@gmail. com 20/02/2009

<include> 11 q. Used to modularize application. q. Always a child of <struts> tag.

<include> 11 q. Used to modularize application. q. Always a child of <struts> tag. q. Only attribute “file” implies the config file. q<include file=“module 1 -config. xml”> q. Order of including files are important. qexplicitly include: “struts-default. xml” and the “struts-plugin. xml” files Avishek Arang : : avishekarang@gmail. com 20/02/2009

<package> 12 qname - unique. qextends - “struts-default”. qnamespace- admin, knowledgecenter, test. q. Abstract-if

<package> 12 qname - unique. qextends - “struts-default”. qnamespace- admin, knowledgecenter, test. q. Abstract-if “true” actions configured will not be accessible via the package name. Avishek Arang : : avishekarang@gmail. com 20/02/2009

Interceptor 13 q. They provide a way to supply pre-processing and post-processing around the

Interceptor 13 q. They provide a way to supply pre-processing and post-processing around the action. qexamples include exception handling, file uploading, lifecycle callbacks and validation. <interceptors> <interceptor name="autowiring“ class="interceptor. Action. Autowiring. Interceptor"/> </interceptors> <action name="my" class="com. fdar. infoq. My. Action" > <result>view. jsp</result> <interceptor-ref name="autowiring"/> </action> Avishek Arang : : avishekarang@gmail. com 20/02/2009

com. opensymphony. xwork 2 Interface Action 14 q. Field Summary qstatic String ERROR The

com. opensymphony. xwork 2 Interface Action 14 q. Field Summary qstatic String ERROR The action execution was a failure. qstatic String INPUT The action execution require more input in order to succeed. qstatic String LOGIN The action could not execute, since the user most was not logged in. qstatic String NONE The action execution was successful but do not show a view. qstatic String SUCCESS The action execution was successful. q. Method Summary String execute() Where the logic of the action is executed. Avishek Arang : : avishekarang@gmail. com 20/02/2009

Bibliography 15 - www. roseindia. com - Starting Struts 2 by Ian Roughley [free

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