Apache Struts 2 Web Application Development


Apache Struts 2 Web Application Development
eBook: $20.99
Formats: PDF, PacktLib, ePub and Mobi formats
$15.74
save 25%!
Print + free eBook + free PacktLib access to the book: $55.98    Print cover: $34.99
$34.99
save 37%!
Free Shipping!
UK, US, Europe and selected countries in Asia.
Also available on:
Overview
Table of Contents
Author
Support
Sample Chapters
  • Design, develop, test, and deploy your web applications using Struts 2 framework
  • No prior knowledge of JavaScript and CSS is required
  • Apply the best of agile development techniques and TDD techniques
  • Step-by-step instructions and careful explanations with lots of code examples

Book Details

Language : English
Paperback : 384 pages [ 235mm x 191mm ]
Release Date : June 2009
ISBN : 1847193390
ISBN 13 : 9781847193391
Author(s) : Dave Newton
Topics and Technologies : All Books, Web Development, Open Source

Back to BOOK PAGE

Table of Contents

Preface
Chapter 1: Struts and Agile Development
Chapter 2: Basic Configuration
Chapter 3: Actions and ActionSupport
Chapter 4: Results and Result Types
Chapter 5: OGNL, the Value Stack, and Custom Tags
Chapter 6: Form Tags
Chapter 7: Form Validation and Type Conversion
Chapter 8: Interceptors
Chapter 9: Exceptions and Logging
Chapter 10: Getting Started with JavaScript
Chapter 11: Advanced JavaScript, the DOM, and CSS
Chapter 12: Themes and Templates
Chapter 13: Rich Internet Applications
Chapter 14: Comprehensive Testing
Chapter 15: Documenting our Application
Index
  • Chapter 1: Struts and Agile Development
    • Struts 2 in a nutshell
      • The filter dispatcher
      • Interceptors
      • Actions
      • Results
      • Plug-ins
    • Agile in a nutshell
      • User stories
      • Testing
      • Refactoring
      • Short iterations
    • Real applications in a nutshell
      • Making it pretty
      • JavaScript
      • Documentation
      • All of the rest
    • Getting started
      • Creating our own applications
        • Doing it "by hand"
        • Using Maven
    • Summary
  • Chapter 2: Basic Configuration
    • Setting up our environment
      • A sanity-checking application
      • Configuring web.xml for Struts 2
      • Writing our first action
        • Configuring our first action with XML
        • Configuring our result
        • Choosing an action method
    • Getting started with our application
      • Gathering user stories—defining our application
      • Building skeletal applications using wildcards
      • Matching multiple wildcards
      • More wildcard tricks
      • Packages and namespaces
      • Creating site navigation
      • Including external configuration files
      • Our application so far
      • Examining our configuration
      • Configuration via convention and annotations
        • The Convention Plug-in and action-less actions
        • The Convention Plug-in and action configuration
        • Configuring the Convention Plug-in with annotations
    • Summary
  • Chapter 3: Actions and ActionSupport
    • ActionSupport and its interfaces
      • The Action interface
        • Action's convenience strings
      • The TextProvider interface
      • Detour—action properties, JSPs, and more tags
      • Continuing with message lookup
      • Parameterized messages
      • The LocaleProvider interface
      • The Validateable and ValidationAware interfaces
    • Implementing our first user story
      • Refining our story
      • Creating the recipe form
      • Adding some validation
      • Displaying our error messages
    • More action interfaces
      • Detour—creating the list of interfaces to explore
        • Leveraging the IDE
        • Using the command line
        • Examining class files
    • Additional action interfaces
      • Preparable interface
      • Accessing scoped attributes (and request parameters)
      • Accessing servlet objects
      • Request parameter/action property filtering
    • Summary
  • Chapter 4: Results and Result Types
    • The dispatcher result type
    • The redirect result type
    • The redirectAction result type
    • The chain result type (action chaining)
    • The parse parameter and a usecase detour
      • Displaying the form
      • Coding our action
      • Configuring our success result
      • Type conversion sneak attack
      • Coding the show action
    • The FreeMarker and Velocity result types
      • FreeMarker result configuration
    • The XSLT result type
    • The plaintext result
    • The stream result
    • The httpheader result
    • The Tiles and JasperReports results
    • Creating custom result types
      • Configuring our custom result type
      • Writing the action
      • Implementing our markdown result type
    • Summary
  • Chapter 5: OGNL, the Value Stack, and Custom Tags
    • OGNL
      • Contents of the value stack and the <s:property> tag
        • Escaping values
        • Default values
        • Escaping values for JavaScript
      • Other value stack objects and the debug tag
      • A dirty EL trick
    • The <s:set> tag
    • Calling static methods from OGNL
    • Conditionals
    • Collections and iteration
      • The <s:iterator> tag
        • Tracking iteration status
        • CSS detour: Alternating table row background color
        • The <s:generator> tag
        • It's not a list, it's an iterator!
        • Silent death
        • Another potential stumper (Struts 2.0 only)
        • What is <s:generator> for?
      • The <s:append> tag
      • The <s:merge> tag
      • The <s:subset> tag
        • Arbitrary filtering with the <s:subset> tag
        • Dirty OGNL secrets
      • The <s:sort> tag
      • Are the collection tags useful?
    • Referencing other pages and actions
      • The <s:include> tag
      • The <s:action> tag
      • The <s:url> tag
    • Summary
  • Chapter 6: Form Tags
    • Form tag basics
      • The xhtml theme in a nutshell
      • The <s:head> tag
      • The <s:form> tag
      • Common input element tag attributes
        • Values, labels, and names (and keys)
        • All the rest
      • Basic rendering
        • But I don't want tables
      • Basic form input elements
        • The <s:textfield>, <s:password>, and <s:hidden> tags
        • The <s:textarea> tag
        • The <s:label> tag
        • The <s:radio> tag
        • The <s:checkbox> tag
        • The <s:checkboxlist> tag
        • Using the <s:checkboxlist> tag to implement a user story
        • The <s:select> tag
        • The <s:optgroup> tag
        • The <s:submit> tag
        • The <s:reset> tag
      • Combination form tags
        • The <s:combobox> tag
        • The <s:updownselect> tag
        • The <s:optiontransferselect> tag
        • The <s:doubleselect> tag
      • Uploading files
      • Preventing double submits with the <s:token> tag
    • Summary
  • Chapter 7: Form Validation and Type Conversion
    • Form validation
      • Manual validation
      • Configuring XML validation
        • Customizing validation messages
      • What validations are available?
        • The requiredstring validator
        • The stringlength validator
        • Detour—playing games with validation messages
        • The required and int validators
        • But wait, there's more
        • The double validator
        • The email validator
        • The url validator
        • The date validator
        • The regex validator
        • The expression and fieldexpression validators
        • Combining validation methods
        • The conversion validator
        • The visitor validator
      • Configuring validation with annotations
        • The @Validation annotation
        • The @Validations annotation
        • The @SkipValidation annotation
        • The @RequiredFieldValidator annotation
        • The @IntRangeFieldValidator annotation
        • The @DoubleRangeFieldValidator annotation
        • The remaining validation annotations
      • Client-side validation
      • Custom validators
    • Type conversion
      • The problem
      • The solution
      • Defining our own converters
        • Type conversion usecase—trimmed BigDecimals
        • Configuring conversion across the entire application
        • Custom type conversion is handy
      • Collections
        • Usecase—adding a list of ingredients
        • Updating our new recipe form
        • Map-based collections
    • Summary
  • Chapter 8: Interceptors
    • The basics
      • Configuring interceptor stacks
      • Configuring interceptors
      • Configuring interceptors for individual actions
      • How interceptors work
    • Interceptors in the default stack
      • The exception interceptor
      • The alias interceptor
      • The servletConfig interceptor
      • The prepare interceptor
      • The i18n interceptor
      • The chain interceptor
      • The debugging interceptor
      • The profiling interceptor
      • The scopedModelDriven interceptor
      • The modelDriven interceptor
        • Getting back to the scopedModelDriven interceptor
      • The fileUpload interceptor
      • The checkbox interceptor
      • The staticParams interceptor
      • The params interceptor
        • Ordered parameters and ad hoc factory patterns
      • The conversionError interceptor
      • The validation interceptor
      • The workflow interceptor
    • Other important interceptors and interceptor stacks
      • The token interceptor
      • The store interceptor
      • The roles Interceptor
      • The clearSession interceptor
      • The paramsPrepareParamsStack interceptor stack
    • Writing our own interceptors
      • The trim interceptor
      • Configuring the trim interceptor
      • The Test Action
      • Testing the trim interceptor
      • Modifying application flow with interceptors
        • Configuring the result
        • Writing the ResultMappingInterceptor
        • Writing the ResultMappingInterceptor and making it work
    • Summary
  • Chapter 9: Exceptions and Logging
    • Handling exceptions in Struts 2
      • Global exception mappings
      • Action-specific exception mappings
      • Accessing the exception
      • Architecting exceptions and exception handling
        • Checked versus unchecked exceptions
        • Application-specific exceptions
        • Abstracting underlying exceptions
      • Handling exceptions
    • Logging
      • Introduction to logging
        • Using the loggers
        • Configuring the loggers
    • Summary
  • Chapter 10: Getting Started with JavaScript
    • Introduction to JavaScript
      • Playing with JavaScript
    • Minor syntax and language notes
      • Unicode
      • Whitespace
      • Semicolons
      • Null and undefined values
      • The equal and strict equal operators
      • The logical OR operator
    • Variables and scoping
      • JavaScript data types
        • Numbers
        • Strings
        • Arrays
    • Exception handling
    • Introduction to JavaScript objects and OOP
      • Open objects and object augmentation
      • Object values can be functions
      • Object maker functions
    • Functions
      • Function parameters
        • Some trickery
      • Inner functions
      • Closures
    • Introduction to JavaScript classes
      • Creating classes
        • Variable and function access
        • JavaScript's "this" keyword
      • Prototypes
    • JavaScript modules and OOP
      • Creating a namespace
    • Summary
  • Chapter 11: Advanced JavaScript, the DOM, and CSS
    • The importance of markup
      • ID or style attribute?
      • Dressing up our form
        • JavaScript modules and jQuery
      • Adding onclick handlers
        • Using a function builder
        • Accessing module data
        • The final trick
    • Adding dynamic form elements
      • Identifying where to add the elements
      • The JavaScript "Recipe" module
    • Summary
  • Chapter 13: Rich Internet Applications
    • What this chapter is and isn't
    • Dojo tags
      • Simple use cases really are simple
      • The Dojo <sx:head> tag
      • The Dojo <sx:a> tag
      • A brief side journey on topics
      • The Dojo <sx:div> tag
        • Finishing our user story
        • Highlighting the need to know
      • Dojo and forms
    • The REST plug-in
      • REST in a nutshell
      • The REST plug-in in a nutshell
        • REST plug-in URLs
        • REST plug-in results
      • A web browser client example
        • The REST controller
        • REST controller responses
      • An example of a useful client
      • A command-line example
      • Custom content handler example
        • YAML in a nutshell
        • Writing our YAML handler
        • Configuring our YAML handler
        • Handling our YAML
    • Summary
  • Chapter 14: Comprehensive Testing
    • Test-driven development
    • Unit testing
      • Test, code, refactor—the "heartbeat" of TDD
      • JUnit
        • Revisiting our iterator filter
        • The test environment
        • The initial test stub
        • Testing vowel recognition
        • Testing non-string parameter exceptions
        • Test granularity and test setup
      • TestNG
      • Legacy code and unit testing
      • Simple action testing
        • Detour: Dependency Injection (Inversion of Control)
        • Dependency Injection helps us test
      • Detour: Struts and Spring in a nutshell
        • Spring web.xml configuration
        • Spring context configuration file
    • Testing Struts 2 in context
      • Testing a Struts interceptor
    • Client-side (functional) testing
      • Selenium
        • Selenium RC
        • The test scenario
        • Our first Selenium test
    • Other forms of testing
      • Acceptance testing
      • Load testing
        • Load testing with JMeter
      • Recovery testing
    • Summary
  • Chapter 15: Documenting our Application
    • Documenting Java
      • Self-documenting code
        • Document why, not what
        • Make your code read like the problem
        • Contract-oriented programming
      • Javadocs
        • Always write Javadocs!
        • The first sentence
        • Add information beyond the API name
        • Write for multiple formats
        • Generating targeted Javadocs
        • The -use argument
        • Creating new Javadoc tags with the -tag argument
        • Never write Javadocs!
        • Never write inline Java comments!
      • Using UML
        • Package diagrams
        • Class diagrams
        • Sequence diagrams
    • Documenting web applications
      • High-level overviews
      • Documenting JSPs
      • Documenting JavaScript
      • Documenting interaction
        • More UML and the power of scribbling
        • Don't spend so much time making pretty pictures
      • User documentation
    • Documenting development
      • Source code control systems
        • Code and mental history
        • Commit comment commitment
        • When (and what) do we commit
        • Branching
        • Branching discipline
      • Issue and bug management
        • Linking to the SCCS
      • Wikis
      • RSS and IRC/chat systems
      • Word processor documents
    • Summary
