Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software...

265
Migrating to Struts 2 A tutorial for Struts 1 Developers Struts University Series

Transcript of Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software...

Page 1: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Migrating to Struts 2A tutorial for Struts 1 Developers

Struts University Series

Page 2: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Migrating to Struts 2A tutorial for Struts 1 Developers

Struts University Series

Page 3: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Ted? Who's Ted?

Apache Software Foundation Member Apache Struts & Apache iBATIS PMCsJUnit in Action, Struts in Action, and Professional JSP Site DesignConsult with teams throughout the United StatesStill working with the OK DEQ

Page 4: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Ted? Who's Ted?

Apache Software Foundation Member Apache Struts & Apache iBATIS PMCsJUnit in Action, Struts in Action, and Professional JSP Site DesignConsult with teams throughout the United StatesStill working with the OK DEQ

Page 5: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Ted? Who's Ted?

Apache Software Foundation Member Apache Struts & Apache iBATIS PMCsJUnit in Action, Struts in Action, and Professional JSP Site DesignConsult with teams throughout the United StatesStill working with the OK DEQ

Page 6: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Ted? Who's Ted?

Apache Software Foundation Member Apache Struts & Apache iBATIS PMCsJUnit in Action, Struts in Action, and Professional JSP Site DesignConsult with teams throughout the United StatesStill working with the OK DEQ

Page 7: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Ted? Who's Ted?

Apache Software Foundation Member Apache Struts & Apache iBATIS PMCsJUnit in Action, Struts in Action, and Professional JSP Site Design.Consult with teams throughout the United StatesStill working with the OK DEQ

Page 8: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Ted? Who's Ted?

Apache Software Foundation Member Apache Struts & Apache iBATIS PMCsJUnit in Action, Struts in Action, and Professional JSP Site Design.Consult with teams throughout the United StatesStill working with the OK DEQ

Page 9: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Migrating to Struts 2

Help Struts 1 developers become knowledgeable Struts 2 developers as quickly as possibleMigrate Struts 1 application to Struts 2Intended for experienced Java web developers

Page 10: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Migrating to Struts 2

Help Struts 1 developers become knowledgeable Struts 2 developers as quickly as possibleMigrate Struts 1 application to Struts 2Intended for experienced Java web developers

Page 11: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Migrating to Struts 2

Help Struts 1 developers become knowledgeable Struts 2 developers as quickly as possibleMigrate Struts 1 application to Struts 2Intended for experienced Java web developers

Page 12: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Migrating to Struts 2

Help Struts 1 developers become knowledgeable Struts 2 developers as quickly as possibleMigrate Struts 1 application to Struts 2Intended for experienced Java web developers

Page 13: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Baseline Questions

What is Struts 2? How are Struts 1 and Struts alike?What's changed in Struts 2? Is Struts 1 obsolete?Is it difficult to migrate?Why are "plain old Java objects" important?Where should a migration begin?

Page 14: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Baseline Questions

What is Struts 2? How are Struts 1 and Struts alike?What's changed in Struts 2? Is Struts 1 obsolete?Is it difficult to migrate?Why are "plain old Java objects" important?Where should a migration begin?

Page 15: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Baseline Questions

What is Struts 2? How are Struts 1 and Struts alike?What's changed in Struts 2? Is Struts 1 obsolete?Is it difficult to migrate?Why are "plain old Java objects" important?Where should a migration begin?

Page 16: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Baseline Questions

What is Struts 2? How are Struts 1 and Struts alike?What's changed in Struts 2? Is Struts 1 obsolete?Is it difficult to migrate?Why are "plain old Java objects" important?Where should a migration begin?

Page 17: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Baseline Questions

What is Struts 2? How are Struts 1 and Struts alike?What's changed in Struts 2? Is Struts 1 obsolete?Is it difficult to migrate?Why are "plain old Java objects" important?Where should a migration begin?

Page 18: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Baseline Questions

What is Struts 2? How are Struts 1 and Struts alike?What's changed in Struts 2? Is Struts 1 obsolete?Is it difficult to migrate?Why are "plain old Java objects" important?Where should a migration begin?

Page 19: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Baseline Questions

What is Struts 2? How are Struts 1 and Struts alike?What's changed in Struts 2? Is Struts 1 obsolete?Is it difficult to migrate?Why are "plain old Java objects" important?Where should a migration begin?

Page 20: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Baseline Questions

What is Struts 2? How are Struts 1 and Struts alike?What's changed in Struts 2? Is Struts 1 obsolete?Is it difficult to migrate?Why are "plain old Java objects" important?Where should a migration begin?

Page 21: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

What is Struts 2?

Free open-source framework Two major versions

Struts 1 Proven solution to common problems

Struts 2 Elegant solution to difficult problems

Page 22: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

What is Struts 2?

Free open-source framework Two major versions

Struts 1 Proven solution to common problems

Struts 2 Elegant solution to difficult problems

Page 23: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

What is Struts 2?

Free open-source framework Two major versions

Struts 1 Proven solution to common problems

Struts 2 Elegant solution to difficult problems

Page 24: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

What is Struts 2?

Free open-source framework Two major versions

Struts 1 Proven solution to common problems

Struts 2 Elegant solution to difficult problems

Page 25: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

How are Struts 1 and Struts 2 alike?

A "request" handler maps Java classes to web application URIs

A "response" handler maps logical names to web resources

A tag library creates rich, form-based applications

Page 26: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

How are Struts 1 and Struts 2 alike?

A "request" handler maps Java classes to web application URIs

A "response" handler maps logical names to web resources

A tag library creates rich, form-based applications

Page 27: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

How are Struts 1 and Struts 2 alike?

A "request" handler maps Java classes to web application URIs

A "response" handler maps logical names to web resources

A tag library creates rich, form-based applications

Page 28: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

How are Struts 1 and Struts 2 alike?

A "request" handler maps Java classes to web application URIs

A "response" handler maps logical names to web resources

A tag library creates rich, form-based applications

Page 29: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

What's changed in Struts 2?

Smarter! Improved Design Intelligent Defaults Enhanced Results Enhanced Tags First-class AJAX support Stateful Checkboxes QuickStart

