Liferay 62 User Interface Development Xinsheng
Chen Jonas X Yuan download
https://ebookbell.com/product/liferay-62-user-interface-
development-xinsheng-chen-jonas-x-yuan-4682260
Explore and download more ebooks at ebookbell.com
Here are some recommended products that we believe you will be
interested in. You can click the link to download.
Liferay Portal 62 Enterprise Intranets Navin Agarwal
https://ebookbell.com/product/liferay-portal-62-enterprise-intranets-
navin-agarwal-6808832
Liferay Portal 52 Systems Development Jonas X Yuan
https://ebookbell.com/product/liferay-portal-52-systems-development-
jonas-x-yuan-1266150
Liferay 6x Portal Enterprise Intranets Cookbook Over 60 Handson
Recipes To Help You Efficiently Create Complex And Highly Personalized
Enterprise Intranet Solutions With Liferay Portal 6x Ce Piotr
Filipowicz
https://ebookbell.com/product/liferay-6x-portal-enterprise-intranets-
cookbook-over-60-handson-recipes-to-help-you-efficiently-create-
complex-and-highly-personalized-enterprise-intranet-solutions-with-
liferay-portal-6x-ce-piotr-filipowicz-5473904
Liferay Portal 6 Enterprise Intranets Jonas X Yuan
https://ebookbell.com/product/liferay-portal-6-enterprise-intranets-
jonas-x-yuan-2313866
Liferay In Action The Official Guide To Liferay Portal Development 1st
Edition Rich Sezov
https://ebookbell.com/product/liferay-in-action-the-official-guide-to-
liferay-portal-development-1st-edition-rich-sezov-2342536
Liferay Portal Enterprise Intranets Jonas X Yuan
https://ebookbell.com/product/liferay-portal-enterprise-intranets-
jonas-x-yuan-2459436
Liferay Beginners Guide Robert Chen Sandeep Nair Samir Bhatt
https://ebookbell.com/product/liferay-beginners-guide-robert-chen-
sandeep-nair-samir-bhatt-2491058
Liferay Portal Systems Development Jonas X Yuan
https://ebookbell.com/product/liferay-portal-systems-development-
jonas-x-yuan-2520586
Liferay Portal Performance Best Practices A Practical Tutorial To
Learn The Best Practices For Building High Performing Liferaybased
Solutions Samir Bhatt
https://ebookbell.com/product/liferay-portal-performance-best-
practices-a-practical-tutorial-to-learn-the-best-practices-for-
building-high-performing-liferaybased-solutions-samir-bhatt-4379406
Liferay 6.2 User Interface
Development
A comprehensive guide to user interface development
with Liferay Portal
Xinsheng Chen
Jonas X. Yuan
BIRMINGHAM - MUMBAI
Liferay 6.2 User Interface Development
Copyright © 2013 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval
system, or transmitted in any form or by any means, without the prior written
permission of the publisher, except in the case of brief quotations embedded in
critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy
of the information presented. However, the information contained in this book is
sold without warranty, either express or implied. Neither the authors, nor Packt
Publishing, and its dealers and distributors will be held liable for any damages
caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the
companies and products mentioned in this book by the appropriate use of capitals.
However, Packt Publishing cannot guarantee the accuracy of this information.
First published: November 2013
Production Reference: 1181113
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78216-234-6
www.packtpub.com
Cover Image by Aashish Variava (aashishvariava@hotmail.com)
Credits
Authors
Xinsheng Chen
Jonas X. Yuan
Frank Yu
Reviewers
Albert Coronado Calzada
Sandeep Nair
Acquisition Editors
Anthony Albuquerque
Rukhsana Khambatta
Lead Technical Editors
Mayur Hule
Vaibhav Pawar
Technical Editors
Nadeem N. Bagban
Aparna Chand
Amit Singh
Copy Editors
Sarang Chari
Tanvi Gaitonde
Mradula Hegde
Gladson Monterio
Lavina Pereira
Kirti Pai
Project Coordinators
Abhishek Kori
Wendell Palmer
Proofreaders
Simran Bhogal
Maria Gould
Paul Hindle
Indexer
Mehreen Deshmukh
Graphics
Ronak Dhruv
Abhinash Sahu
Production Coordinator
Kyle Albuquerque
Cover Work
Kyle Albuquerque
About the Author
Xinsheng Chen is a web application architect. He holds an MS degree in
Computer Science from California State University, San Bernardino. His focus
was on online banking applications. He also has a Bachelor's degree from
Wuhan University, China. Mr. Chen was previously a QA engineer working
at VMware, Inc. He later led a team in developing four educational computer
games for a Florida school district. Mr. Chen has rich experience in J2EE
technologies. He also has extensive experience in Content Management
Systems (CMS), including Alfresco. He has worked on 23 Liferay Portal
projects. He is also the co-author of Liferay Beginner's Guide and Liferay
User Interface Development.
Acknowledgements
I would sincerely like to thank Rukhsana Khambatta (Acquisition Editor),
Abhishek Kori (Project Coordinator), Mayur Hule (Lead Technical Editor),
and Wendell Palmer (Project Coordinator) at Packt Publishing. Thank you
for giving me this opportunity to update this book. I appreciate your excellent
management of the book writing process. It has been a great experience
working together with you.
I would also thank Aparna Chand, Nadeem Bagban, and Amit Singh (Technical
Editors) who have helped me add the final touch to the book before its publication.
Thanks also goes to Shuyang Zhou and Nate Cavanaugh at Liferay, Inc. I learned a
lot from them while I wrote this book and worked on Liferay Portal projects.
I would like to thank Frank Yu and Jonas Yuan at ForgeLife, Inc. I appreciate their
understanding and support both in my life and at my work.
I would like to thank Tushar Shah at LinkedIn, Inc., who supported me when I needed
it. I would also thank Tina Agrawal, Tejash Patel, and Hemen Punjani at Cignex
Datamatics, Inc. They were my co-workers and I had worked happily with them.
I would also thank Xinli Chen, my eldest sister, who has always been supporting
me behind the scenes. My progress and achievements could not have been possible
without her support and sacrifice.
About the Author
Jonas X. Yuan is a Chief Architect of ForgeLife LLC and an expert on Liferay
Portal, e-commerce, and Content Management Systems (CMS). As an open source
community contributor, he has published five Liferay books from 2008 to 2012.
He is also an expert on Liferay integration with Ad Server OpenX, different search
engines, enterprise content including videos, audio, images, documents, and web
contents, and other technologies, such as BPM Intalio and Business Intelligence
Pentaho, LDAP, and SSO. He holds a Ph.D. in Computer Science from the University
of Zurich, where he focused on Integrity Control in federated database systems.
He earned his M.S. and B.S. degrees from China, where he conducted research
on expert systems for predicting landslides. Previously, he worked as a Project
Manager and a Technical Architect in Web GIS (Geographic Information System).
He is experienced in Systems Development Lifecycle (SDLC) and has deep,
hands-on skills in J2EE technologies. He developed a BPEL (Business Process
Execution Language) engine called BPELPower from scratch at the NASA data
center. As the chief architect, Dr. Yuan successfully led and launched several
large-scale Liferay/Alfresco e-commerce projects for millions of users each month.
He has worked on the following books: Liferay Portal Enterprise Intranets,
2008; Liferay Portal 5.2 Systems Development, 2009; Liferay Portal 6 Enterprise
Intranets, 2010; Liferay User Interface Development, 2010; Liferay Portal Systems
Development, 2012.
Acknowledgements
I would like to thank all my team members at Liferay, specially Raymond Auge,
Brian Chan, Bryan Cheung, Jorge Ferrer, Michael Young, Jerry Niu, Ed Shin,
Craig Kaneko, Brian Kim, Bruno Farache, Thiago Moreira, Amos Fong, Scott Lee,
David Truong, Alexander Chow, Mika Koivisto, Julio Camarero, Douglas Wong,
Ryan Park, Eric Min, John Langkusch, Marco Abamonga, Michael Han, Samuel Kong,
Nate Cavanaugh, Arcko Duan, Richard Sezov, Joshua Asbury, Shuyang Zhou,
and Juan Fernández for providing support and valuable information. Many thanks
to all my friends in the Liferay community.
I sincerely thank and appreciate Rukhsana Khambatta (Acquisition Editor),
Abhishek Kori (Project Coordinator), Mayur Hule (Lead Technical Editor),
and Wendell Palmer (Project Coordinator) at Packt Publishing for critiquing
and fixing my writing style.
Last but not least, I would like to thank my parents and my wife, Linda, for their
love, understanding, and encouragement. My special thanks to my wonderful and
understanding kid, Joshua.
About the Reviewers
Albert Coronado Calzada is a highly experienced Information Technology
professional with more than 13 years of experience in Java EE, high performance
portals, e-commerce, and enterprise software solutions. Albert has studied
Information Technology Engineering and has a Master's in Economics and
Financial Management of Companies.
Albert is currently working as a freelance software developer, trainer, and consultant
for international customers. Albert is an open source software contributor and has
released different applications for Liferay and Android.
Albert lives in Girona (Spain) and maintains a blog at
http://www.albertcoronado.com. You can contact him through LinkedIn
(es.linkedin.com/in/albertcoronado/) or Twitter (@acoronadoc).
Sandeep Nair has been working with Liferay for more than four years and overall
has more than seven years of experience in Java and Java EE technologies. He has
executed projects using Liferay in various domains such as construction, financial,
and medical fields providing solutions such as Collaboration, Enterprise Content
Management, and Web Content Management systems.
He has created a free and open source Google Chartlet plugin for Liferay, which has
been downloaded and used by people across 90 countries as per SourceForge statistics.
Besides development, consulting, and implementing solutions, he has also been
involved in providing training in Liferay in other countries. Before he jumped into
Liferay, he had experience in Java and JavaEE platforms and has worked in EJB,
Spring, Struts, Hibernate, and Servicemix. He also has experience in using JitterBit,
which is an ETL tool.
He has also authored Liferay Beginner's Guide and Instant Liferay Portal 6 Starter
with Packt Publishing.
When he is not coding, he loves to read books and write blogs.
www.PacktPub.com
Support files, eBooks, discount offers and more
You might want to visit www.PacktPub.com for support files and downloads related
to your book.
Did you know that Packt offers eBook versions of every book published, with PDF
and ePub files available? You can upgrade to the eBook version at www.PacktPub.com
and as a print book customer, you are entitled to a discount on the eBook copy. Get in
touch with us at service@packtpub.com for more details.
At www.PacktPub.com, you can also read a collection of free technical articles,
sign up for a range of free newsletters and receive exclusive discounts and offers
on Packt books and eBooks.
TM
http://PacktLib.PacktPub.com
Do you need instant solutions to your IT questions? PacktLib is Packt's online
digital book library. Here, you can access, read and search across Packt's entire
library of books.
Why Subscribe?
• Fully searchable across every book published by Packt
• Copy and paste, print and bookmark content
• On demand and accessible via web browser
Free Access for Packt account holders
If you have an account with Packt at www.PacktPub.com, you can use this to access
PacktLib today and view nine entirely free books. Simply use your login credentials
for immediate access.
Table of Contents
Preface 1
Chapter 1: Customizing Your Liferay Portal 9
Liferay functionalities 10
Documents and Media – CMS 10
Dynamic data lists and site/page/display templates 11
Web content management 11
Personalization and internalization 11
Workflow, staging, scheduling, and publishing 12
Social networking and Social Office 12
Understanding the tagging system 13
Integrating with Liferay Sync 13
Integrating with other systems easily 13
Leveraging framework and architecture for user interface development 14
Service Oriented Architecture 14
Understanding Enterprise Service Bus 15
Staging on standards 16
Customization and development strategies 17
Knowing about Ext plugins 19
Knowing about Hook plugins 21
Knowing about portlet and web plugins 23
Customizing the user interface through theme development frameworks 24
Building custom themes 25
Developing the user interface through layout template development
frameworks 25
Alloy UI customization 26
Structure – HTML5 26
Style – CSS 3 27
Behavior – YUI 3 27
Alloy UI forms 28
Table of Contents
[ ii ]
JavaScript frameworks 29
Responsive themes 30
More useful information 30
Summary 32
Chapter 2: Basic Theme 33
Structure of a Liferay Portal page 34
Creating a theme 35
The default content of a custom theme 36
Theme inheritance 36
Theme folders and files 37
The docroot/_diffs folder 37
The docroot/css folder 39
The docroot/images folder 45
The docroot/templates folder 46
The docroot/WEB-INF folder 47
Deployment of the beet theme 48
Cloning the classic theme 51
Analyzing the portal_normal.vm file 51
Velocity variables available in a theme 61
Rendering a theme 63
Summary 64
Chapter 3: Layout Template 65
Out of the box layout templates 65
Creating our first layout template 67
Rendering a layout template 73
Available variables in a layout template 74
Developing a layout template based on the client's requirements 74
One more solution 79
Multiple layout templates in one package 79
Embedding portlets in a layout template 81
Responsive layout templates 85
It works like this 90
Source code 91
Adding source code into the Liferay IDE 92
Summary 92
Chapter 4: Content Collaboration and Publishing 95
Before we start 96
Static content versus dynamic content 96
Basic web content 97
Table of Contents
[ iii ]
Web content based on structure 100
Defining a structure 100
Templates 102
Regarding the web content 103
Developing web content based on a client's requirements 103
Design 104
Implementing the design 106
Analyzing the code 109
Self-contained web content 112
Velocity variables available for web content 113
Web content that accesses a database 114
Reading from a database 114
Code analysis 118
Writing to a database 119
Code analysis 120
Web content for interoperability 121
Displaying XML-formatted data 123
Code explanation 124
Displaying JSON-formatted data 125
JSON solutions 126
JSONP solutions 128
Publishing 130
Source code 131
Summary 132
Chapter 5: Portlet 133
Before we start 133
Understanding a simple JSR-286 portlet 134
The Spring MVC portlet 145
About the Vaadin portlet 152
Vaadin support in Liferay Portal 152
Vaadin portlet for CRUD operations 153
Vaadin portlet for retrieving portal information 158
Characteristics of Vaadin portlets 163
Source code 164
Summary 164
Chapter 6: JavaScript Frameworks and Portlets 165
Before we start 165
The jQuery UI 166
Creating a localized calendar with jQuery 166
User input masking 169
Table of Contents
[ iv ]
Understanding Ext JS 170
About the grid 171
Drawing charts 173
Dojo Toolkit 176
Ajax calls 179
Animation 181
OpenXava for autocoding 182
Analyzing OpenXava 189
Source code 189
Summary 190
Chapter 7: Advanced Theme 191
Creating a theme as per client requirements 191
The client's requirements 192
Analysis and design 193
Implementing the custom theme 193
Embedding portlets in a theme 201
Embedding a non-instanceable portlet 202
Embedding an instanceable portlet 202
Creating a responsive theme 203
Upgrading themes 206
Multiple-level navigation menus in themes 211
Implementing browser support in themes 214
Integrating Google Analytics 216
Source code 221
Summary 222
Chapter 8: Understanding Alloy UI/YUI 223
Knowing the background 224
Peeping into HTML5 224
Trying out CSS3 227
Working with YUI3 228
Learning Alloy UI tags 230
The Button tag 230
The Button row tag 231
The Column tag 231
The Fieldset tag 232
The Input tag 232
The Layout tag 233
The Link tag 233
The Model-context tag 234
The Option tag 234
Table of Contents
[ v ]
The Select tag 234
Getting familiar with Node and Nodelist 236
Learning Node properties 238
Creating events 238
More Node methods 239
Manipulating Nodelist 240
Exploring Node queries 240
Making Ajax calls in Alloy UI 241
Understanding a plugin 244
Finding out widgets in Alloy UI 245
Creating a TreeView instance 245
Creating a data table instance 247
Starting an animation 249
Creating a drag-and-drop instance 250
Coding a delayed task 250
Implementing Overlay and OverlayManager 252
Creating an image gallery 253
Coding SWF file playback 254
Learning other Alloy UI features 254
Implementing the autocomplete feature 254
Creating a character counter 255
Resizing a DOM element 256
Coding a sortable list 256
Creating a tooltip instance 257
Knowing the benefits of using Alloy UI 258
Source code 258
Summary 258
Chapter 9: Using UI Taglib 259
Getting started with the UI tag 260
Understanding the asset tag and category 261
Setting up related assets 262
Asset tags and category settings 263
Getting to know the configuration 265
Things that happened 266
Using the search container 267
Displaying search results 267
Adding columns 269
Search form and search toggle 270
Understanding columns within columns 271
Adding a paginator 272
Speed and iterator 272
Table of Contents
[ vi ]
Getting to know the configuration 273
Let's find out what happened 273
Adding custom attributes 274
Understanding the settings for custom attributes 275
Getting to know the configuration 276
Knowing what happened 276
Using tabs, toggle, and calendar 276
Using the liferay-ui:tabs and liferay-ui:section tags 277
Applying the liferay-ui:toggle and liferay-ui:toggle-area tags 278
Applying the liferay-ui:calendar tag in a JSP page 279
Using breadcrumb, navigation, and panel 279
Understanding the settings 280
Getting to know the configuration 281
Adding social activity tracking and social bookmarks 282
Understanding the settings 282
Getting to know the configuration 283
Understanding what happened 283
Using the discussion, ratings, diff, and flags tags 284
Understanding the settings 284
Getting to know the configuration 286
Adding icons and input forms 287
Getting to know the icon tag settings 287
Learning the input tag and its settings 288
Integrating with CKEditor 290
Enabling SCAYT settings 291
What just happened? 292
Getting to know the configuration 293
Updating content with inline editing 293
Features of inline editing 294
Implementing inline editing 294
Using inline editing 295
Something more 295
Getting to know the configuration 298
Integrating with special sound UI reCAPTCHA 298
Things that happened 299
Summary 300
Chapter 10: Responsive Mobile Theme, Reporting, Searching,
and More 301
Using jQuery in plugins 302
Building jQuery portlets 302
Table of Contents
[ vii ]
Adding jQuery in themes 304
Using jQuery in Alloy UI 304
Knowing workflow capabilities in plugins 305
Preparing a plugin – Knowledge Base 306
Understanding the folder structure 307
Services and models 308
Adding a workflow instance link 308
Adding a workflow handler 309
Updating workflow status 310
Adding workflow-related AUI tags 311
The point of download for the Knowledge Base plugin 312
Custom attributes in plugins 313
Adding custom attribute capabilities 313
Adding custom attributes in plugins 314
Adding custom attributes as references 314
Adding custom attribute display 314
Adding custom attribute capabilities when creating, updating, and indexing
custom entities 315
Adding custom attribute UI tags 316
Finding the sample code 317
OpenSocial, Social Activity, and Social Equity in plugins 317
Knowing OpenSocial 318
Getting to know the working 318
Using OpenSocial 320
Finding the sample code 320
Understanding Social Activity 320
Registering social activity tracking in plugins 320
Using Social Equity 321
Adding Social Equity capabilities to plugins 322
Things that happened 323
Friendly URL routing and mapping in plugins 323
Understanding URL routing 323
Things that happened 324
Getting to know reporting portlets 325
Bringing JasperReports into your portal 325
Getting to know Lucene indexing, search API, and faceted search
in plugins 327
Experiencing Lucene indexing and search API 327
Understanding faceted search 328
Building faceted search in plugins 329
The responsive theme approach 330
Getting to know about the AUI responsive theme 331
Understanding what happened 331
Table of Contents
[ viii ]
Understanding the Bootstrap responsive theme 332
Building the Bootstrap responsive theme 332
Knowing device detection rules 333
Mobile device API 333
Bringing WURFL into your portal 334
Building a mobile theme 335
Delving into jQuery Mobile 336
Benefits of the jQuery Mobile theme 337
Building a jQuery Mobile theme 338
Deploying themes 339
Deploying themes as static content 339
UI performance tuning 340
Summary 342
Index 343
Preface
The Liferay Portal is the most popular open source portal product on the market.
Since its creation in 2000, numerous companies and organizations have set up
their websites using the Liferay Portal. The Liferay Portal is an end-to-end product.
A user can download a Liferay Portal bundle, unzip it, and run it.
The Liferay Portal is also well-known for its award-winning user interface (UI).
Its UI has three layers: theme, page layout, and portlets. It allows a user to apply
different themes to different portal pages. A user can drag-and-drop a portlet to
any cell of a page layout. The user can configure the look and feel of the Liferay
Portal through the user interface.
In the beginning, the Liferay Portal UI consisted of a home-grown JavaScript
application programming interface (API) and JavaServer Pages Standard
Tag Library (JSTL). As the Liferay Portal became more and more popular,
Liferay started an Alloy UI project in 2010 to meet the demand for easy UI
coding. The Liferay Portal has been using Alloy UI since Version 6.0.
Liferay 6.2 User Interface Development is an endeavor to explain the Liferay Portal
UI from the inside out. It leads you through examples so that you can create your
own themes as quickly as possible. The book tells you how to add a portal page and
change its look and feel. Its explicit instructions are accompanied by plenty of source
code. With the open source nature of the Liferay Portal, you will find a user-friendly
environment to design themes using the latest user interface technologies.
The book starts off by showing you how you can structure a Liferay Portal page.
It identifies the components of a portal page: theme, page layout, and portlets.
Its hands-on tutorials explain themes, portlets, and Alloy UI in an easy-to-understand
manner. It covers all aspects of a theme from its inception and implementation through
to rendering with in-depth analysis.
Preface
[ 2 ]
This book talks about developing portlets in different technologies: simple JSR 286
portlets, Spring MVC portlets, and Vaadin portlets. It deliberates on Alloy UI 2.0.
The book also explains how to use jQuery, Ext JS, and Dojo Toolkit in Liferay Portal
UI development.
By the end of this book, you will clearly understand themes, page layouts, and Alloy
UI. More importantly, you will obtain the skills to successfully develop a theme and
layout template. You will also know how to use them on a portal page through user
interface configuration.
With its clear, concise, and practical tutorials, this book will ensure that you develop
the skills to become a competent Liferay Portal UI developer. The detailed instructions
are accompanied by source code that you can learn and update to add custom features.
This book contains original content on solutions to real problems encountered in
real-world projects. Most of the content in the book originates from the authors'
experience with projects they've worked on. It will be an important guide for you in
mastering the customization of the look and feel of the Liferay Portal.
What this book covers
Chapter 1, Customizing Your Liferay Portal, introduces you to the Liferay products.
It also describes the Liferay Portal architecture and features. It talks about Liferay
customization and development strategies. It elaborates on the development
environment and the Liferay Integrated Development Environment (IDE),
including the theme plugin, portlet plugin, hook plugin, and Ext plugin.
Chapter 2, Basic Theme, is about the basics of Liferay Portal themes. It talks about
the layers of a Liferay Portal page. It describes the steps to create a theme in the
Liferay IDE. The chapter talks about the functionality of each file in a Liferay theme.
It especially looks into the portal_normal.vm file in depth. It also introduces you to
Sass and Compass, which are new technologies used in the Liferay Portal.
Chapter 3, Layout Template, introduces out-of-the-box Liferay layout templates and
describes the steps required to create a custom layout template in the Liferay IDE.
This chapter talks about the method to create a thumbnail image for a layout
template. It analyzes the code of the custom layout template in detail. It explains
the procedure to create a layout template based on a client's requirements. It also
talks about embedding portlets in a layout template. It finally describes how to
create a responsive layout template.
Preface
[ 3 ]
Chapter 4, Content Collaboration and Publishing, talks about basic web content and
structure-based web content in the Liferay Portal. It introduces a method to create
web content using images, videos, and the Velocity template language. It describes
a way to access the database in web content. It also shows examples of calling web
services in the web content for Internet interoperability.
Chapter 5, Portlet, focuses on portlet development. It introduces the ways to develop
simple JSR 286 portlets, Spring MVC portlets, and Vaadin portlets. It describes how
to implement the view, edit, and help modes of a portlet, code Ajax calls, and develop
portlet events for inter-portlet communication.
Chapter 6, JavaScript Frameworks and Portlet, talks about integrating third-party user
interface frameworks into the Liferay Portal. It talks about adding a calendar in a
Liferay portlet using jQuery. It introduces a chart into a Liferay portlet with the Ext
JS library. It also describes how to animate with Dojo Toolkit. This chapter proves
that the Liferay Portal has an open structure that accommodates various third-party
user interface APIs.
Chapter 7, Advanced Theme, talks about developing advanced skills for Liferay theme
development. It introduces a procedure to create a custom theme in accordance with a
client's requirements. It describes developing responsive features in a theme. It shows
how to embed a portlet in a theme. It also describes the procedure to update a theme
of an older version. It talks about how to create a three-level navigation menu and
implement browser detection in a theme. It describes how to integrate Google
Analytics in a custom theme.
Chapter 8, Understanding Alloy UI/YUI, explains the Alloy user interface in detail.
It talks about Alloy UI extending Yahoo UI. It describes new features in HTML5,
CSS3, and YUI3. It explains Alloy UI tags and how to use them in a portlet and
also Alloy UI modules and widgets and how to use them in a portlet.
Chapter 9, Using UI Taglib, talks about the JSTL of the Liferay Portal. It describes the
Liferay Portal tags by category. It explains the configuration of tags and how to use
them in coding.
Chapter 10, Responsive Mobile Theme, Reporting, Searching, and More, talks about adding
jQuery in plugins. It explains how to implement workflows and custom attributes in
the Liferay Portal using a plugin called the Knowledge Base portlet. It describes how
to integrate JasperReports with the Liferay Portal and Lucene indexing, search API,
and faceted search in plugins. It also talks about building a responsive mobile theme.
Preface
[ 4 ]
What you need for this book
This book is based on Liferay Portal Version 6.2. The following software,
source code, and documentation have been used in writing this book. It is
recommended that you also download these resources when you are reading
this book and running the source code enclosed within it. The source code is
available for download at the Packt Publishing website:
• MySQL database server Version 14.14 Distribution 5.6.12
• Java JDK Version 1.6.0_45
• Eclipse-jee-juno-SR1-win32-x86_64
• Liferay IDE 1.6.2
• Liferay-portal-tomcat-6.2.0-ce-m2
• Liferay-portal-src-6.2.0-ce-m2
• Liferay-portal-doc-6.2.0-ce-m2
• Liferay-plugins-sdk-6.2.0-ce-m2
You may use software of the same versions as listed in the preceding list or
newer versions.
All the previously mentioned software, source code, and documentation can
be downloaded from public websites such as Eclipse and SourceForge.
Who this book is for
This book is for readers who know how to use Java and have done some
programming for Java web applications. No prior knowledge about the
Liferay Portal is needed. It will also cater to Liferay Portal developers who
have already learned how to use the Liferay Portal or who have worked on
Liferay Portal projects. This book will show you how the Liferay Portal
works and why it works in that way.
Liferay 6.2 User Interface Development is also for architects who work on
Liferay Portal projects. This book includes the best practices in Liferay
Portal customization and the latest technologies and techniques used
in project implementation.
This book is also a good reference for any software engineer because it
talks about a lot of aspects of information systems—the Liferay Portal
is an encyclopedia of information technologies.
Preface
[ 5 ]
Conventions
In this book, you will find a number of styles of text that distinguish between
different kinds of information. Here are some examples of these styles, and an
explanation of their meaning.
Code words in text are shown as follows: "When the keyword showAssetCount
is set to true, the keyword displayStyle would have the value Number or Cloud."
A block of code is set as follows:
<liferay-ui:icon
image="myImage_thumb"
message="show-full-image-message"
url= "<%= showFullImage %>"
/>
When we wish to draw your attention to a particular part of a code block, the relevant
lines or items are set in bold:
<liferay-ui:input-editor
editorImpl="ckeditor"
inlineEdit="<%= true %>"
inlineEditSaveURL="<%= updateContentURL %>"
inlineEditContentURL="<%= editContentURL %>"
name="<%= updateContentId %>"
/>
New terms and important words are shown in bold. Words that you see on the
screen, in menus or dialog boxes for example, appear in the text like this: "Icons of
the inline editing mode include Source, Save, Cancel, Edit, and so on."
Warnings or important notes appear in a box like this.
Tips and tricks appear like this.
Reader feedback
Feedback from our readers is always welcome. Let us know what you think about
this book—what you liked or may have disliked. Reader feedback is important for
us to develop titles that you really get the most out of.
To send us general feedback, simply send an e-mail to feedback@packtpub.com,
and mention the book title via the subject of your message.
If there is a topic that you have expertise in and you are interested in either writing
or contributing to a book, see our author guide on www.packtpub.com/authors.
Customer support
Now that you are the proud owner of a Packt book, we have a number of things to
help you to get the most from your purchase.
Downloading the example code
You can download the example code files for all Packt books you have purchased
from your account at http://www.packtpub.com. If you purchased this book
elsewhere, you can visit http://www.packtpub.com/support and register to have
the files e-mailed directly to you.
Errata
Although we have taken every care to ensure the accuracy of our content, mistakes
do happen. If you find a mistake in one of our books—maybe a mistake in the text or
the code—we would be grateful if you would report this to us. By doing so, you can
save other readers from frustration and help us improve subsequent versions of this
book. If you find any errata, please report them by visiting http://www.packtpub.
com/submit-errata, selecting your book, clicking on the errata submission form link,
and entering the details of your errata. Once your errata are verified, your submission
will be accepted and the errata will be uploaded on our website, or added to any list of
existing errata, under the Errata section of that title. Any existing errata can be viewed
by selecting your title from http://www.packtpub.com/support.
Piracy
Piracy of copyright material on the Internet is an ongoing problem across all
media. At Packt, we take the protection of our copyright and licenses very
seriously. If you come across any illegal copies of our works, in any form,
on the Internet, please provide us with the location address or website name
immediately so that we can pursue a remedy.
Please contact us at copyright@packtpub.com with a link to the suspected
pirated material.
We appreciate your help in protecting our authors, and our ability to bring you
valuable content.
Questions
You can contact us at questions@packtpub.com if you are having a problem with
any aspect of the book, and we will do our best to address it.
Customizing Your
Liferay Portal
Liferay Portal is the world's leading open source portal platform, providing a unified
web interface for data, tools, and system integrations scattered across a large number
of resources and devices. Within the portal, the portal web page interface is composed
of a number of portlets. These portlets are self-contained interactive elements written
to a particular standard, such as JSR 168 or JSR 286. As portlets are built independent
of the portal and are loosely coupled with the portal, they are built apparently using
Service Oriented Architecture (SOA).
This book will show you how to develop and/or customize user interface of
intranets or Internet browsers with Liferay. In this chapter, we will look at:
• The features your user interface will have by the time you reach the end
of this book
• Liferay Portal framework and architecture for customization
• Liferay Portal user interface customizing development strategies
• Themes (including mobile themes—site preview, responsive themes,
and device recognition), layout templates, hooks, and Alloy UI (including
Bootstrap, dockbar, and Accessibility) development and customization
• Finding more technical information about what Liferay is and how it works
Therefore, this book begins by looking at exactly what Liferay Portal is, what portlets
and Social Office are, and how they work to customize user interface.
Customizing Your Liferay Portal
[ 10 ]
Liferay functionalities
Liferay currently has the following main functionalities:
• Liferay Portal: An enterprise portal platform using particular standards,
such as JSR 168/JSR 286.
• Liferay CMS and WCM: A JSR 170 based content management system and a
structure-template based web content management system.
• Liferay Collaboration: It includes a number of collaboration portlets, such as
blogs, calendars, social media, web forms, webmail, message boards, polls,
ratings, RSS feeds, Wiki pages, presence (AJAX chat clients, dynamic friend
lists, activity walls, and activity trackers), alerts, and announcements.
• Liferay Social Office: A social collaboration is a special portal instance on top
of the portal. It provides a dynamic team workspace solution where all you
have to do is log in and work in your own way at your convenience.
• Liferay Sync: It transforms the Liferay platform into a central, easy-to-use
document-sharing service across a range of devices.
In short, a website built by Liferay might consist of a portal, CMS, and WCM.
It might also include Collaboration and/or Social Office and a large number of
custom plugins/portlets.
Documents and Media – CMS
Documents and Media is a useful tool to manage content including images,
documents, videos, and audio. For example, within Documents and Media,
you can add folders and subfolders for documents to manage and publish
them. The Content preview capability is available for some types of content,
such as Word or PDF. In addition, multiple repositories are supported.
Thus, you use the default repository or web services to connect to other
repositories like Alfresco.
Documents and Media makes up the Content Management System's (CMS)
available for both intranet and the Internet. It is equipped with customizable
folders and acts as a web-based shared drive for all your team members,
no matter where they are. As the content is accessible only by those authorized
by administrators, each individual file (either a document or an image) is as
open or as secure as you would need it to be.
Chapter 1
[ 11 ]
Dynamic data lists and site/page/display
templates
Dynamic data lists allow users to graphically define schema and templates,
customize the input forms and the output format, define a workflow for
approving captured information, and to a process that gathers data at various
stages in the workflow.
Site templates allow users to define pages and web content to be included while
creating sites and organizations. Page templates, similar to site templates at the page
level, allow users to provide a preconfigured page to be reused. Application display
templates allow users to apply templates to certain portlet types. Application display
templates work similarly to site templates and page templates at the portlet level.
Application display templates allow portal administrators to override the default
display templates, removing limitations to the way the site's content is displayed.
Web content management
Your company may have a lot of HTML text, audio, videos, images, and documents
using different structures and templates, and you may need to manage all these
HTML text, images, and documents as well. Therefore, you require the ability to
manage a lot of web content and then publish web content on intranets and/or
the Internet. Web content is organized in folders and subfolders in the same way
as Documents and Media is. In addition, Recycle Bin has been supported for Web
Content—you can easily restore your deleted files.
We will see how to manage web content and how to publish web content within
Liferay Portal. Web Content portlets not only provide high availability to create,
edit, publish, manage, and maintain web content, but they also separate content from
structures and layout templates. Generally speaking, Web Content Management
(WCM) allows us to create, edit, and publish web content (articles) as well as article
templates and article structures. It also has built-in workflow, article versioning,
search, permissions, and metadata.
Personalization and internalization
All users can get a personal space that can be either made public (published as a
website with a unique, friendly URL) or kept private. In fact, users can have both
private and public pages at the same time. You can also customize how the space
looks, what tools and applications are included, what goes into the Documents and
Media portlet, and who can view and access all of this content.
Customizing Your Liferay Portal
[ 12 ]
In addition, you can publish your portal website using your own language.
Within the portal, multilingual organizations get support for up to 45 languages
such as Hindi, Hebrew, and Ukrainian. Switching language from one to another
in the portal is straightforward. Users can simply click once to toggle different
language settings and/or produce and publish multilingual documents and
web content. Users can also easily add other languages on public/private pages,
other sites, or other organizations.
Workflow, staging, scheduling,
and publishing
You can use workflows to manage definitions, instances, and tasks. You can also
use the web content article two-step workflow, staging workflow, jBPM workflow,
Kaleo workflow, and Intlio | BPMS. The jBPM workflow and/or Kaleo workflow
can be applied on any assets, such as web content articles, Document Library,
documents and media, blogs, wiki pages, and custom assets. Kaleo is the default
workflow engine of Liferay, and you will get it out of the box. Others like jBPM
and Intlio are not available out of the box.
In addition, the portal allows you to define publishing workflows that track changes
to web content, documents, and media, as well as the pages of the site in which
they reside. Kaleo Forms is an extension of dynamic data lists, enabling us to create
web forms and basic applications first and then apply a workflow to govern the
processing of those forms. Kaleo Designer is a drag-and-drop interface used for
creating new workflow definitions.
Social networking and Social Office
Liferay Portal supports social networking—you can easily own your accounts in
Liferay with Facebook, MySpace, and Twitter among others. In addition, you can
manage your instant messenger accounts in Liferay Portal smoothly such as AIM,
ICQ, Jabber, MSN, Skype, and YM.
Social Office gives us a social collaboration on top of the portal—it provides a fully
virtual workspace with streamlined communication and built-up group/community
cohesion. All components in Social Office are tied together seamlessly, getting
everyone on the same page by sharing the same look and feel. More importantly,
the dynamic activity tracking gives us a bird's-eye view of who has been doing what
and when within each site.
Chapter 1
[ 13 ]
Understanding the tagging system
The portal-tagging system allows us to tag web content, documents and media,
message board threads, wiki pages, blog entries, custom assets, and more, and we
can dynamically publish these assets by tags. Tags provide a way of organizing and
aggregating content. Folksonomies is a user-driven approach to organizing content
through classification of tags. It is cooperative and communicates through shared
metadata. The portal implements folksonomies through tags. Taxonomies is a
hierarchical structure used in scientific classification schemes. The portal implements
taxonomies as vocabularies and categories (including category hierarchy) in order
to tag content and classify it.
Integrating with Liferay Sync
Liferay Sync integrates with existing authentication systems. Either Liferay
or an external SSO solution, Sync will automatically and securely authenticate
with existing credentials. In summary, Sync enables users to publish and access
documents and files from multiple devices.
Integrating with other systems easily
In particular, the portal provides an integrating framework so that you can integrate
external applications easily. For example, you will be able to integrate external
applications such as Alfresco, OpenX, LDAP, SSO CAS, Orbeon Forms, KonaKart,
PayPal, Solr, Coveo, Salesforce, SugarCRM, JasperForge, Drools, and jBPM.
In addition, the portal has got the OSGi framework. That is, the portal is going
to support a module system and service platform for the Java programming
language that implements a complete and dynamic component model. Refer
to http://www.osgi.org.
In short, the portal offers compelling benefits to today's enterprises—reduced
operational costs, improved customer satisfaction, and streamlined
business processes.
Customizing Your Liferay Portal
[ 14 ]
Leveraging framework and architecture
for user interface development
Liferay Portal architecture provides high availability for mission-critical applications,
such as clustering fully distributed cache, replication across multiple application
servers, and integrating many other systems. The following diagram shows a
number of architectural layers and functionalities of portlets:
Service Oriented Architecture
Liferay Portal leverages Service Oriented Architecture (SOA) design principles
and provides a set of tools and frameworks to extend SOA in order to integrate
with other enterprise applications smoothly. Within SOA architecture, users can
access the portal from a large range of devices, ranging from traditional to mobile
devices, but also from exposed APIs, for example, web services, REST, SOAP, RMI,
XML-RPC, XML, JSON, Hessian, Burlap, and custom-tunnel classes.
Chapter 1
[ 15 ]
Generally speaking, Liferay Portal is designed to create/develop/deploy portlets
(or specific plugins) which are compliant with both JSR 168 and JSR 286 standards.
There are a set of useful built-in plugins/portlets such as Documents and Media,
Calendar, Message Boards, Blogs, Wikis, and more. These built-in plugins/portlets
will be used as examples for building custom plugin portlets.
In a nutshell, the main features of Liferay Portal include using SOA design
principles, adding reliable security, integrating with SSO and LDAP,
integrating with other systems, CMS, WCM, dynamic data lists, various
structures and ranges of multitier templates, limitless clustering, high availability
of portlets, caching pages, dynamic virtual hosting, YUI-based AUI JavaScript
frameworks, and more.
Understanding Enterprise Service Bus
The Enterprise Service Bus (ESB) is, generally speaking, a central connection manager
allowing applications and services to be added quickly to an enterprise infrastructure.
Whenever an application needs to be replaced in the ESB, it can be easily disconnected
from the ESB at a single point. Liferay Portal has a defined default ESB, and it can
leverage Mule or ServiceMix as the ESB. In brief, Liferay Message Bus is a service-level
API used to exchange messages within the portal. More precisely, the Message Bus
is a mechanism for sending message payloads to different components in the portal,
providing loose coupling between message producers and consumers.
Through the ESB, as shown in the preceding diagram, the portal can integrate
with SharePoint, BPM (such as jBPM workflow engine and Intalio | BPMS engine),
the rule engine, BI Xforms reporting, JCR repositories, Advertisements, SugarCRM,
and e-commerce, among others. With the integration of JCR repositories such as
Jackrabbit, it also supports JSR 170 for content management systems. In addition,
it uses Hibernate and JDBC to connect to any database. Furthermore, it supports
event-based asynchronous messaging and lightweight message bus mechanisms.
Furthermore, the portal uses the Spring framework for its business and data service
layers, for example, using the Spring framework for its transaction management.
Based on service interfaces, that is, the Spring framework, portal-implementation is
done and exposed only for internal usage. For example, they are used for the extension
environment only. The portal-kernel and portal-service (these two are merged into one
package) are provided for external-usage and remote-service calls or for internal-usage
and local-service calls. For example, they are used for the Plugins SDK environment.
Custom portlets compliant with both JSR 168 and JSR 286, JSON services, and web
services can be built based on the portal-kernel and portal-service.
Customizing Your Liferay Portal
[ 16 ]
Furthermore, the Web 2.0 Mail, Calendar, and Chat portlets are supported as well.
Staging and remote publishing are supported too, for example, scheduled staging
and remote staging—and publishing as a foundation through tunnel web—provide
the capability to publish web content easily or to publish portlets in a page, a set of
pages, or a specific site.
Liferay Portal supports web services and JSON web services to make it easy for
different applications in an enterprise to communicate with one another. Java,
.NET, PHP, and proprietary applications can work together smoothly since web
services use XML standards and JSON web services use JSON standard. Besides
these features, it also supports REST-style JSON web services for lightweight and
maintainable code. AJAX-based user interfaces are supported as well.
Liferay Portal follows industry-standard, government-grade encryption
technologies, including advanced algorithms such as DES, MD5, and RSA.
For this reason, Liferay Portal was benchmarked as one of the most secure
portal platforms using LogicLibrary's Logiscan suite. Liferay Portal also
offers customizable single sign-on with Yale CAS, JAAS, Netegrity,
Microsoft Exchange, LDAP, NTLM, and more. Open ID, OpenAuth,
Yale CAS, Facebook, Siteminder, and OpenSSO (renamed OpenAM)
integration are supported as well.
In summary, the portal uses the ESB in general with an abstraction layer on
top of an enterprise messaging system, allowing integration with both
synchronous and asynchronous messaging systems, such as reporting,
e-commerce, and advertisements. As you can see, understanding the framework
and architecture would be helpful to customize user interface in a proper way.
Staging on standards
The portal is based on Standards with more technical benefit. However, if you want
to use the portal in a more specialized way, understanding these standards would
help. The features/standards that Liferay is using are listed as follows:
• Built using Java: As a very popular programming language, Java code can
run on any computer.
• Based on components: Some of the well-known components and
technologies are Apache ServiceMix, Mule, ehcache, Hibernate, JQuery,
ICEfaces, Primefaces, Java J2EE/JEE, jBPM, Intalio | BPMS, JGroups, Alloy
UI, Lucene, PHP, Ruby, Seam, Spring and AOP, Struts and Tiles, Tapestry,
Velocity, and FreeMarker.
Chapter 1
[ 17 ]
• Based on standards to communicate with other systems: The standards
implemented by Liferay include AJAX, iCalendar, and Microformat, JSR 168,
JSR 127, JSR 170, JSR 286 (Portlet 2.0), and JSR 314 (JSF 2.0), Faceted search,
OpenSearch, Open platform with support for web services (including JSON,
Hessian, Burlap, REST, RMI, and WSRP), WebDAV, and CalDAV.
• WCAG 2.0 (Web Content Accessibility Guidelines) compliant: The portal
standard integrated with CKEditor 4.x. supports W3C (WAI-AA and
WCAG), WAI-ARIA, and 508 (Section 508).
• Alloy UI: Based on HTML5, CSS 3 and Yahoo! User Interface Library (YUI3).
• Apache Ant 1.8 and Maven 2.2: Liferay Portal can be built through either
Apache Ant or Maven 2 SDK.
Many of these standards are things that you will never need to know much about,
so don't worry if you've never heard of them. Liferay is better for using them,
but mostly, you won't even know they are there. Of course, user interface could be
standardized too. Therefore, when developing and/or customizing user interface,
you can leverage the standards that Liferay Portal is using.
Customization and development
strategies
Liferay is first and foremost a platform where you can build your applications using
use the tools you feel most comfortable with, such as Icefaces, Struts 2, Spring MVC,
Vaadin, jQuery, and Dojo.
Of course, you're not required to write a lot of code for yourself. You can use the
Service-Builder to generate a lot of code. Generally speaking, the Service-Builder
is a tool built by Liferay to automate the creation of interfaces and classes that are
used by a given portal or portlet. The Service-Builder is used to build Java services
that can be accessed in a variety of ways, including local access from Java code and
remote access using web services.
Generally speaking, the Service-Builder is a code generator using an XML descriptor:
• Java Beans
• SQL scripts for the creation, update, and deletion of database tables
• Hibernate Configuration
• Spring Configuration
• Local services, remote services, and finder services
• Axis web services
• JSON JavaScript Interface
Customizing Your Liferay Portal
[ 18 ]
In brief, a plugin SDK environment is a simple developing environment for the
development of portal plugins. These custom plugins are completely separate from
the portal's core services by their use of external services only if required.
The portal supports at least six different types of plugins by default: Portlets,
Themes, Layout Templates, Webs, Hooks, and Ext. Here is a brief description
of each of the aforementioned types of plugins:
• Portlets: These are web applications in general that run in a portion of
a web page
• Themes: These are the defined look and feel of pages
• Layout Templates: These are the ways provided to change how the portlets
will be arranged on a web page
• Hooks: It allows hooking into the portal core functionality and JSP files
• Webs: Webs plugins are regular Java web modules designed to work with
the portals, such asEnterprise Service Bus (ESB), Single Sign-On (SSO),
Workflow Kaleo, and Wireless Universal Resource FiLe (WURFL)
Note that a web plugin is purely a web application where a thin layer is
added to provide checking for dependencies. A web plugin also supports
embedding hook definition and/or Service-Builder services. And finally,
you can deploy them using the auto-deploy mechanism the same way
that you do with other plugins.
• Ext: The Ext environment is a plugin, that is, you can use the extension
environment as a plugin in the plugins SDK environment.
As you can see, you can generate code for plugins, portlets, and webs. Normally,
you can have one project for one plugin, for example, theme, layout template,
hook, ext, and web. You can also have many portlets in one plugin project portlet.
Hook plugins could be standalone or can stand with portlets. That is, in one plugin
project portlet, you can have hooks and many portlets as one WAR file. As you can
see, user interfaces can be customized or developed within these plugins, mostly in
the form of portlets, themes, layout templates, hooks, webs, and ext.
Liferay IDE is used to provide best-of-breed Eclipse tooling for Liferay Portal
development platform for Version 6 and beyond. The availability of Liferay IDE
cover is not limited to plugin SDK support, plugin projects support, project import
and conversion, wizards, code assist such as portlet taglibs, customizable templates,
and XML catalogue (DAT/XSD) contributions.
Chapter 1
[ 19 ]
Knowing about Ext plugins
The Extension environment provides the capability to customize the portal core
completely. It is an environment extending the portal development environment,
so it has the name Extension (Ext). With Ext, we can modify internal portlets called
built-in portlets. Furthermore, we can override the JSP files, CSS files, HTML files,
and JavaScript files of the portal and the built-in portlets. This kind of customization
is kept separate from the portal source code. That is, the portal source code does not
have to be modified; therefore, a clear upgrade path is available in Ext.
From Version 6 (including 6.2), the Ext environment is converted into a plugin called
the Ext plugin. As shown in the following figure, the custom code will override the
portal source code in the Ext plugin only. In the deployment phase, custom code will
be merged with the portal source code in Ext. At the end, developers override the
portal source code effectively. Moreover, custom code and the going-to-be-overridden
portal source code will be constructed as a customized going-to-be-overridden portal
in Ext first and then the customized going-to-be-overridden portal source code will be
deployed from Ext to the application server.
During customization, you could use the Service-Builder, but this function was
deprecated and is now used to generate models and services.
Note that Service-Builder is deprecated for the Ext plugin.
Therefore, you should use Service-Builder for the portlet
plugin and the web plugin only.
In general, the Service-Builder is a code generator using an XML descriptor. For a
given XML file service.xml, it will generate SQL for creating/updating/deleting
tables, Java Beans, Hibernate configuration, Spring configuration, caching services,
local services, remote services, finder services, Axis Web Service, JSON JavaScript
Interface, among others.
Customizing Your Liferay Portal
[ 20 ]
JSP files of the portal and the built-in portlets can be overridden with custom JSP
files in Ext.
Note that Ext is used to customize the portal only, since portlets built
in the Ext plugin are not very deployable; moreover, the Ext plugin is
a monolithic environment.
Under the ${ext.plugin.project}/docroot/WEB-INF directory, you'll see a lot of
folders starting with ext-* as shown in the following list:
• ext-impl/src: This contains code that will override portal-impl/src
• ext-lib/global: This contains JARs that are available in the global
class loader
• ext-lib/portal: This contains JARs that are available only to the portal
class loader
• ext-service/src: This contains code that will override portal-service/
src
• ext-util-bridges/src: This contains code that will override util-
bridges/src
• ext-util-java/src: This contains code that will override util-java/src
• ext-util-taglib/src: This contains code that will override util-taglib/
src
• ext-web/docroot: It contains code that will override portal-web
Note that if you modify ext-web/docroot/WEB-INF/web.xml, these changes would
be merged into portal-web/WEB-INF/web.xml. ext-web also contains /WEB-INF/*-
ext.xml files that are used to override what is in the portal-web folder.
Chapter 1
[ 21 ]
As you can see, the Ext plugin works in a way that is very similar to that of the Ext
environment, but it, as a plugin, is much smaller and lighter in weight.
Knowing about Hook plugins
Hooks provide functions to catch hold of the properties and JSP files into an instance
of the portal as if catching them with a hook. Hook plugins are more powerful plugins
that complement portlets, themes, layout templates, ext, and webs. A hook plugin can
be combined with a portlet plugin or a standalone plugin. For instance, the portlet
so-portlet is a portlet plugin for Social Office with hooks; a hook plugin could
simply override language properties or override JSP pages. In general, hooks are very
helpful tools to customize the portal without touching the code part of the portal as
shown in the following screenshot.
Customizing Your Liferay Portal
[ 22 ]
In addition, you would use hooks to provide patches for the portal systems or Social
Office products.
In general, there are a set of hook parameters that should be specified in the
following order:
• portal-properties (called portal properties hooks)
• language-properties (called language properties hooks)
• custom-jsp-dir (called custom JSPs hooks)
• service (called portal service hooks)
• Filters hooks
• Indexer post processor hooks
• Struts action hooks
The following sample code is abstracted from $PORTAL_ROOT_HOME/dtd/liferay-
hook_6_2_0.dtd:
<!ELEMENT hook (portal-properties?, language-properties*,
custom-jsp-dir?,
custom-jsp-global?, indexer-post-processor*, service*, servlet-
filter*,
servlet-filter-mapping*, struts-action*)>
<!ELEMENT portal-properties (#PCDATA)>
<!ELEMENT language-properties (#PCDATA)>
<!ELEMENT custom-jsp-dir (#PCDATA)>
<!ELEMENT indexer-class-name (#PCDATA)
<!ELEMENT indexer-post-processor-impl (#PCDATA)>
<!ELEMENT service (service-type, service-impl)>
<!ELEMENT service-type (#PCDATA)>
<!ELEMENT service-impl (#PCDATA)>
<!ELEMENT servlet-filter-name (#PCDATA)>
<!ELEMENT servlet-filter-impl (#PCDATA)>
<!ELEMENT struts-action-path (#PCDATA)>
<!ELEMENT struts-action-impl (#PCDATA)>
Chapter 1
[ 23 ]
As shown in the preceding code, the ordering of elements is significant in the
Document Type Definition (DTD), that is, you need to have your portal properties
(only one marked by ?), language properties (could be many marked by *),
custom-jsp-dir (only one marked by ?), and indexer post processor, service,
servlet filter, and struts action (could be many marked by *) declared in the
same order.
Language properties hooks allow us to install new translations or override a few
words in existing translations. JSP hooks provide a way to easily modify JSP files
without having to alter the core of the portal, whereas portal properties hooks allow
runtime reconfiguration of the portal. Portal indexer/service/servlet filter/struts
action hooks provide a way to easily override the portal indexer post processor,
services, servlet filters, and struts actions. The portal configuration properties can
be altered by specifying an overridden file, where the properties will immediately
take effect when deployed. For example, you can enable auditing capabilities by
deploying hooks. Note that not all portal properties can be overridden using hooks.
Knowing about portlet and web plugins
As you can see, the plugins SDK is a simple environment for the development of
portal plugins, including portlets and webs. It provides the capability to create
hot-deployable portlets and webs.
How does it work? As shown in the following figure, the plugins SDK provides an
environment for developers to build portlets and webs. Afterwards, it uses either
Ant Target Deploy or Maven to form a WAR file and copies it to the Auto Deploy
directory. Then, the portal, together with the application server, detect any WAR
files in the auto hot-deploy folder and automatically extract the WAR files into the
application server deployment folder. Note that the portal automatically recognizes
the type of plugin and enhances it appropriately before hot-deploying. For example,
the portlet's web.xml file will be modified with the required listeners and filters.
Customizing Your Liferay Portal
[ 24 ]
Customizing the user interface through
theme development frameworks
Generally speaking, a theme defines the styles of all portlets and content in a
web page, so it controls the way the portal looks. Programmatically, a theme
includes a set of CSS, images, JavaScript, and Velocity templates—four
groups—to control the whole look and feel of the web pages generated by
the portal. Therefore, when building customized themes, you need to consider
these four groups as well. From a folder-structure viewpoint, the theme is
made up of a folder, _diffs, with four subfolders, css, images, javascript,
and templates; a folder, WEB-INF, with a properties file called liferay-plugin-
package.properties; and an XML file called liferay-look-and-feel.xml.
The portal will handle the following steps when you build a theme.
First of all, as shown in the following figure, when you deploy theme, the plugins
SDK will copy all files from the folder ${app.server.portal.dir}/html/themes/_
unstyled/ to the folder $PLUGINS_SDK_HOME/themes/${theme-name}/docroot/.
In fact, this will happen during build time instead of deploy time.
Secondly, the plugins SDK will copy all files from the folder ${app.server.portal.
dir}/html/themes/_styled/ to the folder $PLUGINS_SDK_HOME/themes/${theme-
name}/docroot/.
And then, the plugins SDK will copy all files from the folder $PLUGINS_SDK_HOME/
themes/${theme-name}/docroot/_diffs/ to the folder $PLUGINS_SDK_HOME/
themes/${theme-name}/docroot/.
This means that the plugins SDK is going to override existing files with new files
and change files under the folder $PLUGINS_SDK_HOME/themes/${theme-name}/
docroot. Here the ${theme-name} object refers to a real-theme project name.
Afterwards, you will see four folders, css, images, javascript, and templates,
under the folder $PLUGINS_SDK_HOME/themes/${theme-name}/docroot. And each
folder contains all the required merged files and subfolders
from /_unstyled, /_styled, and /_diffs.
Chapter 1
[ 25 ]
Building custom themes
In a word, the best way to build a custom theme is to put only the differences of
the custom theme (the four groups—CSS, images, JavaScript, and templates) into
the folder ${theme-name}/docroot/_diffs. Here, ${theme-name} refers to
any real-theme project name, for example, book-street-theme. Using this best
practice, you only need to put custom CSS, images, JavaScript, and templates in the
folder /_diffs.
More precisely, in the folder /_diffs/css, just create a CSS file called custom.css.
You should place all of the custom CSS files different from the default folder.
By placing custom CSS in this folder and not touching the other default files, you can
be assured that upgrading this theme later on will be more straightforward. In order
to include custom images in the folder /_diffs/images, put all custom images with
subfolders. For example, create two images, screenshot.png and thumbnail.png,
to show how a page with the current theme looks. And furthermore, create a
subfolder, searchbar, and put all search-related images in the folder /searchbar.
In order to include custom JavaScript in the folder /_diffs/javascript, create a
JavaScript file called javascript.js. The portal includes the YUI library by default.
Thus, in the theme, you can include any JavaScript plugins that YUI supports.
To include templates in the folder /_diffs/templates, create custom template
files, such as dock.vm, init_custom.vm, navigation.vm, portal_normal.vm,
portal_pop_up.vm, and portlet.vm. Note that you may use JSP files in template
files under the folder templates. However, keep in mind that you won't have
access to the velocity variables if JSP files were in use.
Developing the user interface through
layout template development frameworks
Layout templates are ways to choose how portlets will be arranged on a page.
Layout templates usually refer to a grid-like structure with HTML tables.
Layout templates form the body of a page, the large area where dragging and
dropping both custom and built-in portlets creates pages. A layout template
sets various columns and rows to display the portlets in the web page. In short,
the layout template controls the visual structure of web pages in the portal.
As shown in the following figure, the plugins SDK provides an environment to build
layout templates that is similar to that of theme, hooks, portlets, and webs. It uses
either Ant Target Deploy or Maven to form a WAR file first and then copies it to the
Auto Deploy directory. Afterwards, the portal will detect any WAR files in the auto
hot-deploy folder and extract the WAR files into the application server deployment
folder automatically.
Customizing Your Liferay Portal
[ 26 ]
Note that both Web and WAP are supported in layout templates. A layout template
plugin should include at least two files: a file called .tpl for Web and another file
called.wap.tpl for WAP. The WEB version specifies the arrangement of portlets in a
web page in desktop browsers, whereas the WAP version specifies the arrangement
of portlets in a web page in mobile WAP devices.
Alloy UI customization
Alloy UI is a YUI3-based user interface meta-framework providing a consistent
and simple API for building web applications across browser level: structure,
style, and behavior. In brief, Alloy UI is a user interface web application JavaScript
framework. It is a unified UI library built on top of the revolutionary YUI3, a library
of tools. Its purpose is to help make building and designing web applications an
enjoyable experience.
Structure – HTML5
Alloy UI is based on the structure of HTML5 in order to provide reusable markup
patterns. HTML5 is the next major revision of Hyper Text Markup Language
(HTML); more precisely, it is the next standard for HTML4 in order to reduce the
need for proprietary, plug-in-based Rich Internet Application (RIA) technologies
such as Adobe Flash, Microsoft Silverlight, Apache Pivot, and Sun JavaFX. In brief,
HTML5 incorporates Web Forms 2.0, another WHATWG specification.
In HTML5 tags, there is the one and only <!doctype> declaration. The following
code shows a simple HTML5 document with the minimum number of required tags:
<!DOCTYPE html>
<html>
<head>
<title>Title of the document</title>
</head>
<body>Body of the document</body>
</html>
HTML5 introduces a number of new elements and attributes that reflect
typical usage on modern websites/pages. Some of them are used for semantic
replacements—for common usage of the generic block <div> and inline <span>
elements—for example, <nav> representing the website navigation block and
<footer> representing the bottom of the web page or the last lines of the
HTML code. Other elements provide new functionalities for multimedia with a
standardized interface, such as <audio> and <video> elements.
Chapter 1
[ 27 ]
HTML5 also has a significant impact on Search Engine Optimization (SEO), that is,
metadata—data (information) about data. The <meta> tag provides metadata about
the HTML document. Meta elements are used to specify page description, keywords,
author, last modified, and other metadata used by web browsers (how to display
content or reload a page), search engines (keywords), or other web services. In this
case, content would be translated to accurate, relevant, and pinpointed
search results.
In brief, HTML5 is a new version of HTML4 that addresses new challenges you
would face in modern website development. It covers a range of things such as
writing web applications and maintaining sanity; creating more distinguished
content using shiny, new elements; acknowledging the huge accessibility advances
and opportunities available; and offering the future of web media using video,
audio, and canvas.
Browsers are going to support HTML5. For example, Chrome, Safari, Firefox,
and Opera have been supporting HTML5, and Microsoft will have all in in IE9/IE10.
Older versions of Internet Explorer browsers can support the structural markup of
these new elements with an enabling script.
Style – CSS 3
Cascading Style Sheets (CSS), a stylesheet language, describes the
presentation semantics of a document written in a markup language.
Most common application-style web pages are written in HTML and
XHTML, but the language can also be applied on any kind of XML
document as well as on SVG and XUL.
CSS level 3 (CSS 3) is modularized, more compact, and richer in semantics.
CSS 3 has abbreviations expanded automatically before a web page is published.
For example, users are not required to create links directly, and can indirectly
include a tag or a special character that indicates the role of a keyword such as
a property name, a technical term, or a bibliographic reference, and each such
word will be automatically linked to its definition.
Behavior – YUI 3
The Yahoo! User Interface Library (YUI) 3 is an open source JavaScript library for
building rich, interactive web pages with techniques, for example, Ajax, DHTML
and DOM scripting, and several core CSS 3 resources.
Customizing Your Liferay Portal
[ 28 ]
As Yahoo!'s next-generation JavaScript and CSS library, the YUI 3 Library has grown
to include core components, a full suite of utilities, the widget infrastructure, and a
few widgets, shipped with a lot of examples that illustrate the implementation of
its components. There is a set of examples that would be good starting points for
your exploration, code snippets to jump-start your own programming, or simply
inspiration as to how various interaction patterns can be enabled in the web
pages via YUI.
YUI modules cover many modules such as, but not limited to,
align-plugin, anim, async-queue, attribute, base, cache,
classnamemanager, collection, console, console-filters,
cookie, dataschema, datasource, datatype, dd, dom, dump,
event, event-custom, event-simulate, gallery-formmgr,
history, imageloader, intl, io, json, loader, node,
node-focusmanager, node-menunav, oop, overlay, plugin,
pluginhost, profiler, querystring, queue-promote, shim-
plugin, slider, sortable, stylesheet, substitute, swf,
swfdetect, tabview, test, widget, widget-anim, widget-parent,
widget-position, widget-position-align, widget-position-
constrain, widget-stack, widget-stdmod, and yui.
Alloy UI forms
Alloy UI forms are useful tools to help developers build nice forms quickly.
The following are some of the advantages of using these forms:
• Usability: Styling of the forms has been specified for better usability.
• Unified styling: All the forms look similar, and they are controlled in
one place.
• Dynamic attributes: Any attribute that can be used for an HTML tag can
also be used for an aui tag. For example, you could use onClick, onChange,
onSubmit, and title in any aui:form, aui:select, or aui:input, and it
will have the same behavior as though you used it as a plain HTML form,
select, or input.
These tags can be used in aui forms and some of their attributes. They all support
dynamic attributes, that is, you can add any additional attributes. For example, if you
add the attribute onFocus to an aui form such as aui:button, the tag <button> will
have the onFocus attribute.
Chapter 1
[ 29 ]
Alloy UI forms are sets of taglibs built on top of the Alloy UI JavaScript plus CSS
framework. Alloy UI forms (aui) provide, but are not limited to, the tags Form,
Field-set, Button, Button Row, Model Context, Input, Select, Option, Link
(a), Field Wrapper, Legend, Layout, Column, Other Examples, Text-area,
and Radio
Alloy UI covers many modules, such as aui-autocomplete,
aui-button, aui-calendar, aui-char-counter, aui-color-
picker, aui-component, aui-datatype, aui-delayed-task,
aui-dialog, aui-editable, aui-event, aui-image-viewer,
aui-io, aui-live-search, aui-loading-mask, aui-nested-
list, aui-node, aui-overlay, aui-paginator, aui-panel,
aui-parse-content, aui-portal-layout, aui-rating, aui-
resize, aui-textboxlist, aui-toolbar, aui-tooltip, and
aui-tree.
JavaScript frameworks
Liferay Portal and built-in portlets use YUI 3 and AUI by default, but other
JavaScript frameworks can be included in custom plugins. These JavaScript
frameworks include, but are not limited to:
• jQuery
• Ext JS
• Dojo
• Google Web Toolkit
• DHTMLX
• PhoneJS
• Knockout JS
• Bootstrap
• jQuery Mobile
• MooTools JS
This book will address how to use different JavaScript frameworks in custom
portlets development.
Customizing Your Liferay Portal
[ 30 ]
Responsive themes
Responsive web design, also called responsive themes, is a theme development
approach. It is aimed at crafting websites/pages to provide an optimal viewing
experience, such as ease of reading, minimum navigation and resizing, panning,
and scrolling. Responsive themes span a range of devices, from desktops and
tablets to smart mobiles.
A responsive theme is basically made up of at least three main ingredients,
as follows:
• Flexible grids, including flexible types, containers, margins, padding,
and images
• Media queries
• Flexible media
This book will introduce you to responsive themes and will show you how to build
responsive mobile themes.
More useful information
In this chapter, we have looked at what Liferay can do for your corporate intranet,
and we have briefly seen why it's a good choice.
If you want more background information on Liferay, the best place to start is the
Liferay corporate website (http://www.liferay.com). You can find the latest
news and events, various training programs offered worldwide, presentations,
demonstrations, and hosted trails. More interestingly, Liferay eats its own dog food;
corporate websites within forums (called message boards), blogs, and wikis are built
by Liferay using its own products. It is a real demonstration of the Liferay Portal.
Liferay is 100 percent open source and all downloads are available from the Liferay
Portal website (http://www.liferay.com/web/guest/downloads/portal) and
SourceForge website http://sourceforge.net/projects/lportal/files.
The source code repository is available at svn://svn.liferay.com/repos/public
(credentials—the username is guest and there is no password) and the source code
can be explored at http://svn.liferay.com. The source code is also available at
GitHub: https://github.com/liferay/liferay-portal.
Chapter 1
[ 31 ]
The Liferay website wiki (http://www.liferay.com/web/guest/community/
wiki) contains documentation such as a tutorial, user guide, developer guide,
administrator guide, and roadmap.
The Liferay website discussion forums can be accessed at http://www.liferay.
com/web/guest/community/forums, and the blogs at http://www.liferay.com/
web/guest/community/blogs. The roadmap can be found at http://www.liferay.
com/web/guest/community/wiki/-/wiki/Main/RoadMap. The official plugins are
available at http://www.liferay.com/web/guest/downloads/official_plugins.
The community plugins are available at http://www.liferay.com/web/guest/
downloads/community_plugins. The marketplace (http://www.liferay.com/
marketplace) is the best place to share your thoughts, get tips and tricks about
Liferay implementation, learn about the roadmap, and use and contribute to
community plugins.
If you would like to file a bug or know more about the fixes in a specific release,
then you must visit the bug-tracking system at http://issues.liferay.com/.
Alloy UI Forms are a set of taglibs built on top of the Alloy UI JavaScript CSS
framework. For more information about the framework, you can visit http://
alloy.liferay.com. CSS3, CSS level 3, is available at http://www.w3.org/
Style/CSS/current-work. A detailed description about HTML5 is available at
http://dev.w3.org/html5/spec/Overview.html. YUI3, Yahoo!'s next-generation
JavaScript and CSS library is available at http://developer.yahoo.com/yui/3/.
Another Random Document on
Scribd Without Any Related Topics
lecturers, on whose damask periods idleness was as a cankering
worm in the bud, got into a sad state of impatience and were
threatening to lecture one another, or do something else desperate,
when the position was saved by a timely visit to them of the Prince
of Wales and his brother, Prince Albert, who had tea with them,
chatted over their work, and convinced them that they were not out
on a fool's errand. Shortly afterwards the transport situation was
relieved, and the lecturers rushed to their audiences and peace
reigned again. But it is dreadful to think of what might have
happened if there had not been the urbane and diplomatic Captain
Hansell smoothing over troubles. A mutiny of lecturers would have
afforded some puzzling problems to the Provost-Marshal.
CAPTAIN H. P. HANSELL
Before the Army Education organisation was born a great number of
men in the Army did some good solid reading. The Camps Libraries
organisation in England sent out to every unit parcels of books. Most
of these were of the opiate class, light magazines and light stories
intended to bemuse and not to educate the mind. But a proportion
of good books slipped in and were warmly appreciated by some.
The Army itself had a very fecund printing press, but it was devoted
almost solely to the production of books of orders and regulations
and text books. Regimental annuals of a humorous kind existed but
were not encouraged. As a rule they were printed in England, not in
France, and the conditions of censorship—more perhaps than the
taste of writers and readers—confined them as a rule to somewhat
feeble japes.
There were very often mooted proposals for a G.H.Q. Monthly. It
might have drawn on a very distinguished band of writers. But
authority contrived that these proposals should never come to
maturity. The expenditure of time and material was grudged, and
G.H.Q. was naturally very nervous on points of "Intelligence." There
are a thousand and one ways in which military secrets can be given
away with quite harmless intent. An Intelligence General's aphorism
on this point ran: "We find out far more from the stupidity of our
enemies than from the cleverness of our spies."
It is clear that silence is the one sound policy. If a man says nothing,
nothing can be discovered from him. If he will speak, even if it is
only with the intention of deceiving, he may disclose something.
British diplomacy abroad (which was not such a foolish show as
some critics say, or else how comes it that the British Empire, from
the tiny foundation of these islands, has come to its present
greatness?) was always the despair of the inquisitive Foreign
Correspondent, for it never said anything. An Embassy or Ministry
which would tell a lie, especially an elaborate lie, was far preferable,
for from something you may deduce something; from nothing,
nothing. G.H.Q. acted with a sound discretion in smothering all
proposals for a G.H.Q. Monthly.
The Army did most of its own printing, of maps, orders, forms, and
training books. Maps were done by the R.E. mapping section, other
printing by the Army Printing and Stationery Services under Colonel
Partridge. This was a highly efficient department with printing
presses of the most modern type at Boulogne, Abbéville, and
elsewhere. A.P. and S.S. printed daily General Routine Orders and,
as occasion demanded, poured out in millions Army Forms, posters,
pamphlets, and books. Both the French and Americans used its
services. It could print in Chinese and Arabic as well as in European
characters, and some of its achievements in the way of quick and
good printing would do credit to a big London printing house.
The Boulogne Printing Press, which was under the care of Major
Bourne, was a particularly up-to-date establishment much praised by
the Americans and the French as well as by our own Army. It put a
strain once, however, on the politeness of the French. The French
Mission at G.H.Q. wanted a book printed giving a record of its
organisation. A.P. and S.S., in the right spirit, did its best to make the
book a handsome one, and designed a special cover with fleur-de-lys
decorations. The French Mission, with tact but with firmness, pointed
out that France was now a Republic and a monarchical symbol could
hardly be permitted on an official publication. It might give rise to a
suspicion that the Army contemplated a coup d'état. The printers
regretted and tried again. The second cover design bore the good
old Roman Republican device of the lictors' fasces. But they were
shown reversed. The French were desolated at being so exiguous,
but could something else be tried, just plain type? The printers were
determined, however, to give the good French something to show
what an artistic people we English really are, and made a third effort
at a decorated cover. This showed a really charming design in which
the Gallic Cock strutted triumphantly along a rose-point border. The
French were enchanted, so enchanted that they found reason to
have another book, an annexe to the original book, printed with the
same cover.
American Army publications were normally somewhat more solemn
and staid than our own. Occasionally, however, the American
humour broke out, as in the gas warning leaflet, which had not,
perhaps, the sanction of American G.H.Q. but was widely (and
usefully) circulated in the trenches. It began:—
In a Gas Attack
There are only Two Crowds
The Quick and the Dead
Be Quick and get that Gas Mask on!
After the Armistice, the Printing Services, no longer so much pressed
with other Army work, were able to undertake some purely
educational printing. But by this time demobilisation was sweeping
away the classes, and the best of the opportunity had passed.
CHAPTER XV.
THE WINTER OF OUR DISCONTENT.
The disappointments of 1916 and 1917—The collapse of
Russia—The Cambrai Battle—The German propaganda—
Fears of irresolution at Home—Reassurances from Home—
Effects of the Submarine war—An economical reorganisation
at G.H.Q.—A new Quartermaster General—Good effects of
cheerfulness at Home.
The Somme campaign, 1916, had been begun with very high hopes.
The main conception of it was a sound one, to attack the German
line at the point of junction between the French and British forces,
the point where, according to all the accepted principles, the Allied
line should have been weakest but actually was not. That was the
only way to bring an element of the unexpected into a grand attack
in those days of long and laborious artillery preparations. (The Tank
did not appear on the scene until the Battle of the Somme was two
months old and did not develop its usefulness as a substitute for
artillery preparation until nearly a year later).
For the Somme battle an enormous artillery concentration was
made, and a special "Army of Pursuit" was trained in the rear of our
lines to follow through when the German line had been breached.
Then there was a preliminary bombardment of the German positions
from the sea to beyond the Somme, and, amidst many feint attacks,
the British and the French offensive north and south of the Somme
was launched.
The First Battle of the Somme made the walls of Jericho quake but
just failed to bring them down. The Army of Pursuit was given no
chance of pushing to the Rhine; its energies had to be diverted
towards sustaining the attack. The fighting season closed in 1916
with the Germans still holding their main defences but convinced, so
far as the reasonable section of their leaders were concerned, that
the game was up and that the best thing to do was to work for a
peace on the best terms possible.
ON THE RAMPARTS
Thus 1916 was a somewhat disappointing year; 1917 was even
more so. The fighting season, that year, closed with the Allied cause
in a worse position than in 1916 and with Germany correspondingly
encouraged. There would have been some reasonable excuse if in
the winter of 1917-18 tails drooped at G.H.Q. The weather was
particularly vile. Every day the winds that howled over the bleak hill-
top seemed to have come straight from Russia and Germany,
bringing with them a moral as well as a physical cold. The casualty
lists of the Autumn were not cheerful to ponder over; and it was
singularly depressing to hear from Home that in some political circles
those casualty lists were being conned over with the idea of
founding on them a case against the Army.
Nobody was inclined to try to represent the late Autumn campaign
as altogether satisfactory. But it was felt by the soldiers that "they
had done their durn'dest, angels can do no more;" and that there
was not sufficient appreciation of the fact at Home that with Russia
down and out, France in a very bad way, Italy tottering, the British
Army had had to step into the breach, had had to take a gruelling
without being able to accomplish much more than defence.
It had seemed in 1916 that the time had arrived for Germany to pay
the penalty. But a triumph not of a military kind came to her rescue.
The German methods of espionage and civil corruption were on the
whole as blundering and as disastrous as her other methods during
the Great War. They helped to alienate practically all the civilised
neutral world. But in Russia—mystic, generous, trusting Russia—they
had an unhappy success. In the Autumn of 1916 this first showed.
Roumania at that time joined in the war against Germany, and this
new accession of strength apparently marked the near end of the
war. But Russia mysteriously collapsed owing to the effects of
German corruption. Roumania was left "in the air," and a large part
of her territory was over-run. From this date, though many of the
gallant soldiers of Russia made heroic efforts to safeguard their
country's honour, that great Ally was practically out of the fight. By
the winter of 1917-18 she was quite out. The French had had grave
troubles. The Italians had had to send out an S.O.S. signal.
We should have been more cheerful if the Cambrai attack, 1917, had
had the full success it deserved. That really was in its conception
and execution a very fine affair. At the time Germany was drawing
troops and guns from the Russian Front and pouring them on to our
Front in wholesale fashion. Both France and Great Britain had had to
send Armies to the help of Italy. Our Battle of Passchendaele was
not exactly flourishing. To undertake a new battle was the last
development the enemy expected of us; and to do what is
absolutely unexpected is to do the big thing in war. The British
command collected an Army ostensibly for Italy, made a great secret
assemblage of Tanks, and suddenly attacked the Germans in the
strongest part of their Hindenburg line. Their line was particularly
strong at that point. It comprised three series of defences each one
covered by triple barriers of wire from 50 to 60 yards deep. A system
of dug-outs (constructed with the labour of Russian prisoners) at a
depth of 50 feet below the surface made an underground city with
water and electric light installations, kitchens, drying-rooms and the
like. Above the surface the houses were closely packed with the
earth removed from the excavations, and thus became great
earthworks indestructible by any shell-fire.
All this the British Third Army, in a surprise attack carried out by the
Tanks and the Infantry, over-ran and captured in a day's attack. So
fierce was the British advance and so feeble the German defence
when taken by surprise that we almost got into Cambrai. If that
centre had been won the German Front in the West would have
been deprived of its central pillar. The German defence, however,
rallied in time to avoid absolute disaster. When the German military
mind was given time to think it could always make a good show, and
the riposte to our Cambrai attack was a good one. We lost most of
the fruits of a dramatic coup. It was more than annoying to think
that just when we had successfully solved the problem of a break-
through we had not the means, owing to commitments elsewhere,
to push the thrust home.
Cambrai was a good deal "boomed" in the English Press at the time
on "popular" lines. But I do not think that the skill of generalship and
organisation that it showed were quite appreciated. The favourite
British pose of being a complete ass, altogether inferior to the "other
fellow," used to be pushed to the extreme point in regard to military
matters. The British had a quaint humility in respect to their military
skill. In a shame-faced kind of way they admitted that their soldiers
were brave; but for examples of military genius they always referred
to the "other fellow." Yet one may be daring enough, perhaps, to say
something on the other side; and to suggest that in the Great War
the German was really surpassed in most points of military skill by
the British. The difference was not always great, but where the
difference was greatest was just in those points of invention, of new
tactics and new strategy, which show the better brain. Heresy it will
seem; but the truth is that from 1914 to 1918 the British military
system showed itself superior to the German in resource and
sagacity. Perhaps it would be better to say the British-French military
system, for it is difficult to separate the achievement of one from the
other.
Consider one by one the main features of the great campaign. The
warfare in the air was its most dramatic feature. Everything of air
tactics and strategy that the German used he copied from the British
and French. It was the British who originated aeroplane attack with
incendiary bullets on captive balloons, aeroplane escort of attacking
infantry, aeroplane sallies at low altitude on enemy trenches, and the
various combinations of observing machines with fighting machines.
In the first battle of the Somme, when the British and French first
disclosed their sky tactics, the German was absolutely driven out of
the air. He had then to learn to copy all our methods; and he
originated none of his own.
Another dramatic feature, the complicated and terribly effective
artillery curtain fire, was evolved by the British-French command. It
was copied by the Germans, who themselves contributed nothing
new to artillery science during the war. Yet another leading feature
was the Tank, the Tank which made its real value first felt at
Cambrai. This was a purely British invention, evolved during this war
for the needs of this war.
Our "Winter of discontent" was not made any sweeter by the
suspicion that existed of a possible yielding on the part of the
political powers at Home to German propaganda. This German
propaganda took the form of blazoning the preparations for a
sensational Spring offensive in 1918; it was trumpeted like a Fat
Woman at a Fair, and supplemented by an almost equally strident
advertisement of a gigantic defensive. In addition to preparing a
great on-rush in which Calais, Paris, Rome, and perhaps London
were to be captured, the German High Command wished the world
to know that it was also preparing a mighty series of defensive
positions back to the Rhine. Wonderful showmen! They had not only
the most marvellous Fat Woman, but also a miraculous Skeleton
Man. And the prize they wished to win, by bluff if not by fighting,
was agreement to an inconclusive peace.
The soldiers were not affected much by these tactics. They took
solid comfort from two facts. The first fact was expressed in the
homely proverb "Much cry, little wool." Had the Germans been
confident that they could smash through the steel wall which barred
them on the West from the sea, from the capitals of civilisation, and
from the supplies of raw material for which they were starving, there
would have been no preliminary advertisement. The effort would
have been made, and Germany's enemies would have had to abide
by the result. There would not have been any compunction at the
consequent cost in blood. The mere extravagance of the
advertisement of the German plans was proof to the soldiers at
G.H.Q. that those plans were recognised not to have a solid enough
military foundation, and had to be reinforced by showy bluff.
The second fact which gave solid comfort was that in any
comparison at all of forces the German group was inferior to the
West European-American group. There was not any doubt at G.H.Q.
Indeed the more the Germans protested of what they were going to
do in the Spring of 1918 the more firm was G.H.Q. in believing that
the enemy was at last coming to the end of his resources and was
anxious to "bluff" a peace rather than "show" a weak hand.
But it was feared that the people at Home might take the other
view, and it had to be admitted that the German put up a very
strong bluff. Perhaps its cleverest form at the time was in the
discussion of "peace terms"—a discussion in which it was presumed
that the German would impose a victorious peace before the
summer of 1918. A characteristic discussion—G.H.Q. kept a close
eye on the German press and minutely examined every German
paper published during the war—would begin with some Prince
pointing out the minimum indemnity that Germany should exact
from her foes, and explaining in what form it should be exacted.
Germany's need, it would be pointed out, would be for raw
materials, food, cotton, wool, rubber, tobacco, silk and the like. It
was these that must be supplied to Germany by way of indemnity.
They would have to be supplied not free, but at a price 20 per cent.
lower than the current market price, and the annual value of this
discount would only reach the modest sum of £50,000,000 a year.
To have had to provide yearly a tribute of any kind to Germany
would of course have taken away the independence of the Allies
completely. They would have been put in the position of admitting a
German suzerainity, and would have become as the oppressed
Christian provinces of the old Turkish Empire. But to provide this
tribute of raw material, the discount on which at 20 per cent. would
be £50,000,000 a year, would have been to engage to send to
Germany yearly raw materials of her choice to the value of
£250,000,000. This would have been the first call on the farms, the
mines, the shipping of the Allies, and only after that call was met
would the Allies have been able to begin to supply their own larders
and their own factories.
That was one direction the German Peace Propaganda took. The
idea of it was, presumably, to strike terror into our hearts, to make
us welcome with something like relief the actual official terms of a
peace negotiation when they came to be promulgated.
Then someone in Germany would take the other side. Assuming with
absolute cock-sureness that Germany must win the war in the Spring
of 1918, this publicist would affect to regret the savage terms of
peace imposed upon Russia. These terms, it was argued, did not
represent the considered wishes of the German people. But in war
the wisdom of the statesmen was pushed aside by the eagerness of
the soldiers. The German politicians were overwhelmed in regard to
the Russian peace because the Russian had allowed things to go too
far. But if only the Western Powers would agree to negotiate for
peace now, the "reasonable German politicians" would be able to
assert their authority. There would be no ruthless military conditions
such as were imposed upon Russia. Sweetly and moderately the
Germans would frame their terms; but the Powers of the Entente
must "put the war into liquidation at once." Delay would mean that
the "reasonable German politicians" would lose their power to
restrain the military party.
G.H.Q. remembered the old fable about certain trustful animals
being invited to pay friendly visits to the cave of a beast of prey. One
wise animal noticed that whilst there were many tracks of visitors
going into the cave there were no tracks of visitors coming out. We
had noticed that a free Russia went into negotiation with Germany
to conclude a friendly and reasonable peace on terms of "no
annexations and no indemnities." No free Russia came out.
But G.H.Q. was honestly alarmed for a time that resolution would be
shaken at Home, and welcomed with joy (as the Germans did with
rage), the firm declarations of the Versailles Council of the Allies and
the unshaken confidence and resolution shown in the speech from
the Throne at the prorogation of the British Parliament.
As soon as the Home political situation was seen to be clear, G.H.Q.
set about preparing for the "wrath to come" with a good deal of
cheerfulness and with some amusement that the German
propaganda should, as a final kick, make a strong though forlorn
effort to revive the old story that Great Britain contemplated the
seizure from France of Calais and the department of Pas-de-Calais.
"Even," said the German Wireless about this time, "if it is not openly
admitted that the English will never voluntarily evacuate the French
port of Calais, which they have occupied—" etc., etc.
This lie revived in our Mess between British and French liaison
officers an old topic of humorous conversation. For when this
particular lie was burdening the German Wireless some time before,
a British General was showing to a French General the arrangements
of the British Base at Etaples. He exhibited with pride the great bath
houses for the men, built of concrete and "good for a hundred
years." "Ah yes, very solid—good for a hundred years," said the
French General, laughing. Then they both laughed.
Christmas, 1917, was celebrated with the usual British merriment at
G.H.Q., and on New Year's Day everybody's cheerful greeting was
"That this year may see the end of the war." But I think there were
few officers of standing who thought that a peace Christmas was
possible in 1918. No one would contemplate the possibility of losing
the war, of stopping on any terms short of a German surrender; but
few could see any possibility of victory near ahead. There were thick
clouds all round the horizon. Russia was finished. Italy was not
cheerful. France was recovering but not yet showing sure signs of
emergence from that fit of depression out of which M. Clemenceau
was to pull her—the soul of a Richelieu in his frail body.
The worst symptom of all from the point of view of the British Army
was the threat of a shortness of supplies. Just when the collapse of
Russia had allowed the enemy to concentrate his full strength on the
Western Front, the great reservoir of British wealth, which was the
main financial resource of the Alliance, showed signs of not being
inexhaustible. There was a call at the same time for greater
preparation and greater economy. From the beginning of 1918 there
were two great cross-currents of correspondence between G.H.Q.
and the Home Government, one demanding new weapons, new
defences, new equipment, the other demanding rigid economy in
steel, in timber, in shipping space, in food, in oil, in expenditure
generally. This was partly due to actual lack of money and of credit.
But in the main it was the result of the submarine war.
It was at the end of 1915 that the German Admiralty prepared a
memorandum arguing that if unrestricted submarine war were
adopted as a policy (i.e., sinking everything, hostile or neutral,
warship or passenger ship), then Great Britain would be compelled
to sue for peace within six months. The memorandum gave various
statistics regarding food supplies, tonnage, etc., to prove this
hypothesis. The memorandum was forwarded to the Imperial
Chancellor, and by him sent to Dr. Helfferich, Secretary of State for
Finance, for a report. Dr. Helfferich reported adversely. He was not
convinced that Great Britain would be brought to her knees. He
feared the effect upon neutral nations of such a policy.
The German Admiralty persisted in its view. Thereupon the matter
was submitted for report to ten experts representing finance,
commerce, mining, and agriculture. These experts were asked to
advise (1) as to the probable effect upon Great Britain (2) as to the
probable effect upon Germany's relations with neutrals and (3) as to
how far the situation in Germany demanded the employment of such
a weapon.
All these experts agreed that the effect on Great Britain would be to
force her to sue for peace within six months or less. Indeed, Herr
Müller, President of the Dresden Bank, thought that Great Britain
would collapse within three months. All the experts also agreed as to
the third point of reference, arguing that Germany's position was so
difficult that the most desperate measures were necessary to end
the war. Herr Engelhardt, of Mannheim, Councillor of Commerce,
thought the economic position of Germany so bad that a few weeks'
delay might render even ruthless submarine war useless. On the
second point, the effect on relations with neutrals, the experts were
divided. Some thought that the United States would be driven to
war, others thought not. In all cases they did not see a reason
against ruthless submarine war in their possible relations with any
neutral.
But the fateful decision was not taken until February, 1917, when the
destruction of peaceful shipping, whether of enemy or of neutral
countries, was ordered. It did not end the war in six months, nor in
twelve months; but by the beginning of 1918 there were some very
serious difficulties of supply just when the strictly military position
demanded the most generous effort.
I wonder if those experts who bandy to and fro explanations and
accusations in regard to the German break-through in the Spring of
1918 ever have looked at the matter from the point of view of
supply, of the supply, say, of one sternly necessary item of defence,
wire? At a careful computation we wanted 12,000 tons of barbed
wire in January, 1918, and 10,000 more tons in February, 1918, to
give our men a reasonable chance of holding the line which we knew
to be threatened. Of that total of 22,000 tons we actually got 7,700
tons, i.e., 35 per cent. of what was needed.
I do not quote this fact to start another quarrel, shuttle-cocking
blame from soldier to politician. I am more than ready to believe
that the people at Home were then doing their best (as, pace all
grousers, I believe they did their best from August, 1914, to
November, 1918). But you cannot spin out wire like you spin out
talk, especially barbed wire. The British soldier can, with his mere
flesh and blood, and that gay courage of his, do wonders in the way
of making up for want of material. But he could not hold up the
attacked sector in the Spring of 1918 against overwhelming odds;
and one of the reasons was that he had not enough wire in front of
him. He had not the wire in front of him because it had not been,
could not be, supplied.
How anxious was the task of G.H.Q. at the dawn of 1918 may be
illustrated with these heads of correspondence, in and out.
To G.H.Q. from Home.
The greatest economy in steel is urged.
The position in regard to shipping is serious; the
strictest economy in everything is necessary.
Lubricants are hard to get. We urge the greatest
economy.
From G.H.Q. to Home.
More machine-guns are urgently needed.
There is a shortage of blankets; there is a shortage of
8,000 tons of barbed wire. New searchlights are
needed; 300,000 box respirators are needed for the
American Forces.
I could fill many pages with matter of the same sort. The poison of
the submarine war began to have its cumulative effect just when we
were getting the most peremptory reminders that Supply was going
to be the determining factor of the final struggle, that war had
become more and more a matter of striking at the enemy's life by
striking at "the means whereby he lives." Munitions, food,
equipment, railways, roads, ships—these had become the most
important factors, and victory would incline to the Force which could
best concentrate the means to maintain an overwhelming force at
some particular point, which could best develop, conserve, and
transport its material. The field for the strategist had moved more
and more from the Front line towards the Base.
Fortunately, the British Army in France had for its Q.M.G. at this
crisis a man with the courage and the knowledge to carry through a
drastic reorganisation of the Supply and Transport services.
Lieutenant-General Sir Travers Clarke, who took over as Q.M.G.,
France, at the end of 1917, was a daring experiment on Lord Haig's
part; for he was a comparative youngster to be put into a post which
was then the most anxious and onerous in the Army, and his actual
substantive rank was that of a major; but he was an acting Major-
General with a fine record in a minor theatre of the war. Lord Haig
knew his man well, though, and, what was just as necessary, knew
how to back his man. He put Sir Travers Clarke in the saddle and
kept him there in spite, I have no doubt, of many thunderous
protests from influential quarters, for Sir Travers Clarke was a
ruthless reformer and a stubborn upholder of any course of action
he thought necessary. A character sketch of him that appeared in
the Morning Post in 1919 is worth quoting in part:
LIEUT-GENERAL SIR TRAVERS CLARKE
"'That big young man,' was a leading American officer's term to
describe Sir Travers Clarke after he had met him in France in
Conference, and had not caught his name. British G.H.Q. perhaps
only learned to appreciate the Q.M.G. fully from the comments of
foreign officers who came into touch with him in 1918. The
masterful man took his power so quietly, came to big decisions with
such an air of ease, such an absence of anything dramatic or violent,
that it was a little difficult to understand his full strength.
"'T.C.'—as often before remarked, the British Army must reduce
everything and everyone to initials—as a regimental officer in the
'Nineties never seemed to get an opening. Nor did his early Staff
work bring him much recognition. But an officer of his to-day, who
was a clerk under him when he was first a Staff Captain, insists that
he always gave the impression of great power in reserve. 'He
believed in the British Army, in hard work, and in himself.' That was
the foundation of the career of a man who, once an opening
showed, forged ahead with marvellous speed to his destiny.
"It took 'T.C.' ten years to become a major; within the next ten years
he had become Lieutenant-General and Quartermaster-General to
the British Armies in France. One year in that post, a year in which
were crowded all the experiences that a great Army could have,
marked him as a great leader of men and a superb organiser. How
much the Allied victory owes to him a grateful country will not
appreciate fully until not only the British but also the French and
American campaigns are analysed.
"'T.C.' had the ideal personality for a military leader. You were always
dreadfully afraid of him and sincerely fond of him. No general ever
made sterner demands on his officers and men. If you could not
stand up to a gruelling day's work and come up smiling for the next
day's and the next day's, until the need had passed, you were no
use, and you moved on to some less exacting sphere. But you were
working under a worker, and you found yourself part of a massive
machine which was rolling flat all obstacles. That made it easy.
Further, there was the most generous appreciation of good work and
a keen personal sympathy.
"Sir Travers Clarke has one rule to which he never permitted an
exception: that it is the fighting man who has to be considered first
and last. In France he was quite willing that the Staff should labour
to the extreme point of endurance to take any of the load off the
man in the trenches. He did not like about him men, however clever,
who had not seen fighting. It was the first duty of the Staff, he
insisted, to enter with the completest sympathy into the feelings and
the difficulties of the fighting man. 'Bad Staff work mostly arises
from not knowing the differences between an office and a trench,'
was one of his aphorisms."
This is not a history of the war; nor a contribution to any of the
numerous war controversies; it is merely a sketch of life at G.H.Q. as
it appeared to a Staff Officer; but I cannot help obtruding a reply to
some current criticisms of Lord Haig: that he was too inclined to
stand by his officers, that he was reluctant to "butcher" a man, and
that in consequence he did not get the highest standard of
efficiency. Faithfulness to his friends and servants was certainly a
marked characteristic of Lord Haig as Commander-in-Chief. He chose
his men cautiously and, I believe, with brilliant insight. Having
chosen them he stood by them faithfully in spite of press or political
or service thunderings, unless he was convinced that they were not
equal to their work.
It is a characteristic which, even allowing that there was an odd case
of over-indulgence, of giving a man a little too much benefit of the
doubt, worked on the whole for the good. Men do not do their best
work with ropes round their necks; and I believe that a great
newspaper magnate whose motto at first was "Sack, Sack, Sack,"
very soon found out that it was a mistake.
In this particular instance I suppose the Commander-in-Chief had
powerful urging often enough to "butcher" his Q.M.G., who did
things of so disturbing a character. He did not; and the event proved
him right, as it did in practically every one of his great trusts during
the war.
Reorganisation of Supply and Transport filled the attention of G.H.Q.
during the early months of 1918. Over a curiously wide range of
subjects swept a wave of reform and retrenchment. As I have
already told, there was a definite organisation to collect the salvage
of the battlefields, an organisation which saved millions of money in
rags, bottles, waste-paper, swill, bones and grease as well as in the
more obvious matters of shell-cases and derelict arms and
ammunition. An Agricultural Directorate was set to work to grow
potatoes and oats and vegetables and other food stuffs behind the
lines. Rations were judiciously reduced, a substantial difference
being left in favour of the man in the actual fighting line as
compared with the man at the Base. The supply of certain luxuries
at the E.F. canteens was stopped or limited, but it was provided that
the man in the fighting line should suffer less from this than the man
at the Base. Weekly conferences were instituted to discuss the most
economical use of labour, of material and of plant. Every matter
great and small had searching attention, and the British Army began
to be run like an up-to-date competitive business. Some of the
injudicious laughed. They christened the General in charge of
Salvage "O.C. Swills" and "Rags and Bones." They could not "see" a
Colonel whose mission in life was to cut down laundry costs and
arrange for the darning of the men's socks when they came out of
the wash.
But all these things had to do with the winning of the war. It is a fact
that if the lavishness of 1914-15-16-17 had been carried into 1918
we could not have won the war, because we should have been
bankrupt of material.
G.H.Q. at the dawn of the Spring of 1918 was very serious in mind,
but not so much so as to fail to get some amusement as well as
interest out of the various new ideas in military administration; and
fully confident now that the people at Home were going to stick it
out. In this connection there was often mentioned with cheerfulness
a London bye-election towards the end of 1917 for an area which
had had special attention from the German air-raids. Some rather
expected to see a candidate come forward from among the little
group known as "Pacifists," who would seek votes on the plea that
the best way to stop air-raids quickly and to get out of the
discomforts of the war would be to meet half-way the proposals of
the Germans who were trying for an inconclusive peace.
What actually happened was quite different. A candidate came
forward under the banner of the Government, pledged to the
Government's programme of carrying on the war until German
militarism was crushed and Germany made reparation for the ruin
she had wrought in Europe. This candidate had the support of both
the old political parties. Against him there came out another
candidate. Did this candidate seek to win votes by pleading for a
friendly consideration of Germany's hypocritical peace proposals? He
did not. From what one could gather of the feeling of the electorate,
if he had done so he would have been ducked in the nearest pond.
No, his appeal was based on the plea that the Government
candidate did not go far enough in hostility to Germany, and that
that gentleman was not fully in favour of carrying to German homes
the dastardly air-war which Germany waged on a civilian population.
Then a third candidate appeared on the scene. He was not for any
half-hearted policy. His cry to the electors was that neither of the
other two candidates was sufficiently earnest in regard to the war
against Germany. His programme was of one clause only, the
necessity of bombing Germany out of her barbarism. He did not
believe that any method of sweet reasonableness was of any use. A
thousand tons of bombs daily on Berlin, and a ration in
proportionate scale on other German towns, was his idea.
Women speakers came to take part in the contest. Did they
advocate making concessions to the German desire to sneak away
from the consequences of the crime of 1914? They did not. They
were more vigorous than any of the men speakers in demanding a
full measure of reprisal on Germany. No one throughout the whole
contest whispered "peace."
It was altogether inspiriting. Here was a chance to see what the
people of England, the people who stood behind the Army and the
Navy and were our ultimate supports, felt about the war. We could
see that they were utterly resolute, with not a sign of weariness, nor
of fear, nor of tolerance for a craven peace. Their message was
"Fight on, Fight on. Bring us home a real peace. We will put up with
everything the Boche can do; we will carry on. But no palter, no
surrender. Finish the job you are at."
The English people terrorised? Not a bit of it. They were only getting
their blood up. And G.H.Q. saw that and was comforted.
There was also a good deal of solid comfort in the way that London
took the bitter experience of "rations." We never had any food
scarcity in the Army and, going on leave, officer or soldier had a
food card that guaranteed him a good holiday supply. So we were in
the best position to appreciate the cheerful way in which Great
Britain took the very thin gruel of ration times. Every officer coming
back from leave expressed his glowing admiration of civilian
patience.
Those German agents in London who relieved the tedium of the war
for the Allies by reporting to Berlin such "happenings" as the Battle
of Oxford Street and the destruction of whole quarters of London by
air attacks, set out, for the fooling of the German public, some fine
accounts of dismay and discontent caused by food tickets. But as a
matter of truth, London on rations surprised and gratified the most
cheerful optimists. The old city "took her medicine" not only with
patience but with an actual gaiety.
To sum up: between the close of the fighting season of 1917 and
the beginning of that of 1918, G.H.Q. was at first a little depressed
at the thought that political developments would prevent the Army
from seeing the job through in a satisfactory way; was subsequently
reassured as to the feeling of the civilian population; and thereafter
faced the future with complete confidence.
CHAPTER XVI.
ENTER THE AMERICANS.
How the Germans were misled about the Americans—Early
American fighters—The arrivals in May, 1918—American
equipment—Our relations with the Americans and what they
thought of us—The Portuguese.
There are many claimants for the honour of being the War Winner.
When I was in Italy in February, 1918, I found a very genuine belief
there that the Italians were the genuine war winners; that they
brought the decisive weight to bear. Without denying the very useful
effect that Italian neutrality had in the first stages of the war, and
Italian participation at a later date, I think it would be hard to
convince, say, the French of the soundness of the Italian claim. The
British might be more inclined to agree; for they still keep up the
curious pose of being a poor feckless people who never do anything
or know anything. Another claimant for the pride of first place in the
Grand Alliance is Greece; and I believe that Portugal has some idea
of putting in a claim.
But on the whole, taking all the circumstances into account and
reckoning not war services only but war effect, the actual final blow
to the Germans' hopes was delivered when the United States of
America declared war. It was when Germany made that declaration
necessary, in spite of the sincere wish of the Americans to keep out
of the war, that all hope vanished of Germany securing an arranged
peace. From that moment it was clear that ultimately she would
have to take exactly what was handed out to her at the conclusion
of the war.
It is hard to believe that the German leaders ever seriously believed
the stuff and nonsense that they gave out to comfort their people on
the subject of American participation in the war. But having
blundered by bringing the United States in they had to try to cover
up their blunders.
German diplomacy was not without successes of a kind in the
preparation and prosecution of the war. If it is the function of
diplomacy to plot murders and strikes and arsons in neutral
countries, to bribe Oriental despots such as those of Turkey and
Bulgaria into betraying their people, German diplomacy had a proud
record. But concerning the sentiments and opinions of honourable
communities German diplomacy showed always an abysmal
ignorance. In no respect was this more clear than in its dealings with
the United States of America.
At first German diplomacy adopted the idea which was embodied in
the German phrase "those idiotic Yankees"—the idea that the United
States was a kind of Wild West Show, whose simpleton rulers could
be fooled without trouble by the intelligent, the super-intelligent,
Germans. When that idea was exploded, the next to take its place
was equally foolish—that anyhow the antagonism of the United
States did not matter, for she would not make war, and if she made
war the effort would be so feeble as not to be worth considering.
Then when the grim shadow of the great American preparation was
already over the German despotism, and the greatest single white
nation of the world was seen preparing its mighty strength to the
full, the German people were asked to take comfort from yet another
delusion, that the American nation would prove to be a "quitter,"
that it would be frightened off the field by the German offensive of
the Spring of 1918. The Hamburger Echo voiced that delusion when
it announced: "It is curious that at this critical moment American war
experts are reported to be planning an inspection trip of the Front. It
looks as though American capitalists were growing nervous. The
dollar-republic has stolen ships which ensure her a great Fleet, but
American capital is not unlimited, hence the liquidation of the war
may be contemplated."
How different the truth about that "inspection trip" which had the
effect, certainly, of impressing the American Staff with the extreme
seriousness of the campaign, but led to the result not of "quitting"
but of brigading the American troops temporarily with those of the
Allies. It was an instance of a sensible sacrifice of national vanity
that has probably no parallel in history—that decision of the
Americans to allow their soldiers to fight under British and French
flags while they learned their business.
Unhappy German people to have been fed by their leaders with such
delusions! The United States a "quitter"! Had any German read the
history of the 18th and 19th centuries—heard of Washington, of
Hamilton, of Lincoln? If the German had searched back only so far
as 1861 he would have found that the nation which he was told
might throw up the sponge at the first hint of hardship and danger,
faced a war which probably, for nerve strain and call for grim
resolution, surpassed even this great war. The United States had
then to fight not a foreign foe but domestic discord. It had to set its
teeth through a series of great military disasters. It had to hold
firmly to a forlorn hope, whilst it was faced by the ever-present
prospect of foreign interference. No nation in modern times has
been put to a harsher test of courage and resolution than the United
States in 1861 and the following year. No nation in history showed a
more indomitable courage. And this was the nation that the German
leaders would fain persuade their people was likely to prove a
"quitter!" I ventured to say at the time that before the German
military despotism was through with the war it would recognise that
the reluctance of the United States to enter the war would be
matched by the reluctance of the United States to go out of the war
until its purpose was finally accomplished.
To tell the story of the American participation in the war does not
come within the province of this work, but some of the facts can be
told of that most dramatic feature of the last stages of the Great
War.
There was a very elaborate and very successful mystification of the
enemy over the time, the extent, and the equipment of American
arrivals on the Western Front. The American "Intelligence," in co-
operation with our own and the French Intelligence Branches,
managed to surround these matters with so much mystery that
some of our own high Staff Officers never knew the exact position,
and strangely over-estimated the strength of the American Force on
the Western Front. There is good reason to believe that the German
High Command was completely deceived and found its difficulties
increased accordingly.
From almost the first day of the war there were a few individual
Americans fighting for the Allies. In September, 1914, I encountered
two personally with the British Army, and I suppose the actual total
number was some hundreds. Later a great many came over with the
Canadian contingents; and there was also a flying unit, which made
a fine reputation for itself. This began with a small group of
Americans in the Foreign Legion of the French Army. In the spring of
1915 the formation of an American squadrilla was decided upon. At
first the French Minister of War was not inclined to sanction the
proposition, but afterwards decided that no international law
prevented Americans from enlisting voluntarily, in spite of their
country's neutrality. The squadrilla was to be known as the
"Escadrille Américaine," and to be commanded by a French captain.
On November 16th, 1916, Colonel Barès, Chief of the French
Aviation at General Headquarters, decided that the name "Escadrille
Américaine" must be dropped and the official military number, N124,
used in future. The reason given was that Bernstorff had protested
to Washington "that Americans were fighting on the French Front,
that the French communiqués contained the name 'Escadrille
Américaine,' and that these volunteer Americans pushed their
brazenness to the point of having a red Sioux Indian in full war-paint
depicted on their machines." Captain Berthaud, at the Ministry of
War, suggested the adoption of the name "Escadrille de Volontaires,"
but the name finally adopted was "Lafayette Escadrille." More than
200 American volunteers entered the Lafayette Escadrille before
America joined in the war. Some remained in the squadrilla, others
were transferred to various French units, where they frequently
distinguished themselves by the brilliance of their exploits.
All these troops, however, were strictly unofficial and of course
discountenanced by the American Government. After the American
declaration of war, American help was confined for a long time to
labour units, forestry and railway workers. It was not until May,
1918, that there was any really considerable American fighting force
in France, and not until June, 1918, that it began to have any weight
in the fighting line, and then only as units brigaded with British and
French troops. It was the usual plan—a plan made possible by the
admirable and business-like lack of false pride among the Americans
—to split up their troops among other troops, allow them thus to be
"blooded," and after experience as platoons, companies, brigades, to
retire to their own training grounds and form "pukka" Divisions of
their own.
By April 25th, 1918, there were 12,700 American troops in our lines
in France, by May 25th 79,000, by June 25th 188,000. Then the
Second Army Corps was formed and absorbed 95,000 men. The
May, 1918, programme provided for the arrival of six American
Divisions within the British zone of operations, and there actually
were 108,921 American troops attached to the British Army at the
end of that month. The British Army took responsibility for the
feeding and equipment of these troops. The system was adopted of
assigning to each American Division as it arrived a British "mother"
Division, to see it through its early troubles of transport, equipment,
food and accommodation. The system worked admirably and there
was very little friction in connection with the settling down of the
Americans. Yet the task of adjustment was not easy. The American
troops had to be equipped with almost everything except uniforms,
badges and caps. The things they had were almost as much a cause
Welcome to our website – the perfect destination for book lovers and
knowledge seekers. We believe that every book holds a new world,
offering opportunities for learning, discovery, and personal growth.
That’s why we are dedicated to bringing you a diverse collection of
books, ranging from classic literature and specialized publications to
self-development guides and children's books.
More than just a book-buying platform, we strive to be a bridge
connecting you with timeless cultural and intellectual values. With an
elegant, user-friendly interface and a smart search system, you can
quickly find the books that best suit your interests. Additionally,
our special promotions and home delivery services help you save time
and fully enjoy the joy of reading.
Join us on a journey of knowledge exploration, passion nurturing, and
personal growth every day!
ebookbell.com

Liferay 62 User Interface Development Xinsheng Chen Jonas X Yuan

  • 1.
    Liferay 62 UserInterface Development Xinsheng Chen Jonas X Yuan download https://ebookbell.com/product/liferay-62-user-interface- development-xinsheng-chen-jonas-x-yuan-4682260 Explore and download more ebooks at ebookbell.com
  • 2.
    Here are somerecommended products that we believe you will be interested in. You can click the link to download. Liferay Portal 62 Enterprise Intranets Navin Agarwal https://ebookbell.com/product/liferay-portal-62-enterprise-intranets- navin-agarwal-6808832 Liferay Portal 52 Systems Development Jonas X Yuan https://ebookbell.com/product/liferay-portal-52-systems-development- jonas-x-yuan-1266150 Liferay 6x Portal Enterprise Intranets Cookbook Over 60 Handson Recipes To Help You Efficiently Create Complex And Highly Personalized Enterprise Intranet Solutions With Liferay Portal 6x Ce Piotr Filipowicz https://ebookbell.com/product/liferay-6x-portal-enterprise-intranets- cookbook-over-60-handson-recipes-to-help-you-efficiently-create- complex-and-highly-personalized-enterprise-intranet-solutions-with- liferay-portal-6x-ce-piotr-filipowicz-5473904 Liferay Portal 6 Enterprise Intranets Jonas X Yuan https://ebookbell.com/product/liferay-portal-6-enterprise-intranets- jonas-x-yuan-2313866
  • 3.
    Liferay In ActionThe Official Guide To Liferay Portal Development 1st Edition Rich Sezov https://ebookbell.com/product/liferay-in-action-the-official-guide-to- liferay-portal-development-1st-edition-rich-sezov-2342536 Liferay Portal Enterprise Intranets Jonas X Yuan https://ebookbell.com/product/liferay-portal-enterprise-intranets- jonas-x-yuan-2459436 Liferay Beginners Guide Robert Chen Sandeep Nair Samir Bhatt https://ebookbell.com/product/liferay-beginners-guide-robert-chen- sandeep-nair-samir-bhatt-2491058 Liferay Portal Systems Development Jonas X Yuan https://ebookbell.com/product/liferay-portal-systems-development- jonas-x-yuan-2520586 Liferay Portal Performance Best Practices A Practical Tutorial To Learn The Best Practices For Building High Performing Liferaybased Solutions Samir Bhatt https://ebookbell.com/product/liferay-portal-performance-best- practices-a-practical-tutorial-to-learn-the-best-practices-for- building-high-performing-liferaybased-solutions-samir-bhatt-4379406
  • 6.
    Liferay 6.2 UserInterface Development A comprehensive guide to user interface development with Liferay Portal Xinsheng Chen Jonas X. Yuan BIRMINGHAM - MUMBAI
  • 7.
    Liferay 6.2 UserInterface Development Copyright © 2013 Packt Publishing All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews. Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the authors, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book. Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information. First published: November 2013 Production Reference: 1181113 Published by Packt Publishing Ltd. Livery Place 35 Livery Street Birmingham B3 2PB, UK. ISBN 978-1-78216-234-6 www.packtpub.com Cover Image by Aashish Variava (aashishvariava@hotmail.com)
  • 8.
    Credits Authors Xinsheng Chen Jonas X.Yuan Frank Yu Reviewers Albert Coronado Calzada Sandeep Nair Acquisition Editors Anthony Albuquerque Rukhsana Khambatta Lead Technical Editors Mayur Hule Vaibhav Pawar Technical Editors Nadeem N. Bagban Aparna Chand Amit Singh Copy Editors Sarang Chari Tanvi Gaitonde Mradula Hegde Gladson Monterio Lavina Pereira Kirti Pai Project Coordinators Abhishek Kori Wendell Palmer Proofreaders Simran Bhogal Maria Gould Paul Hindle Indexer Mehreen Deshmukh Graphics Ronak Dhruv Abhinash Sahu Production Coordinator Kyle Albuquerque Cover Work Kyle Albuquerque
  • 9.
    About the Author XinshengChen is a web application architect. He holds an MS degree in Computer Science from California State University, San Bernardino. His focus was on online banking applications. He also has a Bachelor's degree from Wuhan University, China. Mr. Chen was previously a QA engineer working at VMware, Inc. He later led a team in developing four educational computer games for a Florida school district. Mr. Chen has rich experience in J2EE technologies. He also has extensive experience in Content Management Systems (CMS), including Alfresco. He has worked on 23 Liferay Portal projects. He is also the co-author of Liferay Beginner's Guide and Liferay User Interface Development.
  • 10.
    Acknowledgements I would sincerelylike to thank Rukhsana Khambatta (Acquisition Editor), Abhishek Kori (Project Coordinator), Mayur Hule (Lead Technical Editor), and Wendell Palmer (Project Coordinator) at Packt Publishing. Thank you for giving me this opportunity to update this book. I appreciate your excellent management of the book writing process. It has been a great experience working together with you. I would also thank Aparna Chand, Nadeem Bagban, and Amit Singh (Technical Editors) who have helped me add the final touch to the book before its publication. Thanks also goes to Shuyang Zhou and Nate Cavanaugh at Liferay, Inc. I learned a lot from them while I wrote this book and worked on Liferay Portal projects. I would like to thank Frank Yu and Jonas Yuan at ForgeLife, Inc. I appreciate their understanding and support both in my life and at my work. I would like to thank Tushar Shah at LinkedIn, Inc., who supported me when I needed it. I would also thank Tina Agrawal, Tejash Patel, and Hemen Punjani at Cignex Datamatics, Inc. They were my co-workers and I had worked happily with them. I would also thank Xinli Chen, my eldest sister, who has always been supporting me behind the scenes. My progress and achievements could not have been possible without her support and sacrifice.
  • 11.
    About the Author JonasX. Yuan is a Chief Architect of ForgeLife LLC and an expert on Liferay Portal, e-commerce, and Content Management Systems (CMS). As an open source community contributor, he has published five Liferay books from 2008 to 2012. He is also an expert on Liferay integration with Ad Server OpenX, different search engines, enterprise content including videos, audio, images, documents, and web contents, and other technologies, such as BPM Intalio and Business Intelligence Pentaho, LDAP, and SSO. He holds a Ph.D. in Computer Science from the University of Zurich, where he focused on Integrity Control in federated database systems. He earned his M.S. and B.S. degrees from China, where he conducted research on expert systems for predicting landslides. Previously, he worked as a Project Manager and a Technical Architect in Web GIS (Geographic Information System). He is experienced in Systems Development Lifecycle (SDLC) and has deep, hands-on skills in J2EE technologies. He developed a BPEL (Business Process Execution Language) engine called BPELPower from scratch at the NASA data center. As the chief architect, Dr. Yuan successfully led and launched several large-scale Liferay/Alfresco e-commerce projects for millions of users each month. He has worked on the following books: Liferay Portal Enterprise Intranets, 2008; Liferay Portal 5.2 Systems Development, 2009; Liferay Portal 6 Enterprise Intranets, 2010; Liferay User Interface Development, 2010; Liferay Portal Systems Development, 2012.
  • 12.
    Acknowledgements I would liketo thank all my team members at Liferay, specially Raymond Auge, Brian Chan, Bryan Cheung, Jorge Ferrer, Michael Young, Jerry Niu, Ed Shin, Craig Kaneko, Brian Kim, Bruno Farache, Thiago Moreira, Amos Fong, Scott Lee, David Truong, Alexander Chow, Mika Koivisto, Julio Camarero, Douglas Wong, Ryan Park, Eric Min, John Langkusch, Marco Abamonga, Michael Han, Samuel Kong, Nate Cavanaugh, Arcko Duan, Richard Sezov, Joshua Asbury, Shuyang Zhou, and Juan Fernández for providing support and valuable information. Many thanks to all my friends in the Liferay community. I sincerely thank and appreciate Rukhsana Khambatta (Acquisition Editor), Abhishek Kori (Project Coordinator), Mayur Hule (Lead Technical Editor), and Wendell Palmer (Project Coordinator) at Packt Publishing for critiquing and fixing my writing style. Last but not least, I would like to thank my parents and my wife, Linda, for their love, understanding, and encouragement. My special thanks to my wonderful and understanding kid, Joshua.
  • 13.
    About the Reviewers AlbertCoronado Calzada is a highly experienced Information Technology professional with more than 13 years of experience in Java EE, high performance portals, e-commerce, and enterprise software solutions. Albert has studied Information Technology Engineering and has a Master's in Economics and Financial Management of Companies. Albert is currently working as a freelance software developer, trainer, and consultant for international customers. Albert is an open source software contributor and has released different applications for Liferay and Android. Albert lives in Girona (Spain) and maintains a blog at http://www.albertcoronado.com. You can contact him through LinkedIn (es.linkedin.com/in/albertcoronado/) or Twitter (@acoronadoc). Sandeep Nair has been working with Liferay for more than four years and overall has more than seven years of experience in Java and Java EE technologies. He has executed projects using Liferay in various domains such as construction, financial, and medical fields providing solutions such as Collaboration, Enterprise Content Management, and Web Content Management systems. He has created a free and open source Google Chartlet plugin for Liferay, which has been downloaded and used by people across 90 countries as per SourceForge statistics. Besides development, consulting, and implementing solutions, he has also been involved in providing training in Liferay in other countries. Before he jumped into Liferay, he had experience in Java and JavaEE platforms and has worked in EJB, Spring, Struts, Hibernate, and Servicemix. He also has experience in using JitterBit, which is an ETL tool. He has also authored Liferay Beginner's Guide and Instant Liferay Portal 6 Starter with Packt Publishing. When he is not coding, he loves to read books and write blogs.
  • 14.
    www.PacktPub.com Support files, eBooks,discount offers and more You might want to visit www.PacktPub.com for support files and downloads related to your book. Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at service@packtpub.com for more details. At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks. TM http://PacktLib.PacktPub.com Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can access, read and search across Packt's entire library of books. Why Subscribe? • Fully searchable across every book published by Packt • Copy and paste, print and bookmark content • On demand and accessible via web browser Free Access for Packt account holders If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view nine entirely free books. Simply use your login credentials for immediate access.
  • 16.
    Table of Contents Preface1 Chapter 1: Customizing Your Liferay Portal 9 Liferay functionalities 10 Documents and Media – CMS 10 Dynamic data lists and site/page/display templates 11 Web content management 11 Personalization and internalization 11 Workflow, staging, scheduling, and publishing 12 Social networking and Social Office 12 Understanding the tagging system 13 Integrating with Liferay Sync 13 Integrating with other systems easily 13 Leveraging framework and architecture for user interface development 14 Service Oriented Architecture 14 Understanding Enterprise Service Bus 15 Staging on standards 16 Customization and development strategies 17 Knowing about Ext plugins 19 Knowing about Hook plugins 21 Knowing about portlet and web plugins 23 Customizing the user interface through theme development frameworks 24 Building custom themes 25 Developing the user interface through layout template development frameworks 25 Alloy UI customization 26 Structure – HTML5 26 Style – CSS 3 27 Behavior – YUI 3 27 Alloy UI forms 28
  • 17.
    Table of Contents [ii ] JavaScript frameworks 29 Responsive themes 30 More useful information 30 Summary 32 Chapter 2: Basic Theme 33 Structure of a Liferay Portal page 34 Creating a theme 35 The default content of a custom theme 36 Theme inheritance 36 Theme folders and files 37 The docroot/_diffs folder 37 The docroot/css folder 39 The docroot/images folder 45 The docroot/templates folder 46 The docroot/WEB-INF folder 47 Deployment of the beet theme 48 Cloning the classic theme 51 Analyzing the portal_normal.vm file 51 Velocity variables available in a theme 61 Rendering a theme 63 Summary 64 Chapter 3: Layout Template 65 Out of the box layout templates 65 Creating our first layout template 67 Rendering a layout template 73 Available variables in a layout template 74 Developing a layout template based on the client's requirements 74 One more solution 79 Multiple layout templates in one package 79 Embedding portlets in a layout template 81 Responsive layout templates 85 It works like this 90 Source code 91 Adding source code into the Liferay IDE 92 Summary 92 Chapter 4: Content Collaboration and Publishing 95 Before we start 96 Static content versus dynamic content 96 Basic web content 97
  • 18.
    Table of Contents [iii ] Web content based on structure 100 Defining a structure 100 Templates 102 Regarding the web content 103 Developing web content based on a client's requirements 103 Design 104 Implementing the design 106 Analyzing the code 109 Self-contained web content 112 Velocity variables available for web content 113 Web content that accesses a database 114 Reading from a database 114 Code analysis 118 Writing to a database 119 Code analysis 120 Web content for interoperability 121 Displaying XML-formatted data 123 Code explanation 124 Displaying JSON-formatted data 125 JSON solutions 126 JSONP solutions 128 Publishing 130 Source code 131 Summary 132 Chapter 5: Portlet 133 Before we start 133 Understanding a simple JSR-286 portlet 134 The Spring MVC portlet 145 About the Vaadin portlet 152 Vaadin support in Liferay Portal 152 Vaadin portlet for CRUD operations 153 Vaadin portlet for retrieving portal information 158 Characteristics of Vaadin portlets 163 Source code 164 Summary 164 Chapter 6: JavaScript Frameworks and Portlets 165 Before we start 165 The jQuery UI 166 Creating a localized calendar with jQuery 166 User input masking 169
  • 19.
    Table of Contents [iv ] Understanding Ext JS 170 About the grid 171 Drawing charts 173 Dojo Toolkit 176 Ajax calls 179 Animation 181 OpenXava for autocoding 182 Analyzing OpenXava 189 Source code 189 Summary 190 Chapter 7: Advanced Theme 191 Creating a theme as per client requirements 191 The client's requirements 192 Analysis and design 193 Implementing the custom theme 193 Embedding portlets in a theme 201 Embedding a non-instanceable portlet 202 Embedding an instanceable portlet 202 Creating a responsive theme 203 Upgrading themes 206 Multiple-level navigation menus in themes 211 Implementing browser support in themes 214 Integrating Google Analytics 216 Source code 221 Summary 222 Chapter 8: Understanding Alloy UI/YUI 223 Knowing the background 224 Peeping into HTML5 224 Trying out CSS3 227 Working with YUI3 228 Learning Alloy UI tags 230 The Button tag 230 The Button row tag 231 The Column tag 231 The Fieldset tag 232 The Input tag 232 The Layout tag 233 The Link tag 233 The Model-context tag 234 The Option tag 234
  • 20.
    Table of Contents [v ] The Select tag 234 Getting familiar with Node and Nodelist 236 Learning Node properties 238 Creating events 238 More Node methods 239 Manipulating Nodelist 240 Exploring Node queries 240 Making Ajax calls in Alloy UI 241 Understanding a plugin 244 Finding out widgets in Alloy UI 245 Creating a TreeView instance 245 Creating a data table instance 247 Starting an animation 249 Creating a drag-and-drop instance 250 Coding a delayed task 250 Implementing Overlay and OverlayManager 252 Creating an image gallery 253 Coding SWF file playback 254 Learning other Alloy UI features 254 Implementing the autocomplete feature 254 Creating a character counter 255 Resizing a DOM element 256 Coding a sortable list 256 Creating a tooltip instance 257 Knowing the benefits of using Alloy UI 258 Source code 258 Summary 258 Chapter 9: Using UI Taglib 259 Getting started with the UI tag 260 Understanding the asset tag and category 261 Setting up related assets 262 Asset tags and category settings 263 Getting to know the configuration 265 Things that happened 266 Using the search container 267 Displaying search results 267 Adding columns 269 Search form and search toggle 270 Understanding columns within columns 271 Adding a paginator 272 Speed and iterator 272
  • 21.
    Table of Contents [vi ] Getting to know the configuration 273 Let's find out what happened 273 Adding custom attributes 274 Understanding the settings for custom attributes 275 Getting to know the configuration 276 Knowing what happened 276 Using tabs, toggle, and calendar 276 Using the liferay-ui:tabs and liferay-ui:section tags 277 Applying the liferay-ui:toggle and liferay-ui:toggle-area tags 278 Applying the liferay-ui:calendar tag in a JSP page 279 Using breadcrumb, navigation, and panel 279 Understanding the settings 280 Getting to know the configuration 281 Adding social activity tracking and social bookmarks 282 Understanding the settings 282 Getting to know the configuration 283 Understanding what happened 283 Using the discussion, ratings, diff, and flags tags 284 Understanding the settings 284 Getting to know the configuration 286 Adding icons and input forms 287 Getting to know the icon tag settings 287 Learning the input tag and its settings 288 Integrating with CKEditor 290 Enabling SCAYT settings 291 What just happened? 292 Getting to know the configuration 293 Updating content with inline editing 293 Features of inline editing 294 Implementing inline editing 294 Using inline editing 295 Something more 295 Getting to know the configuration 298 Integrating with special sound UI reCAPTCHA 298 Things that happened 299 Summary 300 Chapter 10: Responsive Mobile Theme, Reporting, Searching, and More 301 Using jQuery in plugins 302 Building jQuery portlets 302
  • 22.
    Table of Contents [vii ] Adding jQuery in themes 304 Using jQuery in Alloy UI 304 Knowing workflow capabilities in plugins 305 Preparing a plugin – Knowledge Base 306 Understanding the folder structure 307 Services and models 308 Adding a workflow instance link 308 Adding a workflow handler 309 Updating workflow status 310 Adding workflow-related AUI tags 311 The point of download for the Knowledge Base plugin 312 Custom attributes in plugins 313 Adding custom attribute capabilities 313 Adding custom attributes in plugins 314 Adding custom attributes as references 314 Adding custom attribute display 314 Adding custom attribute capabilities when creating, updating, and indexing custom entities 315 Adding custom attribute UI tags 316 Finding the sample code 317 OpenSocial, Social Activity, and Social Equity in plugins 317 Knowing OpenSocial 318 Getting to know the working 318 Using OpenSocial 320 Finding the sample code 320 Understanding Social Activity 320 Registering social activity tracking in plugins 320 Using Social Equity 321 Adding Social Equity capabilities to plugins 322 Things that happened 323 Friendly URL routing and mapping in plugins 323 Understanding URL routing 323 Things that happened 324 Getting to know reporting portlets 325 Bringing JasperReports into your portal 325 Getting to know Lucene indexing, search API, and faceted search in plugins 327 Experiencing Lucene indexing and search API 327 Understanding faceted search 328 Building faceted search in plugins 329 The responsive theme approach 330 Getting to know about the AUI responsive theme 331 Understanding what happened 331
  • 23.
    Table of Contents [viii ] Understanding the Bootstrap responsive theme 332 Building the Bootstrap responsive theme 332 Knowing device detection rules 333 Mobile device API 333 Bringing WURFL into your portal 334 Building a mobile theme 335 Delving into jQuery Mobile 336 Benefits of the jQuery Mobile theme 337 Building a jQuery Mobile theme 338 Deploying themes 339 Deploying themes as static content 339 UI performance tuning 340 Summary 342 Index 343
  • 24.
    Preface The Liferay Portalis the most popular open source portal product on the market. Since its creation in 2000, numerous companies and organizations have set up their websites using the Liferay Portal. The Liferay Portal is an end-to-end product. A user can download a Liferay Portal bundle, unzip it, and run it. The Liferay Portal is also well-known for its award-winning user interface (UI). Its UI has three layers: theme, page layout, and portlets. It allows a user to apply different themes to different portal pages. A user can drag-and-drop a portlet to any cell of a page layout. The user can configure the look and feel of the Liferay Portal through the user interface. In the beginning, the Liferay Portal UI consisted of a home-grown JavaScript application programming interface (API) and JavaServer Pages Standard Tag Library (JSTL). As the Liferay Portal became more and more popular, Liferay started an Alloy UI project in 2010 to meet the demand for easy UI coding. The Liferay Portal has been using Alloy UI since Version 6.0. Liferay 6.2 User Interface Development is an endeavor to explain the Liferay Portal UI from the inside out. It leads you through examples so that you can create your own themes as quickly as possible. The book tells you how to add a portal page and change its look and feel. Its explicit instructions are accompanied by plenty of source code. With the open source nature of the Liferay Portal, you will find a user-friendly environment to design themes using the latest user interface technologies. The book starts off by showing you how you can structure a Liferay Portal page. It identifies the components of a portal page: theme, page layout, and portlets. Its hands-on tutorials explain themes, portlets, and Alloy UI in an easy-to-understand manner. It covers all aspects of a theme from its inception and implementation through to rendering with in-depth analysis.
  • 25.
    Preface [ 2 ] Thisbook talks about developing portlets in different technologies: simple JSR 286 portlets, Spring MVC portlets, and Vaadin portlets. It deliberates on Alloy UI 2.0. The book also explains how to use jQuery, Ext JS, and Dojo Toolkit in Liferay Portal UI development. By the end of this book, you will clearly understand themes, page layouts, and Alloy UI. More importantly, you will obtain the skills to successfully develop a theme and layout template. You will also know how to use them on a portal page through user interface configuration. With its clear, concise, and practical tutorials, this book will ensure that you develop the skills to become a competent Liferay Portal UI developer. The detailed instructions are accompanied by source code that you can learn and update to add custom features. This book contains original content on solutions to real problems encountered in real-world projects. Most of the content in the book originates from the authors' experience with projects they've worked on. It will be an important guide for you in mastering the customization of the look and feel of the Liferay Portal. What this book covers Chapter 1, Customizing Your Liferay Portal, introduces you to the Liferay products. It also describes the Liferay Portal architecture and features. It talks about Liferay customization and development strategies. It elaborates on the development environment and the Liferay Integrated Development Environment (IDE), including the theme plugin, portlet plugin, hook plugin, and Ext plugin. Chapter 2, Basic Theme, is about the basics of Liferay Portal themes. It talks about the layers of a Liferay Portal page. It describes the steps to create a theme in the Liferay IDE. The chapter talks about the functionality of each file in a Liferay theme. It especially looks into the portal_normal.vm file in depth. It also introduces you to Sass and Compass, which are new technologies used in the Liferay Portal. Chapter 3, Layout Template, introduces out-of-the-box Liferay layout templates and describes the steps required to create a custom layout template in the Liferay IDE. This chapter talks about the method to create a thumbnail image for a layout template. It analyzes the code of the custom layout template in detail. It explains the procedure to create a layout template based on a client's requirements. It also talks about embedding portlets in a layout template. It finally describes how to create a responsive layout template.
  • 26.
    Preface [ 3 ] Chapter4, Content Collaboration and Publishing, talks about basic web content and structure-based web content in the Liferay Portal. It introduces a method to create web content using images, videos, and the Velocity template language. It describes a way to access the database in web content. It also shows examples of calling web services in the web content for Internet interoperability. Chapter 5, Portlet, focuses on portlet development. It introduces the ways to develop simple JSR 286 portlets, Spring MVC portlets, and Vaadin portlets. It describes how to implement the view, edit, and help modes of a portlet, code Ajax calls, and develop portlet events for inter-portlet communication. Chapter 6, JavaScript Frameworks and Portlet, talks about integrating third-party user interface frameworks into the Liferay Portal. It talks about adding a calendar in a Liferay portlet using jQuery. It introduces a chart into a Liferay portlet with the Ext JS library. It also describes how to animate with Dojo Toolkit. This chapter proves that the Liferay Portal has an open structure that accommodates various third-party user interface APIs. Chapter 7, Advanced Theme, talks about developing advanced skills for Liferay theme development. It introduces a procedure to create a custom theme in accordance with a client's requirements. It describes developing responsive features in a theme. It shows how to embed a portlet in a theme. It also describes the procedure to update a theme of an older version. It talks about how to create a three-level navigation menu and implement browser detection in a theme. It describes how to integrate Google Analytics in a custom theme. Chapter 8, Understanding Alloy UI/YUI, explains the Alloy user interface in detail. It talks about Alloy UI extending Yahoo UI. It describes new features in HTML5, CSS3, and YUI3. It explains Alloy UI tags and how to use them in a portlet and also Alloy UI modules and widgets and how to use them in a portlet. Chapter 9, Using UI Taglib, talks about the JSTL of the Liferay Portal. It describes the Liferay Portal tags by category. It explains the configuration of tags and how to use them in coding. Chapter 10, Responsive Mobile Theme, Reporting, Searching, and More, talks about adding jQuery in plugins. It explains how to implement workflows and custom attributes in the Liferay Portal using a plugin called the Knowledge Base portlet. It describes how to integrate JasperReports with the Liferay Portal and Lucene indexing, search API, and faceted search in plugins. It also talks about building a responsive mobile theme.
  • 27.
    Preface [ 4 ] Whatyou need for this book This book is based on Liferay Portal Version 6.2. The following software, source code, and documentation have been used in writing this book. It is recommended that you also download these resources when you are reading this book and running the source code enclosed within it. The source code is available for download at the Packt Publishing website: • MySQL database server Version 14.14 Distribution 5.6.12 • Java JDK Version 1.6.0_45 • Eclipse-jee-juno-SR1-win32-x86_64 • Liferay IDE 1.6.2 • Liferay-portal-tomcat-6.2.0-ce-m2 • Liferay-portal-src-6.2.0-ce-m2 • Liferay-portal-doc-6.2.0-ce-m2 • Liferay-plugins-sdk-6.2.0-ce-m2 You may use software of the same versions as listed in the preceding list or newer versions. All the previously mentioned software, source code, and documentation can be downloaded from public websites such as Eclipse and SourceForge. Who this book is for This book is for readers who know how to use Java and have done some programming for Java web applications. No prior knowledge about the Liferay Portal is needed. It will also cater to Liferay Portal developers who have already learned how to use the Liferay Portal or who have worked on Liferay Portal projects. This book will show you how the Liferay Portal works and why it works in that way. Liferay 6.2 User Interface Development is also for architects who work on Liferay Portal projects. This book includes the best practices in Liferay Portal customization and the latest technologies and techniques used in project implementation. This book is also a good reference for any software engineer because it talks about a lot of aspects of information systems—the Liferay Portal is an encyclopedia of information technologies.
  • 28.
    Preface [ 5 ] Conventions Inthis book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning. Code words in text are shown as follows: "When the keyword showAssetCount is set to true, the keyword displayStyle would have the value Number or Cloud." A block of code is set as follows: <liferay-ui:icon image="myImage_thumb" message="show-full-image-message" url= "<%= showFullImage %>" /> When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold: <liferay-ui:input-editor editorImpl="ckeditor" inlineEdit="<%= true %>" inlineEditSaveURL="<%= updateContentURL %>" inlineEditContentURL="<%= editContentURL %>" name="<%= updateContentId %>" /> New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "Icons of the inline editing mode include Source, Save, Cancel, Edit, and so on." Warnings or important notes appear in a box like this. Tips and tricks appear like this.
  • 29.
    Reader feedback Feedback fromour readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of. To send us general feedback, simply send an e-mail to feedback@packtpub.com, and mention the book title via the subject of your message. If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors. Customer support Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase. Downloading the example code You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you. Errata Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub. com/submit-errata, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.
  • 30.
    Piracy Piracy of copyrightmaterial on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy. Please contact us at copyright@packtpub.com with a link to the suspected pirated material. We appreciate your help in protecting our authors, and our ability to bring you valuable content. Questions You can contact us at questions@packtpub.com if you are having a problem with any aspect of the book, and we will do our best to address it.
  • 32.
    Customizing Your Liferay Portal LiferayPortal is the world's leading open source portal platform, providing a unified web interface for data, tools, and system integrations scattered across a large number of resources and devices. Within the portal, the portal web page interface is composed of a number of portlets. These portlets are self-contained interactive elements written to a particular standard, such as JSR 168 or JSR 286. As portlets are built independent of the portal and are loosely coupled with the portal, they are built apparently using Service Oriented Architecture (SOA). This book will show you how to develop and/or customize user interface of intranets or Internet browsers with Liferay. In this chapter, we will look at: • The features your user interface will have by the time you reach the end of this book • Liferay Portal framework and architecture for customization • Liferay Portal user interface customizing development strategies • Themes (including mobile themes—site preview, responsive themes, and device recognition), layout templates, hooks, and Alloy UI (including Bootstrap, dockbar, and Accessibility) development and customization • Finding more technical information about what Liferay is and how it works Therefore, this book begins by looking at exactly what Liferay Portal is, what portlets and Social Office are, and how they work to customize user interface.
  • 33.
    Customizing Your LiferayPortal [ 10 ] Liferay functionalities Liferay currently has the following main functionalities: • Liferay Portal: An enterprise portal platform using particular standards, such as JSR 168/JSR 286. • Liferay CMS and WCM: A JSR 170 based content management system and a structure-template based web content management system. • Liferay Collaboration: It includes a number of collaboration portlets, such as blogs, calendars, social media, web forms, webmail, message boards, polls, ratings, RSS feeds, Wiki pages, presence (AJAX chat clients, dynamic friend lists, activity walls, and activity trackers), alerts, and announcements. • Liferay Social Office: A social collaboration is a special portal instance on top of the portal. It provides a dynamic team workspace solution where all you have to do is log in and work in your own way at your convenience. • Liferay Sync: It transforms the Liferay platform into a central, easy-to-use document-sharing service across a range of devices. In short, a website built by Liferay might consist of a portal, CMS, and WCM. It might also include Collaboration and/or Social Office and a large number of custom plugins/portlets. Documents and Media – CMS Documents and Media is a useful tool to manage content including images, documents, videos, and audio. For example, within Documents and Media, you can add folders and subfolders for documents to manage and publish them. The Content preview capability is available for some types of content, such as Word or PDF. In addition, multiple repositories are supported. Thus, you use the default repository or web services to connect to other repositories like Alfresco. Documents and Media makes up the Content Management System's (CMS) available for both intranet and the Internet. It is equipped with customizable folders and acts as a web-based shared drive for all your team members, no matter where they are. As the content is accessible only by those authorized by administrators, each individual file (either a document or an image) is as open or as secure as you would need it to be.
  • 34.
    Chapter 1 [ 11] Dynamic data lists and site/page/display templates Dynamic data lists allow users to graphically define schema and templates, customize the input forms and the output format, define a workflow for approving captured information, and to a process that gathers data at various stages in the workflow. Site templates allow users to define pages and web content to be included while creating sites and organizations. Page templates, similar to site templates at the page level, allow users to provide a preconfigured page to be reused. Application display templates allow users to apply templates to certain portlet types. Application display templates work similarly to site templates and page templates at the portlet level. Application display templates allow portal administrators to override the default display templates, removing limitations to the way the site's content is displayed. Web content management Your company may have a lot of HTML text, audio, videos, images, and documents using different structures and templates, and you may need to manage all these HTML text, images, and documents as well. Therefore, you require the ability to manage a lot of web content and then publish web content on intranets and/or the Internet. Web content is organized in folders and subfolders in the same way as Documents and Media is. In addition, Recycle Bin has been supported for Web Content—you can easily restore your deleted files. We will see how to manage web content and how to publish web content within Liferay Portal. Web Content portlets not only provide high availability to create, edit, publish, manage, and maintain web content, but they also separate content from structures and layout templates. Generally speaking, Web Content Management (WCM) allows us to create, edit, and publish web content (articles) as well as article templates and article structures. It also has built-in workflow, article versioning, search, permissions, and metadata. Personalization and internalization All users can get a personal space that can be either made public (published as a website with a unique, friendly URL) or kept private. In fact, users can have both private and public pages at the same time. You can also customize how the space looks, what tools and applications are included, what goes into the Documents and Media portlet, and who can view and access all of this content.
  • 35.
    Customizing Your LiferayPortal [ 12 ] In addition, you can publish your portal website using your own language. Within the portal, multilingual organizations get support for up to 45 languages such as Hindi, Hebrew, and Ukrainian. Switching language from one to another in the portal is straightforward. Users can simply click once to toggle different language settings and/or produce and publish multilingual documents and web content. Users can also easily add other languages on public/private pages, other sites, or other organizations. Workflow, staging, scheduling, and publishing You can use workflows to manage definitions, instances, and tasks. You can also use the web content article two-step workflow, staging workflow, jBPM workflow, Kaleo workflow, and Intlio | BPMS. The jBPM workflow and/or Kaleo workflow can be applied on any assets, such as web content articles, Document Library, documents and media, blogs, wiki pages, and custom assets. Kaleo is the default workflow engine of Liferay, and you will get it out of the box. Others like jBPM and Intlio are not available out of the box. In addition, the portal allows you to define publishing workflows that track changes to web content, documents, and media, as well as the pages of the site in which they reside. Kaleo Forms is an extension of dynamic data lists, enabling us to create web forms and basic applications first and then apply a workflow to govern the processing of those forms. Kaleo Designer is a drag-and-drop interface used for creating new workflow definitions. Social networking and Social Office Liferay Portal supports social networking—you can easily own your accounts in Liferay with Facebook, MySpace, and Twitter among others. In addition, you can manage your instant messenger accounts in Liferay Portal smoothly such as AIM, ICQ, Jabber, MSN, Skype, and YM. Social Office gives us a social collaboration on top of the portal—it provides a fully virtual workspace with streamlined communication and built-up group/community cohesion. All components in Social Office are tied together seamlessly, getting everyone on the same page by sharing the same look and feel. More importantly, the dynamic activity tracking gives us a bird's-eye view of who has been doing what and when within each site.
  • 36.
    Chapter 1 [ 13] Understanding the tagging system The portal-tagging system allows us to tag web content, documents and media, message board threads, wiki pages, blog entries, custom assets, and more, and we can dynamically publish these assets by tags. Tags provide a way of organizing and aggregating content. Folksonomies is a user-driven approach to organizing content through classification of tags. It is cooperative and communicates through shared metadata. The portal implements folksonomies through tags. Taxonomies is a hierarchical structure used in scientific classification schemes. The portal implements taxonomies as vocabularies and categories (including category hierarchy) in order to tag content and classify it. Integrating with Liferay Sync Liferay Sync integrates with existing authentication systems. Either Liferay or an external SSO solution, Sync will automatically and securely authenticate with existing credentials. In summary, Sync enables users to publish and access documents and files from multiple devices. Integrating with other systems easily In particular, the portal provides an integrating framework so that you can integrate external applications easily. For example, you will be able to integrate external applications such as Alfresco, OpenX, LDAP, SSO CAS, Orbeon Forms, KonaKart, PayPal, Solr, Coveo, Salesforce, SugarCRM, JasperForge, Drools, and jBPM. In addition, the portal has got the OSGi framework. That is, the portal is going to support a module system and service platform for the Java programming language that implements a complete and dynamic component model. Refer to http://www.osgi.org. In short, the portal offers compelling benefits to today's enterprises—reduced operational costs, improved customer satisfaction, and streamlined business processes.
  • 37.
    Customizing Your LiferayPortal [ 14 ] Leveraging framework and architecture for user interface development Liferay Portal architecture provides high availability for mission-critical applications, such as clustering fully distributed cache, replication across multiple application servers, and integrating many other systems. The following diagram shows a number of architectural layers and functionalities of portlets: Service Oriented Architecture Liferay Portal leverages Service Oriented Architecture (SOA) design principles and provides a set of tools and frameworks to extend SOA in order to integrate with other enterprise applications smoothly. Within SOA architecture, users can access the portal from a large range of devices, ranging from traditional to mobile devices, but also from exposed APIs, for example, web services, REST, SOAP, RMI, XML-RPC, XML, JSON, Hessian, Burlap, and custom-tunnel classes.
  • 38.
    Chapter 1 [ 15] Generally speaking, Liferay Portal is designed to create/develop/deploy portlets (or specific plugins) which are compliant with both JSR 168 and JSR 286 standards. There are a set of useful built-in plugins/portlets such as Documents and Media, Calendar, Message Boards, Blogs, Wikis, and more. These built-in plugins/portlets will be used as examples for building custom plugin portlets. In a nutshell, the main features of Liferay Portal include using SOA design principles, adding reliable security, integrating with SSO and LDAP, integrating with other systems, CMS, WCM, dynamic data lists, various structures and ranges of multitier templates, limitless clustering, high availability of portlets, caching pages, dynamic virtual hosting, YUI-based AUI JavaScript frameworks, and more. Understanding Enterprise Service Bus The Enterprise Service Bus (ESB) is, generally speaking, a central connection manager allowing applications and services to be added quickly to an enterprise infrastructure. Whenever an application needs to be replaced in the ESB, it can be easily disconnected from the ESB at a single point. Liferay Portal has a defined default ESB, and it can leverage Mule or ServiceMix as the ESB. In brief, Liferay Message Bus is a service-level API used to exchange messages within the portal. More precisely, the Message Bus is a mechanism for sending message payloads to different components in the portal, providing loose coupling between message producers and consumers. Through the ESB, as shown in the preceding diagram, the portal can integrate with SharePoint, BPM (such as jBPM workflow engine and Intalio | BPMS engine), the rule engine, BI Xforms reporting, JCR repositories, Advertisements, SugarCRM, and e-commerce, among others. With the integration of JCR repositories such as Jackrabbit, it also supports JSR 170 for content management systems. In addition, it uses Hibernate and JDBC to connect to any database. Furthermore, it supports event-based asynchronous messaging and lightweight message bus mechanisms. Furthermore, the portal uses the Spring framework for its business and data service layers, for example, using the Spring framework for its transaction management. Based on service interfaces, that is, the Spring framework, portal-implementation is done and exposed only for internal usage. For example, they are used for the extension environment only. The portal-kernel and portal-service (these two are merged into one package) are provided for external-usage and remote-service calls or for internal-usage and local-service calls. For example, they are used for the Plugins SDK environment. Custom portlets compliant with both JSR 168 and JSR 286, JSON services, and web services can be built based on the portal-kernel and portal-service.
  • 39.
    Customizing Your LiferayPortal [ 16 ] Furthermore, the Web 2.0 Mail, Calendar, and Chat portlets are supported as well. Staging and remote publishing are supported too, for example, scheduled staging and remote staging—and publishing as a foundation through tunnel web—provide the capability to publish web content easily or to publish portlets in a page, a set of pages, or a specific site. Liferay Portal supports web services and JSON web services to make it easy for different applications in an enterprise to communicate with one another. Java, .NET, PHP, and proprietary applications can work together smoothly since web services use XML standards and JSON web services use JSON standard. Besides these features, it also supports REST-style JSON web services for lightweight and maintainable code. AJAX-based user interfaces are supported as well. Liferay Portal follows industry-standard, government-grade encryption technologies, including advanced algorithms such as DES, MD5, and RSA. For this reason, Liferay Portal was benchmarked as one of the most secure portal platforms using LogicLibrary's Logiscan suite. Liferay Portal also offers customizable single sign-on with Yale CAS, JAAS, Netegrity, Microsoft Exchange, LDAP, NTLM, and more. Open ID, OpenAuth, Yale CAS, Facebook, Siteminder, and OpenSSO (renamed OpenAM) integration are supported as well. In summary, the portal uses the ESB in general with an abstraction layer on top of an enterprise messaging system, allowing integration with both synchronous and asynchronous messaging systems, such as reporting, e-commerce, and advertisements. As you can see, understanding the framework and architecture would be helpful to customize user interface in a proper way. Staging on standards The portal is based on Standards with more technical benefit. However, if you want to use the portal in a more specialized way, understanding these standards would help. The features/standards that Liferay is using are listed as follows: • Built using Java: As a very popular programming language, Java code can run on any computer. • Based on components: Some of the well-known components and technologies are Apache ServiceMix, Mule, ehcache, Hibernate, JQuery, ICEfaces, Primefaces, Java J2EE/JEE, jBPM, Intalio | BPMS, JGroups, Alloy UI, Lucene, PHP, Ruby, Seam, Spring and AOP, Struts and Tiles, Tapestry, Velocity, and FreeMarker.
  • 40.
    Chapter 1 [ 17] • Based on standards to communicate with other systems: The standards implemented by Liferay include AJAX, iCalendar, and Microformat, JSR 168, JSR 127, JSR 170, JSR 286 (Portlet 2.0), and JSR 314 (JSF 2.0), Faceted search, OpenSearch, Open platform with support for web services (including JSON, Hessian, Burlap, REST, RMI, and WSRP), WebDAV, and CalDAV. • WCAG 2.0 (Web Content Accessibility Guidelines) compliant: The portal standard integrated with CKEditor 4.x. supports W3C (WAI-AA and WCAG), WAI-ARIA, and 508 (Section 508). • Alloy UI: Based on HTML5, CSS 3 and Yahoo! User Interface Library (YUI3). • Apache Ant 1.8 and Maven 2.2: Liferay Portal can be built through either Apache Ant or Maven 2 SDK. Many of these standards are things that you will never need to know much about, so don't worry if you've never heard of them. Liferay is better for using them, but mostly, you won't even know they are there. Of course, user interface could be standardized too. Therefore, when developing and/or customizing user interface, you can leverage the standards that Liferay Portal is using. Customization and development strategies Liferay is first and foremost a platform where you can build your applications using use the tools you feel most comfortable with, such as Icefaces, Struts 2, Spring MVC, Vaadin, jQuery, and Dojo. Of course, you're not required to write a lot of code for yourself. You can use the Service-Builder to generate a lot of code. Generally speaking, the Service-Builder is a tool built by Liferay to automate the creation of interfaces and classes that are used by a given portal or portlet. The Service-Builder is used to build Java services that can be accessed in a variety of ways, including local access from Java code and remote access using web services. Generally speaking, the Service-Builder is a code generator using an XML descriptor: • Java Beans • SQL scripts for the creation, update, and deletion of database tables • Hibernate Configuration • Spring Configuration • Local services, remote services, and finder services • Axis web services • JSON JavaScript Interface
  • 41.
    Customizing Your LiferayPortal [ 18 ] In brief, a plugin SDK environment is a simple developing environment for the development of portal plugins. These custom plugins are completely separate from the portal's core services by their use of external services only if required. The portal supports at least six different types of plugins by default: Portlets, Themes, Layout Templates, Webs, Hooks, and Ext. Here is a brief description of each of the aforementioned types of plugins: • Portlets: These are web applications in general that run in a portion of a web page • Themes: These are the defined look and feel of pages • Layout Templates: These are the ways provided to change how the portlets will be arranged on a web page • Hooks: It allows hooking into the portal core functionality and JSP files • Webs: Webs plugins are regular Java web modules designed to work with the portals, such asEnterprise Service Bus (ESB), Single Sign-On (SSO), Workflow Kaleo, and Wireless Universal Resource FiLe (WURFL) Note that a web plugin is purely a web application where a thin layer is added to provide checking for dependencies. A web plugin also supports embedding hook definition and/or Service-Builder services. And finally, you can deploy them using the auto-deploy mechanism the same way that you do with other plugins. • Ext: The Ext environment is a plugin, that is, you can use the extension environment as a plugin in the plugins SDK environment. As you can see, you can generate code for plugins, portlets, and webs. Normally, you can have one project for one plugin, for example, theme, layout template, hook, ext, and web. You can also have many portlets in one plugin project portlet. Hook plugins could be standalone or can stand with portlets. That is, in one plugin project portlet, you can have hooks and many portlets as one WAR file. As you can see, user interfaces can be customized or developed within these plugins, mostly in the form of portlets, themes, layout templates, hooks, webs, and ext. Liferay IDE is used to provide best-of-breed Eclipse tooling for Liferay Portal development platform for Version 6 and beyond. The availability of Liferay IDE cover is not limited to plugin SDK support, plugin projects support, project import and conversion, wizards, code assist such as portlet taglibs, customizable templates, and XML catalogue (DAT/XSD) contributions.
  • 42.
    Chapter 1 [ 19] Knowing about Ext plugins The Extension environment provides the capability to customize the portal core completely. It is an environment extending the portal development environment, so it has the name Extension (Ext). With Ext, we can modify internal portlets called built-in portlets. Furthermore, we can override the JSP files, CSS files, HTML files, and JavaScript files of the portal and the built-in portlets. This kind of customization is kept separate from the portal source code. That is, the portal source code does not have to be modified; therefore, a clear upgrade path is available in Ext. From Version 6 (including 6.2), the Ext environment is converted into a plugin called the Ext plugin. As shown in the following figure, the custom code will override the portal source code in the Ext plugin only. In the deployment phase, custom code will be merged with the portal source code in Ext. At the end, developers override the portal source code effectively. Moreover, custom code and the going-to-be-overridden portal source code will be constructed as a customized going-to-be-overridden portal in Ext first and then the customized going-to-be-overridden portal source code will be deployed from Ext to the application server. During customization, you could use the Service-Builder, but this function was deprecated and is now used to generate models and services. Note that Service-Builder is deprecated for the Ext plugin. Therefore, you should use Service-Builder for the portlet plugin and the web plugin only. In general, the Service-Builder is a code generator using an XML descriptor. For a given XML file service.xml, it will generate SQL for creating/updating/deleting tables, Java Beans, Hibernate configuration, Spring configuration, caching services, local services, remote services, finder services, Axis Web Service, JSON JavaScript Interface, among others.
  • 43.
    Customizing Your LiferayPortal [ 20 ] JSP files of the portal and the built-in portlets can be overridden with custom JSP files in Ext. Note that Ext is used to customize the portal only, since portlets built in the Ext plugin are not very deployable; moreover, the Ext plugin is a monolithic environment. Under the ${ext.plugin.project}/docroot/WEB-INF directory, you'll see a lot of folders starting with ext-* as shown in the following list: • ext-impl/src: This contains code that will override portal-impl/src • ext-lib/global: This contains JARs that are available in the global class loader • ext-lib/portal: This contains JARs that are available only to the portal class loader • ext-service/src: This contains code that will override portal-service/ src • ext-util-bridges/src: This contains code that will override util- bridges/src • ext-util-java/src: This contains code that will override util-java/src • ext-util-taglib/src: This contains code that will override util-taglib/ src • ext-web/docroot: It contains code that will override portal-web Note that if you modify ext-web/docroot/WEB-INF/web.xml, these changes would be merged into portal-web/WEB-INF/web.xml. ext-web also contains /WEB-INF/*- ext.xml files that are used to override what is in the portal-web folder.
  • 44.
    Chapter 1 [ 21] As you can see, the Ext plugin works in a way that is very similar to that of the Ext environment, but it, as a plugin, is much smaller and lighter in weight. Knowing about Hook plugins Hooks provide functions to catch hold of the properties and JSP files into an instance of the portal as if catching them with a hook. Hook plugins are more powerful plugins that complement portlets, themes, layout templates, ext, and webs. A hook plugin can be combined with a portlet plugin or a standalone plugin. For instance, the portlet so-portlet is a portlet plugin for Social Office with hooks; a hook plugin could simply override language properties or override JSP pages. In general, hooks are very helpful tools to customize the portal without touching the code part of the portal as shown in the following screenshot.
  • 45.
    Customizing Your LiferayPortal [ 22 ] In addition, you would use hooks to provide patches for the portal systems or Social Office products. In general, there are a set of hook parameters that should be specified in the following order: • portal-properties (called portal properties hooks) • language-properties (called language properties hooks) • custom-jsp-dir (called custom JSPs hooks) • service (called portal service hooks) • Filters hooks • Indexer post processor hooks • Struts action hooks The following sample code is abstracted from $PORTAL_ROOT_HOME/dtd/liferay- hook_6_2_0.dtd: <!ELEMENT hook (portal-properties?, language-properties*, custom-jsp-dir?, custom-jsp-global?, indexer-post-processor*, service*, servlet- filter*, servlet-filter-mapping*, struts-action*)> <!ELEMENT portal-properties (#PCDATA)> <!ELEMENT language-properties (#PCDATA)> <!ELEMENT custom-jsp-dir (#PCDATA)> <!ELEMENT indexer-class-name (#PCDATA) <!ELEMENT indexer-post-processor-impl (#PCDATA)> <!ELEMENT service (service-type, service-impl)> <!ELEMENT service-type (#PCDATA)> <!ELEMENT service-impl (#PCDATA)> <!ELEMENT servlet-filter-name (#PCDATA)> <!ELEMENT servlet-filter-impl (#PCDATA)> <!ELEMENT struts-action-path (#PCDATA)> <!ELEMENT struts-action-impl (#PCDATA)>
  • 46.
    Chapter 1 [ 23] As shown in the preceding code, the ordering of elements is significant in the Document Type Definition (DTD), that is, you need to have your portal properties (only one marked by ?), language properties (could be many marked by *), custom-jsp-dir (only one marked by ?), and indexer post processor, service, servlet filter, and struts action (could be many marked by *) declared in the same order. Language properties hooks allow us to install new translations or override a few words in existing translations. JSP hooks provide a way to easily modify JSP files without having to alter the core of the portal, whereas portal properties hooks allow runtime reconfiguration of the portal. Portal indexer/service/servlet filter/struts action hooks provide a way to easily override the portal indexer post processor, services, servlet filters, and struts actions. The portal configuration properties can be altered by specifying an overridden file, where the properties will immediately take effect when deployed. For example, you can enable auditing capabilities by deploying hooks. Note that not all portal properties can be overridden using hooks. Knowing about portlet and web plugins As you can see, the plugins SDK is a simple environment for the development of portal plugins, including portlets and webs. It provides the capability to create hot-deployable portlets and webs. How does it work? As shown in the following figure, the plugins SDK provides an environment for developers to build portlets and webs. Afterwards, it uses either Ant Target Deploy or Maven to form a WAR file and copies it to the Auto Deploy directory. Then, the portal, together with the application server, detect any WAR files in the auto hot-deploy folder and automatically extract the WAR files into the application server deployment folder. Note that the portal automatically recognizes the type of plugin and enhances it appropriately before hot-deploying. For example, the portlet's web.xml file will be modified with the required listeners and filters.
  • 47.
    Customizing Your LiferayPortal [ 24 ] Customizing the user interface through theme development frameworks Generally speaking, a theme defines the styles of all portlets and content in a web page, so it controls the way the portal looks. Programmatically, a theme includes a set of CSS, images, JavaScript, and Velocity templates—four groups—to control the whole look and feel of the web pages generated by the portal. Therefore, when building customized themes, you need to consider these four groups as well. From a folder-structure viewpoint, the theme is made up of a folder, _diffs, with four subfolders, css, images, javascript, and templates; a folder, WEB-INF, with a properties file called liferay-plugin- package.properties; and an XML file called liferay-look-and-feel.xml. The portal will handle the following steps when you build a theme. First of all, as shown in the following figure, when you deploy theme, the plugins SDK will copy all files from the folder ${app.server.portal.dir}/html/themes/_ unstyled/ to the folder $PLUGINS_SDK_HOME/themes/${theme-name}/docroot/. In fact, this will happen during build time instead of deploy time. Secondly, the plugins SDK will copy all files from the folder ${app.server.portal. dir}/html/themes/_styled/ to the folder $PLUGINS_SDK_HOME/themes/${theme- name}/docroot/. And then, the plugins SDK will copy all files from the folder $PLUGINS_SDK_HOME/ themes/${theme-name}/docroot/_diffs/ to the folder $PLUGINS_SDK_HOME/ themes/${theme-name}/docroot/. This means that the plugins SDK is going to override existing files with new files and change files under the folder $PLUGINS_SDK_HOME/themes/${theme-name}/ docroot. Here the ${theme-name} object refers to a real-theme project name. Afterwards, you will see four folders, css, images, javascript, and templates, under the folder $PLUGINS_SDK_HOME/themes/${theme-name}/docroot. And each folder contains all the required merged files and subfolders from /_unstyled, /_styled, and /_diffs.
  • 48.
    Chapter 1 [ 25] Building custom themes In a word, the best way to build a custom theme is to put only the differences of the custom theme (the four groups—CSS, images, JavaScript, and templates) into the folder ${theme-name}/docroot/_diffs. Here, ${theme-name} refers to any real-theme project name, for example, book-street-theme. Using this best practice, you only need to put custom CSS, images, JavaScript, and templates in the folder /_diffs. More precisely, in the folder /_diffs/css, just create a CSS file called custom.css. You should place all of the custom CSS files different from the default folder. By placing custom CSS in this folder and not touching the other default files, you can be assured that upgrading this theme later on will be more straightforward. In order to include custom images in the folder /_diffs/images, put all custom images with subfolders. For example, create two images, screenshot.png and thumbnail.png, to show how a page with the current theme looks. And furthermore, create a subfolder, searchbar, and put all search-related images in the folder /searchbar. In order to include custom JavaScript in the folder /_diffs/javascript, create a JavaScript file called javascript.js. The portal includes the YUI library by default. Thus, in the theme, you can include any JavaScript plugins that YUI supports. To include templates in the folder /_diffs/templates, create custom template files, such as dock.vm, init_custom.vm, navigation.vm, portal_normal.vm, portal_pop_up.vm, and portlet.vm. Note that you may use JSP files in template files under the folder templates. However, keep in mind that you won't have access to the velocity variables if JSP files were in use. Developing the user interface through layout template development frameworks Layout templates are ways to choose how portlets will be arranged on a page. Layout templates usually refer to a grid-like structure with HTML tables. Layout templates form the body of a page, the large area where dragging and dropping both custom and built-in portlets creates pages. A layout template sets various columns and rows to display the portlets in the web page. In short, the layout template controls the visual structure of web pages in the portal. As shown in the following figure, the plugins SDK provides an environment to build layout templates that is similar to that of theme, hooks, portlets, and webs. It uses either Ant Target Deploy or Maven to form a WAR file first and then copies it to the Auto Deploy directory. Afterwards, the portal will detect any WAR files in the auto hot-deploy folder and extract the WAR files into the application server deployment folder automatically.
  • 49.
    Customizing Your LiferayPortal [ 26 ] Note that both Web and WAP are supported in layout templates. A layout template plugin should include at least two files: a file called .tpl for Web and another file called.wap.tpl for WAP. The WEB version specifies the arrangement of portlets in a web page in desktop browsers, whereas the WAP version specifies the arrangement of portlets in a web page in mobile WAP devices. Alloy UI customization Alloy UI is a YUI3-based user interface meta-framework providing a consistent and simple API for building web applications across browser level: structure, style, and behavior. In brief, Alloy UI is a user interface web application JavaScript framework. It is a unified UI library built on top of the revolutionary YUI3, a library of tools. Its purpose is to help make building and designing web applications an enjoyable experience. Structure – HTML5 Alloy UI is based on the structure of HTML5 in order to provide reusable markup patterns. HTML5 is the next major revision of Hyper Text Markup Language (HTML); more precisely, it is the next standard for HTML4 in order to reduce the need for proprietary, plug-in-based Rich Internet Application (RIA) technologies such as Adobe Flash, Microsoft Silverlight, Apache Pivot, and Sun JavaFX. In brief, HTML5 incorporates Web Forms 2.0, another WHATWG specification. In HTML5 tags, there is the one and only <!doctype> declaration. The following code shows a simple HTML5 document with the minimum number of required tags: <!DOCTYPE html> <html> <head> <title>Title of the document</title> </head> <body>Body of the document</body> </html> HTML5 introduces a number of new elements and attributes that reflect typical usage on modern websites/pages. Some of them are used for semantic replacements—for common usage of the generic block <div> and inline <span> elements—for example, <nav> representing the website navigation block and <footer> representing the bottom of the web page or the last lines of the HTML code. Other elements provide new functionalities for multimedia with a standardized interface, such as <audio> and <video> elements.
  • 50.
    Chapter 1 [ 27] HTML5 also has a significant impact on Search Engine Optimization (SEO), that is, metadata—data (information) about data. The <meta> tag provides metadata about the HTML document. Meta elements are used to specify page description, keywords, author, last modified, and other metadata used by web browsers (how to display content or reload a page), search engines (keywords), or other web services. In this case, content would be translated to accurate, relevant, and pinpointed search results. In brief, HTML5 is a new version of HTML4 that addresses new challenges you would face in modern website development. It covers a range of things such as writing web applications and maintaining sanity; creating more distinguished content using shiny, new elements; acknowledging the huge accessibility advances and opportunities available; and offering the future of web media using video, audio, and canvas. Browsers are going to support HTML5. For example, Chrome, Safari, Firefox, and Opera have been supporting HTML5, and Microsoft will have all in in IE9/IE10. Older versions of Internet Explorer browsers can support the structural markup of these new elements with an enabling script. Style – CSS 3 Cascading Style Sheets (CSS), a stylesheet language, describes the presentation semantics of a document written in a markup language. Most common application-style web pages are written in HTML and XHTML, but the language can also be applied on any kind of XML document as well as on SVG and XUL. CSS level 3 (CSS 3) is modularized, more compact, and richer in semantics. CSS 3 has abbreviations expanded automatically before a web page is published. For example, users are not required to create links directly, and can indirectly include a tag or a special character that indicates the role of a keyword such as a property name, a technical term, or a bibliographic reference, and each such word will be automatically linked to its definition. Behavior – YUI 3 The Yahoo! User Interface Library (YUI) 3 is an open source JavaScript library for building rich, interactive web pages with techniques, for example, Ajax, DHTML and DOM scripting, and several core CSS 3 resources.
  • 51.
    Customizing Your LiferayPortal [ 28 ] As Yahoo!'s next-generation JavaScript and CSS library, the YUI 3 Library has grown to include core components, a full suite of utilities, the widget infrastructure, and a few widgets, shipped with a lot of examples that illustrate the implementation of its components. There is a set of examples that would be good starting points for your exploration, code snippets to jump-start your own programming, or simply inspiration as to how various interaction patterns can be enabled in the web pages via YUI. YUI modules cover many modules such as, but not limited to, align-plugin, anim, async-queue, attribute, base, cache, classnamemanager, collection, console, console-filters, cookie, dataschema, datasource, datatype, dd, dom, dump, event, event-custom, event-simulate, gallery-formmgr, history, imageloader, intl, io, json, loader, node, node-focusmanager, node-menunav, oop, overlay, plugin, pluginhost, profiler, querystring, queue-promote, shim- plugin, slider, sortable, stylesheet, substitute, swf, swfdetect, tabview, test, widget, widget-anim, widget-parent, widget-position, widget-position-align, widget-position- constrain, widget-stack, widget-stdmod, and yui. Alloy UI forms Alloy UI forms are useful tools to help developers build nice forms quickly. The following are some of the advantages of using these forms: • Usability: Styling of the forms has been specified for better usability. • Unified styling: All the forms look similar, and they are controlled in one place. • Dynamic attributes: Any attribute that can be used for an HTML tag can also be used for an aui tag. For example, you could use onClick, onChange, onSubmit, and title in any aui:form, aui:select, or aui:input, and it will have the same behavior as though you used it as a plain HTML form, select, or input. These tags can be used in aui forms and some of their attributes. They all support dynamic attributes, that is, you can add any additional attributes. For example, if you add the attribute onFocus to an aui form such as aui:button, the tag <button> will have the onFocus attribute.
  • 52.
    Chapter 1 [ 29] Alloy UI forms are sets of taglibs built on top of the Alloy UI JavaScript plus CSS framework. Alloy UI forms (aui) provide, but are not limited to, the tags Form, Field-set, Button, Button Row, Model Context, Input, Select, Option, Link (a), Field Wrapper, Legend, Layout, Column, Other Examples, Text-area, and Radio Alloy UI covers many modules, such as aui-autocomplete, aui-button, aui-calendar, aui-char-counter, aui-color- picker, aui-component, aui-datatype, aui-delayed-task, aui-dialog, aui-editable, aui-event, aui-image-viewer, aui-io, aui-live-search, aui-loading-mask, aui-nested- list, aui-node, aui-overlay, aui-paginator, aui-panel, aui-parse-content, aui-portal-layout, aui-rating, aui- resize, aui-textboxlist, aui-toolbar, aui-tooltip, and aui-tree. JavaScript frameworks Liferay Portal and built-in portlets use YUI 3 and AUI by default, but other JavaScript frameworks can be included in custom plugins. These JavaScript frameworks include, but are not limited to: • jQuery • Ext JS • Dojo • Google Web Toolkit • DHTMLX • PhoneJS • Knockout JS • Bootstrap • jQuery Mobile • MooTools JS This book will address how to use different JavaScript frameworks in custom portlets development.
  • 53.
    Customizing Your LiferayPortal [ 30 ] Responsive themes Responsive web design, also called responsive themes, is a theme development approach. It is aimed at crafting websites/pages to provide an optimal viewing experience, such as ease of reading, minimum navigation and resizing, panning, and scrolling. Responsive themes span a range of devices, from desktops and tablets to smart mobiles. A responsive theme is basically made up of at least three main ingredients, as follows: • Flexible grids, including flexible types, containers, margins, padding, and images • Media queries • Flexible media This book will introduce you to responsive themes and will show you how to build responsive mobile themes. More useful information In this chapter, we have looked at what Liferay can do for your corporate intranet, and we have briefly seen why it's a good choice. If you want more background information on Liferay, the best place to start is the Liferay corporate website (http://www.liferay.com). You can find the latest news and events, various training programs offered worldwide, presentations, demonstrations, and hosted trails. More interestingly, Liferay eats its own dog food; corporate websites within forums (called message boards), blogs, and wikis are built by Liferay using its own products. It is a real demonstration of the Liferay Portal. Liferay is 100 percent open source and all downloads are available from the Liferay Portal website (http://www.liferay.com/web/guest/downloads/portal) and SourceForge website http://sourceforge.net/projects/lportal/files. The source code repository is available at svn://svn.liferay.com/repos/public (credentials—the username is guest and there is no password) and the source code can be explored at http://svn.liferay.com. The source code is also available at GitHub: https://github.com/liferay/liferay-portal.
  • 54.
    Chapter 1 [ 31] The Liferay website wiki (http://www.liferay.com/web/guest/community/ wiki) contains documentation such as a tutorial, user guide, developer guide, administrator guide, and roadmap. The Liferay website discussion forums can be accessed at http://www.liferay. com/web/guest/community/forums, and the blogs at http://www.liferay.com/ web/guest/community/blogs. The roadmap can be found at http://www.liferay. com/web/guest/community/wiki/-/wiki/Main/RoadMap. The official plugins are available at http://www.liferay.com/web/guest/downloads/official_plugins. The community plugins are available at http://www.liferay.com/web/guest/ downloads/community_plugins. The marketplace (http://www.liferay.com/ marketplace) is the best place to share your thoughts, get tips and tricks about Liferay implementation, learn about the roadmap, and use and contribute to community plugins. If you would like to file a bug or know more about the fixes in a specific release, then you must visit the bug-tracking system at http://issues.liferay.com/. Alloy UI Forms are a set of taglibs built on top of the Alloy UI JavaScript CSS framework. For more information about the framework, you can visit http:// alloy.liferay.com. CSS3, CSS level 3, is available at http://www.w3.org/ Style/CSS/current-work. A detailed description about HTML5 is available at http://dev.w3.org/html5/spec/Overview.html. YUI3, Yahoo!'s next-generation JavaScript and CSS library is available at http://developer.yahoo.com/yui/3/.
  • 55.
    Another Random Documenton Scribd Without Any Related Topics
  • 56.
    lecturers, on whosedamask periods idleness was as a cankering worm in the bud, got into a sad state of impatience and were threatening to lecture one another, or do something else desperate, when the position was saved by a timely visit to them of the Prince of Wales and his brother, Prince Albert, who had tea with them, chatted over their work, and convinced them that they were not out on a fool's errand. Shortly afterwards the transport situation was relieved, and the lecturers rushed to their audiences and peace reigned again. But it is dreadful to think of what might have happened if there had not been the urbane and diplomatic Captain Hansell smoothing over troubles. A mutiny of lecturers would have afforded some puzzling problems to the Provost-Marshal.
  • 57.
    CAPTAIN H. P.HANSELL Before the Army Education organisation was born a great number of men in the Army did some good solid reading. The Camps Libraries organisation in England sent out to every unit parcels of books. Most of these were of the opiate class, light magazines and light stories intended to bemuse and not to educate the mind. But a proportion of good books slipped in and were warmly appreciated by some.
  • 58.
    The Army itselfhad a very fecund printing press, but it was devoted almost solely to the production of books of orders and regulations and text books. Regimental annuals of a humorous kind existed but were not encouraged. As a rule they were printed in England, not in France, and the conditions of censorship—more perhaps than the taste of writers and readers—confined them as a rule to somewhat feeble japes. There were very often mooted proposals for a G.H.Q. Monthly. It might have drawn on a very distinguished band of writers. But authority contrived that these proposals should never come to maturity. The expenditure of time and material was grudged, and G.H.Q. was naturally very nervous on points of "Intelligence." There are a thousand and one ways in which military secrets can be given away with quite harmless intent. An Intelligence General's aphorism on this point ran: "We find out far more from the stupidity of our enemies than from the cleverness of our spies." It is clear that silence is the one sound policy. If a man says nothing, nothing can be discovered from him. If he will speak, even if it is only with the intention of deceiving, he may disclose something. British diplomacy abroad (which was not such a foolish show as some critics say, or else how comes it that the British Empire, from the tiny foundation of these islands, has come to its present greatness?) was always the despair of the inquisitive Foreign Correspondent, for it never said anything. An Embassy or Ministry which would tell a lie, especially an elaborate lie, was far preferable, for from something you may deduce something; from nothing, nothing. G.H.Q. acted with a sound discretion in smothering all proposals for a G.H.Q. Monthly. The Army did most of its own printing, of maps, orders, forms, and training books. Maps were done by the R.E. mapping section, other printing by the Army Printing and Stationery Services under Colonel Partridge. This was a highly efficient department with printing
  • 59.
    presses of themost modern type at Boulogne, Abbéville, and elsewhere. A.P. and S.S. printed daily General Routine Orders and, as occasion demanded, poured out in millions Army Forms, posters, pamphlets, and books. Both the French and Americans used its services. It could print in Chinese and Arabic as well as in European characters, and some of its achievements in the way of quick and good printing would do credit to a big London printing house. The Boulogne Printing Press, which was under the care of Major Bourne, was a particularly up-to-date establishment much praised by the Americans and the French as well as by our own Army. It put a strain once, however, on the politeness of the French. The French Mission at G.H.Q. wanted a book printed giving a record of its organisation. A.P. and S.S., in the right spirit, did its best to make the book a handsome one, and designed a special cover with fleur-de-lys decorations. The French Mission, with tact but with firmness, pointed out that France was now a Republic and a monarchical symbol could hardly be permitted on an official publication. It might give rise to a suspicion that the Army contemplated a coup d'état. The printers regretted and tried again. The second cover design bore the good old Roman Republican device of the lictors' fasces. But they were shown reversed. The French were desolated at being so exiguous, but could something else be tried, just plain type? The printers were determined, however, to give the good French something to show what an artistic people we English really are, and made a third effort at a decorated cover. This showed a really charming design in which the Gallic Cock strutted triumphantly along a rose-point border. The French were enchanted, so enchanted that they found reason to have another book, an annexe to the original book, printed with the same cover. American Army publications were normally somewhat more solemn and staid than our own. Occasionally, however, the American humour broke out, as in the gas warning leaflet, which had not, perhaps, the sanction of American G.H.Q. but was widely (and usefully) circulated in the trenches. It began:—
  • 60.
    In a GasAttack There are only Two Crowds The Quick and the Dead Be Quick and get that Gas Mask on! After the Armistice, the Printing Services, no longer so much pressed with other Army work, were able to undertake some purely educational printing. But by this time demobilisation was sweeping away the classes, and the best of the opportunity had passed.
  • 61.
    CHAPTER XV. THE WINTEROF OUR DISCONTENT. The disappointments of 1916 and 1917—The collapse of Russia—The Cambrai Battle—The German propaganda— Fears of irresolution at Home—Reassurances from Home— Effects of the Submarine war—An economical reorganisation at G.H.Q.—A new Quartermaster General—Good effects of cheerfulness at Home. The Somme campaign, 1916, had been begun with very high hopes. The main conception of it was a sound one, to attack the German line at the point of junction between the French and British forces, the point where, according to all the accepted principles, the Allied line should have been weakest but actually was not. That was the only way to bring an element of the unexpected into a grand attack in those days of long and laborious artillery preparations. (The Tank did not appear on the scene until the Battle of the Somme was two months old and did not develop its usefulness as a substitute for artillery preparation until nearly a year later). For the Somme battle an enormous artillery concentration was made, and a special "Army of Pursuit" was trained in the rear of our lines to follow through when the German line had been breached. Then there was a preliminary bombardment of the German positions from the sea to beyond the Somme, and, amidst many feint attacks, the British and the French offensive north and south of the Somme was launched. The First Battle of the Somme made the walls of Jericho quake but just failed to bring them down. The Army of Pursuit was given no chance of pushing to the Rhine; its energies had to be diverted
  • 62.
    towards sustaining theattack. The fighting season closed in 1916 with the Germans still holding their main defences but convinced, so far as the reasonable section of their leaders were concerned, that the game was up and that the best thing to do was to work for a peace on the best terms possible. ON THE RAMPARTS Thus 1916 was a somewhat disappointing year; 1917 was even more so. The fighting season, that year, closed with the Allied cause in a worse position than in 1916 and with Germany correspondingly encouraged. There would have been some reasonable excuse if in the winter of 1917-18 tails drooped at G.H.Q. The weather was particularly vile. Every day the winds that howled over the bleak hill-
  • 63.
    top seemed tohave come straight from Russia and Germany, bringing with them a moral as well as a physical cold. The casualty lists of the Autumn were not cheerful to ponder over; and it was singularly depressing to hear from Home that in some political circles those casualty lists were being conned over with the idea of founding on them a case against the Army. Nobody was inclined to try to represent the late Autumn campaign as altogether satisfactory. But it was felt by the soldiers that "they had done their durn'dest, angels can do no more;" and that there was not sufficient appreciation of the fact at Home that with Russia down and out, France in a very bad way, Italy tottering, the British Army had had to step into the breach, had had to take a gruelling without being able to accomplish much more than defence. It had seemed in 1916 that the time had arrived for Germany to pay the penalty. But a triumph not of a military kind came to her rescue. The German methods of espionage and civil corruption were on the whole as blundering and as disastrous as her other methods during the Great War. They helped to alienate practically all the civilised neutral world. But in Russia—mystic, generous, trusting Russia—they had an unhappy success. In the Autumn of 1916 this first showed. Roumania at that time joined in the war against Germany, and this new accession of strength apparently marked the near end of the war. But Russia mysteriously collapsed owing to the effects of German corruption. Roumania was left "in the air," and a large part of her territory was over-run. From this date, though many of the gallant soldiers of Russia made heroic efforts to safeguard their country's honour, that great Ally was practically out of the fight. By the winter of 1917-18 she was quite out. The French had had grave troubles. The Italians had had to send out an S.O.S. signal. We should have been more cheerful if the Cambrai attack, 1917, had had the full success it deserved. That really was in its conception and execution a very fine affair. At the time Germany was drawing troops and guns from the Russian Front and pouring them on to our Front in wholesale fashion. Both France and Great Britain had had to
  • 64.
    send Armies tothe help of Italy. Our Battle of Passchendaele was not exactly flourishing. To undertake a new battle was the last development the enemy expected of us; and to do what is absolutely unexpected is to do the big thing in war. The British command collected an Army ostensibly for Italy, made a great secret assemblage of Tanks, and suddenly attacked the Germans in the strongest part of their Hindenburg line. Their line was particularly strong at that point. It comprised three series of defences each one covered by triple barriers of wire from 50 to 60 yards deep. A system of dug-outs (constructed with the labour of Russian prisoners) at a depth of 50 feet below the surface made an underground city with water and electric light installations, kitchens, drying-rooms and the like. Above the surface the houses were closely packed with the earth removed from the excavations, and thus became great earthworks indestructible by any shell-fire. All this the British Third Army, in a surprise attack carried out by the Tanks and the Infantry, over-ran and captured in a day's attack. So fierce was the British advance and so feeble the German defence when taken by surprise that we almost got into Cambrai. If that centre had been won the German Front in the West would have been deprived of its central pillar. The German defence, however, rallied in time to avoid absolute disaster. When the German military mind was given time to think it could always make a good show, and the riposte to our Cambrai attack was a good one. We lost most of the fruits of a dramatic coup. It was more than annoying to think that just when we had successfully solved the problem of a break- through we had not the means, owing to commitments elsewhere, to push the thrust home. Cambrai was a good deal "boomed" in the English Press at the time on "popular" lines. But I do not think that the skill of generalship and organisation that it showed were quite appreciated. The favourite British pose of being a complete ass, altogether inferior to the "other
  • 65.
    fellow," used tobe pushed to the extreme point in regard to military matters. The British had a quaint humility in respect to their military skill. In a shame-faced kind of way they admitted that their soldiers were brave; but for examples of military genius they always referred to the "other fellow." Yet one may be daring enough, perhaps, to say something on the other side; and to suggest that in the Great War the German was really surpassed in most points of military skill by the British. The difference was not always great, but where the difference was greatest was just in those points of invention, of new tactics and new strategy, which show the better brain. Heresy it will seem; but the truth is that from 1914 to 1918 the British military system showed itself superior to the German in resource and sagacity. Perhaps it would be better to say the British-French military system, for it is difficult to separate the achievement of one from the other. Consider one by one the main features of the great campaign. The warfare in the air was its most dramatic feature. Everything of air tactics and strategy that the German used he copied from the British and French. It was the British who originated aeroplane attack with incendiary bullets on captive balloons, aeroplane escort of attacking infantry, aeroplane sallies at low altitude on enemy trenches, and the various combinations of observing machines with fighting machines. In the first battle of the Somme, when the British and French first disclosed their sky tactics, the German was absolutely driven out of the air. He had then to learn to copy all our methods; and he originated none of his own. Another dramatic feature, the complicated and terribly effective artillery curtain fire, was evolved by the British-French command. It was copied by the Germans, who themselves contributed nothing new to artillery science during the war. Yet another leading feature was the Tank, the Tank which made its real value first felt at Cambrai. This was a purely British invention, evolved during this war for the needs of this war.
  • 66.
    Our "Winter ofdiscontent" was not made any sweeter by the suspicion that existed of a possible yielding on the part of the political powers at Home to German propaganda. This German propaganda took the form of blazoning the preparations for a sensational Spring offensive in 1918; it was trumpeted like a Fat Woman at a Fair, and supplemented by an almost equally strident advertisement of a gigantic defensive. In addition to preparing a great on-rush in which Calais, Paris, Rome, and perhaps London were to be captured, the German High Command wished the world to know that it was also preparing a mighty series of defensive positions back to the Rhine. Wonderful showmen! They had not only the most marvellous Fat Woman, but also a miraculous Skeleton Man. And the prize they wished to win, by bluff if not by fighting, was agreement to an inconclusive peace. The soldiers were not affected much by these tactics. They took solid comfort from two facts. The first fact was expressed in the homely proverb "Much cry, little wool." Had the Germans been confident that they could smash through the steel wall which barred them on the West from the sea, from the capitals of civilisation, and from the supplies of raw material for which they were starving, there would have been no preliminary advertisement. The effort would have been made, and Germany's enemies would have had to abide by the result. There would not have been any compunction at the consequent cost in blood. The mere extravagance of the advertisement of the German plans was proof to the soldiers at G.H.Q. that those plans were recognised not to have a solid enough military foundation, and had to be reinforced by showy bluff. The second fact which gave solid comfort was that in any comparison at all of forces the German group was inferior to the West European-American group. There was not any doubt at G.H.Q. Indeed the more the Germans protested of what they were going to do in the Spring of 1918 the more firm was G.H.Q. in believing that the enemy was at last coming to the end of his resources and was anxious to "bluff" a peace rather than "show" a weak hand.
  • 67.
    But it wasfeared that the people at Home might take the other view, and it had to be admitted that the German put up a very strong bluff. Perhaps its cleverest form at the time was in the discussion of "peace terms"—a discussion in which it was presumed that the German would impose a victorious peace before the summer of 1918. A characteristic discussion—G.H.Q. kept a close eye on the German press and minutely examined every German paper published during the war—would begin with some Prince pointing out the minimum indemnity that Germany should exact from her foes, and explaining in what form it should be exacted. Germany's need, it would be pointed out, would be for raw materials, food, cotton, wool, rubber, tobacco, silk and the like. It was these that must be supplied to Germany by way of indemnity. They would have to be supplied not free, but at a price 20 per cent. lower than the current market price, and the annual value of this discount would only reach the modest sum of £50,000,000 a year. To have had to provide yearly a tribute of any kind to Germany would of course have taken away the independence of the Allies completely. They would have been put in the position of admitting a German suzerainity, and would have become as the oppressed Christian provinces of the old Turkish Empire. But to provide this tribute of raw material, the discount on which at 20 per cent. would be £50,000,000 a year, would have been to engage to send to Germany yearly raw materials of her choice to the value of £250,000,000. This would have been the first call on the farms, the mines, the shipping of the Allies, and only after that call was met would the Allies have been able to begin to supply their own larders and their own factories. That was one direction the German Peace Propaganda took. The idea of it was, presumably, to strike terror into our hearts, to make us welcome with something like relief the actual official terms of a peace negotiation when they came to be promulgated. Then someone in Germany would take the other side. Assuming with absolute cock-sureness that Germany must win the war in the Spring
  • 68.
    of 1918, thispublicist would affect to regret the savage terms of peace imposed upon Russia. These terms, it was argued, did not represent the considered wishes of the German people. But in war the wisdom of the statesmen was pushed aside by the eagerness of the soldiers. The German politicians were overwhelmed in regard to the Russian peace because the Russian had allowed things to go too far. But if only the Western Powers would agree to negotiate for peace now, the "reasonable German politicians" would be able to assert their authority. There would be no ruthless military conditions such as were imposed upon Russia. Sweetly and moderately the Germans would frame their terms; but the Powers of the Entente must "put the war into liquidation at once." Delay would mean that the "reasonable German politicians" would lose their power to restrain the military party. G.H.Q. remembered the old fable about certain trustful animals being invited to pay friendly visits to the cave of a beast of prey. One wise animal noticed that whilst there were many tracks of visitors going into the cave there were no tracks of visitors coming out. We had noticed that a free Russia went into negotiation with Germany to conclude a friendly and reasonable peace on terms of "no annexations and no indemnities." No free Russia came out. But G.H.Q. was honestly alarmed for a time that resolution would be shaken at Home, and welcomed with joy (as the Germans did with rage), the firm declarations of the Versailles Council of the Allies and the unshaken confidence and resolution shown in the speech from the Throne at the prorogation of the British Parliament. As soon as the Home political situation was seen to be clear, G.H.Q. set about preparing for the "wrath to come" with a good deal of cheerfulness and with some amusement that the German propaganda should, as a final kick, make a strong though forlorn effort to revive the old story that Great Britain contemplated the seizure from France of Calais and the department of Pas-de-Calais. "Even," said the German Wireless about this time, "if it is not openly
  • 69.
    admitted that theEnglish will never voluntarily evacuate the French port of Calais, which they have occupied—" etc., etc. This lie revived in our Mess between British and French liaison officers an old topic of humorous conversation. For when this particular lie was burdening the German Wireless some time before, a British General was showing to a French General the arrangements of the British Base at Etaples. He exhibited with pride the great bath houses for the men, built of concrete and "good for a hundred years." "Ah yes, very solid—good for a hundred years," said the French General, laughing. Then they both laughed. Christmas, 1917, was celebrated with the usual British merriment at G.H.Q., and on New Year's Day everybody's cheerful greeting was "That this year may see the end of the war." But I think there were few officers of standing who thought that a peace Christmas was possible in 1918. No one would contemplate the possibility of losing the war, of stopping on any terms short of a German surrender; but few could see any possibility of victory near ahead. There were thick clouds all round the horizon. Russia was finished. Italy was not cheerful. France was recovering but not yet showing sure signs of emergence from that fit of depression out of which M. Clemenceau was to pull her—the soul of a Richelieu in his frail body. The worst symptom of all from the point of view of the British Army was the threat of a shortness of supplies. Just when the collapse of Russia had allowed the enemy to concentrate his full strength on the Western Front, the great reservoir of British wealth, which was the main financial resource of the Alliance, showed signs of not being inexhaustible. There was a call at the same time for greater preparation and greater economy. From the beginning of 1918 there were two great cross-currents of correspondence between G.H.Q. and the Home Government, one demanding new weapons, new defences, new equipment, the other demanding rigid economy in
  • 70.
    steel, in timber,in shipping space, in food, in oil, in expenditure generally. This was partly due to actual lack of money and of credit. But in the main it was the result of the submarine war. It was at the end of 1915 that the German Admiralty prepared a memorandum arguing that if unrestricted submarine war were adopted as a policy (i.e., sinking everything, hostile or neutral, warship or passenger ship), then Great Britain would be compelled to sue for peace within six months. The memorandum gave various statistics regarding food supplies, tonnage, etc., to prove this hypothesis. The memorandum was forwarded to the Imperial Chancellor, and by him sent to Dr. Helfferich, Secretary of State for Finance, for a report. Dr. Helfferich reported adversely. He was not convinced that Great Britain would be brought to her knees. He feared the effect upon neutral nations of such a policy. The German Admiralty persisted in its view. Thereupon the matter was submitted for report to ten experts representing finance, commerce, mining, and agriculture. These experts were asked to advise (1) as to the probable effect upon Great Britain (2) as to the probable effect upon Germany's relations with neutrals and (3) as to how far the situation in Germany demanded the employment of such a weapon. All these experts agreed that the effect on Great Britain would be to force her to sue for peace within six months or less. Indeed, Herr Müller, President of the Dresden Bank, thought that Great Britain would collapse within three months. All the experts also agreed as to the third point of reference, arguing that Germany's position was so difficult that the most desperate measures were necessary to end the war. Herr Engelhardt, of Mannheim, Councillor of Commerce, thought the economic position of Germany so bad that a few weeks' delay might render even ruthless submarine war useless. On the second point, the effect on relations with neutrals, the experts were divided. Some thought that the United States would be driven to war, others thought not. In all cases they did not see a reason
  • 71.
    against ruthless submarinewar in their possible relations with any neutral. But the fateful decision was not taken until February, 1917, when the destruction of peaceful shipping, whether of enemy or of neutral countries, was ordered. It did not end the war in six months, nor in twelve months; but by the beginning of 1918 there were some very serious difficulties of supply just when the strictly military position demanded the most generous effort. I wonder if those experts who bandy to and fro explanations and accusations in regard to the German break-through in the Spring of 1918 ever have looked at the matter from the point of view of supply, of the supply, say, of one sternly necessary item of defence, wire? At a careful computation we wanted 12,000 tons of barbed wire in January, 1918, and 10,000 more tons in February, 1918, to give our men a reasonable chance of holding the line which we knew to be threatened. Of that total of 22,000 tons we actually got 7,700 tons, i.e., 35 per cent. of what was needed. I do not quote this fact to start another quarrel, shuttle-cocking blame from soldier to politician. I am more than ready to believe that the people at Home were then doing their best (as, pace all grousers, I believe they did their best from August, 1914, to November, 1918). But you cannot spin out wire like you spin out talk, especially barbed wire. The British soldier can, with his mere flesh and blood, and that gay courage of his, do wonders in the way of making up for want of material. But he could not hold up the attacked sector in the Spring of 1918 against overwhelming odds; and one of the reasons was that he had not enough wire in front of him. He had not the wire in front of him because it had not been, could not be, supplied. How anxious was the task of G.H.Q. at the dawn of 1918 may be illustrated with these heads of correspondence, in and out. To G.H.Q. from Home. The greatest economy in steel is urged.
  • 72.
    The position inregard to shipping is serious; the strictest economy in everything is necessary. Lubricants are hard to get. We urge the greatest economy. From G.H.Q. to Home. More machine-guns are urgently needed. There is a shortage of blankets; there is a shortage of 8,000 tons of barbed wire. New searchlights are needed; 300,000 box respirators are needed for the American Forces. I could fill many pages with matter of the same sort. The poison of the submarine war began to have its cumulative effect just when we were getting the most peremptory reminders that Supply was going to be the determining factor of the final struggle, that war had become more and more a matter of striking at the enemy's life by striking at "the means whereby he lives." Munitions, food, equipment, railways, roads, ships—these had become the most important factors, and victory would incline to the Force which could best concentrate the means to maintain an overwhelming force at some particular point, which could best develop, conserve, and transport its material. The field for the strategist had moved more and more from the Front line towards the Base. Fortunately, the British Army in France had for its Q.M.G. at this crisis a man with the courage and the knowledge to carry through a drastic reorganisation of the Supply and Transport services. Lieutenant-General Sir Travers Clarke, who took over as Q.M.G., France, at the end of 1917, was a daring experiment on Lord Haig's part; for he was a comparative youngster to be put into a post which was then the most anxious and onerous in the Army, and his actual substantive rank was that of a major; but he was an acting Major- General with a fine record in a minor theatre of the war. Lord Haig knew his man well, though, and, what was just as necessary, knew how to back his man. He put Sir Travers Clarke in the saddle and
  • 73.
    kept him therein spite, I have no doubt, of many thunderous protests from influential quarters, for Sir Travers Clarke was a ruthless reformer and a stubborn upholder of any course of action he thought necessary. A character sketch of him that appeared in the Morning Post in 1919 is worth quoting in part: LIEUT-GENERAL SIR TRAVERS CLARKE
  • 74.
    "'That big youngman,' was a leading American officer's term to describe Sir Travers Clarke after he had met him in France in Conference, and had not caught his name. British G.H.Q. perhaps only learned to appreciate the Q.M.G. fully from the comments of foreign officers who came into touch with him in 1918. The masterful man took his power so quietly, came to big decisions with such an air of ease, such an absence of anything dramatic or violent, that it was a little difficult to understand his full strength. "'T.C.'—as often before remarked, the British Army must reduce everything and everyone to initials—as a regimental officer in the 'Nineties never seemed to get an opening. Nor did his early Staff work bring him much recognition. But an officer of his to-day, who was a clerk under him when he was first a Staff Captain, insists that he always gave the impression of great power in reserve. 'He believed in the British Army, in hard work, and in himself.' That was the foundation of the career of a man who, once an opening showed, forged ahead with marvellous speed to his destiny. "It took 'T.C.' ten years to become a major; within the next ten years he had become Lieutenant-General and Quartermaster-General to the British Armies in France. One year in that post, a year in which were crowded all the experiences that a great Army could have, marked him as a great leader of men and a superb organiser. How much the Allied victory owes to him a grateful country will not appreciate fully until not only the British but also the French and American campaigns are analysed. "'T.C.' had the ideal personality for a military leader. You were always dreadfully afraid of him and sincerely fond of him. No general ever made sterner demands on his officers and men. If you could not stand up to a gruelling day's work and come up smiling for the next day's and the next day's, until the need had passed, you were no use, and you moved on to some less exacting sphere. But you were working under a worker, and you found yourself part of a massive machine which was rolling flat all obstacles. That made it easy.
  • 75.
    Further, there wasthe most generous appreciation of good work and a keen personal sympathy. "Sir Travers Clarke has one rule to which he never permitted an exception: that it is the fighting man who has to be considered first and last. In France he was quite willing that the Staff should labour to the extreme point of endurance to take any of the load off the man in the trenches. He did not like about him men, however clever, who had not seen fighting. It was the first duty of the Staff, he insisted, to enter with the completest sympathy into the feelings and the difficulties of the fighting man. 'Bad Staff work mostly arises from not knowing the differences between an office and a trench,' was one of his aphorisms." This is not a history of the war; nor a contribution to any of the numerous war controversies; it is merely a sketch of life at G.H.Q. as it appeared to a Staff Officer; but I cannot help obtruding a reply to some current criticisms of Lord Haig: that he was too inclined to stand by his officers, that he was reluctant to "butcher" a man, and that in consequence he did not get the highest standard of efficiency. Faithfulness to his friends and servants was certainly a marked characteristic of Lord Haig as Commander-in-Chief. He chose his men cautiously and, I believe, with brilliant insight. Having chosen them he stood by them faithfully in spite of press or political or service thunderings, unless he was convinced that they were not equal to their work. It is a characteristic which, even allowing that there was an odd case of over-indulgence, of giving a man a little too much benefit of the doubt, worked on the whole for the good. Men do not do their best work with ropes round their necks; and I believe that a great newspaper magnate whose motto at first was "Sack, Sack, Sack," very soon found out that it was a mistake.
  • 76.
    In this particularinstance I suppose the Commander-in-Chief had powerful urging often enough to "butcher" his Q.M.G., who did things of so disturbing a character. He did not; and the event proved him right, as it did in practically every one of his great trusts during the war. Reorganisation of Supply and Transport filled the attention of G.H.Q. during the early months of 1918. Over a curiously wide range of subjects swept a wave of reform and retrenchment. As I have already told, there was a definite organisation to collect the salvage of the battlefields, an organisation which saved millions of money in rags, bottles, waste-paper, swill, bones and grease as well as in the more obvious matters of shell-cases and derelict arms and ammunition. An Agricultural Directorate was set to work to grow potatoes and oats and vegetables and other food stuffs behind the lines. Rations were judiciously reduced, a substantial difference being left in favour of the man in the actual fighting line as compared with the man at the Base. The supply of certain luxuries at the E.F. canteens was stopped or limited, but it was provided that the man in the fighting line should suffer less from this than the man at the Base. Weekly conferences were instituted to discuss the most economical use of labour, of material and of plant. Every matter great and small had searching attention, and the British Army began to be run like an up-to-date competitive business. Some of the injudicious laughed. They christened the General in charge of Salvage "O.C. Swills" and "Rags and Bones." They could not "see" a Colonel whose mission in life was to cut down laundry costs and arrange for the darning of the men's socks when they came out of the wash. But all these things had to do with the winning of the war. It is a fact that if the lavishness of 1914-15-16-17 had been carried into 1918 we could not have won the war, because we should have been bankrupt of material.
  • 77.
    G.H.Q. at thedawn of the Spring of 1918 was very serious in mind, but not so much so as to fail to get some amusement as well as interest out of the various new ideas in military administration; and fully confident now that the people at Home were going to stick it out. In this connection there was often mentioned with cheerfulness a London bye-election towards the end of 1917 for an area which had had special attention from the German air-raids. Some rather expected to see a candidate come forward from among the little group known as "Pacifists," who would seek votes on the plea that the best way to stop air-raids quickly and to get out of the discomforts of the war would be to meet half-way the proposals of the Germans who were trying for an inconclusive peace. What actually happened was quite different. A candidate came forward under the banner of the Government, pledged to the Government's programme of carrying on the war until German militarism was crushed and Germany made reparation for the ruin she had wrought in Europe. This candidate had the support of both the old political parties. Against him there came out another candidate. Did this candidate seek to win votes by pleading for a friendly consideration of Germany's hypocritical peace proposals? He did not. From what one could gather of the feeling of the electorate, if he had done so he would have been ducked in the nearest pond. No, his appeal was based on the plea that the Government candidate did not go far enough in hostility to Germany, and that that gentleman was not fully in favour of carrying to German homes the dastardly air-war which Germany waged on a civilian population. Then a third candidate appeared on the scene. He was not for any half-hearted policy. His cry to the electors was that neither of the other two candidates was sufficiently earnest in regard to the war against Germany. His programme was of one clause only, the necessity of bombing Germany out of her barbarism. He did not believe that any method of sweet reasonableness was of any use. A thousand tons of bombs daily on Berlin, and a ration in proportionate scale on other German towns, was his idea.
  • 78.
    Women speakers cameto take part in the contest. Did they advocate making concessions to the German desire to sneak away from the consequences of the crime of 1914? They did not. They were more vigorous than any of the men speakers in demanding a full measure of reprisal on Germany. No one throughout the whole contest whispered "peace." It was altogether inspiriting. Here was a chance to see what the people of England, the people who stood behind the Army and the Navy and were our ultimate supports, felt about the war. We could see that they were utterly resolute, with not a sign of weariness, nor of fear, nor of tolerance for a craven peace. Their message was "Fight on, Fight on. Bring us home a real peace. We will put up with everything the Boche can do; we will carry on. But no palter, no surrender. Finish the job you are at." The English people terrorised? Not a bit of it. They were only getting their blood up. And G.H.Q. saw that and was comforted. There was also a good deal of solid comfort in the way that London took the bitter experience of "rations." We never had any food scarcity in the Army and, going on leave, officer or soldier had a food card that guaranteed him a good holiday supply. So we were in the best position to appreciate the cheerful way in which Great Britain took the very thin gruel of ration times. Every officer coming back from leave expressed his glowing admiration of civilian patience. Those German agents in London who relieved the tedium of the war for the Allies by reporting to Berlin such "happenings" as the Battle of Oxford Street and the destruction of whole quarters of London by air attacks, set out, for the fooling of the German public, some fine accounts of dismay and discontent caused by food tickets. But as a matter of truth, London on rations surprised and gratified the most cheerful optimists. The old city "took her medicine" not only with patience but with an actual gaiety.
  • 79.
    To sum up:between the close of the fighting season of 1917 and the beginning of that of 1918, G.H.Q. was at first a little depressed at the thought that political developments would prevent the Army from seeing the job through in a satisfactory way; was subsequently reassured as to the feeling of the civilian population; and thereafter faced the future with complete confidence.
  • 80.
    CHAPTER XVI. ENTER THEAMERICANS. How the Germans were misled about the Americans—Early American fighters—The arrivals in May, 1918—American equipment—Our relations with the Americans and what they thought of us—The Portuguese. There are many claimants for the honour of being the War Winner. When I was in Italy in February, 1918, I found a very genuine belief there that the Italians were the genuine war winners; that they brought the decisive weight to bear. Without denying the very useful effect that Italian neutrality had in the first stages of the war, and Italian participation at a later date, I think it would be hard to convince, say, the French of the soundness of the Italian claim. The British might be more inclined to agree; for they still keep up the curious pose of being a poor feckless people who never do anything or know anything. Another claimant for the pride of first place in the Grand Alliance is Greece; and I believe that Portugal has some idea of putting in a claim. But on the whole, taking all the circumstances into account and reckoning not war services only but war effect, the actual final blow to the Germans' hopes was delivered when the United States of America declared war. It was when Germany made that declaration necessary, in spite of the sincere wish of the Americans to keep out of the war, that all hope vanished of Germany securing an arranged peace. From that moment it was clear that ultimately she would have to take exactly what was handed out to her at the conclusion of the war.
  • 81.
    It is hardto believe that the German leaders ever seriously believed the stuff and nonsense that they gave out to comfort their people on the subject of American participation in the war. But having blundered by bringing the United States in they had to try to cover up their blunders. German diplomacy was not without successes of a kind in the preparation and prosecution of the war. If it is the function of diplomacy to plot murders and strikes and arsons in neutral countries, to bribe Oriental despots such as those of Turkey and Bulgaria into betraying their people, German diplomacy had a proud record. But concerning the sentiments and opinions of honourable communities German diplomacy showed always an abysmal ignorance. In no respect was this more clear than in its dealings with the United States of America. At first German diplomacy adopted the idea which was embodied in the German phrase "those idiotic Yankees"—the idea that the United States was a kind of Wild West Show, whose simpleton rulers could be fooled without trouble by the intelligent, the super-intelligent, Germans. When that idea was exploded, the next to take its place was equally foolish—that anyhow the antagonism of the United States did not matter, for she would not make war, and if she made war the effort would be so feeble as not to be worth considering. Then when the grim shadow of the great American preparation was already over the German despotism, and the greatest single white nation of the world was seen preparing its mighty strength to the full, the German people were asked to take comfort from yet another delusion, that the American nation would prove to be a "quitter," that it would be frightened off the field by the German offensive of the Spring of 1918. The Hamburger Echo voiced that delusion when it announced: "It is curious that at this critical moment American war experts are reported to be planning an inspection trip of the Front. It looks as though American capitalists were growing nervous. The dollar-republic has stolen ships which ensure her a great Fleet, but
  • 82.
    American capital isnot unlimited, hence the liquidation of the war may be contemplated." How different the truth about that "inspection trip" which had the effect, certainly, of impressing the American Staff with the extreme seriousness of the campaign, but led to the result not of "quitting" but of brigading the American troops temporarily with those of the Allies. It was an instance of a sensible sacrifice of national vanity that has probably no parallel in history—that decision of the Americans to allow their soldiers to fight under British and French flags while they learned their business. Unhappy German people to have been fed by their leaders with such delusions! The United States a "quitter"! Had any German read the history of the 18th and 19th centuries—heard of Washington, of Hamilton, of Lincoln? If the German had searched back only so far as 1861 he would have found that the nation which he was told might throw up the sponge at the first hint of hardship and danger, faced a war which probably, for nerve strain and call for grim resolution, surpassed even this great war. The United States had then to fight not a foreign foe but domestic discord. It had to set its teeth through a series of great military disasters. It had to hold firmly to a forlorn hope, whilst it was faced by the ever-present prospect of foreign interference. No nation in modern times has been put to a harsher test of courage and resolution than the United States in 1861 and the following year. No nation in history showed a more indomitable courage. And this was the nation that the German leaders would fain persuade their people was likely to prove a "quitter!" I ventured to say at the time that before the German military despotism was through with the war it would recognise that the reluctance of the United States to enter the war would be matched by the reluctance of the United States to go out of the war until its purpose was finally accomplished.
  • 83.
    To tell thestory of the American participation in the war does not come within the province of this work, but some of the facts can be told of that most dramatic feature of the last stages of the Great War. There was a very elaborate and very successful mystification of the enemy over the time, the extent, and the equipment of American arrivals on the Western Front. The American "Intelligence," in co- operation with our own and the French Intelligence Branches, managed to surround these matters with so much mystery that some of our own high Staff Officers never knew the exact position, and strangely over-estimated the strength of the American Force on the Western Front. There is good reason to believe that the German High Command was completely deceived and found its difficulties increased accordingly. From almost the first day of the war there were a few individual Americans fighting for the Allies. In September, 1914, I encountered two personally with the British Army, and I suppose the actual total number was some hundreds. Later a great many came over with the Canadian contingents; and there was also a flying unit, which made a fine reputation for itself. This began with a small group of Americans in the Foreign Legion of the French Army. In the spring of 1915 the formation of an American squadrilla was decided upon. At first the French Minister of War was not inclined to sanction the proposition, but afterwards decided that no international law prevented Americans from enlisting voluntarily, in spite of their country's neutrality. The squadrilla was to be known as the "Escadrille Américaine," and to be commanded by a French captain. On November 16th, 1916, Colonel Barès, Chief of the French Aviation at General Headquarters, decided that the name "Escadrille Américaine" must be dropped and the official military number, N124, used in future. The reason given was that Bernstorff had protested to Washington "that Americans were fighting on the French Front, that the French communiqués contained the name 'Escadrille Américaine,' and that these volunteer Americans pushed their brazenness to the point of having a red Sioux Indian in full war-paint
  • 84.
    depicted on theirmachines." Captain Berthaud, at the Ministry of War, suggested the adoption of the name "Escadrille de Volontaires," but the name finally adopted was "Lafayette Escadrille." More than 200 American volunteers entered the Lafayette Escadrille before America joined in the war. Some remained in the squadrilla, others were transferred to various French units, where they frequently distinguished themselves by the brilliance of their exploits. All these troops, however, were strictly unofficial and of course discountenanced by the American Government. After the American declaration of war, American help was confined for a long time to labour units, forestry and railway workers. It was not until May, 1918, that there was any really considerable American fighting force in France, and not until June, 1918, that it began to have any weight in the fighting line, and then only as units brigaded with British and French troops. It was the usual plan—a plan made possible by the admirable and business-like lack of false pride among the Americans —to split up their troops among other troops, allow them thus to be "blooded," and after experience as platoons, companies, brigades, to retire to their own training grounds and form "pukka" Divisions of their own. By April 25th, 1918, there were 12,700 American troops in our lines in France, by May 25th 79,000, by June 25th 188,000. Then the Second Army Corps was formed and absorbed 95,000 men. The May, 1918, programme provided for the arrival of six American Divisions within the British zone of operations, and there actually were 108,921 American troops attached to the British Army at the end of that month. The British Army took responsibility for the feeding and equipment of these troops. The system was adopted of assigning to each American Division as it arrived a British "mother" Division, to see it through its early troubles of transport, equipment, food and accommodation. The system worked admirably and there was very little friction in connection with the settling down of the Americans. Yet the task of adjustment was not easy. The American troops had to be equipped with almost everything except uniforms, badges and caps. The things they had were almost as much a cause
  • 85.
    Welcome to ourwebsite – the perfect destination for book lovers and knowledge seekers. We believe that every book holds a new world, offering opportunities for learning, discovery, and personal growth. That’s why we are dedicated to bringing you a diverse collection of books, ranging from classic literature and specialized publications to self-development guides and children's books. More than just a book-buying platform, we strive to be a bridge connecting you with timeless cultural and intellectual values. With an elegant, user-friendly interface and a smart search system, you can quickly find the books that best suit your interests. Additionally, our special promotions and home delivery services help you save time and fully enjoy the joy of reading. Join us on a journey of knowledge exploration, passion nurturing, and personal growth every day! ebookbell.com