Back to BOOK PAGE

Dave Newton

Dave Newton, a Struts PMC member, has been a professional developer for over twenty years, getting his start in Lisp and Smalltalk development, moving on to a lengthy stint in embedded system, game, and device driver development, before (confusingly) finding himself writing Java-based web applications for a variety of clients.

He is a strong proponent of agile practices and tool creation and use, particularly in relationship to documentation generation and testing. He's a regular (if crabby) fixture on the Struts user mailing list, prodding people to read the documentation and think outside the box.




Contact Dave Newton

Sorry, we don't have any reviews for this title yet.

Code Downloads

Download the code and support files for this book.


Submit Errata

Please let us know if you have found any errors not listed on this list by completing our errata submission form. Our editors will check them and add them to this list. Thank you.


Errata

- 1 submitted: last submission 10 Sep 2012

Errata type: Technical| Page number: 98

In chapter 5, The tag, This snippet will produce the following: 1 a 2 b 3 c d e f It should be 0 a 1 b 2 c d e f

 

Sample chapters

You can view our sample chapters and prefaces of this title on PacktLib or download sample chapters in PDF format.

Frequently bought together

Apache Struts 2 Web Application Development +    Learning QlikView Data Visualization =
50% Off
the second eBook
Price for both: $30.05

Buy both these recommended eBooks together and get 50% off the cheapest eBook.