Page 30: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

What's changed in Struts 2?

Smarter! Improved Design Intelligent Defaults Enhanced Results Enhanced Tags First-class AJAX support Stateful Checkboxes QuickStart

Page 31: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

What's changed in Struts 2?

Smarter! Improved Design Intelligent Defaults Enhanced Results Enhanced Tags First-class AJAX support Stateful Checkboxes QuickStart

Page 32: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

What's changed in Struts 2?

Smarter! Improved Design Intelligent Defaults Enhanced Results Enhanced Tags First-class AJAX support Stateful Checkboxes QuickStart

Page 33: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

What's changed in Struts 2?

Smarter! Improved Design Intelligent Defaults Enhanced Results Enhanced Tags First-class AJAX support Stateful Checkboxes QuickStart

Page 34: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

What's changed in Struts 2?

Smarter! Improved Design Intelligent Defaults Enhanced Results Enhanced Tags First-class AJAX support Stateful Checkboxes QuickStart

Page 35: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

What's changed in Struts 2?

Smarter! Improved Design Intelligent Defaults Enhanced Results Enhanced Tags First-class AJAX support Stateful Checkboxes QuickStart

Page 36: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

What's changed in Struts 2?

Smarter! Improved Design Intelligent Defaults Enhanced Results Enhanced Tags First-class AJAX support Stateful Checkboxes QuickStart

Page 37: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

What's changed in Struts 2?

Smarter! Improved Design Intelligent Defaults Enhanced Results Enhanced Tags First-class AJAX support Stateful Checkboxes QuickStart

Page 38: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

What's Changed in Struts 2?

Easier! Easy-to-test Actions Easy-to-customize controller Easy-to-tweak tags Easy cancel handling Easy Spring integration Easy plugins

Page 39: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

What's Changed in Struts 2?

Easier! Easy-to-test Actions Easy-to-customize controller Easy-to-tweak tags Easy cancel handling Easy Spring integration Easy plugins

Page 40: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

What's Changed in Struts 2?

Easier! Easy-to-test Actions Easy-to-customize controller Easy-to-tweak tags Easy cancel handling Easy Spring integration Easy plugins

Page 41: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

What's Changed in Struts 2?

Easier! Easy-to-test Actions Easy-to-customize controller Easy-to-tweak tags Easy cancel handling Easy Spring integration Easy plugins

Page 42: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

What's Changed in Struts 2?

Easier! Easy-to-test Actions Easy-to-customize controller Easy-to-tweak tags Easy cancel handling Easy Spring integration Easy plugins

Page 43: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

What's Changed in Struts 2?

Easier! Easy-to-test Actions Easy-to-customize controller Easy-to-tweak tags Easy cancel handling Easy Spring integration Easy plugins

Page 44: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

What's Changed in Struts 2?

Easier! Easy-to-test Actions Easy-to-customize controller Easy-to-tweak tags Easy cancel handling Easy Spring integration Easy plugins

Page 45: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

What's Changed in Struts 2

POJO-ier! POJO forms POJO Actions

Page 46: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

What's Changed in Struts 2

POJO-ier! POJO forms POJO Actions

Page 47: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

What's Changed in Struts 2

POJO-ier! POJO forms POJO Actions

Page 48: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Is Struts 1 obsolete?

Robust and vibrant communityThousands of applications in production New 1.3.5 releaseBut, is it time to try Struts 2?

Page 49: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Is Struts 1 obsolete?

Robust and vibrant communityThousands of applications in production New 1.3.5 releaseBut, is it time to try Struts 2?

Page 50: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Is Struts 1 obsolete?

Robust and vibrant communityThousands of applications in production New 1.3.5 releaseBut, is it time to try Struts 2?

Page 51: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Is Struts 1 obsolete?

Robust and vibrant communityThousands of applications in production New 1.3.5 releaseBut, is it time to try Struts 2?

Page 52: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Is Struts 1 obsolete?

Robust and vibrant communityThousands of applications in production New 1.3.5 releaseBut, is it time to try Struts 2?

Page 53: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Is it difficult to migrate?

Not difficult but non-trivial Migrating Actions takes time and effortStable: may not be worth the effortGrowth: good investment

Page 54: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Is it difficult to migrate?

Not difficult but non-trivial Migrating Actions takes time and effortStable: may not be worth the effortGrowth: good investment

Page 55: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Is it difficult to migrate?

Not difficult but non-trivial Migrating Actions takes time and effortStable: may not be worth the effortGrowth: good investment

Page 56: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Is it difficult to migrate?

Not difficult but non-trivial Migrating Actions takes time and effortStable: may not be worth the effortGrowth: good investment

Page 57: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Is it difficult to migrate?

Not difficult but non-trivial Migrating Actions takes time and effortStable: may not be worth the effortGrowth: good investment

Page 58: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Is it difficult to migrate?

Not difficult but non-trivial Migrating Actions takes time and effortStable: may not be worth the effortGrowth: good investmentStruts 2 is smarter, easier

Page 59: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Is it difficult to migrate?

Not difficult but non-trivial Migrating Actions takes time and effortStable: may not be worth the effortGrowth: good investmentStruts 2 is smarter, easier, and POJO-ier

Page 60: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Why are POJOs important?

No "extra" objects Instantiate Actions with new or Spring Simulate servlet state with HashMap

Rich input properties No ActionForms! Use Action or any other object Non-String properties are not a problem

Page 61: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Why are POJOs important?

No "extra" objects Instantiate Actions with new or Spring Simulate servlet state with HashMap

Rich input properties No ActionForms! Use Action or any other object Non-String properties are not a problem

Page 62: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Why are POJOs important?

No "extra" objects Instantiate Actions with new or Spring Simulate servlet state with HashMap

Rich input properties No ActionForms! Use Action or any other object Non-String properties are not a problem

Page 63: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Struts University Series

Page 64: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

How are Struts 1 and Struts 2 alike?

A "r******" handler maps Java classes to web application URIs

A "r*******" handler maps logical names to web resources

A *** library creates rich, form-based applications

Page 65: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

How are Struts 1 and Struts 2 alike?

