Expert Spring MVC and Web Flow



Similar documents
Java Building Web Apps with Spring Rob Harrop, Interface21 Ltd.

Complete Java Web Development

Expert One-on-One J2EE Design and Development

Beginning POJOs. From Novice to Professional. Brian Sam-Bodden

How To Write A Web Framework In Java

Mastering Tomcat Development

Client-server 3-tier N-tier

Building Web Applications, Servlets, JSP and JDBC

SSC - Web development Model-View-Controller for Java web application development

The Spring Framework: An Open Source Java Platform for Developing Robust Java Applications

Course Name: Course in JSP Course Code: P5

Web Frameworks and WebWork

Model-View-Controller. and. Struts 2

Web Container Components Servlet JSP Tag Libraries

Web Applications and Struts 2

2012 LABVANTAGE Solutions, Inc. All Rights Reserved.

JAVA ENTERPRISE IN A NUTSHELL. Jim Farley and William Crawford. O'REILLY 4 Beijing Cambridge Farnham Koln Paris Sebastopol Taipei Tokyo.

Cocoon 2 Programming: Web Publishing with XML and Java"

Spring 3.1 to 3.2 in a Nutshell. Sam Brannen Senior Software Consultant

Case Studies of Running the Platform. NetBeans UML Servlet JSP GlassFish EJB

Converting Java EE Applications into OSGi Applications

An introduction to creating JSF applications in Rational Application Developer Version 8.0

OUR COURSES 19 November All prices are per person in Swedish Krona. Solid Beans AB Kungsgatan Göteborg Sweden

Reporting and JSF. Possibilities, solutions, challenges. Slide 1. Copyright 2009, Andy Bosch,

White Paper On. Single Page Application. Presented by: Yatin Patel

Beginning ASP.NET 4.5

Client-Server Architecture & J2EE Platform Technologies Overview Ahmed K. Ezzat

CQCON 2013: five Sling features you should know

Multi Factor Authentication API

The Oracle Fusion Development Platform

Simplify Your Web App Development Using the Spring MVC Framework

Architecture Guide Jahia EE v6.1

CrownPeak Java Web Hosting. Version 0.20

Java Platform, Enterprise Edition (Java EE) From Yes-M Systems LLC Length: Approx 3 weeks/30 hours Audience: Students with experience in Java SE

PL/SQL Programming Workbook

COMPARISON BETWEEN SPRING AND ASP.NET FRAMEWORKS

Programma corso di formazione J2EE

Patterns of Enterprise Application Architecture

Enterprise Application Development In Java with AJAX and ORM

Nicholas S. Williams. wrox. A Wiley Brand

Jaspersoft APIs. Integrating BI with your Applications. Community and Professional Editions

Practical Eclipse Rich Client Platform Projects

JAVA/J2EE DEVELOPER RESUME

What s new in Spring 3.1?

GOA365: The Great Office 365 Adventure

Customer Bank Account Management System Technical Specification Document

Spring Web Flow Reference Guide

Web Frameworks. web development done right. Course of Web Technologies A.A. 2010/2011 Valerio Maggio, PhD Student Prof.

Portals, Portlets & Liferay Platform

Tutorial: Building a Web Application with Struts

Introduction. Acknowledgments Support & Feedback Preparing for the Exam. Chapter 1 Plan and deploy a server infrastructure 1

Rapid Application Development. and Application Generation Tools. Walter Knesel

Title Page. Hosted Payment Page Guide ACI Commerce Gateway

Developing XML Solutions with JavaServer Pages Technology

SwiftScale: Technical Approach Document

Evaluating Presentation Layer Development Frameworks for EJB Applications in J2EE Architecture

Workflow Administration of Windchill 10.2

