100% found this document useful (4 votes)
26 views

(Ebook) Beginning Java and Flex: Migrating Java, Spring, Hibernate and Maven Developers to Adobe Flex (Expert's Voice in Web Development) by di Pisa, Filippo ISBN 9781430223856, 1430223855 2024 scribd download

The document provides information on various ebooks available for download, including titles related to Java, Flex, and other subjects. It highlights the benefits of using Adobe Flex in combination with Java technologies like Spring and Hibernate for web development. Additionally, it includes details about the structure and content of the book 'Beginning Java and Flex' by Filippo di Pisa, which guides readers through the integration of these technologies.

Uploaded by

missikindlyb
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (4 votes)
26 views

(Ebook) Beginning Java and Flex: Migrating Java, Spring, Hibernate and Maven Developers to Adobe Flex (Expert's Voice in Web Development) by di Pisa, Filippo ISBN 9781430223856, 1430223855 2024 scribd download

The document provides information on various ebooks available for download, including titles related to Java, Flex, and other subjects. It highlights the benefits of using Adobe Flex in combination with Java technologies like Spring and Hibernate for web development. Additionally, it includes details about the structure and content of the book 'Beginning Java and Flex' by Filippo di Pisa, which guides readers through the integration of these technologies.

Uploaded by

missikindlyb
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 67

Download the Full Ebook and Access More Features - ebooknice.

com

(Ebook) Beginning Java and Flex: Migrating Java,


Spring, Hibernate and Maven Developers to Adobe
Flex (Expert's Voice in Web Development) by di
Pisa, Filippo ISBN 9781430223856, 1430223855
https://ebooknice.com/product/beginning-java-and-flex-
migrating-java-spring-hibernate-and-maven-developers-to-
adobe-flex-expert-s-voice-in-web-development-55585704

OR CLICK HERE

DOWLOAD EBOOK

Download more ebook instantly today at https://ebooknice.com


Instant digital products (PDF, ePub, MOBI) ready for you
Download now and discover formats that fit your needs...

Start reading on any device today!

(Ebook) Biota Grow 2C gather 2C cook by Loucas, Jason; Viles, James ISBN
9781459699816, 9781743365571, 9781925268492, 1459699815, 1743365578, 1925268497

https://ebooknice.com/product/biota-grow-2c-gather-2c-cook-6661374

ebooknice.com

(Ebook) SAT II Success MATH 1C and 2C 2002 (Peterson's SAT II Success) by Peterson's
ISBN 9780768906677, 0768906679

https://ebooknice.com/product/sat-ii-success-math-1c-and-2c-2002-peterson-s-sat-
ii-success-1722018

ebooknice.com

(Ebook) Matematik 5000+ Kurs 2c Lärobok by Lena Alfredsson, Hans Heikne, Sanna
Bodemyr ISBN 9789127456600, 9127456609

https://ebooknice.com/product/matematik-5000-kurs-2c-larobok-23848312

ebooknice.com

(Ebook) Beginning JSP, JSF and Tomcat: Java Web Development (Expert's Voice in Java)
by Zambon, Giulio ISBN 9781430246237, 1430246235

https://ebooknice.com/product/beginning-jsp-jsf-and-tomcat-java-web-development-
expert-s-voice-in-java-55585798

ebooknice.com
(Ebook) Master SAT II Math 1c and 2c 4th ed (Arco Master the SAT Subject Test: Math
Levels 1 & 2) by Arco ISBN 9780768923049, 0768923042

https://ebooknice.com/product/master-sat-ii-math-1c-and-2c-4th-ed-arco-master-
the-sat-subject-test-math-levels-1-2-2326094

ebooknice.com

(Ebook) Cambridge IGCSE and O Level History Workbook 2C - Depth Study: the United
States, 1919-41 2nd Edition by Benjamin Harrison ISBN 9781398375147, 9781398375048,
1398375144, 1398375047

https://ebooknice.com/product/cambridge-igcse-and-o-level-history-
workbook-2c-depth-study-the-united-states-1919-41-2nd-edition-53538044

ebooknice.com

(Ebook) Flex Solutions: Essential Techniques for Flex 2 and 3 Developers by Marco
Casario ISBN 9781590598764, 1590598768

https://ebooknice.com/product/flex-solutions-essential-techniques-for-
flex-2-and-3-developers-1354994

ebooknice.com

(Ebook) Flex on Java by Bernerd Allmon, Jeremy Anderson ISBN 9781933988795,


1933988797

https://ebooknice.com/product/flex-on-java-1405358

ebooknice.com

(Ebook) Enterprise Development with Flex: Best Practices for RIA Developers (Adobe
Dev Lib) by Yakov Fain, Victor Rasputnis, Anatole Tartakovsky ISBN 9780596154165,
059615416X

https://ebooknice.com/product/enterprise-development-with-flex-best-practices-
for-ria-developers-adobe-dev-lib-1339782

ebooknice.com
CYAN YELLOW
MAGENTA BLACK
PANTONE 123 C

BOOKS FOR PROFESSIONALS BY PROFESSIONALS ® THE EXPERT’S VOICE ® IN WEB DEVELOPMENT


Companion
eBook Available

Beginning Java and Flex: Beginning


Migrating Java, Spring, Hibernate, and

Java and Flex


Maven Developers to Adobe Flex
Dear Reader, Beginning

Java Flex
The Adobe Flex Framework has been adopted by the Java community as the
Filippo di Pisa
preferred framework for Java RIAs development using Flash for the presenta-
tion layer. Flex helps Java developers build and maintain expressive web and
desktop applications that deploy consistently on most web browsers and a
growing number of mobile devices.
Combining Flex and Java is the new frontier of web development. Spring,

and
Hibernate, and Maven have taken my application development to a higher
level, and in this book I show you how these technologies can do the same for
your development. With Java and Flash, our applications can be easier to main-
tain, build, and test and they are completely portable. And with the release of
the FlashPlayer 9 and 10, Adobe has added ActionScript 3, which is now truly

Migrating Java, Spring, Hibernate, and


object-oriented and offers even better performance in our RIAs.
I will help you work with these technologies by showing you Flex-Java devel-
opment step-by-step, starting with the development environment configura-

Maven Developers to Adobe Flex


tion, then moving on to UML design, the Spring development, the Hibernate
development, Maven configuration, Flex development, and the BlazeDS server
configuration so that you can:
• Discover what Adobe Flex is and how to use it
• Create amazing client applications based on the FlashPlayer with Flex
• Learn to use Spring, Hibernate, or Maven with Flex
• Write more stable Java-based Flex applications and reusable code
After reading this book, you will be able to create amazing applications and
bring a new level of presentation to your Java applications using Flex.” Learn to build powerful enterprise Java
Companion eBook applications using Adobe Flash as the
I hope you enjoy it.
Filippo di Pisa
presentation layer

See last page for details


THE APRESS ROADMAP
on $10 eBook version

Beginning Java and Flex Pro Flex on Spring

SOURCE CODE ONLINE


www.apress.com ISBN 978-1-4302-2385-6
di Pisa Filippo di Pisa
5 46 9 9
US $46.99

Shelve in:
Programming Languages/Java

User level: 9 781430 223856


Beginner—Intermediate

this print for content only—size & color not accurate trim 7.5 x 9.25 spine = 0.84375" 448 page count
Beginning Java™ and Flex
Migrating Java, Spring, Hibernate, and Maven
Developers to Adobe Flex

■■■
Filippo di Pisa
Begi nnin g Jav a™ an d F lex: Mi g rating J av a, Spri ng, Hibe rn ate, and M ave n Deve lope rs to
Adobe Fle x
Copyright © 2009 by Filippo di Pisa
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-13 (pbk): 978-1-4302-2385-6
ISBN-13 (electronic): 978-1-4302-2386-3
Printed and bound in the United States of America 9 8 7 6 5 4 3 2 1
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.
President and Publisher: Paul Manning
Lead Editor: Tom Welsh
Technical Reviewer: Bradford Taylor
Editorial Board: Clay Andres, Steve Anglin, Mark Beckner, Ewan Buckingham, Gary Cornell,
Jonathan Gennick, Jonathan Hassell, Michelle Lowman, Matthew Moodie, Duncan Parkes,
Jeffrey Pepper, Frank Pohlmann, Douglas Pundick, Ben Renow-Clarke, Dominic Shakeshaft,
Matt Wade, Tom Welsh
Project Manager: Debra Kelly
Copy Editor: Sharon Terdeman
Compositor: Tricia Bronkella
Indexer: Ann Rogers and Ron Strauss
Artist: April Milne
Cover Designer: Anna Ishchenko
Distributed to the book trade worldwide by Springer-Verlag New York, Inc., 233 Spring Street, 6th Floor,
New York, NY 10013. Phone 1-800-SPRINGER, fax 201-348-4505, e-mail [email protected],
or visit http://www.springeronline.com.
For information on translations, please e-mail [email protected], or visit http://www.apress.com.
Apress and friends of ED books may be purchased in bulk for academic, corporate, or promotional use.
eBook versions and licenses are also available for most titles. For more information, reference our
Special Bulk Sales–eBook Licensing web page at http://www.apress.com/info/bulksales.
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.
The source code for this book is available to readers at http://www.apress.com. A "live" version of the
source code is maintained by the author at
https://filippodipisa.svn.cvsdude.com/apress_flexjava/archive/. (Username: apressapress,
Password: FlexAndJava).

ii
■ CONTENTS

I dedicate this book to my father, Pino, my mother, Raffaella, my sister, Beatrice, and my wife,
Soledad, the most important people in my life.

iii
Contents at a Glance

Content s at a Glance ......................................................................... iv


Content s ........................................................................................... v
About the Author ............................................................................. xii
About the Technical R eviewer .......................................................... xiii
Acknowledgment s ............................................................................xiv
Introduct ion .................................................................................... xv
■Chapter 1: D eveloping wit h Java and Flex ........................................ 1
■Chapter 2: Pr esenting t he Sample Application ................................. 21
■Chapter 3: C onfiguring Your Development Environment ................... 31
■Chapter 4: Inver sion of C ontrol ....................................................... 89
■Chapter 5: S pring JDBC and Hibernate .......................................... 131
■Chapter 6: S pring S ecurit y .......................................................... 183
■Chapter 7: Flex (The View Layer) .................................................. 195
■Chapter 8: Working wit h Data in Flex ............................................ 251
■Chapter 9: B lazeDS ..................................................................... 303
■Chapter 10: U sing Flex, S pring, and Hiber nate Together ................. 353

iv
■ CONTENTS

Contents

Content s at a Glance .......................................................................... iv


Content s ............................................................................................ v
About the Author .............................................................................. xii
About the Technical R eviewer ........................................................... xiii
Acknowledgment s ............................................................................ xiv
Introduct ion ..................................................................................... xv
■Chapter 1: D eveloping wit h Java and Flex ........................................ 1
Why Java?............................................................................................................................................ 1
Why ActionScript?..........................................................................................................2
Why Java and ActionScript Together? ...........................................................................2
Programming Using Lightweight Frameworks...............................................................3
Benefits of Lightweight Frameworks ................................................................................................... 3
Introduction to Spring ....................................................................................................4
Introduction to Hibernate ...............................................................................................8
The Benefits of Hibernate .................................................................................................................... 9
Introduction to BlazeDS ...............................................................................................10
BlazeDS vs. Adobe LiveCycle Data Services ...................................................................................... 11
Introduction to Flex ......................................................................................................13
Flex vs. Ajax ..................................................................................................................................... 13
Flex, Flash Cs3, and ActionScript....................................................................................................... 14
ActionScript vs. MXML ....................................................................................................................... 15

v
■ CONTENTS

Introduction to UML......................................................................................................15
Basic Diagrams .................................................................................................................................. 15
Summary......................................................................................................................18
■Chapter 2: Pr esenting t he Sample Application ................................. 21
Architecture .................................................................................................................21
The Presentation Layer ................................................................................................25
The Service Layer ........................................................................................................25
The Data Access Layer.................................................................................................27
The Domain Model .......................................................................................................28
Summary......................................................................................................................30
■Chapter 3: C onfiguring Your Development Environment ................... 31
The Source Code Editor: Eclipse IDE............................................................................31
Eclipse Projects.................................................................................................................................. 32
Eclipse Plug-ins ................................................................................................................................. 35
Installing Eclipse ................................................................................................................................ 36
Configure Eclipse for Flex and J2EE .................................................................................................. 37
Version Control: Subversion.........................................................................................40
Subversion Installation....................................................................................................................... 42
Basic SVN Project Structure............................................................................................................... 42
Using SVN with the Command-Line Client ......................................................................................... 42
Installing Subclipse ............................................................................................................................ 48
The Database Tools: MySQL.........................................................................................49
Install MySQL on Windows................................................................................................................. 50
Installing MySQL on a Mac................................................................................................................. 52
Adding the MySQL GUI Tools.............................................................................................................. 53
Basic MySQL Operation from the Command Line .............................................................................. 54
Basic MySQL Operations Using MySQL Query Browser ..................................................................... 57

vi
■ CONTENTS

The Java Application Container: Tomcat......................................................................63


Installing Tomcat................................................................................................................................ 64
Tomcat Directories............................................................................................................................. 65
Tomcat Configuration Files ................................................................................................................ 65
The Presentation Tools: Flex Builder............................................................................66
Installing the Flex Builder .................................................................................................................. 66
Installing the Flex SDK 4 .................................................................................................................... 69
The Build, Test and Deploy Tool: Maven ......................................................................71
Installing Maven ................................................................................................................................. 72
Configuring Maven ............................................................................................................................. 72
Installing the Maven Eclipse Plug-in .................................................................................................. 73
Creating Your First Maven Project ..................................................................................................... 73
The POM Document............................................................................................................................ 75
Building a Project with Maven ........................................................................................................... 77
Using Maven Plug-ins ........................................................................................................................ 77
Using Maven Dependencies............................................................................................................... 79
Using Repositories ............................................................................................................................. 79
Deploying Your Application ................................................................................................................ 81
Creating a Maven Archetype .............................................................................................................. 82
Flex Maven Archetypes ...................................................................................................................... 83
Useful Maven Commands .................................................................................................................. 83
Summary......................................................................................................................87
■Chapter 4: Inver sion of C ontrol ....................................................... 89
Spring Modules ............................................................................................................91
Spring Maven Dependencies .......................................................................................93
Creating a Spring Project .............................................................................................97
Configure the Spring Container..................................................................................108
XML-Based Configuration ................................................................................................................ 108
Injecting Lists and Collections ......................................................................................................... 112
Annotation-Based Configuration ...................................................................................................... 117

vii
■ CONTENTS

The Bean Factory ............................................................................................................................. 124


ApplicationContext and WebApplicationContext .............................................................................. 125
Properties......................................................................................................................................... 125
Summary....................................................................................................................129
■Chapter 5: S pring JDBC and Hibernate .......................................... 131
The DAO Design Pattern.............................................................................................131
Introduction to Plain Old JDBC ...................................................................................133
Introduction to Spring JDBC.......................................................................................141
JDBC Template................................................................................................................................. 141
JDBC DAO Support ........................................................................................................................... 141
Hibernate and Spring .................................................................................................148
Add Hibernate to your Spring Project............................................................................................... 148
Configure Hibernate ......................................................................................................................... 150
XML-Based Configuration ................................................................................................................ 153
Annotation-Based Configuration ...................................................................................................... 157
Using Hibernate with Spring ......................................................................................173
Querying Using HQL ......................................................................................................................... 174
HQL and Hibernate Support Matrix .................................................................................................. 176
Use Native SQL................................................................................................................................. 179
Introduction to Transactions ............................................................................................................ 179
Summary.......................................................................................................................................... 182
■Chapter 6: S pring S ecurit y ........................................................... 183
Introduction to Spring Security ..................................................................................183
Web Authorization Using URL Patterns ......................................................................184
The Importance of Filters ...........................................................................................184
Authentication and Authorization...............................................................................186
Authentication Methods ................................................................................................................... 187
Decision Managers and Voters ........................................................................................................ 192
Summary....................................................................................................................194

viii
■ CONTENTS

■Chapter 7: Flex (The View Layer) .................................................. 195


The FlashPlayer Overview..........................................................................................195
Flex Components .......................................................................................................195
The Flex Framework Architecture..............................................................................196
Flex Development Overview.......................................................................................198
Flex Builder ................................................................................................................198
Create a Project................................................................................................................................ 199
Flex Builder Perspectives................................................................................................................. 205
Build an Application ......................................................................................................................... 205
Run an Application ........................................................................................................................... 206
Debug an Application ....................................................................................................................... 207
Navigate between Classes ............................................................................................................... 207
Shortcut keys ................................................................................................................................... 208
Flex Components .......................................................................................................209
Containers ........................................................................................................................................ 213
Layout Containers ............................................................................................................................ 213
Navigation Containers ...................................................................................................................... 214
Control Components......................................................................................................................... 215
Using External CSS Styles..........................................................................................219
Use Flex with Flash IDE..............................................................................................222
Create Flash Animations for Flex ..................................................................................................... 226
Flex Events.................................................................................................................229
Custom Events ................................................................................................................................. 233
Data Binding...............................................................................................................237
Creating Custom Components ...................................................................................239
MXML Custom Components ............................................................................................................. 240
AS Custom Components................................................................................................................... 241
Deploying Custom Components ....................................................................................................... 245
Summary....................................................................................................................249

ix
Visit https://ebooknice.com to
discover a wide range of
eBooks across various genres.
Enjoy exclusive deals and
discounts to enhance your
reading experience. Start your
digital reading journey today!
■ CONTENTS

■Chapter 8: Working wit h Data in Flex ............................................ 251


An Overview of Data Models ......................................................................................251
Structuring Data for Views.........................................................................................256
Data Collections ............................................................................................................................... 256
Access to Remote Data ..............................................................................................261
HTTPService Components ................................................................................................................ 262
Building Our First Java and Flex Application.................................................................................... 263
RemoteObject Component ............................................................................................................... 286
WebService Component ................................................................................................................... 289
Using Eclipse Web Services Explorer............................................................................................... 291
Using the WebService Component ................................................................................................... 293
Creating ActionScript Code to Consume a Web Service using Flex Builder..................................... 294
Storing Data on the Local Machine ............................................................................298
Summary....................................................................................................................300
■Chapter 9: B lazeDS ..................................................................... 303
Flex BlazeDS Architecture..........................................................................................303
Configuring BlazeDS ..................................................................................................305
Using Remoting Services ...........................................................................................309
Creating a Flex Java POJO BlazeDS Application .............................................................................. 311
Creating the Flex Client.................................................................................................................... 332
Using Messaging Services .........................................................................................338
Real-Time Messaging with BlazeDS ................................................................................................ 338
Creating a Simple Chat Application.................................................................................................. 338
Summary....................................................................................................................352
■Chapter 10: U sing Flex, S pring, and Hiber nate Together ................. 353
The Flex-Spring-Hibernate Maven Archetype ............................................................353
Using the Flex-Spring-Hibernate Archetype .................................................................................... 357
Configuring the Application........................................................................................361
Planning the Application with UML ............................................................................363

x
■ CONTENTS

The Data Model UML Diagrams........................................................................................................ 363


The DAOs UML Diagrams ................................................................................................................. 365
The Service Layer UML Diagram ...................................................................................................... 366
Architecting Application Security..................................................................................................... 367
Injecting the Spring Beans ............................................................................................................... 368
Flex Client GUI Architecture .......................................................................................369
Develop the Flex-Java-Spring-Hibernate Application................................................373
Coding the Domain Objects.............................................................................................................. 373
Coding the Hibernate DAO objects ................................................................................................... 380
Create a Test Case ........................................................................................................................... 382
Coding the Service layer .................................................................................................................. 386
Export Spring Services to BlazeDS................................................................................................... 390
Coding the Flex GUI application ....................................................................................................... 391
Add a Login Form to Flex ................................................................................................................. 395
Summary....................................................................................................................414

xi
■ CONTENTS

About the Author

■ F ili ppo d i Pis a fell in love with IT in 1983, when his auntie Maria Rosa gave him
one of the first home computers on the market—the Texas Instruments TI-
99/4A—for Christmas. After passing through the Sinclair Spectrum and
Commodore era at the age of 24, he started his first IT company assembling PCs.
Then he rode the new economy bubble launching various dot-coms—always
software driven. Partly for business reasons, but largely because of a passion for
programming and software engineering, he learned many high-productivity
technologies such as Java, Spring, Hibernate, Acegi Security, ActionScript, Flex,
ColdFusion, Fusebox, JavaScript, and Perl. Filippo is now a London-based
consultant working for a number of household names in the UK market. Since
growing up in Bologna (Italy), he has lived in Milan, Madrid, and Barcelona. He
married Soledad in Ibiza on June 27, 2009.

xii
■ CONTENTS

About the Technical Reviewer

■ Brad for d T ayl or is an Architect for the Dallas-based business and technology consulting firm Credera.
He has more than 13 years of experience in Java Enterprise Application Development and has been
developing Flex/Spring applications for the past 4 years. Most recently he has been helping develop the
Open Source E-Commerce framework Broadleaf Commerce.
Bradford has been involved in a variety of projects, including e-commerce, company portals and
Flex applications. While at Credera, he has worked on The Container Store’s implementation of
Broadleaf Commerce. He has also helped Pursuant re-architect its Unifyer application, wrote the latest
implementation of Truthcasting, worked with Blockbuster on enhancements to its e-commerce
platform, and made enhancements to its Silverlight Movie browsing application.
Before his work at Credera, Bradford consulted at Neiman Marcus to create user applications to
work with its customer data mart. He started his career at Nextel, where he worked on the company
portal and developed Nextel’s internet application for phone resellers. He has worked with banks, the
Department of Defense, major retailers, and small companies to help develop both Java and Flash/Flex
applications to meet their business needs.

xiii
■ CONTENTS

Acknowledgments

I dedicate this book to my father, Pino, my mother, Raffaella, and my sister, Beatrice, who have stood by
me through my whole crazy life.
I have many people to thank for their support on this book, but the one person I would really like to
acknowledge is my wife, Soledad. For the past six months she has watched TV using a headset, or just
reading the subtitles, so as not to disturb me in my nightly writing.
The second person without whom this book could not have been written is my colleague and friend
Chris Seal. He helped me a lot, reading chapter after chapter, making suggestions from the project
management point of view and improving my Italian-English. Thanks Chris!
I would also like to thank the fantastic Apress team who believed in me while I was writing this book, and
provided excellent support in authoring and the technical aspect. In particular, I am really pleased to
have worked with Steve Anglin, Tom Welsh, Debra Kelly, Bradford Taylor, Sharon Terdeman, and
Matthew Moodie. Thanks a lot!
A special thanks also to my agent and friend Shervin Rahmani from explorerec.com who believed in me
from the beginning and introduced my consulting services to some of the UK's top-name companies.
Filippo di Pisa

xiv
■ INTRODUCTION

Introduction

Over the past few years, the now open source Adobe Flex Framework has been adopted by the Java
community as the preferred framework for Java RIAs using Flash for the presentation layer. Flex helps
Java developers build and maintain expressive web and desktop applications that deploy consistently on
most web browsers and a growing number of mobile devices.
Beginning Java and Flex describes new, simpler, and faster ways to develop enterprise RIAs.
This book is not only for Java or Flex developers but for all web developers who want to increase their
productivity and the quality of their development.
In this book I will show you how to develop using the most popular Java lightweight frameworks
such as Spring and Hibernate, using Flex and ActionScript 3 as the view layer. Once you have mastered
this new development frontier, including concepts like Dependency Injection (DI) and Object
Relationship Management (ORM), you will very likely want to use them for all your projects.
Flex and Java are becoming very popular for both business and interactive applications, and they can
open doors to the different branches of software development such as gaming, finance, advertising, and
desktop applications of all kinds.

Who This Book Is For


If you are a developer who wants to use Java and Flex together, then this book is for you! This is
especially so if you are any of the following.

• An ActionScript/Flash developer–You really should read this book because it will show you how
best to use Java in your applications. Learning Java is a great way of immersing yourself in the
latest software engineering patterns and frameworks.

• A Java developer–If you are a Java developer and know about Enterprise JavaBeans (EJBs), I really
suggest you should think about using POJOs and Java frameworks such as Spring and Hibernate.
By reading this book you will also pick up Flex, which puts the power of Flash into your
presentation layer. Learning Flex will bring you into the world of Adobe and Flash, which
promises to become increasingly important. With CS5, the next release of Flash, Adobe promises
that we will be able to write ActionScript applications and compile them to native Objective-C
ready to run on the iPhone!
• A Web developer–If you are using languages such as PHP or Cold Fusion, please consider
switching to Java lightweight frameworks. I guarantee that once you have mastered them your
productivity will soar, and–thanks to Java–the quality of your code will get better too. For any web
developer, learning Flex is a must even if you are already an Ajax or JavaFX guru. And along with
Flex and ActionScript 3 you will also pick up knowledge of Flash, which at the time of this writing
is everywhere.

xv
■ INTRODUCTION

The Book
This book has been designed to help you in three ways.

1. First, it gives you an easily understood overview of the different technologies that we are going to
use.
2. Then it shows you how to set up your development environment.
3. With all the prerequisites taken care of, you learn how to use each framework in turn, starting
with Spring and moving on to Hibernate, then BlazeDS, then Flex, and finally putting everything
together using Maven.

Here is a brief summary of what each chapter deals with.

Chapt er 1 introduces you to the technologies that we are going to use, including Java, Flex, Spring, and
Hibernate. It also sums up the benefits of object-oriented programming over procedural or scripting
languages, and the strengths of a lightweight programming approach.

Chapt er 2 introduces the sample application that we are going to use in this book and its architecture.

Chapt er 3 shows you how to set up all the development tools you will need. While reasonably
straightforward, this could turn out to be a painful, annoying, and time-consuming process unless you
do it right. It can take a lot of time and effort to configure a complex development environment, but it
really makes a difference once you have it up and running smoothly.

Chapt er 4 covers the most important aspects of the Spring framework. You will learn the key concepts
of DI and Inversion of Control (IoC) and how to configure Spring and inject beans into the Spring IoC
container using both XML configuration and Java annotations.

Chapt er 5 demonstrates how to create a Java EE data-driven application using both JDBC and ORM
frameworks. I will show you the Data Access Object (DAO) pattern architecture and the difference
between using "plain old JDBC" and Spring JDBC to connect to a database. Then I will explain the value
of using Hibernate and Spring instead of the Spring JDBC and introduce transactions, which play an
important role in Java EE development.

Chapt er 6 shows you how to secure a Java application using the Spring Security framework (formerly
Acegi Security). You will see how Spring Security delegates all requests to filters added by default into the
Spring Security filter chain stack. Then I will show you how to add a custom authentication filter into the
filter chain stack, replacing the default one. Finally, I will set out the different authentication processes
using databases, LDAP repositories, and static values.

Chapt er 7 gives you a complete overview of the Flex framework and the Flex Builder IDE. I will explain
how to create and compile a Flex project using the Flex Builder Eclipse plug-in. Then you will learn how
to listen for and dispatch Flex events, create custom components, use external CSS files, data binding,
control Flash MovieClips, and more. This chapter takes you through all the concepts that I think are
fundamental for starting to develop using Flex.

Chapt er 8 shows you the most important ways to structure data on the Flex client and to access data on
a remote server. First, I will show you how to bind ActionScript data collection to ActionScript DataGrid
components and how to create a real-time search into the collection using filters. Next, I will create a
Java application that provides a list of users through servlets. The Flex client will retrieve the XML using
the HTTPService component. Finally, I will show you how to use the Flex RemoteObject component.

xvi
■ INTRODUCTION

Chapt er 9 introduces the BlazeDS server. You will learn how to retrieve and send data from a Flex
application to a Java application and how to exchange real-time messages among different clients using
the BlazeDS server.

Chapt er 10 puts it all together–Spring, Hibernate, BlazeDS, and Flex. We will create a Flex-Spring-
Hibernate project using the Flex-Spring-Hibernate Maven archetype. The archetype creates the entire
project directory structure containing all the Spring, Hibernate, and BlazeDS configuration and
properties files. It also adds all the packages usually needed for this kind of application using the Model
View Controller (MVC) and DAO patterns. In this chapter, I cover all the most important aspects of Flex-
Spring-Hibernate-Maven development. You can reuse the same archetype to start your own project, and
you’ll see how your developer productivity will quickly increase.

Java and Flex let you create amazing applications using object-oriented languages and the latest
software engineering techniques, making you not just a better developer but also a better software
engineer.

xvii
CHAPTER 1
■■■

Developing with Java


and Flex

Two of the most difficult decisions for a project manager, CIO, or developer are which platform to target
and which language to use. Books have been dedicated to the relative merits of one language over
another and the options are much more complex than you might think. While a developer may have a
preference, based on his own experiences or selfish desires, the project may be best served by different
choices.
And there are many available. The IT/developer world is constantly changing. During the last 15
years, many languages have found and lost favor, while seemingly “dead” languages such as Ruby have
experienced a resurgence. (In Ruby's case, this is due to the arrival of the Rails framework). I expect this
trend to continue and that the life of a developer will be one of constant evolution.
To survive in today’s market, developers need to learn more than one language. However, they also
need to be able to choose which is best for a particular endeavor, which can sometimes be just as
difficult. In the next sections, I’m going to discuss the choices I made for this book.

Why Java?
I am not a Java fanatic, and I don’t want to create a polemic saying that Java is better than C# or vice
versa. My view is that every language has its place and has a market, especially since so much effort
involves working with existing applications and code.
A nontechnical manager I worked with used to advise using “the best tool for the job.” The best
example from my past is when I had to create a Windows application that worked with iTunes via COM
objects. I felt that C# would be the fastest, so C# is what I used.
I do believe that enterprise Web applications are better served by using Java. This is partly due to the
hosting platforms Java runs on and the lack of dependencies on operating environments like .NET.
Developers should enjoy programming in Java and are often surprised at how fast they can obtain
results. Studies have consistently shown that switching to the Java platform increases programmer
efficiency. Java is a simple and elegant language that has a well-designed and intuitive set of APIs.
Programmers write cleaner code with a lower bug count when compared with other languages, which in
turn reduces development time.
Java is certainly more difficult to learn than scripting languages such as PHP, ColdFusion, and the
like. Still, once you have mastered Java, you will find there is no comparison for writing stable, scalable
enterprise applications.
PHP and ColdFusion are excellent languages, and possibly even too successful. The problem with
these two languages, so common in Web environments, is not that they are not powerful enough but
that they make it too easy to code poorly and still get usable results. They forgive a lot of mistakes. This
has meant that too many developers write bad code, just because they can get away with it. Too often,
though, while they do get usable results, their code is not stable or scalable.

1
Visit https://ebooknice.com to
discover a wide range of
eBooks across various genres.
Enjoy exclusive deals and
discounts to enhance your
reading experience. Start your
digital reading journey today!
CHAPTER 1 ■ DEVELOPING WITH JAVA AND FLEX

Of course, there is plenty of badly written Java code, too. However, in Java, before you are actually
able to do anything, you must at least know the basics of object-oriented programming, data types,
serialization, unit testing, and so forth.
So while there is bad code in Java, you don't tend to get really bad code that works— unlike what
you see in many ColdFusion or PHP applications.
I’ve been developing for many years (some would say too many!) and I am constantly striving to use
the best technologies available. In my opinion, at the moment the best technologies are Java and
lightweight programming (which I’ll discuss later in the chapter).

Why ActionScript?
A lot of developers think of ActionScript (AS) simply as a scripting language for Flash animation and for
attaching scripts on the timeline.
Well, it’s not!
At least ActionScript 3 (AS3), which arrived with Flash Player 9, isn’t and should in no way be
confused with earlier versions of ActionScript. It is a completely new language and a whole new virtual
machine, with an ability to build Web applications and games that are like nothing else in the
marketplace.
With Adobe AS3, you can do so much more than with Ajax and JavaScript. It is more efficient, and
elegant, and without the bizarre restrictions of what works and what doesn’t. Furthermore, AS3 is cross-
platform, which is crucial in today’s diverse environment (Mac OS, Windows and Linux), and cross-
browser without too much hassle. AS3 supports regular expressions, binary sockets, remote data access,
X-Y-Z axis manipulation, 3D drawing, 3D effects, audio mixing, peer-to-peer (P2P) communication and
more. AS3 is compiled in a totally different bytecode from its predecessor. Flash Player 9 and Flash
Player 10 both contain two virtual machines for backward compatibility with all AS releases.
Adobe Flex, a software development kit for creating applications based on Flash, has added a new
dimension. It allows you to develop amazing user interfaces (UI) and rich Internet applications (RIA) in
an elegant way while using Java design patterns and server-side capabilities.

Why Java and ActionScript Together?


If you are already an AS developer, you may be asking yourself why you should bother to learn Java,
especially as Flex and AS allow you to use any number of server-side technologies and Web services.
On the other hand if you are a Java developer, you may be thinking—AS and Flex are still scripting
languages, and Ajax with Spring MVC Swing or other Java frameworks work, so why bother? (MVC is a
complete design pattern that I’ll cover in Chapter 5.)
The fact is, even aside from Java’s stability, elegance, and performance, the frameworks that Java
has at its disposal greatly improve the software engineering productivity cycle. And Flex and Java
together allow the developer to build very complex and well-presented applications in very quick time
frame.
Furthermore, server frameworks like BlazeDS allow you to connect to back-end distributed data and
push data in real time to Adobe Flex and Adobe AIR applications. The results can be staggering. This
means you can work with Java objects directly within your Flex application and vice versa.
You can use the power of Java for server-side business logic, and the AS3 API to create a fantastic UI,
games, video streaming applications, and much more. Moreover, Flex and AS are not JavaScript
competitors; you need to use both to obtain the best results for your RIA applications.
Flex provides different APIs and libraries to use JavaScript, Ajax, and certain browser features. The
only negative that I see in both Flex/AS3 and Java is the steep learning curve for scripters. And that is
exactly why I have written this book!

2
CHAPTER 1 ■ DEVELOPING WITH JAVA AND FLEX

Programming Using Lightweight Frameworks


A framework is a basic conceptual structure used to address complex issues. In software programming,
the term commonly denotes code that is generic in function but can be overridden by user code using
specific functionality. Frameworks can be similar to software libraries and they share many common
characteristics, such as being reusable abstractions of code wrapped in an API. One difference with
libraries is that the flow of control is dictated by the framework and not the caller.
In the past few years, there have been a lot of frameworks built in the Java community using plain
old Java objects (POJO). A POJO is "plain" in the sense that it is not a JavaBean, an Enterprise JavaBean,
or anything of that sort; it’s just an ordinary object.

■ N ote An Enterprise JavaBean is not a single class but a representative of an entire component model. The core
principle shared by all lightweight enterprise Java frameworks is the use of plain old Java objects (POJOs) for the
data access and business logic.

Lightweight technologies have evolved due in large part to a “developer rebellion” against the
heavyweight and cumbersome EJB 2.1 (and earlier). Lightweight frameworks have the stated aim of
making developers more productive and their applications less error-prone. This is achieved by
removing the rigid EJB 2.1 infrastructure classes and interfaces and the "over the top" XML deployment
descriptors. (Lightweight, by the way, means light load, not soft or weak.) Lightweight frameworks
promote better and cleaner applications through better architecture. They are easier to reuse, which
saves time and money.
Hibernate, for example, is a lightweight ORM (Object-relational Mapping) framework that can be
great for implementing business and persistence logic. It allows interaction between the database and
Java. For example, you can generate your database schema directly from your Java classes, and vice
versa.
In this book I have chosen to use the most popular and stable Java and AS frameworks for creating
business and media web applications, namely:
• Spring (a lightweight container)
• Hibernate (the most popular ORM )

Benefits of Lightweight Frameworks


When you have to develop an enterprise application, you must decide on the best language and the
correct development methodology. There are 2 main approaches to developing an application—
procedural and object-oriented (OO). The procedural approach organizes the code by manipulating
data with functions. This style of programming dominated software development for years,
implemented by very popular languages such as C, Pascal and others.
The object-oriented method organizes code around objects that have relationships and
collaborations with other objects, making the application easier to understand, maintain, extend, and
test than with a procedural design.
Despite the benefits of object-oriented design, most Web applications, including Java EE
applications, are written in procedural style. Web languages such as PHP and Cold Fusion haven’t
supported OO design until the latest releases, and Java EE itself encourages developers to write
procedural code because of EJB, a standard architecture for writing distributed business applications.

3
CHAPTER 1 ■ DEVELOPING WITH JAVA AND FLEX

EJB is a heavyweight framework that provides a large number of useful services like declarative
transactions, security management, and so forth. It was adopted enthusiastically by most Java
developers, who had to abandon their OO skills to configure lots of XML, and write procedural Java code
to build EJB components. For several years, EJB was the de facto standard— until the rise of POJO
lightweight frameworks.
The goal of POJO is to support writing Java applications using standard OO design and patterns. EJB
encouraged developers to write procedural code, thus losing the advantage of many of the best practices
used for normal Java development. Other Web languages tried to follow the EJB architecture by
concentrating development on a component base. Now both Java and other Web languages are moving
back to OO design. However POJO alone is not sufficient in enterprise applications development, where
you need security management, persistence objects, and all the other services implemented by the EJB
framework.
The solution is to use POJO lightweight frameworks that are not as intrusive as EJB and significantly
increase developer productivity. POJO lightweight frameworks provide services without requiring that
the application classes implement any special interfaces. With lightweight frameworks you can write EE
applications using an OO design, and later in this book I’ll show you how to manage these libraries just
by configuring an XML file.
Lightweight framework programming can save you lots of time, in particular through avoiding the
need for lots of code and complex OO design patterns. However, before using Java and Flex lightweight
programming, you need to have good OO design skills otherwise you will get into trouble. If your OO
design skills are in need of refreshing, you may want to take a look at Java objects and Java design
patterns before proceeding.
The lightweight frameworks that I use and describe in this book are Spring, Hibernate for Java, and
Flex for AS and Flash. Using all of these together, you’ll see how you can write fast and elegant code to
produce amazing RIA applications.
In Table 1-1, I have summarized the differences between standard EJB, Web languages, and POJO
approaches.

Table 1-1. Differences in various progamming approaches

Operation Web Languages EJB POJO

Business logic Procedural style Procedural style Object-oriented design

Database access Odbc, Jdbc, Sql JDBC/Entity beans Persistence framework

Returning data to the view Components DTOs Business objects

Application assembly Most of the times Explicit JNDI lookups Dependency injection
architected by the
developer

Transaction management - EJB container Spring framework

Security management - EJB container Spring security

Introduction to Spring
Spring is a lightweight framework based on the Dependency Injection (DI) pattern. It is lightweight
because Spring uses POJO, which makes it very powerful and very easy to extend or implement.

4
CHAPTER 1 ■ DEVELOPING WITH JAVA AND FLEX

Spring’s primary use is as a framework for enabling the use of Inversion of Control (IOC). It is also a
powerful Java Enterprise application framework that provides a large number of features and services.
Spring is initially a bit difficult to understand, but once mastered, you will see a great improvement in
your productivity. For enterprise applications, Spring is an excellent tool because it is a complete, well-
written, well-documented, scalable, and open source—with a lot of community support.
With Spring, you are able to inject all your classes directly into the container using an XML file. This
means that the Spring container instantiates all classes and injects into others as defined by XML. You
no longer have any dependency lookup problems.
Think of Spring as a container that assembles all your classes together and any part can easily be
swapped out. Each part is just a plain Java object.
Without DI, you would have to create a layer that assembles everything, and probably you would
also have to change the code for any environment because of the code embedded relationship between
the different classes.

public class UserService (){

private UserDao userDao;

public UserService(){
userDao = new UserDao();
}
}

With DI, you solve this problem because you have to create a parameterized version of the same
code, allowing it to accept injected classes

public class UserService (){

private UserDao userDao;

public UserService(UserDao userDao){


userDao = userDao;
}
}

But Spring is not just an IOC framework (though everything is based on the IOC framework). Spring
provides services and resources for database connection pools, database transaction, security,
messaging, caching, and much more. To manage the security of all your application with groups, roles,
and permissions, for example, you only have to inject some classes into the Spring security framework.
Spring supports all major data access technologies such as JDBC, Hibernate, JPA, and Ibatis. For
example, to query a database you don’t have to create the code to manage the connection, process the
result set, and release the connection itself. All these processes are handled by Spring.
The typical architecture of a Spring application comprises a presentation layer that uses a service
layer to communicate to the data access layer, which can deal with database, mail servers, or any other
data containers, as shown in Figure 1-1.

5
CHAPTER 1 ■ DEVELOPING WITH JAVA AND FLEX

Figure 1-1. Architecture of a Spring application

The presentation layer contains all views and components that are concerned with the presentation
of the application to the user. Typically, the view is implemented with JSP or a similar technology; in this
book we’ll use Flex.
The service layer represents the business logic of the application. All operations pass through the
service layer. You can have different service layers for different services, such as UserServices,
MailServices, and so on. In the upcoming chapters, you will learn how to expose the Java Spring service
layer to Flex/AS, and to allow the presentation layer to use it.
The data access layer provides all methods to save, send, and retrieve data. Usually the data access
layer works with the database, mail servers, .xml, or the file system.
As mentioned previously, Spring is based on a IoC container where all objects(beans) are
instantiated. To help you understand this concept better, I’m going to use a basic IOC Flex container I
wrote to inject different .xml files to different service layers. My application needed to provide different
content to the view, such as video, images, and text, and everything is based on different XML files. At
the time, I had to create the application as quickly as possible, and I had other applications to create, so
the more code I could reuse and the faster I could deliver the project, the better I would be.
My goal was to create a container where I could inject the .xml files and relate them to the different
content factories of the application. I copied precisely the Spring .xml syntax to make it readable by the
Spring developer. Below is the application .xml file to show you how I injected the .xml files to the
different content factories.

6
CHAPTER 1 ■ DEVELOPING WITH JAVA AND FLEX

<beans>
<bean id="XMLArticlesList" claz="com.publicis.iocframework.core.XMLLoader"
path="articlesList.XML" />

XMLLoader is a core class of my IOC framework that loads XML from a given path.

<bean id="articlesService"
claz="com.publicis.articles.business.ArticlesServiceImpl">
<constructorarg value="articlesDao" ref="articlesDao" />
</bean>

ArticlesServiceImpl is the application service layer, and you have to pass into the default
constructor the object type articlesDao.

<bean id="articlesDao" claz="com.publicis.articles.dao.XML.ArticleDaoXML">


<constructorarg value="XMLArticlesList" />
</bean>

ArticlesDaoXML is the data access layer and you have to pass into the constructor an object XML
type.
As you can see, I am able to inject classes and manage their dependencies directly from an XML file
without recompiling and changing my code. Moreover, I can reuse the XmlLoader core class to load into
the IOC container any XML file and reuse it for a different application. For example, I could pass the
XmlArticlesList object to another object simply by adding a new XML tag like this:

<bean id="mediaDao" claz="com.publicis.articles.dao.XML.mediaDaoXML">


<constructorarg value="XMLArticlesList" />

Dependency injection frameworks exist for a number of platforms and languages, such as AS, Flex,
Java, C++, PHP, ColdFusion, Microsoft, .NET, Ruby, Python and Perl. Below is a table with the most
popular IOC frameworks for AS, Flex, and Java.

Table 1-2. Dependency injection frameworks

Language/platform DI Framework

AS Spring ActionScript (formerly Prana Framework)

AS di-as3

AS Syringe

Flex Flicc

Flex Mate

Flex Swiz

7
CHAPTER 1 ■ DEVELOPING WITH JAVA AND FLEX

Java Google Guice

Java JBoss microcontainer

Java Spring framework

Java Java 5 / EJB 3

Java Spring ME

Introduction to Hibernate
Hibernate is another very popular lightweight POJO Java framework. Before I discuss Hibernate, let me
introduce you to object-relational mapping (ORM) frameworks.
Many software applications use relational databases to store data, including such products as
Oracle, MySql, Microsoft SQL Server, PostgreSql, and others. Various frameworks, such as JDBC or ORM,
are used to retrieve data from such databases. An ORM framework provides a service to map the
relational model to the OO model. Hibernate is an ORM framework that has become a natural choice for
working with POJO (though it supports EJB 3.0 as well).
In practice, Hibernate maps your database tables to classes. A standard ORM also provides
persistence objects, which means it will persist data for you so that you don't have to write tedious SQL
statements using JDBC. For example, to insert or update data into the database, you can use the method
save(entity), which saves you a lot of time compared with writing the full SQL INSERT or UPDATE.
The table mapped in the OO model is called an entity and all entities are persistent in a Hibernate
session. You will learn how to inject this session into the Spring container and also how to use Spring
Hibernate Templates to make your life easier. After mastering these techniques, you’ll see how easy it is
to work with databases and OO, and if you have worked with SQL, JDBC and other technologies before, I
think you will be pleasantly surprised.
Hibernate also provides Hibernate Query Language (HQL), in which you can write code that’s
similar to SQL to retrieve data from a persisted object. For example, imagine that you have mapped the
database table users to the entity User, and you want to select a user by his id. To do so, you can write an
HQL query like this:

int id = 2;
String hql='from User u where u.id = :id ';
Query query = session.createQuery(hql);
query.setInt(id);
User user = (User)query.uniqueResult();

Hibernate works with a large number of databases such as Oracle, MySQL, MS SQL server, Sybase,
IBM DB2, and others. You just have to tell Hibernate the database dialect you want to use, to ensure that
Hibernate uses the correct and fully optimized SQL for that database. In the next chapter, you will learn
how to set the dialect for MySQL and the other databases.
To round off this Hibernate introduction, let me use a UML diagram, shown in Figure 1-2, to
illustrate a simple physical relational database mapped to OO classes.

8
CHAPTER 1 ■ DEVELOPING WITH JAVA AND FLEX

Figure 1-2. Database tables mapped to object-oriented classes.

The Benefits of Hibernate


After reading the previous sections, you probably already recognize the many advantages that ORM
frameworks and persistence objects offer. We talked about the method save that allows you to
insert/update data into the database, avoiding the tedious INSERT or UPDATE SQL statements.
Hibernate saves you typing in the tedious SQL, though it allows you to use SQL when necessary.
Another benefit of Hibernate is that it never updates the database if the object state hasn’t changed.
In hand-coded JDBC, it is very common to have to write code to avoid this very problem. When a user
presses the submit button on a form, even without making any changes, JDBC doesn’t know so it
updates the database anyway.
Hibernate also provides a very efficient caching system. You can cache persistent objects and enable
cluster cache to memory or the local disk.
With Hibernate, you can work with different database types just by changing the property dialect.
This means you can use your application with a different database by just changing one line of code.
Sometimes, however, you will still need to write SQL to retrieve data using complex queries. These are
hard to formulate with just the Hibernate filters, so Hibernate offers you a choice. Either you can work
with Hibernate's query language (HQL), which allows you to query your persisted objects with a
language similar to SQL, or you can revert to standard SQL usage, which forces Hibernate to use normal
SQL.

9
CHAPTER 1 ■ DEVELOPING WITH JAVA AND FLEX

A key advantage of Hibernate from my point of view is its integration with Spring. In fact, Spring
provides a Hibernate Template that simplifies the use of Hibernate. The Hibernate Template provides
convenience methods that enable the developer to write less code, as you can see from the following:.

public v oid remove(User user) {


getHibernateTemplate().delete(user);
}

Hibernate also provides hooks so Spring can manage sessions and transactions in a transparent and
elegant way.

Introduction to BlazeDS
Now we’re ready to look at another important piece for connecting Spring services to the user
interface—BlazeDS, a technology for remotely connecting to Java objects and for sending messages
between clients. As Adobe points out, BlazeDS allows you to connect to back-end distributed data and
push data in real time to Adobe Flex and Adobe AIR rich Internet applications (RIA). You can think of
Blaze as a bridge between Adobe Flex (the presentation layer) and Java Spring Services (the business
logic layer), as shown in Figure 1-3. Figure 1-4 outlines the BlazeDS server architecture.

Figure 1-3. BlazeDS acts as a bridge between Flex and Java.

If you are an AS developer, you may have developed many applications using XML or SOAP.
Adopting BlazeDS means your application will load data up to 10 times faster than with those text-based
formats, as it employs an AMF (Action Message Format) data transfer format. (AMF is based on SOAP. If
you’re from an AS and Flash background, you should be familiar with AMF; if you’re from a Java
background, you just need to know AMF is much faster than standard SOAP in this environment).

Figure 1-4. The architecture of a BlazeDS server.

10
Exploring the Variety of Random
Documents with Different Content
that the best chance of the Allies would have been to attempt a
storm on this breach when first it became more or less practicable.
The delay enabled the besieged to execute repairs, to scarp down the
broken front, and to cut off the damaged corner by interior
retrenchments.
Meanwhile, since doubts were felt as to the main operation of
storming the new breach, No. III, subsidiary efforts were made to
incommode the enemy in other ways. At intervals on the 9th, 10th,
and 11th red-hot shot were fired at the church of Santa Maria la
Blanca, where it was known that the French magazine of food lay.
The experience of the Salamanca forts had led the artillery officers to
think that a general conflagration might be caused. But the plan had
no success; the building proved to be very incombustible, and one or
two small fires which burst out were easily extinguished. Another
device was to mine out from the end houses of the city towards the
church of San Roman, an isolated structure lying close under the
south-east side of the Castle, which the French held as an outwork.
Nothing very decisive could be hoped from its capture, as if taken it
could only serve as a base for operations against the two enceintes
above it[52]. But, as an eye-witness remarked, at this period of the
siege any sort of irregular scheme was tried, on the off chance of
success. By October 17 the mine had got well under the little church.
A more feasible plan, which might have done some good if it had
succeeded, was to run out a small mine or fougasse from the sap-
head of the trench in front of breach I to the palisades of the second
enceinte. It was a petty business, no more than two barrels of
powder being used, and only slightly damaged an angle of the work
in front when fired on October 17. An attempt to push on the sap
after the explosion was frustrated by the musketry fire of the
besieged.
On the 18th the engineers reported that the church of San Roman
was completely undermined, and could be blown up at any moment.
On the same morning the one good and two lame 18-pounders in
battery 2 on San Miguel swept away, not for the first time, the
sandbag parapets and chevaux de frise with which the French had
strengthened the breach III. They were then turned against the third
enceinte, immediately behind that breach, partly demolished its
‘fraises,’ and even did some damage to its rampart. This was as much
as could have been expected, as the whole of the enemy’s guns
were, as usual, turned upon the battering-guns, and presently
obtained the mastery over them, blowing up an expense-magazine in
No. 2, and injuring a gun in No. 1. But in the afternoon the defences
were in a more battered condition than usual, and Wellington
resolved to make his last attempt. Already the French army outside
was showing signs of activity; and, as a precaution, some of the
investing troops—two brigades of the 6th Division—had been sent
forward to join the covering army. If this assault failed, the siege
would have to be given up, or at the best turned into a blockade.
The plan of the assault was drawn up by Wellington himself, who
dictated the details to his military secretary, Fitzroy Somerset, in
three successive sections, after inspecting from the nearest possible
point each of the three fronts which he intended to attack[53].
Stated shortly the plan was as follows:
(1) At 4.30 the mine at San Roman was to be fired, and the ruins
of the church seized by Brown’s caçadores (9th battalion), supported
by a Spanish regiment (1st of Asturias) lent by Castaños. A brigade of
the 6th Division was to be ready in the streets behind, to support the
assault, if its effect looked promising, i.e. if the results of the
explosion should injure the enceinte behind, or should so drive the
enemy from it that an escalade became possible.
(2) The detachments of the Guards’ brigade of the 1st Division,
who were that day in charge of the trenches within the captured
outer enceinte, and facing the west front of the second enceinte,
were to make an attempt to escalade that line of defence, at the
point where most of its palisades had been destroyed, opposite and
above the original breach No. I in the lower enceinte.
(3) The detachments of the German brigade of the 1st Division,
who were to take charge of the trenches for the evening in
succession to the Guards, were to attempt to storm the breach III in
the re-entering angle, the only point where there was an actual
opening prepared into the inner defences.
From all the works, both those on St. Miguel and those to the
west of the Castle, marksmen left in the trenches were to keep up as
hot a musketry fire as possible on any of the enemy who should
show themselves, so as to distract their attention from the stormers.
The most notable point in these instructions was the small
number of men devoted to the two serious attacks. Provision was
made for the use of 300 men only in the attack to be made by the
Guards: they were to move forward in successive rushes—the first or
forlorn hope consisting of an officer and twenty men, the supports or
main assaulting force, of small parties of 40 or 50 men, each of which
was to come forward only when the one in front of it had reached a
given point in its advance. Similarly the German Legion’s assault was
to be led by a forlorn hope of 20, supported by 50 more, who were
only to move when their predecessors had reached the lip of the
breach, and by a reserve of 200 who were to charge out of the
trench only when the support was well established on the rampart.
Burgoyne, the senior engineer present, tells us that he protested
all through the siege, at each successive assault, against the paucity
of the numbers employed, saying that the forlorn hope had, in fact,
to take the work by itself, since they had no close and strong column
in immediate support; and if the forlorn hope failed, ‘the next party,
who from behind their cover have seen them bayoneted, are
expected to valiantly jump up and proceed to be served in the same
way.’ He reminded Wellington, as he says, that the garrison at Burgos
was as large as that at Ciudad Rodrigo, where two whole divisions
instead of 500 or 600 men had been thrown into the assault. The
Commander-in-Chief, condescending to argument for once, replied,
‘why expose more men than can ascend the ladders [as at the
Guards’ attack] or enter the work [as at the breach in the K.G.L.
attack] at one time, when by this mode the support is ordered to be
up in time to follow the tail of the preceding party[54]?’ And his
objection to the engineer’s plea was clinched by the dictum, ‘if we fail
we can’t lose many men.’ This controversy originally arose on the
details of the abortive storm of September 22, but Burgoyne’s
criticism was even more convincing for the details of the final assault
on October 18. The number of men risked was far too small for the
task that was set them.
The melancholy story of the storm runs as follows. On the
explosion of the mine at San Roman, punctually at 4.30, all three of
the sections of the assault were duly delivered. At the breach the
forlorn hope of the King’s German Legion charged at the rough slope
with great speed, reached the crest, and were immediately joined by
the support, led most gallantly by Major Wurmb of the 5th Line
Battalion. The first rush cleared a considerable length of the rampart
of its defenders, till it was checked against a stockade, part of the
works which the French had built to cut off the breach from the main
body of the place. Foiled here, on the flank, some of the Germans
turned, and made a dash at the injured rampart of the third line, in
their immediate front: three or four actually reached the parapet of
this inmost defence of the enemy. But they fell, and the main body,
penned in the narrow space between the two enceintes, became
exposed to such an overpowering fire of musketry that, after losing
nearly one man in three, they finally had to give way, and retired
most reluctantly down the breach to the trenches they had left. The
casualties out of 300 men engaged were no less than 82 killed and
wounded[55], among the former, Wurmb, who had led the assault, and
among the latter, Hesse, who commanded the forlorn hope, and was
one of the few who scaled the inner wall as well as the outer.
The Guards in their attack, 100 yards to the right of the breach,
had an even harder task than the Germans, for their storm was a
mere escalade. It was executed with great decision: issuing from the
front trench they ran up to the line of broken palisades, passed
through gaps in it, and applied their ladders to the face of the
rampart of the second enceinte. Many of them succeeded in
mounting, and they established themselves successfully on the
parapet, and seized a long stretch of it, so long that some of their
left-hand men got into touch with the Germans who had entered at
the breach. But they could not clear the enemy out of the terre-
pleine of the second enceinte, where a solid body of the French kept
up a rolling fire upon them, while the garrison of the upper line
maintained a still fiercer fusillade from their high-lying point of
vantage. The Guards were for about ten minutes within the wall, and
made several attempts to get forward without success. At the end of
that time a French reserve advanced from their left, and charging in
flank the disordered mass within the enceinte drove them out again.
The Guards retired as best they could to the advanced trenches,
having lost 85 officers and men out of the 300 engaged. The French
returned their casualties at 11 killed and 30 wounded.
Wellington’s dispatch, narrating the disaster, gives the most
handsome testimonial to the resolution of both the bodies of
stormers. ‘It is impossible to represent in adequate terms the conduct
of the Guards and the German Legion upon this occasion. And I am
quite satisfied that if it had been possible to maintain the posts which
they gained with so much gallantry, these troops would have
maintained them[56].’ But why were 600 men only sent forward, and
no support given them during the precious ten minutes when their
first rush had carried them within the walls? Where were the brigades
to which the stormers belonged? It is impossible not to subscribe to
Burgoyne’s angry comment that ‘the miserable, doubting, unmilitary
policy of small storming-parties’ caused the mischief[57]. He adds,
‘large bodies encourage one another, and carry with them confidence
of success: if the Castle of Badajoz was stormed with ten or twelve
ladders, and not more than 40 or 50 men could mount at once, I am
convinced that it was only carried because the whole 3rd Division was
there, and the emulation between the officers of the different
regiments got their men to mount; although we lost 600 or 700 men,
it caused success—which eventually saves men.’
The third section of the assault of October 18, the unimportant
attack on the church of San Roman, had a certain measure of
success. The mine, though it did not level the whole building, as had
been hoped, blew up the terrace in front of, and part of its west end.
Thereupon the French evacuated it, after exploding a mine of their
own which brought down the bell-tower and much more, and
crushed a few of the caçadores and Spaniards[58] who were ahead of
their comrades. The besiegers were able to lodge themselves in the
ruins, but could make no attempt to approach the actual walls of the
second enceinte. So the 6th Division remained behind, within the
streets of Burgos, and never came forward or showed themselves.
Such was the unhappy end of this most unlucky siege. All through
the day of the assault there had been heavy skirmishing going on at
the outposts of the covering army; Souham was at last on the move.
On the 19th the Guards’ brigade and the K.G.L. brigade of the 1st
Division marched to join the 5th and 7th Divisions at the front,
leaving only the line brigade (Stirling’s) to hold the trenches on the
north and west sides of the Castle. Two-thirds of the 6th Division had
already gone off in the same direction before the storm: now the rest
followed, handing over the charge of Burgos city and the chain of
picquets on the east side of the Castle to Pack’s Portuguese. There
was little doing in the lines this day—the French built up the oft-
destroyed parapet of breach III with sandbags, and made an
incursion into the church of San Roman, driving out the Portuguese
guard for a short time, and injuring the lodgement which had been
made in the ruins. But they withdrew when the supports came up.
On the 20th, news being serious at the front—for Souham showed
signs of intending to attack in force, and it was ascertained that he
had been reinforced by great part of the Army of the North, under
Caffarelli in person—Wellington gave orders to withdraw the guns
from the batteries, leaving only two of the captured French pieces to
fire an occasional shot. All transportable stores and ammunition were
ordered to be loaded up. There was some bickering in San Roman
this day, but at night the Portuguese were again in possession of the
much-battered church.
On the 21st came the final orders for retreat. The artillery were
directed to burn all that could not be carried off—platforms, fascines,
&c.—to blow up the works on San Miguel, and to retire down the
high-road to Valladolid. The three 18-pounders were taken a few
miles only. The roads being bad from heavy rain, and the bullocks
weak, it was held that there was no profit in dragging about the two
guns which had lost trunnions and were practically useless. The
surviving intact gun shared the fate of its two ‘lame’ fellows: all three
were wrecked[59], their carriages were destroyed, and they were
thrown out on the side of the road. The artillery reserve, now
reduced to the five ineffective 24-lb. howitzers, then continued its
retreat.

BURGOS
On the night of the 21st-22nd, Pack’s brigade and the other
troops left to hold the works retired, the covering army being now in
full retreat by various roads passing through or around the city. The
main column crossed at the town bridge—the artillery with wheels
muffled with straw to deaden their rumbling—risking the danger of
being shelled in the darkness by the Castle, which had several guns
that bore upon it. The long series of mishaps which constituted the
history of the siege of Burgos ended by the failure of the plan for the
explosions on San Miguel: the French found there next day more
than twenty barrels of powder intact. The arsenal in the town was
fired when the last troops had passed, but was only partly consumed.
Next morning (October 22) the advanced guard of the Army of
Portugal entered Burgos, and relieved the garrison after thirty-five
days of siege. Dubreton had still nearly 1,200 effective men under
arms: he had lost in his admirable and obstinate defence 16 officers
and 607 men, of whom 304 were killed or died of their wounds. The
corresponding total British casualty list was no less than 24 officers
and 485 men killed, 68 officers and 1,487 men wounded and missing
[the last item accounting for 2 officers and 42 men]. Almost the
whole of the loss came from the ranks of the 1st Division and Pack’s
Portuguese, the 6th Division troops having had little to do with the
trenches or assaults[60].
The external causes of the raising of the siege will be dealt with in
their proper place—the strategical narrative of the general condition
of affairs in both the Castiles which opens the next chapter. Here it
remains only to recapitulate the various reasons which made the
siege itself a failure. They have been summed up by several writers
of weight and experience—John Jones, the official historian of the
sieges of Spain, John Burgoyne the commanding engineer, William
Napier, and Belmas the French author, who (using Jones as a primary
authority) told its story from the side of the besieged. Comparing all
their views with the detailed chronicle of the operations of those
thirty-five eventful days, the following results seem to emerge.
(1) Burgos would not have been a strong fortress against an army
provided with a proper battering-train, such as that which dealt with
Ciudad Rodrigo or Badajoz. But Wellington—by his own fault as it
turned out in the end—had practically no such train at all: three 18-
pound heavy guns were an absurd provision for the siege of a place
of even third-rate strength. If Wellington had realized on September
20 that the siege was to last till October 21, he might have had
almost as many guns as he pleased. But the strength of Burgos was
underrated at the first; and by the time that it was realized,
Wellington considered (wrongly, as it turned out) that it was too late
to get the necessary ordnance from the distant places where it lay.
(2) Encouraged by the experience of Badajoz and Almaraz,
Wellington and his staff considered that an imperfect fortification like
the Castle of Burgos might be dealt with by escalade without artillery
preparation. The Hornwork of San Miguel was taken on this irregular
system; but the attempts against the enceintes of the Castle failed.
Burgoyne is probably right in maintaining that the repeated failures
were largely due to the general’s reluctance to put in large masses of
men at once, owing to his wish to spare the lives in units already
worked down to a low strength by long campaigning. The principle ‘if
we fail we can’t lose many men’ was ruinous. On October 18 the
place must have fallen if 3,000 instead of 600 men had been told off
for the assault.
(3) Notwithstanding the lack of artillery, Burgos might have been
taken if Wellington had owned a large and efficient body of
engineers. But (as at Badajoz, where he had made bitter complaints
on this subject[61]) the provision of trained men was ludicrously small
—there were just five officers of Royal Engineers[62] with the army,
and eight ‘Royal Military Artificers’. The volunteers from the Line, both
officers and men, used as auxiliaries, were not up to the work
required of them. It was a misfortune that none of the divisions
before Burgos had experience of siege-work, like that which the
Light, 3rd, and 4th Divisions (all left at Madrid) had been through.
(4) After the heavy losses in the early assaults the rank and file,
both the British and still more the Portuguese, were much
discouraged. As Burgoyne says, ‘the place might have been, and
ought to have been, taken if every one had done his duty[63].’ In the
actual assaults splendid courage was often displayed, but in the
trench-work there was much sulkiness, apathy, and even shirking.
‘Our undertaking, every night that we broke ground, appeared most
pitiful: there was scarcely a single instance where at least double the
work was not projected, with sufficient men and tools collected, that
was afterwards executed, owing to the neglect and misconduct of the
working parties. It was seldom that the men could be induced to take
out their gabions and set to work, and I myself placed at different
times hundreds of gabions with my own hands, and then entreated
the men to go and fill them, to no purpose. The engineers blamed
the men—the men blamed the engineers, who, as they grumbled,
were by unskilful direction ‘sending them out to be butchered[64].’ All
this, in the end, was due to the want of artillery for proper
preparation, and of trained sappers.
(5) Burgoyne, D’Urban, and other observers are probably right in
saying that the failure of the assaults was partly due to the bad
principle of composing the storming-parties of drafts from many
different corps, collected, under officers whom they did not
personally know, from the units that chanced to be on duty that day.
The one case where a brilliant success was scored with small loss,
was seen when a whole battalion, the 2/24th, carried the outer
enceinte on October 4.
(6) Wellington’s doubts, expressed almost from the first, as to the
practicability of the affair that he had taken in hand, were known to
many officers, and affected the general morale.
(7) Dubreton deserves unstinted praise. A general of more
ordinary type, such as Barrois at Ciudad Rodrigo, would have lost
Burgos for want of the extraordinary resourcefulness, determination,
and quick decision shown by this admirable governor. His garrison
must share his glory: the French 34th certainly got in this siege a
good revanche for their last military experience, the surprise of
Arroyo dos Molinos.
SECTION XXXIV: CHAPTER III
WELLINGTON’S RETREAT FROM BURGOS:
OCTOBER-NOVEMBER 1812. (1) FROM THE
ARLANZON TO THE DOURO: OCTOBER 22-
OCTOBER 30

Having completed the depressing chronicle of the leaguer of the


Castle of Burgos, it is necessary that we should turn back for a week
or two, to examine the changing aspect of external affairs, which
had affected the general strategical position in Spain while the siege
lingered on. It will be remembered that the original scheme for the
campaign had been that, after the Army of Portugal had been
pushed back to the Ebro, a great part of Wellington’s field force
should return to Madrid, to pick up the divisions left there, and the
corps of Hill, before Soult and King Joseph should begin to give
trouble on the side of Valencia. Only a containing force was to have
been left behind, to aid Castaños and his Galicians in keeping Clausel
(or his successor Souham) out of mischief, while more important
movements were on foot in New Castile[65]. As to the command of
this containing force there was a difficulty: Wellington was not at all
satisfied with the way in which Clinton had handled the troops left
on the Douro in August, and it seems doubtful whether he wished to
give him a far more important commission in the first half of
October, when he was the natural person to be chosen for it. For at
this time none of the other senior officers who had served in the
recent campaigns were available: Beresford, Stapleton Cotton, and
Picton were all three invalided at the moment. Graham, the best of
them all, had returned to England. Hill could not be removed from
the charge of his old army in the South. Of the five divisions before
Burgos four were commanded by brigadiers acting in the position of
locum tenens[66]: most of the brigades were, in a similar fashion,
being worked by colonels for want of a sufficient number of major-
generals to go round. But after October 11th the formal difficulty
was solved: there was now available an officer whom it was fitting to
leave in charge against Souham, viz. Sir Edward Paget, who came up
to the front on that day, after having been three years absent from
the Peninsula; he had last served under Wellington at the Passage of
the Douro in 1809, where he lost an arm. He had now come out
nominally to succeed Graham at the head of the 1st Division, but
also with the commission to act as second-in-command in the event
of the illness or disabling of the general-in-chief. Paget was known
as a good soldier, and had served with distinction during the
Corunna retreat; but he had never been trusted with the
management of a large force, and had little knowledge either of the
army which Wellington had trained, or of the parts of Spain in which
the campaign was now going on. Moreover, Wellington disliked on
principle the idea of having a second-in-command, occupying to a
certain extent a position independent of his own.
The separate containing force never came into existence,
because Wellington never left the North or returned to Madrid,
though rumours were afloat after Paget’s arrival that he was about
to do so without delay. Why, contrary to his own expressed
intentions did he never go South? The answer must certainly be that
down to a very late period of the siege he continued to keep in his
mind the idea of returning to Madrid[67], but that he was distracted
from his purpose by several considerations. The first was the
abominable weather in October, which made the prospect of a long
forced march distasteful—the army was sickly and would suffer. The
second was his insufficient realization of the nearness of the danger
in the South: he thought that Hill was in a less perilous position than
was actually the case. The third was that he was beginning to mark
the growing strength of the Army of Portugal, which lay in his own
front, and to see that he could not hope to ‘contain’ it by any mere
detachment, if he departed for the South with his main body.
Souham’s host was no longer a spent force, which could be ignored
as a source of danger; if Wellington took away two or three
divisions, the officer left in charge in the North would be at once
assailed by very superior numbers. He did not like the idea of
trusting either Clinton or Paget with the conduct of a retreat before
an enemy who would certainly press him fiercely. In addition, there
was the lingering hope that Burgos might fall: if it were captured the
situation would be much improved, since the allies could use it as a
sort of point d’appui—to use the terminology of the day—on which
the containing army could rest; and the enemy would be forced to
detach heavily for the investment of the place.
By the day of the last assault (October 18) Wellington had clearly
lingered too long, for very large reinforcements had just come up to
join Souham, who on that morning was in a position to evict from
before Burgos not only any mere ‘covering force’ that might be left
opposite him, but the whole 35,000 men which formed the total of
the allied host. For by now the Army of Portugal was recruited up to
a strength of 38,000 men present with the colours: it had also just
received the disposable battalions of the Bayonne Reserve, a strong
brigade of 3,500 men under General Aussenac, and what was more
important still—Caffarelli had appeared at Briviesca with the main
field-force of the Army of the North. The operations of Home
Popham, Mendizabal, Mina and Longa, which had detained and
confused the French troops in Biscay and Navarre for the whole
summer, had at last reached their limits of success, and having
patched up affairs on the coast, and left some 20,000 men to hold
the garrison places, and to curb the further raids of the British
commodore and the Spanish bands, Caffarelli had come southwards
with the whole of his cavalry—1,600 sabres,—three batteries, and
nearly 10,000 infantry, forming the greater part of the divisions of
Vandermaesen and Dumoustier. There were something like 50,000
French concentrated between Pancorbo and Briviesca on October
18th[68], while Wellington—allowing for his losses in the siege—had
not more than 24,000 Anglo-Portuguese and 11,000 Spaniards in
hand. The arrival of the Army of the North not only made the further
continuance of the siege of Burgos impossible, but placed Wellington
in a condition of great danger. It is clear that his campaign in the
North had only been able to continue for so long as it did because
Popham, Mina, and the Cantabrian bands had kept Caffarelli
employed for a time that exceeded all reasonable expectation. It was
really surprising that a small squadron and 10,000 half-organized
troops, of whom a large part were undisciplined guerrillero bands,
and the rest not much better, should have held the 37,000 men of
the Army of the North in play for three months. But the combination
of a mobile naval force, and of local levies who knew every goat-
path of their native mountains, had proved efficacious in the
extreme. It had taken Caffarelli the whole summer and much of the
autumn to vindicate his position, and recover the more important
strategical points in his wide domain. Even when he was marching
on Burgos there was fierce fighting going on round Pampeluna, on
which Mina had pressed in more closely when he heard of the
departure of the general-in-chief. The Cantabrians and Navarrese did
marvels for Wellington, and their work has never been properly
acknowledged by British writers.
It is clear that the whole situation would have been different if
Wellington had brought up to the North in September the 16,000
veteran British troops left at Madrid. For want of them he was in a
state of hopeless inferiority to his immediate opponents. And yet at
the same time they were useless at Madrid, because Hill—even with
their aid—was not nearly strong enough to keep Soult and King
Joseph in check. Wellington had in all at this time some 55,000
Anglo-Portuguese troops under arms and at the front; but they were
so dispersed that on both theatres of war he was inferior to his
enemies. He had 24,000 himself in Old Castile—Hill some 31,000 in
New Castile; each of the two halves of the army could count on the
help of some 10,000 or 12,000 Spaniards[69]. But of what avail were
the 35,000 men of all nations at Burgos against the 50,000 French
under Souham and Caffarelli, or the 43,000 men of all nations near
Madrid against the 60,000 of Soult and the King? The whole
situation would have been different if a superiority or even an
equality of numbers had been established against one of the two
French armies; and it is clear that such a combination could have
been contrived, if Wellington had adopted other plans.
There can be no doubt that the excessive tardiness of Soult’s
evacuation of Andalusia was the fact which caused the unlucky
distribution of Wellington’s forces in October. The Marshal, it will be
remembered, only left Granada on September 16th, and did not
come into touch with the outlying cavalry of the Valencian Army till
September 29-30, or reach Almanza, where he was in full connexion
with Suchet and King Joseph, till October 2. There was, therefore,
no threatening combination of enemies on the Valencia side till
thirteen days after the siege of Burgos had begun; and Wellington
did not know that it had come into existence till October 9th, when
he received a dispatch from Hill informing him that the long
foreseen, but long deferred, junction had taken place. If it had
occurred—as it well might have—three weeks earlier, there would
have been no siege of Burgos, and Wellington would have been at
Madrid, after having contented himself with driving the army of
Portugal beyond the Douro. It is probable that he would have done
well, even at so late a date as October 9th, if he had recognized that
the danger in front of Madrid was now pressing, and had abandoned
the siege of Burgos, in order to make new arrangements. Souham
was not yet in a condition to press him, and Caffarelli’s 10,000 men
had not arrived on the scene. But the last twelve days spent before
Burgos ruined his chances.
On getting Hill’s dispatch Wellington pondered much—but came
to an unhappy decision. In his reply he wrote, ‘I cannot believe that
Soult and the King can venture to move forward to attack you in the
position on the Tagus, without having possession of the fortresses in
the province of Murcia [Cartagena and Chinchilla] and of Alicante;—
unless indeed they propose to give up Valencia entirely. They would
in that case[70] bring with them a most overwhelming force, and you
would probably have to retire in the direction given to General Alten
[i.e. by the Guadarrama Pass, Villa Castin, and Arevalo] and I should
then join you on the Adaja. If you retire in that direction, destroy the
new bridge at Almaraz.... I write this, as I always do, to provide for
every event, not believing that these instructions are at all
necessary[71].’
In a supplementary letter, dated two days later, Wellington tells
Hill that he imagines that the autumn rains, which have made the
siege of Burgos so difficult, will probably have rendered the rivers of
the South impassable. ‘I should think that you will have the Tagus in
such a state as to feel in no apprehension in regard to the enemy’s
operations, be his numbers what they may[72].’ Yet though he does
not consider the danger in the South immediate or pressing, he
acknowledges that he ought to bring the siege of Burgos to an end,
even though it be necessary to raise it, and to give up the hope of
its capture. But the continual storms and rains induced him to delay
his departure toward the South: ‘I shall do so as soon as the
weather holds up a little.’ On the same day (October 12) he wrote to
Popham to say that if he had to march towards Madrid, he expected
that Souham would follow him, but that Caffarelli must on no
account be allowed to accompany Souham. At all costs more trouble
must be made in Cantabria and Biscay, to prevent the Army of the
North from moving. Popham must not withdraw his squadron, or
cease from stimulating the Northern insurgents[73]. Wellington was
not aware that Caffarelli was already on the move, and that the
diversion in the North—through no fault of the officers in charge of it
—had reached its limit of success.
The moment had now arrived at which it was necessary at all
costs to come to some decision as to the movements of the Army at
Burgos, for Caffarelli (though Wellington knew it not) had started for
Briviesca, while Soult and King Joseph were also getting ready for an
immediate advance on Madrid, which must bring matters in the
South to a head. But relying on letters from Hill, dated October 10th,
which stated that there was still no signs of movement opposite him,
Wellington resolved on October 14 to stay yet another week in the
North, and try his final assault on Burgos: it came off with no
success (as will be remembered) on the 18th of that month. He was
not blind to the possible consequences to Hill of a prompt advance
of the French armies from Valencia, but he persuaded himself that
the weather would make it difficult, and that he had means of
detaining Soult and Joseph, if they should, after all, begin the move
which he doubted that they proposed to make.
The scheme for stopping any forward march on the part of the
French had two sections. The first was to be executed by the Anglo-
Spanish Army at Alicante. Maitland had fallen sick, and this force of
some 16,000 men was now under the charge of General John
Mackenzie. To this officer Wellington wrote on October 13th: ‘In case
the enemy should advance from Valencia into La Mancha, with a
view to attack our troops on the Tagus, you must endeavour to
obtain possession of the town and kingdom of Valencia.’ He was
given the option of marching by land from Alicante, or of putting his
men on shipboard and making a descent from the sea on
Valencia[74]. The second diversion was to be executed by Ballasteros
and the Army of Andalusia. Wellington wrote to him that he should
advance from Granada, cross the Sierra Morena with all his available
strength, and place himself at Alcaraz in La Mancha[75]. He ought to
have at least 12,000 men, as some of the Cadiz troops were coming
up to join him. Such a force, if placed on the flank of Soult and the
King, when they should move forward for Almanza and Albacete,
could not be ignored. And Wellington hoped to reinforce Ballasteros
with that part of the Murcian Army, under Elio and Freire, which had
got separated from the Alicante force, and had fallen back into the
inland. There were also irregular bodies, such as the division of the
Empecinado, which could be called in to join, and if 20,000 men lay
at Alcaraz, Soult could not go in full force to assail Hill in front of
Madrid. He must make such a large detachment to watch the
Spaniards that he would not have more than 30,000 or 35,000 men
to make the frontal attack on the Anglo-Portuguese force, which
would defend the line of the Tagus. Against such numbers Hill could
easily hold his ground.
It may be objected to these schemes that they did not allow
sufficient consideration to the power of Suchet in Valencia.
Mackenzie’s force, of a very heterogeneous kind, was not capable of
driving in the detachments of the Army of Aragon, which still lay
cantoned along the Xucar, facing the Allies at Alicante. Suchet was
able to hold his own, without detaining any of the troops of Soult or
of King Joseph from their advance upon Madrid. Mackenzie’s
projected expedition against the city of Valencia had no chance of
putting a check upon the main manœuvre that the French had in
hand.
But the use of Ballasteros, whose movement must certainly have
exercised an immense restraining power upon Soult and King
Joseph, if only it had been carried out, was an experiment of a kind
which Wellington had tried before, nearly always with disappointing
results. To entrust to a Spanish general an essential part of a wide
strategical plan had proved ere now a doubtful expedient. And
Ballasteros had always shown himself self-willed if energetic; it was
dangerous to reckon upon him as a loyal and intelligent assistant in
the great game. And at this moment the captain-general of
Andalusia was in the most perverse of moods. His ill temper was
caused by the recent appointment of Wellington as commander-in-
chief of all the Spanish armies, a measure to which the Cortes had at
last consented, after the consequences of the battle of Salamanca
and the occupation of Madrid had prepared public opinion for this
momentous step. It had been bitterly opposed at the secret session
when it was brought forward, but there could no longer be any valid
excuse for putting off the obviously necessary policy of combining all
military effort in the Peninsula, by placing the control of the whole of
the Spanish armies in the hands of one who had shown himself such
a master of the art of war.
Wellington’s nomination as Generalissimo of the Spanish armies
had been voted by the Cortes on September 22nd, and conveyed to
him before Burgos on October 2nd. He had every intention of
accepting the offer, though (as he wrote to his brother Henry[76]) the
change in his position would not be so great in reality as in form,
since Castaños and most of the other Spanish generals had of late
been wont to consult him on their movements, and generally to fall
in with his views. There had been exceptions, even of late, such as
Joseph O’Donnell’s gratuitous forcing on of battle at Castalla, when
he had been specially asked to hold back till the Anglo-Sicilian
expedition began to work upon the East Coast. But it would certainly
be advantageous that, for the future, he should be able to issue
orders instead of advice. Meanwhile he could not formally accept the
post of general-in-chief without the official leave of the Prince
Regent, and prompt information of the offer and a request for
permission to accept it, were sent to London. The Cortes, foreseeing
the necessary delay, had refrained from publishing the decree till it
should be certain that Wellington was prepared to assume the
position that was offered him. But the fact soon became known in
Cadiz, and was openly spoken of in the public press. Wellington
continued to write only letters of advice to the Spanish generals, and
did not assume the tone of a commander-in-chief as yet, but his
advice had already a more binding force. There was no opposition
made to him, save in one quarter—but that was the most important
one. Ballasteros, as Commander of the 4th Army and Captain-
General of Andalusia, burst out into open revolt against the Cortes,
the Regency, and the commander-in-chief elect.
This busy and ambitious man had taken up his abode in Granada,
after Soult’s departure on September 23rd, and since then had not
stirred, though Wellington had repeatedly asked him to advance into
La Mancha with his available force, and to put himself in touch with
Elio, Penne Villemur, and Hill. But Ballasteros was suffering from an
acute attack of megalomania: after years of skulking in the
mountains and forced marches, he was now in the position of a
viceroy commanding the resources of a great province. Though
Andalusia had been cleared of the French by no merit of his, but as
a side-effect of the battle of Salamanca, he gave himself the airs of
a conqueror and deliverer, and fully believed himself to be the most
important person in Spain. As an acute observer remarked,
‘Ballasteros wanted to begin where Bonaparte ended, by seizing
supreme authority, though he had performed no such services for his
fatherland as the French general. He spared no effort to attach his
army to his person, and to win its favour sacrificed without
hesitation the whole civil population. The land was drained of all
resources, but he found new means of extorting money. His officers
went from town to town exacting a so-called “voluntary contribution”
for the army. Those who gave much were put in his white book as
patriots—those who did not were enrolled in his black book as
supporters of King Joseph. He wanted to collect all the troops in
Andalusia into a great army, with himself as commander. But the
Regency directed him, in accordance with Wellington’s advice, to
march at once with the troops immediately available and take post in
La Mancha[77].’
Then came the news of Wellington’s nomination as commander-
in-chief. Ballasteros thought the moment favourable for an open bid
for the dictatorship. Instead of obeying the orders sent, he issued on
October 23rd a manifesto directed to the Regency, in which he
declared that Wellington’s appointment to supreme power was an
insult to the Spanish nation, and especially to the Spanish Army. He
openly contemned the decree, as dishonourable and debasing—
Spaniards should never become like Portuguese the servants of the
foreigner. If—what he could not believe—the national army and the
nation itself should ratify such an appointment, he himself would
throw up his post and retire to his home. At the same time there
was an outburst of pamphlets and newspaper articles inspired by
him, stating that England was to be feared as an oppressor no less
than France; and all sorts of absurd rumours were put about as to
the intentions of the British Government and the servility of the
Cortes.
Ballasteros, however, had altogether mistaken his own
importance and popularity: budding Bonapartes must be able to rely
on their own troops, and he—as the event showed—could not. The
Cortes took prompt measures for his suppression: one Colonel
Rivera, a well-known Liberal, was sent secretly to Granada to bear to
Virues, the second in command of the 4th Army, orders to arrest his
chief, and place him in confinement. And this was done without any
difficulty, so unfounded was the confidence which Ballasteros had
placed in his omnipotence with the army. Virues and the Prince of
Anglona, his two divisional generals, carried out the arrest in the
simplest fashion. On the morning of October 30th they ordered out
their troops for a field day on the Alcalá road, save a battalion of the
Spanish Guards, who had not belonged to Ballasteros’s old army,
and had no affection for him. This regiment surrounded his
residence, and when he issued out the picquet refused him passage,
and Colonel Rivera presented him with the warrant for his arrest.
There was some little stir in Granada among the civil population, but
the army made no movement when Virues read the decree of the
Cortes to them. Before he well understood what had happened,
Ballasteros was on his way under a guard to the African fortress of
Ceuta. He was afterwards given Fregenal in Estremadura as the
place of his detention.
But all this happened on October 30th, and meanwhile the Army
of Andalusia had remained motionless, though Wellington had
believed that it had marched for La Mancha as early as October
5th[78]. Nearly a month had been lost by Ballasteros’s perversity, and
when he was finally arrested and his troops became available, it was
too late; for Hill had been forced to retreat, and Madrid was about to
fall into the hands of the French, who had advanced through La
Mancha unmolested. The Fourth Army was put under the command
of the Duke del Parque, the victor of Tamames, but the vanquished
of Alba de Tormes in the campaign of 1809. It marched early in
November to its appointed position at Alcaraz; but it was of no use
to have it there when the enemy had changed all his positions, and
had driven Hill beyond the Guadarrama into the valley of the Douro.
Wellington’s arrangements for the defence of Madrid were
therefore insufficient as the event proved, for three reasons. The
diversion from Alicante was too weak—Suchet alone was able to
keep Maitland in check. The main Spanish force which was to have
co-operated with Hill never put in an appearance, thanks to the
disloyal perversity of its general. And, thirdly, the autumn rains,
which had so incommoded Wellington before Burgos, turned out to
be late and scanty in New Castile. The Tagus and its affluents
remained low and fordable almost everywhere.
As late as the 17th October Wellington had no fears about Hill’s
position. The probability that the enemy from Valencia would
advance upon Madrid, as he wrote on that morning, seemed
diminishing day by day—reinforcements were coming up from the
South to Hill, and Ballasteros was believed to be already posted in La
Mancha, ‘which renders the enemy’s movement upon the Tagus very
improbable[79].’ On the 19th, when his last assault on the Castle of
Burgos had just been beaten off, and he was thinking of retreat,
came much less satisfactory news from Hill. The enemy seemed to
be drawing together: they had laid siege to the Castle of Chinchilla,
and it was not impossible that they were aiming at Madrid, perhaps
only with a view of forcing the abandonment of the siege of Burgos,
perhaps with serious offensive intention. If so, Wellington might be
caught with not one but both of the halves of his army exposed to
immediate attack by a superior enemy, who was just assuming the
offensive. And the total force of the French was appalling—50,000
men on the Northern field of operations, 60,000 on the other—while
the united strength of all the available troops under Wellington’s
orders was about 80,000, of whom 25,000 were Spaniards, whose
previous record was not in many cases reassuring. He had often
warned the ministers at home that if the French evacuated outlying
provinces, and collected in great masses, they were too many for
him[80]. But that ever-possible event had been so long delayed, that
Wellington had gone on, with a healthy and cheerful opportunism,
facing the actual situation of affairs without taking too much thought
for the morrow. Now the conjunction least to be desired appeared to
be at length coming into practical existence and it remained to be
seen what could be done.
As for his own army, there was no doubt that prompt retreat,
first beyond the Pisuerga, then beyond the Douro, was necessary.
Souham had already made his first preliminary forward movement.
On the evening of October 18th a strong advance guard, consisting
of a brigade of Maucune’s division, pushed in upon the front of the
allied army at the village of Santa Olalla, and surprised there the
outlying picket of an officer and thirty men of the Brunswick-Oels,
who were nearly all taken prisoners. The heights above this place
commanded the town of Monasterio, wherefore Wellington directed
it to be evacuated, and drew in its line to a position slightly nearer
Burgos, for it was clear that there were heavy forces behind the
brigade which had formed the French attacking force[81].
On the 19th he was in order of battle with all his army except the
troops left before Burgos—Pack’s Portuguese, a brigade of the 6th
Division, and three weak battalions from the 1st Division. The
position extended from Ibeas on the Arlanzon, through Riobena to
Soto Palacios, and was manned by the 1st, 5th, and 7th Divisions,
two brigades of the 6th, Bradford’s Portuguese, Castaños’s Galicians,
and all the cavalry—about 30,000 men. Wellington expected to be
attacked on the 20th, and was not prepared to give back till he had
ascertained what force was in his front. He knew that the Army of
Portugal had been reinforced, but was not sure whether the report
that Caffarelli had come up with a large portion of the Army of the
North was correct or no.
Souham’s movement on the 18th had been intended as the
commencement of a general advance: he brought up his whole force
to Monasterio, and he would have attacked on the 20th if he had not
received, before daybreak, and long ere his troops were under way,
a much-delayed dispatch from King Joseph. It informed him that the
whole mass of troops from Valencia was on the march for Madrid,
that this movement would force Wellington to abandon the siege of
Burgos and to fall back, and that he was therefore not to risk a
general action, but to advance with caution, and pursue the allied
force in front of him so soon as it should begin to retreat, when it
might be pressed with advantage.[82] He was to be prepared to link
his advance with that of the armies from the South, which would
have columns in the direction of Cuenca. Souham was discontented
with the gist of this dispatch, since he had his whole army
assembled, while Caffarelli was close behind, within supporting
distance, at Briviesca. He thought that he could have fought with
advantage, and was probably right, since he and Caffarelli had a
marked superiority of numbers, though Wellington’s positions were
strong.
Balked of the battle that he desired, he resolved to make a very
strong reconnaissance against the allied centre, to see whether the
enemy might already be contemplating retreat, and might consent to
be pushed back, and to abandon Burgos. This reconnaissance was
conducted by Maucune’s and Chauvel’s (late Bonnet’s) divisions and
a brigade of light cavalry: it was directed against Wellington’s centre,
in front of the villages of Quintana Palla and Olmos, where the 7th
division was posted. Maucune’s troops, forming the front line of the
French, were hotly engaged in this direction, when Wellington,
seeing that the main body of the enemy was very remote, and that
the two vanguard divisions had ventured far forward into his ground,
directed Sir Edward Paget with the 1st and 5th divisions—forming his
own left wing—to swing forward by a diagonal movement and take
Maucune in flank. The French general discovered the approaching
force only just in time, and retreated in great haste across the fields,
without calling in his tirailleurs or forming any regular order of
march. Each regiment made off by its own way, just early enough to
escape Paget’s turning movement. The British horse artillery arrived
only in time to shell the last battalions; the infantry was too far off to
reach them. Dusk fell at this moment, and Paget halted: if there had
been one hour more of daylight Maucune and Chauvel would have
been in an evil case, for they were still some distance from their own
main body on the Monasterio position, and the British cavalry was
coming up in haste. The reconnaissance had been pushed recklessly
and too far—in accordance with the usual conduct of Maucune, who
was (as his conduct at Salamanca had proved) a gallant but a very
rash leader. The losses on both sides were trifling—apparently about
80 in the French ranks[83], and 47 in the British 7th division. Paget’s
troops did not come under fire.
On the morning of the 21st Wellington received a letter of Hill’s,
written on the 17th, which made it clear to him that he must delay
no longer. It reported that the enemy were very clearly on the move
—the whole of Drouet’s corps was coming forward from Albacete,
the castle of Chinchilla had fallen into the hands of the French on
Oct. 9th, and—what was the most discomposing to learn—
Ballasteros had failed to advance into La Mancha: by the last
accounts he was still at Granada. He would certainly come too late,
if he came at all. The only compensating piece of good news was
that Skerrett’s brigade from Cadiz was at last near at hand, and
would reach Talavera on the 20th. Elio, from his forward position at
Villares, reported that Suchet’s troops opposite Alicante were
drawing back towards Valencia; possibly they were about to join
Soult and King Joseph, who were evidently coming forward. Hill was
inclined to sum up the news as follows: ‘The King, Soult, and Suchet
having united their armies are on the frontiers of Murcia and
Valencia, and appear to be moving this way. It is certain that a
considerable force is advancing toward Madrid, but I think it doubtful
whether they will attempt to force their way to the capital.’
Meanwhile he had, as a precautionary measure, brought up the
troops in cantonments round Madrid to Aranjuez and its
neighbourhood, and had thrown forward a cavalry screen beyond
the Tagus, to watch alike the roads from Albacete and those from
Cuenca.
The mere possibility that Soult and the King were advancing on
Madrid was enough to move Wellington to instant retreat: if he
waited for certainty, he might be too late. And his own position in
front of Souham and Caffarelli was dangerous enough, even if no
more bad news from the South should come to hand. Accordingly on
the afternoon of the 21st orders were sent to Pack to prepare to
raise the siege of Burgos, when the main army in its backward
movement should have passed him. The baggage was to be sent off,
the stores removed or burned in the following night. The divisions in
line opposite Souham were to move away, after lighting camp fires
to delude the enemy, in two main columns, one on each side of the
Arlanzon. The northern column, composed of the 5th Division, two-
thirds of the Galician infantry, the heavy dragoons of Ponsonby (late
Le Marchant’s brigade) and the handful of Spanish regular cavalry,
was to skirt the northern side of the city of Burgos, using the cross-
roads by Bivar and Quintana Dueñas, and to retire to Tardajos,
beside the Urbel river. The southern and larger column, consisting of
the 1st, 7th, and 6th Divisions (marching in that order), of Bradford’s
Portuguese and the remainder of the Galicians, was to move by the
high road through Villa Fria, to cross the town-bridge of Burgos
(with special caution that silence must be observed, so as not to
alarm the garrison of the Castle) to Frandovinez and Villa de Buniel.
Here they would be in touch with the other column, which was to be
only two miles away at Tardajos. Anson’s cavalry brigade was to
cover the rear of this column, only abandoning the outposts when
the infantry should have got far forward. They were to keep the old
picquet-line till three in the morning. Bock’s German dragoons and
the cavalry of Julian Sanchez formed a flank guard for the southern
column: they were to cross the Arlanzon at Ibeas, five miles east of
Burgos, and to retire parallel to the infantry line of march, by a
circuit on cross-roads south of Burgos, finally joining the main body
at Villa de Buniel[84].
All this complicated set of movements was carried out with
complete success: the army got away without arousing the attention
of the French of Souham, and the column which crossed the bridge
of Burgos, under the cannon of the Castle[85], was never detected,
till a Spanish guerrilla party galloped noisily across the stones and
drew some harmless shots. Since the enemy was alarmed, the rear
of the column had to take a side-path. Pack filed off the troops in
the trenches, and got away quietly from the investment line. In the
morning the two infantry columns were safely concentrated within
two miles of each other at Tardajos and Villa de Buniel. There being
no sign of pursuit, they were allowed some hours’ rest in these
positions, and then resumed their retreat, the northern column
leading, with the 5th Division at its head, the southern column
following, and falling into the main road by crossing the bridge of
Buniel. The 7th Division formed the rearguard of the infantry; it was
followed by Bock’s dragoons, Anson and Julian Sanchez bringing up
the rear. On the night of the 22nd the army bivouacked along the
road about Celada, Villapequeña, and Hornillos; the light cavalry, far
behind, were still observing the passages of the Arlanzon at Buniel
and of the Urbel at Tardajos.
The French pursuit was not urged with any vigour on this day.
The departure of Wellington had only been discovered in the early
morning hours by the dying down of the camp fires along his old
position[86]. At dawn Souham advanced with caution; finding nothing
in front of it, his vanguard under Maucune entered Burgos about 10
o’clock in the morning, and exchanged congratulations with
Dubreton and his gallant garrison. The light cavalry of the Army of
Portugal pushed out along the roads north and south of the
Arlanzon: those on the right bank found the three broken 18-
pounders of Wellington’s battering train a few miles outside of
Burgos, and went as far as the Urbel, where they came on the rear
vedettes of the Allies. Those on the left bank obtained touch with
Anson’s outlying picquet at San Mames, and drove it back to the
Buniel bridge.
The 23rd October, however, was to be a day of a much more
lively sort. Souham and Caffarelli, having debouched from Burgos,
brought all their numerous cavalry to the front, and at dawn it was
coming up for the pursuit, in immense strength. There were present
of the Army of Portugal Curto’s light horse, Boyer’s dragoons, and
the brigade formerly commanded by Chauvel now under Colonel
Merlin of the 1st Hussars. These, by the morning state of October
15th, made up 4,300 sabres. The Army of the North contributed the
bulk of its one—but very powerful—cavalry brigade, that of
Laferrière, 1,650 strong.[87] Thus there were nearly 6,000 veteran
horsemen hurrying on to molest Wellington’s rear, where the
covering force only consisted of Anson’s and Bock’s two brigades and
of the lancers of Julian Sanchez—1,300 dragoons British and
German[88], and 1,000 Spaniards admirable for raids and ambushes
but not fit to be placed in battle line. Ponsonby’s dragoons and the
regular squadrons of the Galician army were far away with the head
of the column. To support the cavalry screen were the two horse-
artillery batteries of Downman and Bull, and the two Light Battalions
of the German Legion from the 7th Division, under Colonel Halkett,
which were left behind as the extreme rearguard of the infantry.
All day the main marching column of the allied army laboured
forward unmolested along the muddy high road from Celada del
Camino to Torquemada, a very long stage of some 26 miles:
Wellington seldom asked his infantry to make such an effort. What
would have happened to Clausel’s army if the British had marched at
this rate in the week that followed the battle of Salamanca? Behind
the infantry column, however, the squadrons of the rearguard were
fighting hard all day long, to secure an unmolested retreat for their
comrades. This was the most harassing and one of the most costly
efforts that the British cavalry was called upon to make during the
Peninsular War. The nearest parallel to it in earlier years was the
rearguard action of El Bodon in September 1811[89]. But there the
forces engaged on both sides had been much smaller.
The French advanced guard consisted of Curto’s light cavalry
division of the Army of Portugal, supported by Maucune’s infantry
division. It had started at dawn, and found the British cavalry
vedettes where they had been marked down on the preceding night,
at the bridge of Villa Buniel. They retired without giving trouble,
being in no strength, and the morning was wearing on when the
French came upon Wellington’s rearguard, the horsemen of Anson
and Julian Sanchez, and Halkett’s two German battalions, a mile or
two east of Celada, holding the line of the Hormaza stream. Anson
was in position behind its ravine, with a battalion of the light infantry
dispersed along the bushes above the water, and the cavalry in
support. Julian Sanchez was visible on the other side of the
Arlanzon, which is not here fordable, beyond Anson’s right: on his
left, hovering on hills above the road, was a small irregular force, the
guerrilla band of Marquinez[90]. The ground along the Hormaza was
strong, and the infantry fire surprised the enemy, who were stopped
for some time. They came on presently in force, and engaged in a
bickering fight: several attempts to cross the ravine were foiled by
partial charges of some of Anson’s squadrons. Wellington says in his
dispatch that the skirmishing lasted nearly three hours, and that
Stapleton Cotton, who had recently come up from the Salamanca
hospital cured of his wound, made excellent dispositions. But the
odds—more than two to one—were far too great to permit the
contest to be maintained for an indefinite period; and when, after
much bickering, the French (O’Shee’s brigade of Curto’s division) at
last succeeded in gaining a footing beyond the Hormaza, Anson’s
squadrons went off in good order. The ground for the next five or six
miles was very unfavourable for a small detaining force, as the valley
of the Arlanzon widened out for a time, and allowed the enemy
space to deploy his superior numbers. Nevertheless the light
dragoons turned again and again, and charged with more or less
success the pursuing Chasseurs. While Curto’s division was pressing
back the British brigade in front, Merlin’s brigade, pushing out on the
French right, ascended the hills beyond Anson’s left flank, and there
found and drove off the partida of Marquinez. The fugitive
guerrilleros, falling back for support towards the British, came in
upon the flank of the 16th Light Dragoons with French hussars in
close pursuit, and mixed with them. The left squadron of the 16th
was thrown into confusion, and suffered heavily, having some thirty
casualties; and the commander of the regiment, Colonel Pelly, and
seven of his men were taken prisoners. As Curto was pushing on at
the same time, Anson’s brigade was much troubled, and was greatly
relieved when it at last came in sight of its support, Bock’s German
Heavy Dragoons and Bull’s battery, posted behind a bridge spanning
a watercourse near the lonely house called the Venta del Pozo. The
two battalions of Halkett, who had been retiring under cover of
Anson’s stubborn resistance, were now some little way behind Bock,
near the village of Villadrigo. On seeing the obstacle of the
watercourse in front of them, and the British reserves behind it, the
cavalry of the Army of Portugal halted, and began to re-form.
Anson’s harassed brigade was permitted to cross the bridge and to
join Bock.
At this moment there came on the scene the French cavalry
reserves, Boyer’s dragoons and the three regiments of the Army of
the North, which were commanded that day not by their brigadier
Laferrière (who had been injured by a fall from his horse) but by
Colonel Faverot of the 15th Chasseurs. Souham, who had arrived in
their company as had Caffarelli also, gave orders that the pursuit
was not to slacken for a minute. While the cavalry of Curto and
Merlin were re-forming and resting, the newly arrived squadrons
were directed to drive in the British rearguard from its new position.
The brigade of Faverot was to attack in front, the dragoons of Boyer
were to turn the hostile line, by crossing the watercourse some way
to their right, and to fall on its flank and rear. So great was the
superiority in numbers of the attacking party that they came on with
supreme confidence, ignoring all disadvantages of ground. Faverot’s
brigade undertook to pass the bridge in column, in face of Bock’s
two regiments drawn up at the head of the slope, and of Bull’s
battery placed on the high road so as to command the crossing.
Boyer’s dragoons trotted off to the right, to look for the first
available place where the water should allow them a practicable
ford.
What followed was not in accordance with the designs of either
party. Souham had intended Boyer and Faverot to act
simultaneously; but the former found the obstacle less and less
inviting the farther that he went on: he rode for more than a mile
without discovering a passage, and finally got out of sight of
Souham and the high road[91]. Meanwhile Faverot had advanced
straight for the bridge, and had begun to cross it. Of his three
regiments the Berg lancers led, the 15th Chasseurs came next, the
Legion of Gendarmerie brought up the rear. They were ten
squadrons in all, or some 1,200 sabres. As each squadron got quit of
the bridge it formed up in line, the first to pass to the right of the
road, while those which followed successively took ground to the
left, between the chaussée and the bank of the Arlanzon. Eight
squadrons had got into position before the British line gave any
signs of movement on the hillside above.
It is clear that to cross a bridge in this fashion was a reckless
manœuvre. If Bock had charged when two or three squadrons only
had passed[92], he must have crushed them in the act of deployment,
and have jammed the rest of the French column at the bridgehead
in a position of helpless immobility. That no such charge was made
resulted from a curious chance. Stapleton Cotton, who was still
conducting the retreat, had placed Bull’s battery at a point on the
slope where he judged that it fully commanded the bridge, with
Bock’s four squadrons on its right. Then Anson’s brigade, not in the
best of order after its long pursuit by the enemy, trotted over the
bridge and came up the slope. Cotton intended that it should deploy
on the left of the guns, but the retreating regiments, before the
directions reached them, turned to the right and began to form up
behind Bock’s line. The general at once sent them orders to cross to
the left and prolong the line on the other side of Bull’s battery. By
some extraordinary blunder the leading regiment (perhaps to
shorten its route) passed to the left in front of the guns, instead of
moving behind them. It was thus masking the battery just at the
moment that the French, to the surprise of every one, began to
cross the bridge. There was considerable confusion in changing the
march of the light dragoons, and before they were cleared off and
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

ebooknice.com

You might also like