A "request" handler maps Java classes to web application URIs

A "r*******" handler maps logical names to web resources

A *** library creates rich, form-based applications

Page 66: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

How are Struts 1 and Struts 2 alike?

A "request" handler maps Java classes to web application URIs

A "response" handler maps logical names to web resources

A *** library creates rich, form-based applications

Page 67: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

How are Struts 1 and Struts 2 alike?

A "request" handler maps Java classes to web application URIs

A "response" handler maps logical names to web resources

A tag library creates rich, form-based applications

Page 68: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

How are Struts 1 and Struts 2 alike?

A "request" handler maps Java classes to web application URIs

A "response" handler maps logical names to web resources

A tag library creates rich, form-based applications

Page 69: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Where should a migration begin?

Add Struts 2 JARs Migrate application page at a timeUse both versions at the same timeArchitectures can remain the sameRemove Struts 1 red tapeSwap in new tags

Page 70: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Where should a migration begin?

Add Struts 2 JARs Migrate application page at a timeUse both versions at the same timeArchitectures can remain the sameRemove Struts 1 red tapeSwap in new tags

Page 71: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Where should a migration begin?

Add Struts 2 JARs Migrate application page at a timeUse both versions at the same timeArchitectures can remain the sameRemove Struts 1 red tapeSwap in new tags

Page 72: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Where should a migration begin?

Add Struts 2 JARs Migrate application page at a timeUse both versions at the same timeArchitectures can remain the sameRemove Struts 1 red tapeSwap in new tags

Page 73: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Where should a migration begin?

Add Struts 2 JARs Migrate application page at a timeUse both versions at the same timeArchitectures can remain the sameRemove Struts 1 red tapeSwap in new tags

Page 74: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Where should a migration begin?

Add Struts 2 JARs Migrate application page at a timeUse both versions at the same timeArchitectures can remain the sameRemove Struts 1 red tapeSwap in new tags

Page 75: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Where should a migration begin?

Add Struts 2 JARs Migrate application page at a timeUse both versions at the same timeArchitectures can remain the sameRemove Struts 1 red tapeSwap in new tags

Page 76: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Where should a migration begin?

Migrate "Hello World" applicationDisplays message in two languagesAdd input form for custom messageValidate data entry

Page 77: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Where should a migration begin?

Migrate "Hello World" applicationDisplays message in two languagesAdd input form for custom messageValidate data entry

Page 78: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Where should a migration begin?

Migrate "Hello World" applicationDisplays message in two languagesAdd input form for custom messageValidate data entry

Page 79: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Where should a migration begin?

Migrate "Hello World" applicationDisplays message in two languagesAdd input form for custom messageValidate data entry

Page 80: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Where should a migration begin?

Update web.xml to add ...1)The Struts 2 Filter2)A filter mapping3)The Spring Listener

Page 81: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Where should a migration begin?

Update web.xml to add ...1)The Struts 2 Filter2)A filter mapping3)The Spring Listener

Page 82: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Where should a migration begin?

Update web.xml to add ...1)The Struts 2 Filter2)A filter mapping3)The Spring Listener

Page 83: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Where should a migration begin?

Update web.xml to add ...1)The Struts 2 Filter2)A filter mapping3)The Spring Listener

Page 84: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Where should a migration begin?

Update web.xml to add ...1)The Struts 2 Filter2)A filter mapping3)The Spring Listener

Page 85: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

<web-app> <!-- Struts 2 --> <filter> <filter-name>struts2</filter-name> <filter-class> org.apache.struts2.dispatcher.FilterDispatcher </filter-class> </filter> <filter-mapping><filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <listener> <listener-class> org.springframework.web.context.ContextLoaderListener </listener-class> </listener>

Page 86: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

<!-- Struts 1 --> <servlet> <servlet-name>action</servlet-name> <servlet-class> org.apache.struts.action.ActionServlet </servlet-class> <init-param> <param-name>config</param-name> <param-value> /WEB-INF/classes/struts-config.xml </param-value> </init-param> <load-on-startup>2</load-on-startup> </servlet> <servlet-mapping> <servlet-name>action</servlet-name> <url-pattern>*.do</url-pattern> </servlet-mapping>

Page 87: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

<!-- Either version --> <welcome-file-list> <welcome-file>index.html</welcome-file> </welcome-file-list></web-app>

Page 88: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> <beans></beans>

applicationContext.xml

Page 89: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Lets code it!

Page 90: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Where should a migration begin?

Struts 1 actions handle *.do Struts 2 actions handle *.actionMigrate one to the other, until there's nothing left to "do"!

Page 91: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Where should a migration begin?

Struts 1 actions handle *.do Struts 2 actions handle *.actionMigrate one to the other, until there's nothing left to "do"!

Page 92: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Where should a migration begin?

Struts 1 actions handle *.do Struts 2 actions handle *.actionMigrate one to the other, until there's nothing left to "do"!

Page 93: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Where should a migration begin?

Struts 1 actions handle *.do Struts 2 actions handle *.actionMigrate one to the other, until there's nothing left to "do"!

Page 94: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Struts University Series

Page 95: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Where should a migration begin?

For dependency injection, by default, Struts 2 uses HiveMind Spring Castle Pico

Page 96: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Where should a migration begin?

For dependency injection, by default, Struts 2 uses HiveMind Spring Castle Pico

Page 97: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Where should a migration begin?

Update web.xml to add ... The Struts 2 ****** A filter ******* The ****** Listener

Page 98: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Where should a migration begin?

Update web.xml to add ... The Struts 2 ****** A filter ******* The ****** Listener

Page 99: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Where should a migration begin?

Update web.xml to add ... The Struts 2 Filter A filter ******* The ****** Listener

Page 100: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Where should a migration begin?

Update web.xml to add ... The Struts 2 Filter A filter mapping The ****** Listener

Page 101: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Where should a migration begin?

Update web.xml to add ... The Struts 2 Filter A filter mapping The Spring Listener

Page 102: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Where should a migration begin?

Update web.xml to add ... The Struts 2 Filter A filter mapping The Spring Listener

Page 103: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Is the Struts 2 configuration file different?

