EC38 - Struts 2 Programming Workshop
Duration2 Days (customisation)
Availability

Course Description

This course is targeted at the developer, already familiar with programming using J2EE, looking to gain a knowledge of Struts 2 Programming. During the course the student will build a fully featured Struts applications including advanced topics such as validation, error handling and internationalisation.

Pre-requisites

The student should be familiar with J2EE programming. This knowledge can be gained by attending course EC31.

Objectives

This course provides students with the skills to write effective Struts 2 Applications.

While covering these in detail, the course retains a 'high level' overview of the MVC Design Patterns used for such development.

During the course the student will write a complete Struts application to ensure that the content has been fully understood and practical experience is gained.

On completion of this course the student will be able to:

  • understand the Model View Controller architecture
  • understand the various Struts 2 components
  • understand the configuration files
  • code Struts2 Actions
  • unterstand Struts2 Type Conversion
  • use ONGL and the ValueStack
  • use and code Interceptors
  • use the various Custom Tags that Struts 2 provides
  • configure Internationalised applications
  • use Struts Error handling
  • use the Struts Validator Framework
  • use Struts2 Annotations
  • integrate Struts2 with alternative frameworks

Environment

Development will be performed using:

  • Eclipse
  • IntelliJ
  • NetBeans
  • Websphere Studio Application Developer
  • Rational Application Developer
  • JBuilder
  • the Java Development Kit (JDK) plus a text editor

Customisation

For on-site courses (i.e. at your premises), we are more than happy to tailor the course agenda to suit your exact requirements. In many cases, we are able to build your in-house standards and naming conventions into the delivered course.

Course Details

INTRODUCTION TO STRUTS
Model View Controller Architecture
Struts2 Framework
Struts2 Features and Enhancements
Struts2 vs. Traditional MVC
FIRST STEPS
Environment Setup
Build Automation Option
Struts 2 Project Structure
Struts2 Components
Steps to Create a Struts 2 Application
Create a Project
Struts2 Classpath Requirements
Create the Input Form
Define Controller Behaviour in Web.xml
Define the Action / View Components in struts.xml
Create the Action Class
Create the View
Additional Setup Configuration
Multiple Result Mappings
Deploying / Testing outside of IDE
CONFIGURATION FILES
web.xml
struts.xml
struts.xml - using Includes
struts-config.xml
struts.properties
ACTIONS
Create Action
Extending The ActionSupport Class
Separating Action / Bean Behaviour
Wildcard Method Selection
TAGS
Form Tags
FORM VALIDATION
Validation in the Action Class
Message Resource Files
Associating Messages with Forms and Actions
Message Problems
Nested Messages
XML Based Validation
Validator Types
TYPE CONVERSION
Array Type Conversion
Collection Type Conversion
Creating a Type Converter
Registering a Type Converter
A More Complex Type Converter Example
ONGL AND THE VALUE STACK
Ongl
The ValueStack
Ognl / ValueStack Named Objects
ValueStack Methods
Accessing ValueStack Properties
Accessing static properties
Accessing Arrays
Accessing Lists
Accessing Maps
The Iterator Tag
Accessing the HttpServletRequest
Adding Properties to the ValueStack
Further JSP Tags
The Ognl / Jsp Expression Language
RESULT TYPES
The Dispatcher Result Type
The Chain Result Type
The Redirect Result Type
The Freemarker Result Type
Other Result Types
LOCALIZATION, INTERNATIONALIZATION (I18N)
Resource Bundles
Locale Property File Example
Access the messages
Switching Locales
INTERCEPTORS
Struts2 Framework Interceptors
Using Interceptors
Specifying Interceptor Stacks
Create Custom Interceptors
The Custom Interceptor Class
Create Action Class
Stacking multiple Interceptors
EXCEPTION HANDLING
TAGS, THEMES AND TEMPLATES
Selecting Themes
How Does a Theme Work?
Creating New Themes
ANNOTATIONS
Create main page
Create Views
Create Action
Configuration Files
Struts 2 Annotations Types
DATABASE ACCESS
Create Action
FILE UPLOADS
File Uploads using Struts2
Error Messages
SENDING EMAIL
Sending Email using Struts2
CREATING RESPONSIVE USER INTERFACES WITH AJAX
Overview of Ajax and Web 2.0 concepts
Creating Ajaxified applications in Struts 2
Handling asynchronous requests with Ajax
Returning JSON and XML data
INTEGRATING STRUTS 2 WITH ALTERNATIVE FRAMEWORKS
Integrating Struts 2 with Java Enterprise Edition and the Spring Framework

Course Format

Practical sessions make up a large part of the course, allowing delegates to demonstrate and reinforce the lectures given.

Examples are used extensively, ranging from simple code 'snippets' to full applications with complete 'real world' functionality. These are supplied at the start of the course and it is encouraged that the delegates execute and 'experiment' with these under the instructor's guidance as they are introduced.

These examples are available to take away, along with the delegate's own work.

The comprehensive Student Guide supplied is fully indexed serving as a useful reference tool long after the course has finished. Delegates will also be able to access a free help-line with technical questions relating to topics covered on the course.