Pentesting Web Frameworks (preview of next year's SEC642 update)

NetBeans IDE Field Guide

Java EE 7: Back-End Server Application Development

The Great Office 365 Adventure

Core J2EE Patterns, Frameworks and Micro Architectures

SPRING INTERVIEW QUESTIONS

Copyright 2014 Jaspersoft Corporation. All rights reserved. Printed in the U.S.A. Jaspersoft, the Jaspersoft

The end. Carl Nettelblad

Server side PDF generation based on L A TEX templates

Automated Testing of Java Web Applications. Master of Science Thesis in Software Engineering and Technology MÄRT KALMO

Oracle Application Development Framework Overview

Research Article. ISSN (Print) *Corresponding author Lili Wang

Design Approaches of Web Application with Efficient Performance in JAVA

Yes Bank open source CRM. Yes Bank Collaborative CRM (YCCRM) Case Study. Empower business with Professional Open Source. Solutions.

Java 7 Recipes. Freddy Guime. vk» (,\['«** g!p#« Carl Dea. Josh Juneau. John O'Conner

Welcome The webinar will begin shortly

NextRow - AEM Training Program Course Catalog

Red Hat Enterprise Portal Server: Architecture and Features

How to Build an E-Commerce Application using J2EE. Carol McDonald Code Camp Engineer

How to Easily Integrate BIRT Reports into your Web Application

Preface. Motivation for this Book

APAC WebLogic Suite Workshop Oracle Parcel Service Overview. Jeffrey West Application Grid Product Management

In this chapter, we lay the foundation for all our further discussions. We start

Oracle JDeveloper 10g for Forms & PL/SQL

Creating an EAD Finding Aid. Nicole Wilkins. SJSU School of Library and Information Science. Libr 281. Professor Mary Bolin.

Leveraging the Eclipse TPTP* Agent Infrastructure

JVA-122. Secure Java Web Development

Amplify Service Integration Developer Productivity with Oracle SOA Suite 12c

Alfresco. Wiley Publishing, Inc. PROFESSIONAL. PRACTICAL SOLUTIONS FOR ENTERPRISE. John Newton CONTENT MANAGEMENT. Michael Farman Michael G.

Day 1 - Technology Introduction & Digital Asset Management

Professional Portal Development with Open Source lools: Java' Portlet API, Lucene, James, SUde

Framework Adoption for Java Enterprise Application Development

Course Number: IAC-SOFT-WDAD Web Design and Application Development

About the Authors About the Technical Reviewer

Software Development Interactief Centrum voor gerichte Training en Studie Edisonweg 14c, 1821 BN Alkmaar T:

Server-side OSGi with Apache Sling. Felix Meschberger Day Management AG 124

Building and Using Web Services With JDeveloper 11g

AppFabric. Pro Windows Server. Stephen Kaufman. Danny Garber. Apress. INFORMATIONSBIBLIOTHbK TECHNISCHE. U N! V En SIT AT S R!

Transcription:

Expert Spring MVC and Web Flow Seth Ladd with Darren Davison, Steven Devijver and Colin Yates ULB Darmstadt 76386 Apress*

Contents at a Glance About the Authors About the Technical Reviewers Acknowledgments xv xvii xviii ECHAPTER 1 DCHAPTER 2 DCHAPTER 3 CCHAPTER 4 CCHAPTER 5 ECHAPTER 6 CCHAPTER 7 CCHAPTER 8 ECHAPTER 9 ECHAPTER 10 CCHAPTER 11 ECHAPTER 12 CAPPENDIX A CAPPENDIX B EiNDEX Introduction 1 Spring Fundamentals 7 Spring MVC Application Architecture 21 Jump into Spring MVC 41 The Processing Pipeline 77 The Controller Menagerie 115 The View Layer 201 Supported View Types 223 Validation 265 Testing Spring MVC Applications 283 Introduction to Spring Web Flow 309 Advanced Spring Web Flow 335 Documenting Your MVC Application 371 Ajax and DWR 377 389

Contents About the Authors About the Technical Reviewers Acknowledgments xv xvii xviii CCHAPTER 1 Introduction 1 Skipping Ahead 2 How to View This Book.. 2 Roadmap 2 Target Audience 4 For More Information... 4 Sample Applications 5 Spring 2.0 5 Summary 6 CCHAPTER 2 Spring Fundamentals Inversion of Control 7 loc Example 8 Summary 10 Dependency Injection 11 Service Locator 12 Dependency Injection 14 Spring ApplicationContexts 17 The Return of the POJO 18 Impact on Web Applications 19 Summary 19 ECHAPTER 3 Spring MVC Application Architecture 21 Layers of Abstractions 21 Layer Isolation 23 Java Interface As Layer Contract 23 Layers in a Spring MVC Application 24 Options: There's More Than One Way to Do It 38 Summary 39

VIII ECONTENTS HIHAPTER 4 Jump into Spring MVC 41 Use Cases 41 Service Interface 42 Use Case #1 42 Use Case #2 45 Summary 50 Web Components 50 JAR Dependencies 50 Controllers 52 Views 52 ModelAndView 53 Building the Home Page Use Case 53 Spring MVC Components '. 53 Web Application Configuration 58 Start the Application 63 Request Handling Sequence 63 Summary 64 Building the Search for Flights Use Case 65 SimpleFormController 65 SearchFlightsController 67 Form View 69 Spring JSPTags 72 Success View 73 Summary 74 Now Let's Learn How to Swim 75 CHAPTER 5 The Processing Pipeline 77 Processing Requests 77 Request Work Flow 77 Functionality Overview 78 Pieces of the Puzzle 79 Summary 114 CHAPTER 6 The Controller Menagerie 115 Introduction v 115 The Controller Interface and Implementations 116 A Look at Design 116 AbstractController 118 Summary 122

EXONTENTS BaseCommandController 122 Binding a Form to a Bean 124 Summary 148 SimpleFormController and Handling Forms 149 Redirect After Submit Pattern 164 MultiActionController 168 AbstractWizardFormController 176 ThrowawayController 193 ValidatableThrowawayController 196 Handlerlnterceptors 196 Handlerlnterceptor Example 197 Summary 198 Controllers Summary 199 ECHAPTER 7 The View Layer 201 What's in a View 201 Treating Views in Isolation 202 Spring's View Interface 202 Implementing View 203 Views and Controllers: Happily Divorced 207 ViewResolvers 208 Putting View Resolution in Context 209 Types of ViewResolver 210 Making ViewResolvers Known to the Dispatcher 213 A Word on Redirecting 215 Themes 216 ThemeSources 217 ThemeResolvers 218 Internationalization in the View Layer 218 Locale Resolution 218 MessageSource Beans 219 View Resolution 220 Theme Resolution 221 Bind Support 221 Recap of Binding and Validation Sequence 221 Bind Support in View Templates 221 Summary.'. 222

CCONTENTS ECHAPTER 8 Supported View Types 223 JSP and JSTL 223 Exposing the Model As Request Attributes 224 Displaying the Model 225 JSP Tag Libraries 227 Forms 228 Tiles 233 Summary 235 Velocity and FreeMarker 235 Templating Pros and Cons 235 Basic Configuring for Template Engines 236 Exposing the Model ^ 238 The Template Language 238 Advanced Configuration Options 239 Forms and the SpringBind Macros.241 Number and Date Tools 247 Additional Velocity Views 249 Summary 249 XML and XSLT 250 Defining an XSLT View 250 Transforming the XML Source 252 Returning XML in the Raw 254 Other Noteworthy XSLT Features 254 Summary 255 PDF 256 Configuring the Application to Use a PDF View 257 Template PDFs with FOP 257 Excel 258 Creating the Template 258 Coding the View 259 Configuring the Application 260 JasperReports 260 MultiformatView 261 Populating the Report 262 Summary 263 Creating New Views 263 Summary." 264

^CONTENTS DCHAPTER 9 Validation 265 Programmatic Validators 265 Declarative Validators 267 Message Sources 278 Validators and Business Logic 279 Errors Interface ) 279 Testing Validators 281 Summary., 282 DCHAPTER 10 Testing Spring MVC Applications 283 Overview 283 Unit Tests 283 Unit Test Summary 302 Integration Tests v 302 Testing Summary 308 ECHAPTER 11 Introduction to Spring Web Flow 309 What Itch Does Spring Web Flow Scratch? 309 The Problem with the Servlet Specification 310 The Solution 311 Not a Golden Hammer 314 The Big Picture 314 Architectural Overview 315 Inside the Spring Web Flow System 315 Different Scopes 316 Building Blocks 316 Your First Flow 319 Installing Spring Web Flow 319 Proposed Flow Directory Structure 319 The Purchase Product Flow Definition 320 Implementing the First Step: View States 320 Transitions 320 Actions 321 Action Bean Definitions 322 TestiQg the Flow Execution 324 Extending AbstractFlowExecutionTests 324 Decision States 326

xii EEONTENTS Action States 327 End States 328 The Purchase Product Flow: What's Next 329 Spring MVC Deployment 330 The FlowController 330 FlowRegistry 330 Additional Configuration 331 View Template Resolution 331 View Template Requirements 331 Launching the Flow from the Browser 332 Summary 333 Model Conversations 333 Allows for Extension >. 334 Testable 334 Identifying Flows (Easy, Natural Language) 334 CHAPTER 12 Advanced Spring Web Flow 335 Business Logic and Flows 335 Business Logic 335 Flow Granularity 337 Subflows 337 Inline Flows 343 Summary 345 Managing FlowExecutions 346 Integration with Web Frameworks 346 The FlowExecutionManager 347 FlowExecutions 348 FlowExecutionListener 351 FlowExecution Repositories 353 Continuations 354 FlowExecutionRepository Implementations 356 Stateful FlowExecution Repositories 356 Stateless FlowExecution Repositories 357 Conversation Invalidation After Completion 358 States and Transitions Revisited 358 Action States 359, POJO Actions 362 Exposing POJO Method Return Values 363 Customizing View Selection with View States and End States... 363 Decision States 365

ECONTENTS XIII Exception Handling 367 State Scoped ExceptionHandlers 369 Exception Handling Summary 369 Summary 369 APPENDIX A Documenting Your MVC Application 371 BeanDoc 371 Installing and Building BeanDoc 372 Running BeanDoc on Your Configuration Files 373 Other Options 374 Controlling the Output 374 Summary 375 CAPPENDIX B Ajax and DWR 377 Spring and DWR 377 A Practical Example 378 Configuration and Code Changes 378 Presentation File Changes 381 Accessibility 387 Summary 388 NDEX '...' 389