Struts 2 configuration file is streamlinedLess to configureElement names are shorterStruts 1 is "struts-config.xml"Struts 2 is "struts.xml"

Page 104: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Is the Struts 2 configuration file different?

Struts 2 configuration file is streamlinedLess to configureElement names are shorterStruts 1 is "struts-config.xml"Struts 2 is "struts.xml"

Page 105: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Is the Struts 2 configuration file different?

Struts 2 configuration file is streamlinedLess to configureElement names are shorterStruts 1 is "struts-config.xml"Struts 2 is "struts.xml"

Page 106: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Is the Struts 2 configuration file different?

Struts 2 configuration file is streamlinedLess to configureElement names are shorterStruts 1 is "struts-config.xml"Struts 2 is "struts.xml"

Page 107: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Is the Struts 2 configuration file different?

Struts 2 configuration file is streamlinedLess to configureElement names are shorterStruts 1 is "struts-config.xml"Struts 2 is "struts.xml"

Page 108: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Is the Struts 2 configuration file different?

Struts 2 configuration file is streamlinedLess to configureElement names are shorterStruts 1 is "struts-config.xml"Struts 2 is "struts.xml"

Page 109: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

<?xml version="1.0" encoding="ISO-8859-1" ?><!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.3//EN" "http://struts.apache.org/dtds/struts-config_1_3.dtd">

<struts-config> <form-beans> <form-bean name="HelloForm" type="actions.HelloForm"> </form-bean> </form-beans> <action-mappings> <action path="/Hello" name="HelloForm" type="actions.HelloAction" validate="false"> <forward name="success" path="/HelloPage.jsp"/> </action> </action-mappings> <message-resources parameter="resources"/> </struts-config>

Page 110: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

<?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd">

<struts> <include file="struts-default.xml"/> <package name="hello-default" extends="struts-default"> <action name="Hello" class="actions.Hello"> <result>/Hello.jsp</result> </action> </package> </struts>

Page 111: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Lets code it!

Page 112: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

To migrate configuration

Replace the DTD Change <struts-config> to <struts>Add <include file="struts-default.xml"/>Remove the <form-beans> element Change <action-mappings> to <package name="hello-default" extends="struts-default">Update each <action> element

Page 113: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

To migrate configuration

Replace the DTD Change <struts-config> to <struts>Add <include file="struts-default.xml"/>Remove the <form-beans> element Change <action-mappings> to <package name="hello-default" extends="struts-default">Update each <action> element

Page 114: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

To migrate configuration

Replace the DTD Change <struts-config> to <struts>Add <include file="struts-default.xml"/>Remove the <form-beans> element Change <action-mappings> to <package name="hello-default" extends="struts-default">Update each <action> element

Page 115: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

To migrate configuration

Replace the DTD Change <struts-config> to <struts>Add <include file="struts-default.xml"/>Remove the <form-beans> element Change <action-mappings> to <package name="hello-default" extends="struts-default">Update each <action> element

Page 116: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

To migrate configuration

Replace the DTD Change <struts-config> to <struts>Add <include file="struts-default.xml"/>Remove the <form-beans> element Change <action-mappings> to <package name="hello-default" extends="struts-default">Update each <action> element

Page 117: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

To migrate configuration

Replace the DTD Change <struts-config> to <struts>Add <include file="struts-default.xml"/>Remove the <form-beans> element Change <action-mappings> to <package name="hello-default" extends="struts-default">Update each <action> element

Page 118: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

To migrate configuration

Replace the DTD Change <struts-config> to <struts>Add <include file="struts-default.xml"/>Remove the <form-beans> element Change <action-mappings> to <package name="hello-default" extends="struts-default">Update each <action> element

Page 119: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

To migrate configuration

To update each <action> element, we 1)Remove from <action> the "name" attribute2)Change the <action> "path" attribute to

"name", and "type" to "class"3)Change the <forward> element into a

<result> element.

Page 120: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

To migrate configuration

To update each <action> element, we 1)Remove from <action> the "name" attribute2)Change the <action> "path" attribute to

"name", and "type" to "class"3)Change the <forward> element into a

<result> element.

Page 121: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

To migrate configuration

To update each <action> element, we 1)Remove from <action> the "name" attribute2)Change the <action> "path" attribute to

"name", and "type" to "class"3)Change the <forward> element into a

<result> element.

Page 122: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

To migrate configuration

To update each <action> element, we 1)Remove from <action> the "name" attribute2)Change the <action> "path" attribute to

"name", and "type" to "class"3)Change the <forward> element into a

<result> element.

Page 123: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Struts University Series

Page 124: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Is the Struts 2 configuration file different?

Struts 2 configuration file is (less/more) to configureStruts 2 configuration file is named "******.xml"Most Struts 2 configurations include the “struts-*******.xml”

Page 125: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Is the Struts 2 configuration file different?

Struts 2 configuration file is (less/more) to configureStruts 2 configuration file is named "******.xml"Most Struts 2 configurations include the “struts-*******.xml”

Page 126: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Is the Struts 2 configuration file different?

Struts 2 configuration file is (less/more) to configureStruts 2 configuration file is named "struts.xml"Most Struts 2 configurations include the “struts-*******.xml”

Page 127: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Is the Struts 2 configuration file different?

Struts 2 configuration file is (less/more) to configureStruts 2 configuration file is named "struts.xml"Most Struts 2 configurations include the “struts-default.xml”

Page 128: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Is the Struts 2 configuration file different?

Struts 2 configuration file is (less/more) to configureStruts 2 configuration file is named "struts.xml"Most Struts 2 configurations include the “struts-default.xml”

Page 129: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

To migrate configuration

Replace the DTD ****** <struts-config> to <struts>Add <include file="struts-default.xml"/>****** the <form-beans> element Change <action-mappings> to <package name="hello-default" extends="struts-default">****** each <action> element

Page 130: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

To migrate configuration

Replace the DTD Change <struts-config> to <struts>Add <include file="struts-default.xml"/>****** the <form-beans> element Change <action-mappings> to <package name="hello-default" extends="struts-default">****** each <action> element

Page 131: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

To migrate configuration

