ebook img

Pro Jakarta Velocity: From Professional to Expert PDF

378 Pages·2004·13.93 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Pro Jakarta Velocity: From Professional to Expert

Pro Jakarta Velocity: From Professional to Expert ROB HARROP Pro Jakarta Velocity: From Professional to Expert Copyright © 2004 by Rob Harrop Originally published by APress in 2004 All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission of the copyright owner and the publisher. ISBN 978-1-59059-410-0 ISBN 978-1-4302-0750-4 (eBook) DOI 10.1007/978-1-4302-0750-4 Trademarked names may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, we use the names only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. Lead Editor: Steve Anglin Technical Reviewer: Jan Machacek Editorial Board: Steve Anglin, Dan Appleman, Ewan Buckingham, Gary Cornell, Tony Davis, Jason Gilmore, Chris Mills, Steve Rycroft, Dominic Shakeshaft, Jim Sumser, Gavin Wray Project Manager: Tracy Brown Collins Copy Edit Manager: Nicole LeClerc Copy Editor: Kim Wimpsett Production Manager: Kari Brooks Production Editor: Laura Cheu Compositor: Linda Weidemann, Wolf Creek Press Proofreader: Linda Seifert Indexer: Valerie Perry Artist: Kinetic Publishing Services, LLC Cover Designer: Kurt Krames Manufacturing Manager: Tom Debolski The information in this book is distributed on an "as is" basis, without warranty. Although every precaution has been taken in the preparation of this work, neither the author{s) nor Apress shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in this work. To my Dad, Ken, who bought me my first computer and supplied me with endless programming manuals when I was just a wee boy. And, ofc ourse, to my girlfriend Sally, who put up with the late nights and lack of weekends while the book was underway. Contents at a Glance About the Author ................................................... xi About the Technical Reviewer .................................... xii Acknowledgments ................................................... xiii Introduction ...................................................... xiv Chapter 1 Introducing Velocity ................................ 1 Chapter 2 Getting Started wi th Velocity ......................9 Chapter 3 Using the Velocity Template Language ............ .41 Chapter 4 Introducing Patterns and Best Practices ..........8 1 Chapter 5 Creating Stand-Alone Applications with Velocity ......................................1 17 Chapter 6 Creating Web Applications with Velocity ......... 157 Chapter 7 Using Velocity and Anakia .........................2 15 Chapter 8 Using Additional Velocity Tools ..................2 35 Chapter 9 Going Inside Velocity .............................2 67 Chapter 10 Extending Velocity .................................3 13 Chapter 11 Using Velocity Development Tools .................3 39 Appendix Velocity Reference .................................3 47 Index ..............................................................3 57 v Contents About the Author ................................................... xi About the Technical Reviewer .................................... xii Acknowledgments ................................................... xiii Introduction ...................................................... xiv Chapter 1 Introducing Velocity ............................ l What Is Velocity? .................................................. 1 Introducing Java Template Engines ................................2 Understanding the Uses of Velocity .............................. .4 Seeing Velocity in Detail .........................................5 Seeing Velocity in Action .........................................6 Summary ..............................................................B Chapter 2 Getting Started with Velocity ................ 9 Installing Velocity ................................................9 Creating Hello World .............................................. 13 Using Context Chaining ............................................ 17 Configuring the Velocity Runtime ................................ 18 Configuring VTL ....................................................3 5 Summary .............................................................3 9 Chapter 3 Using the Velocity Template Language ...... 41 Introducing VTL ....................................................4 1 Introducing VTL Constructs ...................................... .42 Improving Reusability with Macros ............................... 64 Overcoming VTL Shortcomings with VelocityTools ................ .71 Summary .............................................................B O Chapter 4 Introducing Patterns and Best Practices ................................... 81 Hints, Tips, and Best Practices .................................B 1 Using Velocity in an MVC Environment ............................9 4 vii Contents Decoupling Velocity ............................................. .1 05 Summary ............................................................1 16 Chapter 5 Creating Stand-Alone Applications with Velocity .................................... 117 Application Overview .............................................1 18 Building the Application ......................................... 119 Summary ............................................................1 55 Chapter 6 Creating Web Applications with Velocity ................................... . 157 Using VelocityServlet ............................................1 57 Easier Views with VelocityViewServlet ..........................1 64 Building a Web Application ...................................... 172 Using Velocity with Struts ...................................... 197 Using Velocity with the Spring Framework ..................... .2 06 Summary ............................................................2 14 Chapter 7 Using Velocity and Anakia ................... 215 Getting Started ...................................................2 16 Summary ............................................................2 34 Chapter 8 Using Additional Velocity Tools ........... 235 Using Vel tag ......................................................2 35 Using Texen .......................................................2 43 Using DVSL ........................................................2 53 Summary ............................................................2 66 Chapter 9 Going Inside Velocity ........................ . 267 Introducing a Typical Processing Cycle .........................2 67 Examining the Initialization Phase .............................2 70 Using the Velocity Template Parser .............................3 05 Summary ............................................................3 11 viii Contents Chapter 10 Extending Velocity ............................. 313 Hooking Into Velocity Events ....................................3 14 Creating a Custom logSystem .....................................3 20 Creating a Custom Resourceloader ...............................3 23 Creating Custom Directives ......................................3 30 Summary ............................................................3 38 Chapter 11 Using Velocity Development Tools .......... 339 Introducing VeloGUI ..............................................3 39 Introducing VeloEdit for Eclipse ............................. ..3 40 Using Velocity in IntelliJ IDEA ................................3 42 Using Velocity in J Edit ..........................................3 42 Using Velocity in Ul traEdit .....................................3 43 Using Velocity in TextPad .......................................3 44 Using Velocity in Emacs ..........................................3 45 Summary ............................................................3 45 Appendix Velocity Reference ............................. 347 Introducing the Directives ......................................3 47 Configuring Velocity .............................................3 50 Index ............................................................. 357 ix About the Author Rob Harrop is the lead software architect of the UK-based development house, Cake Solutions Limited (http://WvM.cakesolutions.net). At Cake, Rob leads a team of six developers working on enterprise solutions for a variety of clients, in cluding the Department of Trade and Industry, the Metropolitan Police, and NUS Services Limited. Rob (and Cake) specializes in both .NET and J2EE-based development, with Rob having been involved with .NET since the alpha stages. Rob is also the coauthor of Pro Jakarta Struts, Second Edition (Apress, 2004), Pro Visual Studio .NET(Apress, 2004), and Oracle Application Server 109: J2EE Deployment and Administration (Apress, 2004). In his limited spare time, Rob enjoys playing with different technologies; his current favorites are Groovy and AOP. Rob is a committer on the open-source Spring project (http://www . springframework. org), a Java and .NET application framework built around the principle of dependency injection. When not sitting in front of the computer, Rob usually has his head buried in a book and prefers the fantasy parodies of Terry Pratchett's Discworld. xi About the Technical Reviewer Jan Machacek is the lead programmer at the UK-based software company Cake Solutions Limited (http://www.cakesolutions.net). where he has helped design and implement enterprise-level applications for a variety of UK- and US-based clients. In his spare time he enjoys discovering new software and hardware technologies. Apart from Java, Jan is interested in the .NET Framework and non procedural and AI programming. As a proper computer geek, Jan loves Star Wars and The Lord a/the Rings. Jan lives in Manchester, UK, and can be reached at [email protected]. xii

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.