Using Struts to Develop J2EE Applications

beehuntervivaciousΛογισμικό & κατασκευή λογ/κού

14 Ιουλ 2012 (πριν από 5 χρόνια και 1 μήνα)

309 εμφανίσεις

Australia | Canada | China | France | India | New Zealand | Singapore | Switzerland | UAE | UK | USA
info@keane.com
www.keane.com/education/
Using Struts to Develop

J2EE Applications
3492
This course introduces the developer to the Struts architecture and provides the basis for planning, developing,
and deploying Web based applications using the Struts framework. Upon completion of this class, the developer
will be able to quickly construct dynamic server-side web pages using Struts. It includes all the important concepts,
and hands on labs that will enable you to build working Struts.
Experienced Java Developers who want to learn how to use J2EE components to build enterprise web applications.
Students should have six months prior Java development experience, including some experience using Server
Side technologies (Servlets/JSPs) Students should be comfortable creating a servlet and JSP. Or students can be
participating in our focused training curriculum.
Struts is an advanced Model-View-Controller (MVC) framework for building Servlet/JSP based web applications.
It is an open source framework built as part of the Jakarta project (the makers of Tomcat) that leverages the
capabilities of Servlets/JSP and custom tags to make it easier to use these technologies on large or complex web
systems.
Struts addresses many major issues in using vanilla Servlets/JSP to build web systems. It solves the problem of
controller complexity by removing the workflow logic from the servlets, and directing workflow in an XML
configuration file. Struts improves on the limited form support in JSP by adding numerous capabilities to form
processing including easy validation, easy error display, and the refilling of form input on form retries from a users
previous entries. It minimizes the complexity of JSP pages, by supplying a very extensive and flexible set of custom
tag libraries for many of the standard operations needed in JSP pages.
This course will get you up to speed with Struts in a very short time. It includes all the important concepts, and
hands on labs that will have you building working Struts applications in no time flat.
Working in a hands-on environment, students will learn to:
• Understand the problems with vanilla servlets/JSP, and the motivation for Struts
• Understand MVC and the Struts architecture
• Understand the Struts controller, Struts views, and Struts resource bundles
• Create & configure applications using Struts
• Define views, actions, and FormBeans
• Use Struts for form processing
• Use ActionMappings
• Handle errors and debug Struts applications
• Use the Bean, Logic, and HTML Custom Tag Libraries
• Use the flow-of-control custom tags
Description
Audience
Objectives
©2007-08 | Keane, Inc.
Course No.
Prerequisites
Australia | Canada | China | France | India | New Zealand | Singapore | Switzerland | UAE | UK | USA
info@keane.com
www.keane.com/education/
• Servlets/JSP Review
• Struts Architecture: Model View Controller
• Struts – Overview
• Configuration
• Struts Components: The Action Class
• ActionForms and FormBeans
• Struts Components: ActionForwards
• Struts Tags
• I18N and Struts
• DynaActionForms
• Struts Components: Validator
• Tiles
5 days
Duration
Major Topics
Australia | Canada | China | France | India | New Zealand | Singapore | Switzerland | UAE | UK | USA
info@keane.com
www.keane.com/education/
• Servlet Creates JavaBean
• JSP Uses JavaBean
• Summary
2. Struts Architecture: Model View Controller
• Objectives
• Separation of Concerns Principle
• Application Partitioning
• MVC Architecture Pattern
• MVC and MVC Model 2
• MVC in J2EE
• What is Struts?
• What is a Framework?
• View Layer in MVC
• View Elements in Struts
• Examples of View Elements
• Controller Layer in MVC
• The Struts Controller
• Other Controller Components
• Model Layer in MVC
• Model Elements in Struts
• Examples of Model Elements
• Command Pattern
• Why Struts?
• Alternatives to Struts
• Summary
3. Struts – Overview
• Objectives
• How Did Struts Get Here?
• What is a Framework?
• Basic Elements of Struts
• Struts Component Interactions
• Struts Components and Classes
• Comparison of JSP and Struts Implementation
• Typical Struts Request/Response
• User Request Flow Using Struts
• ActionServlet
• web-xml
• ActionMapping
o Entry in struts-config.xml
o Action Tag Attributes
• Action
Course Contents
1. Servlets/JSP Review
• Objectives
• Overview – J2EE Web App
• Class Hierarchy
• Requests and Responses
• Returning Content From a Servlet
• Servlet Example
• Servlet Lifecycle
• Invoking a Servlet
• Web Applications
• J2EE Containers
• Servlet Bindings
• Sample web.xml File
• Session Tracking Overview
• Session Tracking API
• Using HttpSession
• Session Example
• Closing Connections
• Servlet Communication
• Redirection
• Redirection Example
• Request Dispatching
• Forward Dispatching
• Include Dispatching
• MVC
• JSP Review
• JSP Motivation
• JSP Example
• Directives
• Page Directive Example
• Scriptlets
• Implicit Objects
• Declarations
• Expressions
• Comments
• JSP Example
• Using Java Beans in JSPs
• What are JavaBeans?
• Architectural View
• JSPs: The useBean Tag
• Using the Bean – jsp:getProperty
Australia | Canada | China | France | India | New Zealand | Singapore | Switzerland | UAE | UK | USA
info@keane.com
www.keane.com/education/
o Code Snippet
• ActionForm
• ActionForward
• Global Forwards
• ActionError
• ActionMessage
• ActionErrors
• Summary
4. Configuration
• Objectives
• Java Web Apps
• Configuring web.xml for Struts
• Example web.xml
• struts-config.xml
• Example struts-config.xml
• Cache of struts-config.xml
• Reloading config file
• Multiple config files
• Multiple config files example
• Other config files
• Struts Modules
• Summary
5. Struts Components: The Action Class
• Objectives
• What are Actions?
• ActionServlet and RequestProcessor
• The Action Class’s execute( ) method
• Thread Safety in Actions
• What Does execute( ) Do?
• Avoid Business Logic in execute( )
• How Errors Work
• Errors in Response JSP
• Sample <action> Entry of struts-config.xml
• Attributes of the <action> Element
• Pre-defined Action classes
• Exceptions in an Action class
• Local Exceptions
• Global Exceptions
• How Actions are Accessed
• Actions “in action”
• Action Tips and Tricks
• Summary
6. ActionForms and FormBeans
• Objectives
• ActionForms and FormBeans
o Whats the difference?
o Role – Data Carrier
o Autopopulation
o Simple Example
• Data types
• Lifecycle of FormBeans
• ActionForms
o reset( )
o What If reset() Is Not Defined for a Property?
o reset() with Check Boxes
o validate( )
• ActionError
• ActionErrors
• Sample validate( )
• validate( ) Best Practices
• FormBean
o Setting up FormBeans in struts-config.xml
• Summary
7. Struts Components: ActionForwards
• Objectives
• User Interface Navigation
• What is an ActionForward?
• The <forward> Entry in struts-config.xml
• <forward> Attributes
• ActionForward in Action classes
• The ActionForward Class
• The ActionMapping Class
• Forward vs. Redirect
• Return a null ActionForward
• Global vs. Action Forwards
• ActionForward Tips and Tricks
• Summary
Australia | Canada | China | France | India | New Zealand | Singapore | Switzerland | UAE | UK | USA
info@keane.com
www.keane.com/education/
8. Struts Tags
• Objectives
• Tags in JSP
• Struts custom tags
• Taglib directive
• Struts HTML tags
• Struts <html:form> tag
• <html:text> and <html:password>
• Struts <html:select> tag
• <html:options>
• <html:link>
• <html:errors>
• Struts Bean Tags
• <bean:define>
• <bean:cookie>
• <bean:header> & <bean:parameter>
• <bean:message>
o Arguments
• <bean:write>
• Struts Logic Tags
• <logic:iterate>
• <logic:match>
• Other Logic Branching Tags
• <logic:redirect>
• Summary
9. I18N and Struts
• Objectives
• I18N
• Localization
• Elements to Consider
• Java Support for Localization
• Locale Review
• ResourceBundle Review
• Example Properties
• Word Order and Substitutions
• MessageFormat
• I18N and Struts
• Locale in Struts
• Cached Locale Object
• Configuring MessageResources
• Locale aware tags:
• <bean:message> tag
• <bean:write> tag
o formatKey Example
• <html:tags>
• html img and image tags
• <html:errors> and <html:messages>
• Summary
10. DynaActionForms
• Objectives
• ActionForms - Reminder of Struts Data Container
• Issue with ActionForms
• DynaActionForm to the Rescue
• What About reset()?
• What about validate()?
• DynaActionForms
o Recap Using
o Recap configuring
• DynaActionForms Recap Using
11. Struts Components: Validator
• Objectives
• Validation Overview
• Validation “Under the Hood”
• Components of Struts Validator
• Predefined Validators
• Default Messages for Predefined Validators
• Using Validators in a Struts Application
• Configuring the Validator Plugin
• Creating the Form Class
• Creating a Dynamic Validator Form Bean
• Defining Field Validation in validation.xml
• The <field> Element in validation.xml
• Enabling Client-Side Validation
• Using Masks
• Field Validation Examples
• Final Steps in Validation
• Validator Tips and Tricks
• Summary
Australia | Canada | China | France | India | New Zealand | Singapore | Switzerland | UAE | UK | USA
info@keane.com
www.keane.com/education/
12. Tiles
• Objectives
• Tiles Overview
• Tiles Example Website
• Implementing Tiles
• Putting it all together
• Steps to use Tiles
• Tiles Plug-in Overview
• Tile Definitions
o Overview
o Creating a Tile Definition in XML
o Example tile definitions
o Tile definitions via custom tags
o Example JSP using a layout
defined in “definitions.jsp”
• Layouts
o Overview
o Example
• Steps to use Tiles - Creating Content
JSPs (creating the Tiles)
• Use the Tiles Definitions
o Overview
o Inserting the Definition
o Passing a Value in a Body
• Extending Tile Definitions - “Inheritence” for Tiles
• Tile Scope Overview
• Tile Scope <tiles:useAttribute>
• Summary