Replace the DTD Change <struts-config> to <struts>Add <include file="struts-default.xml"/>Remove the <form-beans> element Change <action-mappings> to <package name="hello-default" extends="struts-default">****** each <action> element

Page 132: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

To migrate configuration

Replace the DTD Change <struts-config> to <struts>Add <include file="struts-default.xml"/>Remove the <form-beans> element Change <action-mappings> to <package name="hello-default" extends="struts-default">Update each <action> element

Page 133: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

To migrate configuration

Replace the DTD Change <struts-config> to <struts>Add <include file="struts-default.xml"/>Remove the <form-beans> element Change <action-mappings> to <package name="hello-default" extends="struts-default">Update each <action> element

Page 134: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Why so many changes?

Obsolesce We just plain don't need them anymore

Consistency Attribute names are applied consistently

Comprehension Concise and easier to understand

Page 135: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Why so many changes?

Obsolesce We just plain don't need them anymore

Consistency Attribute names are applied consistently

Comprehension Concise and easier to understand

Page 136: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Why so many changes?

Obsolesce We just plain don't need them anymore

Consistency Attribute names are applied consistently

Comprehension Concise and easier to understand

Page 137: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Why so many changes?

Obsolesce We just plain don't need them anymore

Consistency Attribute names are applied consistently

Comprehension Concise and easier to understand

Page 138: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Intelligent Defaults

When an essential value is omitted, the system automatically provides

a predefined value, eliminating the need to explicitly qualify

each and every aspect of a declaration. (Adapted from the CULE Knowledgebase)

Page 139: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Intelligent Defaults

When an essential value is omitted, the system automatically provides

a predefined value, eliminating the need to explicitly qualify

each and every aspect of a declaration. (Adapted from the CULE Knowledgebase)

Page 140: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Intelligent Defaults

When an essential value is omitted, the system automatically provides

a predefined value, eliminating the need to explicitly qualify

each and every aspect of a declaration. (Adapted from the CULE Knowledgebase)

Page 141: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Intelligent Defaults

When an essential value is omitted, the system automatically provides

a predefined value, eliminating the need to explicitly qualify

each and every aspect of a declaration. (Adapted from the CULE Knowledgebase)

Page 142: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Intelligent Defaults<forward name="success" path="/Hello.jsp"/>

<result>/Hello.jsp</result>

The <result> name defaults to "success"The <result> content defaults to "location" (e.g. path)The <result> type defaults to "dispatch"

Page 143: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Intelligent Defaults<forward name="success" path="/Hello.jsp"/>

<result>/Hello.jsp</result>

The <result> name defaults to "success"The <result> content defaults to "location" (e.g. path)The <result> type defaults to "dispatch"

Page 144: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Intelligent Defaults<forward name="success" path="/Hello.jsp"/>

<result>/Hello.jsp</result>

The <result> name defaults to "success"The <result> content defaults to "location" (e.g. path)The <result> type defaults to "dispatch"

Page 145: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Intelligent Defaults<result name="cancel" type="redirect"> /Welcome.jsp</result>

Changing the result name and type

Page 146: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Struts University Series

Page 147: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Why so many changes?

O******** We just plain don't need them anymore

C********** Attribute names are uniform

C************ Concise and easier to understand

Page 148: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Why so many changes?

Obsolesce We just plain don't need them anymore

C********** Attribute names are uniform

C************ Concise and easier to understand

Page 149: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Why so many changes?

Obsolesce We just plain don't need them anymore

Consistency Attribute names are uniform

C************ Concise and easier to understand

Page 150: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Why so many changes?

Obsolesce We just plain don't need them anymore

Consistency Attribute names are uniform

Comprehension Concise and easier to understand

Page 151: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Why so many changes?

Obsolesce We just plain don't need them anymore

Consistency Attribute names are uniform

Comprehension Concise and easier to understand

Page 152: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Intelligent Defaults

When an ********* value is omitted, the system automatically provides

a ********** value, eliminating the need to explicitly qualify

each and every aspect of a declaration. (Adapted from the CULE Knowledgebase)

Page 153: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Intelligent Defaults

When an essential value is omitted, the system automatically provides

a ********** value, eliminating the need to explicitly qualify

each and every aspect of a declaration. (Adapted from the CULE Knowledgebase)

Page 154: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Intelligent Defaults

When an essential value is omitted, the system automatically provides

a predefined value, eliminating the need to explicitly qualify

each and every aspect of a declaration. (Adapted from the CULE Knowledgebase)

Page 155: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Intelligent Defaults

When an essential value is omitted, the system automatically provides

a predefined value, eliminating the need to explicitly qualify

each and every aspect of a declaration. (Adapted from the CULE Knowledgebase)

Page 156: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Do Action classes change too?

Mostly simpler Can combine Struts 1 ActionForm, Add input properties directly to Action Or, use POJO

Page 157: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Do Action classes change too?

Mostly simpler Can combine Struts 1 ActionForm, Add input properties directly to Action Or, use POJO

Page 158: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Do Action classes change too?

Mostly simpler Can combine Struts 1 ActionForm, Add input properties directly to Action Or, use POJO

Page 159: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

package forms; import org.apache.struts.action.ActionForm;

public class HelloForm extends ValidatorForm {

private String message;

public String getMessage() { return message; }

public void setMessage(String message) { this.message = message; }}

Page 160: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

package actions;import javax.servlet.http.*;import org.apache.struts.action.*;

public class HelloAction extends Action {

public ActionForward execute( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { HelloForm input = (HelloForm) form; input.setMessage(MESSAGE); return mapping.findForward(SUCCESS); }

public static final String MESSAGE = "Hello World!"; public static final String SUCCESS = "success";

}

Page 161: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

package actions;import com.opensymphony.xwork2.ActionSupport;

public class Hello extends ActionSupport {

public String execute() throws Exception { setMessage(MESSAGE); return SUCCESS; }

public static final String MESSAGE = "Hello World!";

private String message;

public String getMessage() { return message; }

public void setMessage(String message) { this.message = message; }}

Page 162: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Lets code it!

Page 163: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Do Action classes change too?

To convert our Hello World Action class 1) Update or remove imports.2) Move input property to the Action