What you will learn from this book

  • Explore the features of Struts 2.1 to develop your application
  • Enhance your web application by writing your own custom result type
  • Create your own type converter to handle custom data types
  • Automatically generate application and development documentation
  • Learn good exception handling practices for your applications
  • Implement rich client behavior using JavaScript, the DOM, and CSS
  • Create custom themes and templates to make shorter, cleaner JSP pages
  • Run many types of tests both to prove functionality and to make change safe

In Detail

Struts 2.1 is a modern, extensible, agile web application framework suitable for both small- and large-scale web applications.

The book begins with a comprehensive look at Struts 2.1 basics, interspersed with detours into more advanced development topics. You'll learn about configuring Struts 2.1 actions, results, and interceptors via both XML and Java annotations. You'll get an introduction to most of the Struts 2.1 custom tags and learn how they can assist in rapid application prototyping and development.

From there you'll make your way into Struts 2.1's strong support for form validation and type conversion, which allows you to treat your form values as domain objects without cluttering your code. A look at Struts 2.1's interceptors is the final piece of the Struts 2.1 puzzle, allowing you to leverage the standard Struts 2 interceptors as well as implement your own custom behavior.

After covering Struts 2.1 you'll journey into the world of JavaScript, a surprisingly capable language, the Document Object Model (DOM), and CSS, and learn how to create clean and concise client-side behavior. You'll leverage that knowledge as you move on to Struts 2 themes and templates, which give you a powerful way to encapsulate site-wide user interface behavior.

The book closes with a look at some tools that make the application development life cycle easier to manage, particularly in a team environment, and more automatic.

This book provides an in-depth introduction to Struts 2 and crash-courses in JavaScript, CSS, Test-Driven Development, agile programming techniques, and tool development, focusing on the delivery of complete, documented, maintainable web applications.

Approach

This book takes a clear approach, focusing on one topic per chapter, but interspersing other issues in the mainline text and in chapter detours. Taking a practical approach, it discusses agile web development using Struts 2, with plenty of examples for better understanding.

Who this book is for

This book is for Java developers who are interested in developing web applications using Struts. If you need a comprehensive introduction to Struts 2.1, along with the most important aspects of additional web application development technologies, agile programming practices, tool creation, and application life cycle management this book is for you. You don't need to know JavaScript and CSS to use this book as the author will teach you the required basics.

If you are a Struts 1 or WebWork user and wish to go ahead and migrate to Struts 2, this practical guide is also for you.

Code Download and Errata
Packt Anytime, Anywhere
Register Books
Print Upgrades
eBook Downloads
Video Support
Contact Us
Awards Voting Nominations Previous Winners
Judges Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
Resources
Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software