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
- Creating our own applications
- Summary
- Struts 2 in a nutshell
- 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
- Setting up our environment
- 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
- The Action interface
- 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
- Detour—creating the list of interfaces to explore
- Additional action interfaces
- Preparable interface
- Accessing scoped attributes (and request parameters)
- Accessing servlet objects
- Request parameter/action property filtering
- Summary
- ActionSupport and its interfaces
- 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
- Contents of the value stack and the <s:property> tag
- 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?
- The <s:iterator> tag
- Referencing other pages and actions
- The <s:include> tag
- The <s:action> tag
- The <s:url> tag
- Summary
- OGNL
- 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
- Form tag basics
- 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
- Form validation
- 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
- The basics
- 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
- Introduction to logging
- Summary
- Handling exceptions in Struts 2
- 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
- JavaScript data types
- 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
- Function parameters
- Introduction to JavaScript classes
- Creating classes
- Variable and function access
- JavaScript's "this" keyword
- Prototypes
- Creating classes
- JavaScript modules and OOP
- Creating a namespace
- Summary
- Introduction to JavaScript
- 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
- The importance of markup
- Chapter 12: Themes and Templates
- Extracting the templates
- A maze of twisty little passages
- Creating our theme
- Other uses of templates
- 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
- Selenium
- 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
- Self-documenting code
- 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
- Source code control systems
- Summary
- Documenting Java