● Remove obsolete ActionForm3) Extend ActionSupport 4) Reference input property directly5) Remove SUCCESS static

Page 164: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Do Action classes change too?

To convert our Hello World Action class 1) Update or remove imports.2) Move input property to the Action

● Remove obsolete ActionForm3) Extend ActionSupport4) Reference input property directly5) Remove SUCCESS static

Page 165: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Do Action classes change too?

To convert our Hello World Action class 1) Update or remove imports.2) Move input property to the Action

● Remove obsolete ActionForm3) Extend ActionSupport4) Reference input property directly5) Remove SUCCESS static

Page 166: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Do Action classes change too?

To convert our Hello World Action class 1) Update or remove imports.2) Move input property to the Action

● Remove obsolete ActionForm3) Extend ActionSupport4) Reference input property directly5) Remove SUCCESS static

Page 167: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Do Action classes change too?

To convert our Hello World Action class 1) Update or remove imports.2) Move input property to the Action

● Remove obsolete ActionForm3) Extend ActionSupport4) Reference input property directly5) Remove SUCCESS static

Page 168: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Do Action classes change too?

To convert our Hello World Action class 1) Update or remove imports.2) Move input property to the Action

● Remove obsolete ActionForm3) Extend ActionSupport4) Reference input property directly5) Remove SUCCESS static

Page 169: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Struts University Series

Page 170: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Do Action classes change too?

Can combine Struts 1 ********** Move ***** property to the ActionOr, use Plain Old Java ******Extend ******Support

Page 171: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Do Action classes change too?

Can combine Struts 1 ActionForm Move ***** property to the ActionOr, use Plain Old Java ******Extend ******Support

Page 172: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Do Action classes change too?

Can combine Struts 1 ActionForm Move input property to the ActionOr, use Plain Old Java ******Extend ******Support

Page 173: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Do Action classes change too?

Can combine Struts 1 ActionForm Move input property to the ActionOr, use Plain Old Java ObjectExtend ******Support

Page 174: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Do Action classes change too?

Can combine Struts 1 ActionForm Move input property to the ActionOr, use Plain Old Java ObjectExtend ActionSupport

Page 175: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Do Action classes change too?

Can combine Struts 1 ActionForm, Move input property to the ActionOr, use Plain Old Java ObjectExtend ActionSupport

Page 176: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

What about the tags?

Page 177: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

<%@ taglib prefix="bean" uri="http://struts.apache.org/tags-bean" %><html><head> <title>Hello World!</title></head><body> <h2><bean:write name="HelloForm" property="message"/></h2></body></html>

<%@ taglib prefix="s" uri="/struts-tags" %><html><head> <title>Hello World!</title></head><body> <h2><s:property value="message"/></h2></body></html>

Page 178: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

<%@ taglib prefix="bean" uri="http://struts.apache.org/tags-bean" %><html><head> <title>Hello World!</title></head><body> <h2><bean:write name="HelloForm" property="message"/></h2></body></html>

<%@ taglib prefix="s" uri="/struts-tags" %><html><head> <title>Hello World!</title></head><body> <h2><s:property value="message"/></h2></body></html>

Page 179: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Lets code it!

Page 180: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

What about the tags?

Replace the <%@ taglib @%> directiveChange <bean:write /> to <s:property />

Page 181: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

What about the tags?

Replace the <%@ taglib @%> directiveChange <bean:write /> to <s:property />

Page 182: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

What about the tags?

Replace the <%@ taglib @%> directiveChange <bean:write /> to <s:property />

Page 183: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

What about the tags?

New tags streamline page <bean:write> needs ActionForm name <s:property> finds property automatically

Page 184: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

What about the tags?

New tags streamline page <bean:write> needs ActionForm name <s:property> finds property automatically

Page 185: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

What about the tags?

New tags streamline page <bean:write> needs ActionForm name <s:property> finds property automatically

Page 186: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Struts University Series

Page 187: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

What about the tags?

Change <bean:write /> to <s:******** />New tags streamline page <bean:write> needs ActionForm name <s:********> finds ******** automatically

Page 188: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

What about the tags?

Change <bean:write /> to <s:property />New tags streamline page <bean:write> needs ActionForm name <s:********> finds ******** automatically

Page 189: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

What about the tags?

Change <bean:write /> to <s:property />New tags streamline page <bean:write> needs ActionForm name <s:property> finds property automatically

Page 190: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

What about the tags?

Change <bean:write /> to <s:property />New tags streamline page <bean:write> needs ActionForm name <s:property> finds property automatically

Page 191: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Can we still localize messages?

Struts 2 uses standard message bundleExisting bundle set in struts.properties

struts.custom.i18n.resources = resources

resources.propertiesresources_es.propertiesresources_fr_CA.properties

Page 192: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Can we still localize messages?

Struts 2 uses standard message bundleExisting bundle set in struts.properties

struts.custom.i18n.resources = resources

resources.propertiesresources_es.propertiesresources_fr_CA.properties

Page 193: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Can we still localize messages?

Struts 2 uses standard message bundleExisting bundle set in struts.properties

struts.custom.i18n.resources = resources

resources.propertiesresources_es.propertiesresources_fr_CA.properties

Page 194: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

resources.properties message = Hello World

resources_es.properties message = ¡Hola Mundo!

Page 195: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Can we still localize messages?

Lookup message by key in ActionSet localized message to property

Page 196: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Can we still localize messages?

Lookup message by key in ActionSet localized message to property

Page 197: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

public class HelloAction extends Action {

public ActionForward execute( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {

HelloForm input = (HelloForm) form;- input.setMessage(MESSAGE);+ input.setMessage(getResources(+ request).getMessage(MESSAGE)); return mapping.findForward(SUCCESS); }

- public static final String MESSAGE = "Hello World!";+ public static final String MESSAGE = "message"; public static final String SUCCESS = "success";}

Page 198: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

public class Hello extends ActionSupport {

public String execute() throws Exception {- setMessage(MESSAGE);+ setMessage(getText(MESSAGE));

return SUCCESS; }

- public static final String MESSAGE = "Hello World!";+ public static final String MESSAGE = "message";}

Page 199: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Can we still localize messages?

Tags can output localized messages, based on a keyLet's change page title to look up message

Page 200: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Can we still localize messages?

Tags can output localized messages, based on a keyLet's change page title to look up message

Page 201: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

<%@ taglib prefix="bean" uri="http://struts.apache.org/tags-bean" %> <html><head>- <title>Hello World!</title>+ <title><bean:message key="message"/></title> </head> <body> <h2><bean:write name="HelloForm" property="message"/></h2> </body></html>

<%@ taglib prefix="s" uri="/struts-tags" %> <html><head>- <title>Hello World!</title>+ <title><s:text name="message"/></title> </head> <body> <h2><s:property value="message"/></h2> </body></html>

Page 202: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Lets code it!

Page 203: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Can we still localize messages?

Lookup message by key in ActionSet localized message to propertyTags can output localized messages, based on a key

Page 204: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Can we still localize messages?

Lookup message by key in ActionSet localized message to propertyTags can output localized messages, based on a key

Page 205: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Can we still localize messages?

Lookup message by key in ActionSet localized message to propertyTags can output localized messages, based on a key

Page 206: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Struts University Series

Page 207: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Can we still localize messages?

(A)setMessage(getText(MESSAGE));(B)input.setMessage(

getResources(request).getMessage(MESSAGE));

The Struts 1 statement is shown as (A) / (B). The Struts 2 statement is shown as (A) / (B).

Page 208: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Can we still localize messages?

(A)setMessage(getText(MESSAGE));(B)input.setMessage(

getResources(request).getMessage(MESSAGE));

The Struts 1 statement is shown as (A) / (B). The Struts 2 statement is shown as (A) / (B).

Page 209: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Can we still localize messages?

struts.custom.i18n.********* = resources

Page 210: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Can we still localize messages?

struts.custom.i18n.resources = resources

Page 211: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

How do we change Locales?

Locale is stored in user's session Struts 1 requires a special Action

Page 212: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

How do we change Locales?

Locale is stored in user's session Struts 1 requires a special Action

Page 213: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

How do we change Locales?

Locale is stored in user's session Struts 1 requires a special Action

Page 214: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

public final class LocaleAction extends Action {

private static final String LANGUAGE = "language"; private static final String COUNTRY = "country"; private static final String SUCCESS = "success";

public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { String language = request.getParameter(LANGUAGE); String country = request.getParameter(COUNTRY); Locale locale = getLocale(request); if ((language != null && language.length() > 0) && (country != null && country.length() > 0)) { locale = new java.util.Locale(language, country); } else if (language != null && language.length() > 0) { locale = new java.util.Locale(language, ""); } setLocale(request, locale); return mapping.findForward(SUCCESS); }}

Page 215: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

How do we change Locales?

Link to change Struts 1 locale Calls Action to change Locale

<li><html:link

action="/Locale?language=es">Español</html:link></li>

Page 216: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

How do we change Locales?

Link to change Struts 2 locale No Action needed

<li> <s:url id="es" action="Hello"> <s:param name="request_locale">es</s:param> </s:url> <s:a href="%{es}">Español</s:a></li>

Page 217: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Lets code it!

Page 218: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

How do we change Locales?

Pass "request_locale=es" as parameter1) "es" can be any standard locale code.2) Framework updates locale for session.

Page 219: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

How do we change Locales?

Pass "request_locale=es" as parameter1) "es" can be any standard locale code.2) Framework updates locale for session.

Page 220: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

How do we change Locales?

Pass "request_locale=es" as parameter1) "es" can be any standard locale code.2) Framework updates locale for session.

Page 221: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Struts University Series

Page 222: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

How do we change Locales?(A) <li><html:link action="/Locale?language=es">Español </html:link></li>(B) <li><s:url id="es" action="Hello"> <s:param name="request_locale">es</s:param> </s:url><s:a href="%{es}">Español</s:a> </li>

The Struts 1 statement is shown as (A) / (B). The Struts 2 statement is shown as (A) / (B).

Page 223: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

How do we change Locales?(A) <li><html:link action="/Locale?language=es">Español </html:link></li>(B) <li><s:url id="es" action="Hello"> <s:param name="request_locale">es</s:param> </s:url><s:a href="%{es}">Español</s:a> </li>

The Struts 1 statement is shown as (A) / (B). The Struts 2 statement is shown as (A) / (B).

Page 224: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Does Struts 2 use Commons Validator?

Struts 2 uses XWork ValidatorSimilar but differentLet's compare configurations

Page 225: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Does Struts 2 use Commons Validator?

Struts 2 uses XWork ValidatorSimilar but differentLet's compare configurations

Page 226: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Does Struts 2 use Commons Validator?

Struts 2 uses XWork ValidatorSimilar but differentLet's compare configurations

Page 227: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Does Struts 2 use Commons Validator?

Struts 2 uses XWork ValidatorSimilar but differentLet's compare configurations

Page 228: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

<?xml version="1.0" encoding="ISO-8859-1" ?><!DOCTYPE form-validation PUBLIC "-//Apache Software Foundation//DTD Commons Validator Rules Configuration 1.3.0//EN" "http://jakarta.apache.org/commons/dtds/validator_1_3_0.dtd">

<form-validation> <formset> <form name="HelloForm"> <field property="message" depends="required"> <arg key="message"/> </field> </form> </formset></form-validation>

Page 229: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

<?xml version="1.0" encoding="ISO-8859-1" ?><!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 1.0.2//EN" "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">

<validators> <field name="message"> <field-validator type="requiredstring"> <message key="requiredstring"/> </field-validator> </field></validators>

Page 230: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Does Struts 2 use Commons Validator?

Struts 1 We validate data on input Add input form to set message

Rather than Action

Page 231: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Does Struts 2 use Commons Validator?

Struts 1 We validate data on input Add input form to set message

Rather than Action

Page 232: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Does Struts 2 use Commons Validator?

Struts 1 We validate data on input Add input form to set message

Rather than Action

Page 233: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Does Struts 2 use Commons Validator?

Struts 1 We validate data on input Add input form to set message

Rather than Action

Page 234: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

<!-- ... --> <action-mappings>

<action path="/HelloInput" name="HelloForm" forward="/HelloInput.jsp" validate="false" />

<action path="/Hello" name="HelloForm" forward="/HelloPage.jsp" validate="true" input="/HelloInput.do" />

</action-mappings></struts-config>

Page 235: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

<html:errors/><html:form action="/Hello" focus="message" onsubmit="return validateRegistrationForm(this);"><table> <tr><td> Message: </td><td> <html:text property="message" /> </td></tr></table></html:form>

Page 236: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Does Struts 2 use Commons Validator?

Struts 2 Can reuse the same mapping Input represented by an alternate method Methods can be called via wildcards

Page 237: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Does Struts 2 use Commons Validator?

Struts 2 Can reuse the same mapping Input represented by an alternate method Methods can be called via wildcards

Page 238: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Does Struts 2 use Commons Validator?

Struts 2 Can reuse the same mapping Input represented by an alternate method Methods can be called via wildcards

Page 239: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Does Struts 2 use Commons Validator?

Struts 2 Can reuse the same mapping Input represented by an alternate method Methods can be called via wildcards

Page 240: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

<action name="Hello!*" method="{1}" class="actions.Hello"> <result>/Hello.jsp</result> <result name="input">/Hello!input.jsp</result></action>

<s:actionerrors/><s:form action="Hello"> <s:textfield label="Message" name="message"/></s:form>

Page 241: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

<action name="Hello!*" method="{1}" class="actions.Hello"> <result>/Hello.jsp</result> <result name="input">/Hello!input.jsp</result></action>

<s:actionerrors/><s:form action="Hello"> <s:textfield label="Message" name="message"/></s:form>

Page 242: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Does Struts 2 use Commons Validator?

Struts 1 has wildcards tooStill need to set validate=false on inputS2 input method returns “input” symbolS2 validation skipped on input methodInput form posts back to execute (or save, or store, or submit)

Page 243: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Does Struts 2 use Commons Validator?

Struts 1 has wildcards tooStill need to set validate=false on inputS2 input method returns “input” symbolS2 validation skipped on input methodInput form posts back to execute (or save, or store, or submit)

Page 244: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Does Struts 2 use Commons Validator?

Struts 1 has wildcards tooStill need to set validate=false on inputS2 input method returns “input” symbolS2 validation skipped on input methodInput form posts back to execute (or save, or store, or submit)

Page 245: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Does Struts 2 use Commons Validator?

Struts 1 has wildcards tooStill need to set validate=false on inputS2 input method returns “input” symbolS2 validation skipped on input methodInput form posts back to execute (or save, or store, or submit)

Page 246: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Does Struts 2 use Commons Validator?

Struts 1 has wildcards tooStill need to set validate=false on inputS2 input method returns “input” symbolS2 validation skipped on input methodInput form posts back to execute (or save, or store, or submit)

Page 247: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Does Struts 2 use Commons Validator?

Struts 1 has wildcards tooStill need to set validate=false on inputS2 input method returns “input” symbolS2 validation skipped on input methodInput form posts back to execute (or save, or store, or submit)

Page 248: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

resources.properties prompt = Enter Message message = Hello World! # Struts 1 errors.required={0} is required. # Struts 2 requiredstring = ${getText(fieldName)} is required. resources_es.properties prompt = Entre el mensaje message = ¡Hola Mundo! # Struts 1 errors.required={0} se requiere. # Struts 2 requiredstring = ${getText(fieldName)} se requiere.

Page 249: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Lets code it!

Page 250: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Does Struts 2 use Commons Validator?

Struts 1: numeric parameter errors.required= {0} is required

Struts 2: expression language requiredstring= ${getText(fieldName)} is required.

Page 251: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Does Struts 2 use Commons Validator?

Struts 1: numeric parameter errors.required= {0} is required

Struts 2: expression language requiredstring= ${getText(fieldName)} is required.

Page 252: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Struts University Series

Page 253: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Does Struts 2 use Commons Validator?

Struts 2 uses X**** ValidatorS2 validation skipped on ***** method

Page 254: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Does Struts 2 use Commons Validator?

Struts 2 uses XWork ValidatorS2 validation skipped on ***** method

Page 255: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Does Struts 2 use Commons Validator?

Struts 2 uses XWork ValidatorS2 validation skipped on input method

Page 256: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Does Struts 2 use Commons Validator?

Struts 2 uses XWork ValidatorS2 validation skipped on input method

Page 257: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Does Struts 2 use Commons Validator?

(A) errors.required = {0} is required(B) requiredstring = ${getText(fieldName)} is required.

The Struts 1 statement is shown as (A) / (B). The Struts 2 statement is shown as (A) / (B).

Page 258: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Does Struts 2 use Commons Validator?

(A) errors.required = {0} is required(B) requiredstring = ${getText(fieldName)} is required.

The Struts 1 statement is shown as (A) / (B). The Struts 2 statement is shown as (A) / (B).

Page 259: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Is that all there is?

Cover the basics mappings, Actions, tags, localization, and

validation. Converted Hello World to Struts 2 Moved one at a time Actions, pages, and

configuration elements Shared essential resources, like message

bundles, between the versions.

Page 260: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Is that all there is?

Cover the basics mappings, Actions, tags, localization, and

validation. Converted Hello World to Struts 2 Moved one at a time Actions, pages, and

configuration elements Shared essential resources, like message

bundles, between the versions.

Page 261: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Is that all there is?

Cover the basics mappings, Actions, tags, localization, and

validation. Converted Hello World to Struts 2 Moved one at a time Actions, pages, and

configuration elements Shared essential resources, like message

bundles, between the versions.

Page 262: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Is that all there is?

Struts 2 is a giant leap forward, but, for Struts 1 developers, it's a learning curve we can walk, one step at a time.

Page 263: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Struts University Series

Page 264: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Struts University Series

Page 265: Migrating to Struts 2 A tutorial for Struts 1 Developers · Ted? Who's Ted? Apache Software Foundation Member Apache Struts & Apache iBATIS PMCs JUnit in Action, Struts in Action,

Struts University Series