100% found this document useful (2 votes)
160 views62 pages

Mastering Ext JS Second Edition Groner Loiane 2024 Scribd Download

JS

Uploaded by

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

Mastering Ext JS Second Edition Groner Loiane 2024 Scribd Download

JS

Uploaded by

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

Download the full version of the textbook now at textbookfull.

com

Mastering Ext JS Second Edition Groner Loiane

https://textbookfull.com/product/mastering-ext-js-
second-edition-groner-loiane/

Explore and download more textbook at https://textbookfull.com


Recommended digital products (PDF, EPUB, MOBI) that
you can download immediately if you are interested.

Mastering Ext JS 1st Edition Loiane Groner

https://textbookfull.com/product/mastering-ext-js-1st-edition-loiane-
groner/

textbookfull.com

JavaScript Regular Expressions 1st Edition Groner Loiane


Manricks Gabriel

https://textbookfull.com/product/javascript-regular-expressions-1st-
edition-groner-loiane-manricks-gabriel/

textbookfull.com

Instant Ext JS Starter 1st Edition Bhava Nagarajan

https://textbookfull.com/product/instant-ext-js-starter-1st-edition-
bhava-nagarajan/

textbookfull.com

Hagenberg Business Process Modelling Method 1st Edition


Felix Kossak

https://textbookfull.com/product/hagenberg-business-process-modelling-
method-1st-edition-felix-kossak/

textbookfull.com
Rethinking Bail: Court Reform or Business as Usual? Max
Travers

https://textbookfull.com/product/rethinking-bail-court-reform-or-
business-as-usual-max-travers/

textbookfull.com

Principles of Seismology Agustín Udías

https://textbookfull.com/product/principles-of-seismology-agustin-
udias/

textbookfull.com

Lonely Planet Pocket Stockholm Ohlsen

https://textbookfull.com/product/lonely-planet-pocket-stockholm-
ohlsen/

textbookfull.com

Advantages and Pitfalls of Pattern Recognition: Selected


Cases in Geophysics: Volume 3 1st Edition Horst Langer

https://textbookfull.com/product/advantages-and-pitfalls-of-pattern-
recognition-selected-cases-in-geophysics-volume-3-1st-edition-horst-
langer/
textbookfull.com

The right of self determination of peoples the


domestication of an illusion First English Edition Fisch

https://textbookfull.com/product/the-right-of-self-determination-of-
peoples-the-domestication-of-an-illusion-first-english-edition-fisch/

textbookfull.com
Lesson Plans to Train Like You Fly a flight instructor s
reference for scenario based training Mcmahon

https://textbookfull.com/product/lesson-plans-to-train-like-you-fly-a-
flight-instructor-s-reference-for-scenario-based-training-mcmahon/

textbookfull.com
Mastering Ext JS
Second Edition

Learn how to develop advanced and efficient Internet


applications with Ext JS

Loiane Groner

BIRMINGHAM - MUMBAI
Mastering Ext JS
Second Edition

Copyright © 2015 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 author 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: July 2013

Second edition: February 2015

Production reference: 1180215

Published by Packt Publishing Ltd.


Livery Place
35 Livery Street
Birmingham B3 2PB, UK.

ISBN 978-1-78439-045-7

www.packtpub.com
Credits

Author Project Coordinator


Loiane Groner Sanchita Mandal

Reviewers Proofreaders
Peter Holcomb Simran Bhogal
Girish Srivastava Maria Gould
Thorsten Suckow-Homberg Paul Hindle

Commissioning Editor Indexer


Ashwin Nair Hemangini Bari

Acquisition Editor Graphics


Kevin Colaco Abhinash Sahu

Content Development Editor Production Coordinator


Adrian Raposo Aparna Bhagat

Technical Editor Cover Work


Vijin Boricha Aparna Bhagat

Copy Editor
Sarang Chari
About the Author

Loiane Groner has over 9 years of experience in software development. While


at university, she demonstrated great interest in IT. Loiane worked as a teaching
assistant for 2.5 years and taught algorithms, data structures, and computing theory.
She represented her university at the ACM International Collegiate Programming
Contest—Brazilian Finals (South America Regionals) and also worked as a student
delegate of the Brazilian Computing Society (SBC) for 2 years. Loiane won a merit
award in her senior year for being one of the top three students with the best GPAs
in the computer science department and also graduated with honors.

Loiane has worked at multinational companies, such as IBM. Her areas of expertise
include Java SE and Java EE and also Sencha technologies (Ext JS and Sencha
Touch). Nowadays, Loiane works as a software development manager at a financial
institution, where she manages overseas solutions. She also works as an independent
Sencha consultant and coach.

Loiane is also the author of Ext JS 4 First Look, Mastering Ext JS, Sencha Architect App
Development, and Learning JavaScript Data Structure and Algorithms, all published by
Packt Publishing.

She is passionate about Sencha and Java; she is a leader of Campinas Java Users
Group (CampinasJUG) and a coordinator of Espirito Santo Java Users Group
(ESJUG), both Brazilian JUGs.

Loiane also contributes to the software development community through her blogs,
http://loianegroner.com (English) and http://loiane.com (Portuguese-
BR), where she writes about IT careers, Ext JS, Sencha Touch, PhoneGap, Spring
Framework, and general development notes, as well as publishing screencasts.

If you want to keep in touch, you can find Loiane on Facebook


(https://www.facebook.com/loianegroner) and Twitter (@loiane).

Loiane's profile is already available on the Packt Publishing website,


https://www.packtpub.com/books/info/authors/loiane-groner.
Acknowledgments
I would like to thank my parents for giving me education, guidance, and advice all
these years and helping me to become a better human being and professional. A
very special thanks to my husband for being patient and supportive and giving
me encouragement.

I also would like to thank the readers of this book and the other books I have written,
for their support and feedback. Your feedback is very valuable to me to improve as
an author and as a professional. Thank you very much!
About the Reviewers

Peter Holcomb has been working with Ext JS for several years, right from version
2, and has thoroughly enjoyed being a part of the Sencha community as it has grown.
A tinkerer at heart, Peter tries to spend his free time on a variety of projects to keep
his skills sharp and stay on top of new frameworks and technologies. He's currently
a lead frontend engineer at SailPoint Technologies, Inc., a company that he's been
fortunate to be a part of for over 8 years. He lives in Austin with his wife, Courtney,
and two children and thoroughly enjoys breakfast tacos.

Girish Srivastava works as a technical associate at Vision Technologies,


Bengaluru (formerly, Bangalore). He is a good speaker and an industry expert on
data warehousing and web-based solutions and their implementations. He used
to facilitate training sessions on different technologies such as Java SE/Java EE,
JavaScript, Ext JS, IBM PureData System for Analytics (IBM Netezza), Perl/CGI, SAP
BO, Tableau, and so on. Girish has worked as a technical consultant in the IT industry.

I would like to thank the Almighty, my parents, B.M.P. Kiran


and Mina Devi, my family, and my loveable friends, who have
supported and backed me throughout my life. I would also like to
thank Rawal Thakur, the managing director of my company, who
gave me brilliant opportunities, ample time, and some extraordinary
resources to explore new and emerging technologies. My thanks
also goes to Packt Publishing for selecting me as one of the technical
reviewers for this wonderful book. It is an honor to be a part of it.
Thorsten Suckow-Homberg is a software developer from Aachen, Germany.
He took his first programming steps with AmigaBASIC, peeked into Turbo Pascal,
Modula-3, and learned to love the strange yet wonderful abstract world of object-
oriented programming (OOP) with Java. Most of the time, he works on PHP/
JavaScript-driven web applications, such as conjoon.com, of which he is the main
developer. If he's not traveling around teaching JavaScript and Ext JS, you'll most
likely find him in the woods, riding his mountain bike, or sitting in front of his desk,
sipping coffee and engineering code.
www.PacktPub.com

Support files, eBooks, discount offers, and more


For support files and downloads related to your book, please visit www.PacktPub.com.

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 [email protected] 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

https://www2.packtpub.com/books/subscription/packtlib

Do you need instant solutions to your IT questions? PacktLib is Packt's online digital
book library. Here, you can search, access, and read 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 a 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 9 entirely free books. Simply use your login credentials for
immediate access.
Table of Contents
Preface 1
Chapter 1: Sencha Ext JS Overview 7
Understanding Sencha Ext JS 7
Architecture of Ext JS applications 8
Ext JS overview 9
Basic tutorial 9
Class system 9
Components 10
The component hierarchy 10
GridPanel 11
TreePanel 12
Forms 12
Other components 13
Layouts 13
Data package 14
The MVC and MVVM architectures 14
Look and feel of Ext JS applications 15
Installing Ext JS 15
Prerequisites for Ext JS and Sencha Cmd 15
Downloading Ext JS and Sencha Cmd 17
Offline documentation 18
IDE 20
Summary 20
Chapter 2: Getting Started 21
Preparing the development environment 21
Presenting the application and its capabilities 24
The splash screen 25
The login screen 25
Visit https://textbookfull.com
now to explore a rich
collection of eBooks, textbook
and enjoy exciting offers!
Table of Contents

The main screen 26


User administration 28
MySQL table management 28
Content management control 29
Charts 31
Creating the application with Sencha Cmd 31
A quick word about MVC 32
Creating the application 33
Looking out for changes with the watch command 38
Applying the first changes in our app 40
Understanding the Application.js file 41
Creating the loading page 43
Summary 52
Chapter 3: The Login Page 53
The Login screen 53
Creating the Login screen 54
Client-side validations 60
Creating custom VTypes 62
Adding the toolbar with buttons 64
Running the code 66
Adding Font Awesome support (Glyph icons) 68
Creating the Login Controller 70
Introducing the MVVM architecture 70
Creating the ViewController for Login View 72
Listening to the button click event 73
Creating the User and Groups tables 79
Handling the Login page on the server 80
Connecting to the database 80
Login.php 81
Handling the return of the server – logged in or not? 84
Reusing code by creating a Util class 89
Enhancing the Login screen 91
Applying a loading mask on the form while authenticating 91
Form submit on Enter 92
Caps Lock warning message 93
Summary 97
Chapter 4: The Logout and Multilingual Capabilities 99
The base of the application – view/main/Main.js 100
The Viewport 100
Using the Viewport plugin 101
Organizing the main screen using the Border layout 102
Creating the main TabPanel component 104

[ ii ]
Table of Contents

Creating the footer 105


Creating the Header class 107
The main screen and MVVM 111
The main ViewModel 112
Logout capability 113
Handling the logout on the server 115
Ajax request success versus failure 115
Client-side activity monitor 118
The multilingual capability 120
Creating the change language component 121
Adding the CSS – country flags 122
Using the translation component 123
Creating the multilingual files 124
Applying the translation on the application's components 125
HTML5 local storage 126
Handling change language in real time 128
The early life of the ViewController 129
Using locale files to translate Ext JS 131
Summary 132
Chapter 5: Advanced Dynamic Menu 133
An overview of the dynamic menu 134
Ext JS TreePanel 135
Accordion layout 136
The database model – groups, menus, and permissions 137
The dynamic menu – an MVC approach 139
Creating the models 140
Working with the hasMany association 142
Creating the store-loading menu from the server 143
Handling the dynamic menu on the server 145
Fetching the user permissions 146
Fetching the modules the user is entitled to 147
Fetching the menu options based on modules and permissions 148
Creating the menu with the Accordion layout and TreePanel 149
Creating the menu Controller 151
Rendering the menu from nested JSON (the hasMany association) 154
Opening a menu item programmatically 160
Summary 162
Chapter 6: User Management 163
Managing users 163
Listing all the users using a simple GridPanel 165
Creating a User Model 165
Defining store-less grids with Users GridPanel 168

[ iii ]
Table of Contents

Declaring the User ViewModel 176


Working with ViewModel data binding 177
Creating the User ViewController 177
Adding and editing a new user 179
Controller – listening to the Add button 188
Controller – listening to the Edit button 189
Controller – listening to the Cancel button 190
Controller – saving a user 190
Previewing a file before uploading 196
Deleting a user 198
Displaying the group name in the Grid 199
Summary 200
Chapter 7: Static Data Management 201
Presenting the tables 202
Creating a Model 204
Abstract Model 204
Adapting the Base Model schema 205
Specific models 207
Creating a Store 209
Abstract Store 210
Specific Store 211
Creating an abstract GridPanel for reuse 212
To initComponent or not? 215
Handling the Widget Column in the MVC architecture 219
Live Search plugin versus Filter plugin 220
Specific GridPanels for each table 221
Adding the Live Search CSS 224
Generic Controller for all tables 224
Finding the correct selector 226
Using itemId versus id – Ext.Cmp is bad! 230
Adding a new record on the GridPanel 231
Editing an existing record 233
Deleting the handling Widget Column in the Controller 234
Saving the changes 235
Validating cellediting in GridPanel 236
The autoSync configuration 240
Canceling the changes 240
Clearing the filter 241
Listening to Store events in the Controller 242
Debug tip – Sencha extension for Chrome 243
Firefox extension – Illuminations for Developers 244
Summary 245

[ iv ]
Table of Contents

Chapter 8: Content Management 247


Managing information – films 247
Displaying the Film data grid 252
The Film Model 252
Films ModelView 253
Film data grid (with paging) 254
Creating the Base Grid 256
Adding the RowExpander plugin 257
Actor-Language – handling a hasOne association 258
Adding the PagingToolbar 259
Creating the films container 262
Handling many-to-many associations 264
Loading nested JSON from the server 266
Film-Actor – handling many-to-many associations 268
Film-Category – handling many-to-many associations 269
Creating the ViewController 270
The base ViewController 270
Creating the FilmsController 272
Adding or editing a film 273
Packt.view.base.WindowForm 275
The films form 277
Film categories 282
Film Actors 283
Complementing the ViewModel 288
Working with formulas and two-way data binding 289
The Films ViewController 290
The createDialog method 291
Getting the selected actor from Live Search 292
Saving the form and working with sessions 293
Custom Writer – saving associated data 294
Saving session data manually 295
Summary 296
Chapter 9: Adding Extra Capabilities 297
Exporting a GridPanel to PDF and Excel 297
Exporting to PDF 299
Generating the PDF file on the server – PHP 300
Generating and viewing the PDF file with JavaScript – HTML5 301
Exporting to Excel 301
Printing GridPanel content with the GridPrinter plugin 302
Creating a Sales by Film Category chart 304
Ext JS 5 charts and terminology 304
Adding Sencha Charts to the project 306
Creating the Store inside the ViewModel 307

[v]
Table of Contents

Pie chart 308


3D column chart 310
The Chart panel 313
The ViewController 317
Changing the chart type 317
Exporting charts to images (PNG or JPEG) 318
Summary 321
Chapter 10: Routing, Touch Support, and Debugging 323
Ext JS routing 323
Default token 324
Loading a Controller programmatically 325
Handling routes 325
Refactoring the Menu code 327
Handling unmatched routes 329
Handling parameters 329
Using the responsive design plugin 332
Enabling touch support 336
From Ext JS to mobile 339
Debugging Ext JS applications 340
Testing Ext JS applications 343
Helpful tools 344
Third-party components and plugins 346
Summary 346
Chapter 11: Preparing for Production and Themes 347
Before we start 347
Creating a new theme 348
Changing the base color 353
Customizing components 354
Some useful tips while creating new themes 358
Creating custom UIs 360
Applying the UI 364
Packaging the application for production 366
Compiling ext-locale 368
What to deploy in production 369
Benefits 369
Summary 372
Index 373

[ vi ]
Preface
If you are an Ext JS developer, it probably took you a while to learn the framework.
We know that the Ext JS learning curve is not short. After we have learned the basics,
and we need to use Ext JS in our daily jobs, a lot of questions pop up: how can one
component talk to another? What are the best practices? Is it really worth using this
approach and not another one? Is there any other way I can implement the same
feature? This is normal.

This book was written thinking about these developers.

So this is what this book is about: how do we put everything together and create
really nice applications with Ext JS? We are going to create a complete application,
from the mockup of the screens all the way to putting it into production. We
are going to create the application structure, a splash screen, a login screen, a
multilingual capability, an activity monitor, a dynamic menu that depends on user
permission, and modules to manage database information (simple and complex
information). And then, we will learn how to build the application for production,
how to customize the theme, and how to debug it.

We will use real-world examples and see how we can implement them using Ext JS
components. And throughout the book, we've also included a lot of tips and best
practices to help you boost your Ext JS knowledge and take you to the next level.

What this book covers


Chapter 1, Sencha Ext JS Overview, introduces Sencha Ext JS and its capabilities. This
chapter provides references that you can read before diving into the other chapters of
this book. This is done taking into consideration the possibility that this is your first
contact with the framework.
Preface

Chapter 2, Getting Started, introduces the application that is implemented throughout


the book, its features, and the mockup of each screen and module (each chapter
covers a different module), and also demonstrates how to create the structure of the
application using Sencha Cmd and how to create a splash screen.

Chapter 3, The Login Page, explains how to create a login page with Ext JS and how
to handle it on the server side and also shows some extra capabilities, such as adding
the Caps Lock warning message and submitting the login page when pressing the
Enter key.

Chapter 4, The Logout and Multilingual Capabilities, covers how to create the logout
capability and also the client-side activity monitor timeout, which means if the
user does not use the mouse or press any key on the keyboard, the system ends
the session automatically and logs out. This chapter also provides an example of
multilingual capability and shows how to create a component so that the user can
use it to change the system's language and locale settings.

Chapter 5, Advanced Dynamic Menu, is about how to create a dynamic menu that
depends on user permission. The options of the menu are rendered depending on
whether the user has permission or not; if not, the option will not be displayed.

Chapter 6, User Management, explains how to create a screen to list all the users that
already have access to the system.

Chapter 7, Static Data Management, covers how to implement a module where the
user is able to edit information as though they were editing information directly
from a MySQL table. This chapter also explores capabilities such as live search, filter,
and inline editing (using the Cell Editing and Row Editing plugins). Also, we start
exploring real-world issues when we develop big applications with Ext JS, such as
the reuse of components throughout the application.

Chapter 8, Content Management, further explores the complexity of managing


information from a table of the database and all its relationships with other tables.
So we cover how to manage complex information and how to handle associations
within data Grids and FormPanels.

Chapter 9, Adding Extra Capabilities, covers how to add features, such as printing and
the ability to export to PDF and Excel, that are not supported natively by Ext JS. This
chapter also covers charts and how to export them to image and PDF and also how
to use third-party plugins.

[2]
Preface

Chapter 10, Routing, Touch Support, and Debugging, demonstrates how to enable
routing in the project; it is also about debugging Ext JS applications, including what
we need to be careful about and why it is very important to know how to debug.
We also quickly talk about transforming Ext JS projects into mobile apps (responsive
design and touch support), a few helpful tools that can help you in your daily work
as a developer, and also a few recommendations of where to find extra and open
source plugins to use in Ext JS projects.

Chapter 11, Preparing for Production and Themes, covers how to customize a theme
and create custom UIs. It also explores the steps required for, and the benefits of,
packaging the application to production.

What you need for this book


The following is a list of the software you will need to have installed prior to
executing the examples of the book. The following list covers the exact software used
to implement and execute the examples of this book, but you can use any similar
software that you already have installed that has the same features.

For a browser with a debugger tool, use the following:

• Firefox with Firebug: https://www.mozilla.org/firefox/ and


http://getfirebug.com/
• Google Chrome: http://www.google.com/chrome

For a web server with PHP support, use the following:

• Xampp: http://www.apachefriends.org/en/xampp.html

For the database, use the following:

• MySQL: http://dev.mysql.com/downloads/mysql/
• MySQL Workbench: http://dev.mysql.com/downloads/tools/
workbench/
• MySQL Sakila sample database: http://dev.mysql.com/doc/index-
other.html and http://dev.mysql.com/doc/sakila/en/index.html

For Sencha Cmd and the required tools, use the following:

• Sencha Cmd: http://www.sencha.com/products/sencha-cmd/download


• Ruby 1.8 or 1.9: http://www.ruby-lang.org/en/downloads/
• Sass: http://sass-lang.com/

[3]
Preface

• Compass: http://compass-style.org/
• Java JDK (version 7 or later): http://www.oracle.com/technetwork/java/
javase/downloads/index.html
• Java environment variables: http://docs.oracle.com/javase/tutorial/
essential/environment/paths.html
• Apache ANT: http://ant.apache.org/bindownload.cgi
• Apache ANT environment variable: http://ant.apache.org/manual/
install.html
• And of course, Ext JS: http://www.sencha.com/products/extjs/

We will use Ext JS 5.0.1 in this book.

Who this book is for


If you are a developer who is familiar with Ext JS and want to augment your skills
to create even better web applications, this is the book for you. Basic knowledge
of JavaScript/HTML/CSS and any server-side language (PHP, Java, C#, Ruby, or
Python) is required.

Conventions
In this book, you will find a number of text styles that distinguish between different
kinds of information. Here are some examples of these styles and an explanation of
their meaning.

Code words in text, database table names, folder names, filenames, file extensions,
pathnames, dummy URLs, user input, and Twitter handles are shown as follows:
"If we want to create a class to represent the client details, we could name it
ClientDetails."

A block of code is set as follows:


Ext.define('Packt.model.film.Film', {
extend: 'Packt.model.staticData.Base', //#1

When we wish to draw your attention to a particular part of a code block, the
relevant lines or items are set in bold:
Ext.application({
name: 'Packt',

extend: 'Packt.Application',

[4]
Preface

autoCreateViewport: 'Packt.view.main.Main'
});

Any command-line input or output is written as follows:


sencha generate app Packt ../masteringextjs

New terms and important words are shown in bold. Words that you see on the
screen, for example, in menus or dialog boxes, appear in the text like this: "Scroll
until the end of the page and select OPEN SOURCE GPL LICENSING."

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 disliked. Reader feedback is important for us as it helps
us develop titles that you will really get the most out of.

To send us general feedback, simply e-mail [email protected], and mention


the book's title in 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 at 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 from your account at http://www.
packtpub.com for all the Packt Publishing books you have purchased. 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.

[5]
Visit https://textbookfull.com
now to explore a rich
collection of eBooks, textbook
and enjoy exciting offers!
Preface

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 could 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 to our website or added
to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to https://www.packtpub.com/books/


content/support and enter the name of the book in the search field. The required
information will appear under the Errata section.

Piracy
Piracy of copyrighted 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 [email protected] 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
If you have a problem with any aspect of this book, you can contact us at
[email protected], and we will do our best to address the problem.

[6]
Sencha Ext JS Overview
Nowadays, there are many flavors for frontend frameworks and libraries in the
market. There are frameworks you can use if you only want to manipulate the
Document Object Model (DOM), frameworks used only for styling, frameworks for
user-friendly components, frameworks used to design your project, and so on. Also
there is Ext JS, a framework used to create Rich Internet Applications (RIA), but it
has many other features than just pretty components.

In this book, we are going to learn how to develop an application from the beginning
to the end with Ext JS 5, also covering some pieces of the backend required to make
our application work. We will learn how to use Ext JS with hands-on examples
covering some components, how they work, and how to use them in each chapter.

But first, you are going to learn what Ext JS is capable of if this is the first time you
have come into contact with the framework.

Understanding Sencha Ext JS


Can we use Ext JS to manipulate DOM? Can we use it if we want pretty and
user-friendly components (forms, grids, trees, and so on)? Can we use it if we need
some nice charts? Can we use the Model View Controller (MVC) architecture to
organize the application with Ext JS? What if we want to use a two-way data-binding
between the Model and the View? Can we do that using Ext JS? And what if we do
not like the colors of Ext JS components' look and feel? Can we easily change it too?
And now a difficult one; can we make a build to obfuscate and optimize the CSS and
JavaScript files of our application using Ext JS? Is Ext JS responsive? Can we use it in
mobile devices?

Amazingly, the answer is positive to all the preceding questions! As we can see, Ext
JS is a complete frontend framework. The mastermind company behind Ext JS is
Sencha Inc. (http://sencha.com).
Sencha Ext JS Overview

Sencha Ext JS also has a cousin called Sencha Touch. It also has the amazing features
we just mentioned, but focuses on the mobile cross-platform world. We will talk very
briefly about Ext JS and Sencha Touch in later chapters of this book.

Architecture of Ext JS applications


Before we get started, let's make sure we understand a few of the core concepts.
Ext JS is a frontend framework based on JavaScript and HTML5. This means Ext JS
does not connect to the database directly. For storage, we can use one of the types of
HTML5 storage, such as Web SQL or local storage, but these types of storage allow
us to store only 5 MB of data, which is very little for a common application.

Usually, we want to use MySQL, Oracle, MS Server or any other database. To be able
to store information in a database, we need to use a server-side language, such as
PHP, Java, C#, Ruby, Python, Node.js, and so on. Ext JS will communicate with the
server-side language (or web services), and the server will connect to the database or
any other storage (documents repository, for example).

The following diagram exemplifies the architecture of an application developed


with Ext JS:

User

interacts with browser

Components Data Architecture


Layouts
Grid Model MVC
Fit
Form Proxy MVVM
Border
Tree Schema Hybrid
Card Sencha
Chart Session Accordion Ext JS
Button Store Themes
Hbox/Vbox
Toolbar CSS3
Center
Window Sass
Events Absolute
Compass

Request/Response HTTP/S JSON/ XML Asynchronous callback


Request

PHP/Java/ASP.NET/Python/Ruby
(frameworks)

Web Container (Tomcat, IIS, WebSphere, Apache)

Database (MySQL/Oracle/MS Server/Firebird/others)


document repository and
other services

[8]
Chapter 1

Ext JS overview
We have already mentioned some Ext JS capabilities. Let's take a brief look at each
one of them. But first, if you want to take a look at the official Sencha Ext JS webpage,
visit http://www.sencha.com/products/extjs/.

Basic tutorial
Before diving into this book, it is recommended that you read the contents of the
following links. They contain the basic information that any developer needs
to learn before starting with Ext JS:

• Basic tutorial and Ext JS overview: http://www.sencha.com/products/


extjs/up-and-running
• Ext JS guides: http://docs.sencha.com/extjs/5.0/
• Ext JS documents: http://docs.sencha.com/extjs/5.0/apidocs/
• Ext JS examples: http://dev.sencha.com/ext/5.0.1/examples/index.
html
• Forum (become part of the community): http://www.sencha.com/forum/

Class system
Ext JS uses an object-oriented (OO) approach. We declare classes with attributes
known in Ext JS as configurations and methods (functions in JavaScript).

Ext JS also follows a naming convention. If you are familiar with OO programming,
you are probably familiar with the naming conventions of Ext JS as well. For
example, class names are alphanumeric, starting with an uppercase character, and
and then the rest of the letters are in CamelCase. For example, if we want to create a
class to represent the client details, we could name it ClientDetails. Method and
attribute names start with a lowercase character and then the rest of the letters are in
CamelCase. For example, retrieveClientDetails() is a good name for a method
and clientName is a good name for an attribute.

Ext JS is organized in packages as well. Packages are a way of organizing the code
that has the same purpose. For example, in Ext JS, there is a package called data that
handles everything related to data in the framework. There is a packaged named
grid that contains all the code related to GridPanels.

[9]
Sencha Ext JS Overview

For more information about the class system, please read http://docs.
sencha.com/extjs/5.0/core_concepts/classes.html.

Components
The main reason some people consider using Ext JS is probably because of its rich and
user-friendly components. Ext JS contains some of the most used components in web
applications, such as forms, grids, and trees. We can also use charts that are touch-
friendly (meaning they work on touchscreens as well) and the drawing package that
uses all the advantages of Scalable Vector Graphics (SVG) and HTML5.

You can checkout the official Sencha Ext JS examples page at http://dev.sencha.
com/extjs/5.0.0/examples/index.html to have an idea of what we can do with
the examples.

The component hierarchy


You will notice that throughout this book, we will mention terms such as component,
container, and widget. The following diagram exemplifies the component hierarchy
in Ext JS:

Component

Tool
LoadMask
Button Container

Viewport Toolbar

Panel

TabPanel Window
Menu
Table
Form

Grid Tree

[ 10 ]
Random documents with unrelated
content Scribd suggests to you:
I WAS not with the rest at play;
My brothers laughed in joyous mood:
But I—I wandered far away
Into the fair and silent wood;
And with the trees and flowers I stood,
As dumb and full of dreams as they:
—For One it seemed my whole heart knew,
Or One my heart had known long since,
Was peeping at me through the dew;
And with bright laughter seemed to woo
My beauty, like a Fairy prince.

Oh, what a soft enchantment filled


The lonely paths and places dim!
It was as though the whole wood thrilled,
And a dumb joy, because of him,
Weighed down the lilies tall and slim,
And made the roses blush, and stilled
The great wild voices in half fear:
It was as though his smile did hold
All things in trances manifold;
And in each place as he drew near
The leaves were touched and turned to gold.

And well I seemed to know, the while,


It was for me and for my sake,
He wrought that magic with his smile,
And set the unseen spells to make
The lonely ways I loved to take
So full of sweetness, to beguile
My heart and keep me there for hours;
And sometimes I was sure he lay
Beside me hid among the flowers,
Or climbed above me and in play
Or climbed above me, and in play
Shook down the white tree-bloom in showers.

But more and more he seemed to seek


My heart: till, dreaming of all this,
I thought one day to hear him speak,
Or feel, indeed, his sudden kiss
Bind me to some great unknown bliss:
Then there would stay upon my cheek
Full many a light and honied stain,
That told indeed how I had lain
Deep in the flowery banks all day;
And round me too there would remain
Some strange wood-blossom’s scent alway.

’Twas not the bright and fond deceit


Of that first summer,—whose great bloom
Quite overcame me with its sweet,
And seemed to fill me and consume
My very brain with its perfume;—
’Twas no false spell made my heart beat
With such a joy to be alone
With all the bloom and all the scent:
It was a thing I dared not own,
Already whispered there and known,
Already with my whole life blent.

It was this secret, vast, sublime,


Too full of wonder to be told—
Whose extreme rapture from that time
Doth ever more and more enfold
My spirit, like a robe of gold,
Or, as it were, the magic clime
Of some fair heaven about me shed—
Wherein are songs of unseen birds,
And whispers of delicious words
And whispers of delicious words
More sweet than any man hath said
Of all the living or the dead.

—O, the incomparable love


Of him, my Lover!—O, to tell
Its way and measure were above
The throbbing chords of speech that swell
Within me!—Doth it not excel
All other, sung or written of?
Yea now, O all ye fair mankind—
Consider well the gracious line
Of those your lovers; call to mind
Their love of you, and ye shall find
Not one among them all like mine.

It seems as though, from calm to calm,


A whole fair age had passed me by,
Since first this Lover, through a charm
Of flowers, wooed so tenderly,
I had no fear of drawing nigh,
Nor knew, indeed, that—with an arm
Closed round and holding me—he led
My eager way from sight to sight
Of all the summer magic—right
To where himself had surely spread
Some pleasant snare for my delight.

And now, in an eternal sphere,


Beneath one flooding look of his—
Wherein, all beautiful and dear,
That endless melting gold that is
His love, with flawless memories
Grows ever richer and more clear—
My life seems held, as some faint star
Beneath its sun: and through the far
g
Celestial distances for miles,
To where vast mirage futures are,
I trace the gilding of his smiles.

And, in the long enthralling dream,


That, ever—through each purer zone
Of love translating me—doth seem
To bring my spirit near his own,
I hear the veiled angelic tone
Of many voices; as I deem,
Assuring me of something sweet,
And strange, and wondrous, and intense;
Which thing they evermore repeat
In fair half parables, from whence
I draw a vague all-blissful sense.

For, one by one, e’en as I rise,


And feel the pure Ethereal
Refining all before my eyes:
Whole beauteous worlds material
Are seen to enter gradual
The great transparent paradise
Of this my dream; and, all revealed,
To break upon me more and more
Their inward singing souls, and yield
A wondrous secret half concealed
In all their loveliness before.

And so, when, through unmeasured days,


The far effulgence of the sea
Is holding me in long amaze,
And stealing with strange ecstasy
My heart all opened silently;—
There reach me, from among the sprays,
Ineffable faint words that sing
Within me,—how, for me alone,
One who is lover—who is King,
Hath dropt, as ’twere a precious stone,
That sea—a symbol of his throne.

And now, indeed, some precious time


It hath,—all inexpressible!
All rapture!—yea, through many a rhyme
Of wordless speech made fairly well,
And beauteous worlds’ whole visible
Unbosomings of love sublime—
It hath some blessèd while become
Familiar, how all things take part
For him to whose love I am come,
And in their ways—not weak nor dumb—
Are ever calling on my heart.

And, through the long charmed solitude


Of throbbing moments, whose strong link
Is one delicious hope pursued
From trance to trance, the while I think
And know myself upon the brink
Of His eternal kiss,—endued
With part of him, the very wind
Hath power to ravish me in sips
Or long mad wooings that unbind
My hair,—wherein I truly find
The magic of his unseen lips.

And, so almighty is the thrill


I feel at many a faintest breath
Or stir of sound—as ’twere a rill
Of joy traversing me, or death
Dissolving all that hindereth
My thought from power to fulfil
Some new embodiment of bliss,—
I do consume with the immense
Delight as of some secret kiss,
And am become like one whose sense
Is used with raptures too intense!

O like some soft insidious breath,


Whose first invasion winneth quite
To all its madness or its death
The heart, resisting not the might
And poison of its new delight,—
E’en so is this that entereth
In whispers, or through subtly wrought
Enchantment snaring every thought;
Yea, by the whole mysterious pore
Of life,—this joy surpassing aught
That heart of man hath known before.

And, though, indeed, a hapless end


Of damning ruin were but sure,
Yet could I none of me defend
From such a sweet and perfect lure;
But must, as long as they endure,
To all these sorceries still lend
My heart; believing how I stand
Nigh some unearthly bliss that lies
Dissembled all before my eyes;—
Do I not see a radiant Hand
Transmuting earth, and air, and skies?

—And is not the great language mute


The stars’ deep looks are wont to melt
Upon my soul, the very suit
Of this unearthly wooer—felt
So clearly pleading—I have knelt
Full oft, most dreading to pollute
The holy rapture with a sigh?
And doth not every accent nigh
Consume each Past to a thin shred;
While endless visions glorify
My sight, and haloes touch my head?

Yea, mystic consummation! yea,


O Wondrous suitor,—whosoe’er
Thou art; that in such mighty way,
In distant realms, athwart the air
And lands and seas, with all things fair,
Hast wooed me even till this day;—
It seems thou drawest near to me;
Or I, indeed, so nigh to thee,
I catch rare breaths of a delight
From thy most glorious country, see
Its distant glow upon some height.

At times there is vouchsafed me, e’en


Some sign that certainly foretells
Of thee at hand: so I have seen—
Caught by no earthly clash of bells—
A gleam of silver citadels;
Distant, and radiant with such sheen
As only on high virgin snows,
Or from the diamond one knows;
Displayed a moment, without shroud,
Eclipsing all the night’s fair shows
From some dim pinnacle of cloud:

Or, through a calm hushed interval


Of most charmed thinking, there hath passed,
And with no rumour or footfall,
A troop of blonde ones who surpassed
All l f l li d
All tales of loveliness amassed
In my child’s dreamland; costumed all
As for a bridal; who did shine
With such a splendour on each face,
And light upon the garments fine,
I knew them surely of a race
That dwells in that fair realm of thine.

O thou my Destiny! O thou


My own—my very Love—my Lord!
Whom from the first day until now
My heart, divining, hath adored
So perfectly it hath abhorred
The tie of each frail human vow—
O I would whisper in thine ear—
Yea, may I not, once, in the clear
Pure night, when, only, silver shod
The angels walk?—thy name, I fear
And love, and tremble saying—GOD!
A WHISPER FROM THE GRAVE.
MY life points with a radiant hand,
Along a golden ray of sun
That lights some distant promised land,
A fair way for my feet to run:
My Death stands heavily in gloom,
And digs a soft bed in the tomb
Where I may sleep when all is done.

The flowers take hold upon my feet;


Fair fingers beckon me along;
I find Life’s promises so sweet
Each thought within me turns to song:
But Death stands digging for me—lest
Some day I need a little rest,
And come to think the way too long.

O seems there not beneath each rose


A face?—the blush comes burning through;
And eyes my heart already knows
Are filling themselves from the blue,
Above the world; and One, whose hair
Holds all my sun, is coming, fair,
And must bring heaven if all be true:

And now I have face, hair, and eyes;


And lo, the Woman that these make
Is more than flower, and sun, and skies!
Her slender fingers seem to take
My whole fair life, as ’twere a bowl,
Wherein she pours me forth her soul,
And bids me drink it for her sake.

Methinks the world becomes an isle;


And there—immortal, as it seems—
I gaze upon her face, whose smile
Flows round the world in golden streams:
Ah, Death is digging for me deep,
Lest some day I should need to sleep
And solace me with other dreams!

But now I feel as though a kiss


Of hers should ever give me birth
In some new heaven of life-long bliss;
And heedlessly, athwart my mirth,
I see Death digging day by day
A grave; and, very far away,
I hear the falling of the earth.

Ho there, if thou wilt wait for me


Thou Death!—I say—keep in thy shade;
Crouch down behind the willow tree,
Lest thou shouldst make my love afraid;
If thou hast aught with me, pale friend,
Some flitting leaf its sigh shall lend
To tell me when the grave is made!

And lo, e’en while I now rejoice,


Encircled by my love’s fair arm,
There cometh up to me a voice,
Yea, through the fragrance and the charm;
Quite like some sigh the forest heaves
Quite soft—a murmur of dead leaves,
And not a voice that bodeth harm:

O lover, fear not—have thou joy;


For life and love are in thy hands:
I seek in no wise to destroy
The peace thou hast, nor make the sands
Run quicker through thy pleasant span;
Blest art thou above many a man
Blest art thou above many a man,
And fair is She who with thee stands:

I only keep for thee out here—


O far away, as thou hast said,
Among the willow trees—a clear
Soft space for slumber, and a bed;
That after all, if life be vain,
And love turn at the last to pain,
Thou mayst have ease when thou art dead.

O grieve not: back to thy love’s lips


Let her embrace thee more and more,
Consume that sweet of hers in sips:
I only wait till it is o’er;
For fear thou’lt weary of her kiss,
And come to need a bed like this
Where none shall kiss thee evermore.

Believe each pleasant muttered vow


She makes to thee, and see with ease
Each promised heaven before thee now;
I only think, if one of these
Should fail thee—O thou wouldst need then
To come away right far from men,
And weep beneath the willow trees.

And, therefore, have I made this place,


Where thou shouldst come on that hard day,
Full of a sad and weary grace;
For here the drear wind hath its way
With grass, and flowers, and withered tree—
As sorrow shall that day with thee,
If it should happen as I say.

And, therefore, have I kept the ground,


As ’twere quite holy year by year;
As twere quite holy, year by year;
The great wind lowers to a sound
Of sighing as it passes near;
And seldom doth a man intrude
Upon the hallowed solitude,
And never but to shed a tear.

So, if it be thou come, alas,


For sake of sorrow long and deep,
I—Death, the flowers, and leaves, and grass—
Thy grief-fellows, do mourn and weep:
Or if thou come, with life’s whole need
To rest a life-long space indeed,
I too and they do guard thy sleep.

Moreover, sometimes, while all we


Have kept the grave with heaviness,
The weary place hath seemed to be
Not barren of all blessedness:
Spent sunbeams rest them here at noon,
And grieving spirits from the moon
Walk here at night in shining dress.

And there is gazing down on all


Some great and love-like eye of blue,
Wherefrom, at times, there seem to fall
Strange looks that soothe the place quite through;
As though indeed, if all love’s sweet
And all life’s good should prove a cheat,
They knew some heaven that might be true.

—It is a tender voice like this


That comes to me in accents fair:
Well; and through much of love and bliss,
It seemeth not a thing quite bare
Of comfort, e’en to be possest
Of that one spot of earth for rest,
Among the willow trees down there.
BISCLAVARET.
Bisclaveret ad nun en Bretan,
Garwall l’apelent li Norman.
Jadis le poët-hum oïr,
E souvent suleit avenir,
Humes plusurs Garwall devindrent
E es boscages meisun tindrent.
Marie de France: Lais.
IN either mood, to bless or curse,
God bringeth forth the breath of man;
No angel sire, no woman nurse
Shall change the work that God began:

One spirit shall be like a star,


He shall delight to honour one;
Another spirit he shall mar;
None shall undo what God hath done.

The weaker holier season wanes;


Night comes with darkness and with sins;
And, in all forests, hills, and plains,
A keener, fiercer life begins.

And, sitting by the low hearth fires,


I start and shiver fearfully;
For thoughts all strange and new desires
Of distant things take hold on me;

And many a feint of touch or sound


Assails me, and my senses leap
As in pursuit of false things found
And lost in some dim path of sleep.

But, momently, there seems restored


A triple strength of life and pain;
I thrill, as though a wine were poured
Upon the pore of every vein:

I burn—as though keen wine were shed


On all the sunken flames of sense—
Yea, till the red flame grows more red,
And all the burning more intense,
And, sloughing weaker lives grown wan
With needs of sleep and weariness,
I quit the hallowed haunts of man
And seek the mighty wilderness.

—Now over intervening waste


Of lowland drear, and barren wold,
I scour, and ne’er assuage my haste,
Inflamed with yearnings manifold;

Drinking a distant sound that seems


To come around me like a flood;
While all the track of moonlight gleams
Before me like a streak of blood;

And bitter stifling scents are past


A-dying on the night behind,
And sudden piercing stings are cast
Against me in the tainted wind.

And lo, afar, the gradual stir,


And rising of the stray wild leaves;
The swaying pine, and shivering fir,
And windy sound that moans and heaves

In first fits, till with utter throes


The whole wild forest lolls about:
And all the fiercer clamour grows,
And all the moan becomes a shout;

And mountains near and mountains far


Breathe freely: and the mingled roar
Is as of floods beneath some star
Of storms, when shore cries unto shore.

But soon, from every hidden lair


Beyond the forest tracts in thick
Beyond the forest tracts, in thick
Wild coverts, or in deserts bare,
Behold They come—renewed and quick—

The splendid fearful herds that stray


By midnight, when tempestuous moons
Light them to many a shadowy prey,
And earth beneath the thunder swoons.

—O who at any time hath seen


Sight all so fearful and so fair,
Unstricken at his heart with keen
Whole envy in that hour to share

Their unknown curse and all the strength


Of the wild thirsts and lusts they know,
The sharp joys sating them at length,
The new and greater lusts that grow?

But who of mortals shall rehearse


How fair and dreadfully they stand,
Each marked with an eternal curse,
Alien from every kin and land?

—Along the bright and blasted heights


Loudly their cloven footsteps ring!
Full on their fronts the lightning smites,
And falls like some dazed baffled thing.

Now through the mountain clouds they break,


With many a crest high-antlered, reared
Athwart the storm: now they outshake
Fierce locks or manes, glossy and weird,

That sweep with sharp perpetual sound


The arid heights where the snows drift,
And drag the slain pines to the ground,
And all into the whirlwind lift

The heavy sinking slopes of shade


From hidden hills of monstrous girth,
Till new unearthly lights have flayed
The draping darkness from the earth.

Henceforth what hiding-place shall hide


All hallowed spirits that in form
Of mortal stand beneath the wide
And wandering pale eye of the storm?

The beadsman in his lonely cell


Hath cast one boding timorous look
Toward the heights; then loud and well,
—Kneeling before the open book—

All night he prayeth in one breath,


Nor spareth now his sins to own:
And through his prayer he shuddereth
To hear how loud the forests groan.

For all abroad the lightnings reign,


And rally, with their lurid spell,
The multitudinous campaign
Of hosts not yet made fast in hell:

And us indeed no common arm,


Nor magic of the dark may smite,
But, through all elements of harm,
Across the strange fields of the night—

Enrolled with the whole giant host


Of shadowy, cloud-outstripping things
Whose vengeful spells are uppermost,
And convoyed by unmeasured wings,
We foil the thin dust of fatigue
With bright-shod phantom feet that dare
All pathless places and the league
Of the light shifting soils of air;

And loud, mid fearful echoings,


Our throats, aroused with hell’s own thirst,
Outbay the eternal trumpetings;
The while, all impious and accurst,

Revealed and perfected at length


In whole and dire transfigurement,
With miracle of growing strength
We win upon a keen warm scent.

Before us each cloud fastness breaks;


And o’er slant inward wastes of light,
And past the moving mirage lakes,
And on within the Lord’s own sight—

We hunt the chosen of the Lord;


And cease not, in wild course elate,
Until we see the flaming sword
And Gabriel before His gate!

O many a fair and noble prey


Falls bitterly beneath our chase;
And no man till the judgment day,
Hath power to give these burial place;

But down in many a stricken home


About the world, for these they mourn;
And seek them yet through Christendom
In all the lands where they were born.

And oft, when Hell’s dread prevalence


I t d t th th
Is past, and once more to the earth
In chains of narrowed human sense
We turn,—around our place of birth,

We hear the new and piercing wail;


And, through the haunted day’s long glare,
In fearful lassitudes turn pale
With thought of all the curse we bear.

But, for long seasons of the moon,


When the whole giant earth, stretched low,
Seems straightening in a silent swoon
Beneath the close grip of the snow,

We well nigh cheat the hideous spells


That force our souls resistless back,
With languorous torments worse than hell’s
To the frail body’s fleshly rack:

And with our brotherhood the storms,


Whose mighty revelry unchains
The avalanches, and deforms
The ancient mountains and the plains,—

We hold high orgies of the things,


Strange and accursèd of all flesh,
Whereto the quick sense ever brings
The sharp forbidden thrill afresh.

And far away, among our kin,


Already they account our place
With all the slain ones, and begin
The Masses for our soul’s full grace.
THOUGHT.

THERE is no place at all by night or day,


Where I—who am of that hard tyrant Thought
The slave—can find security in aught,
But He, almighty, reaching me, doth lay
His hand upon me there, so rough a way
Assaulting me,—however I am caught,
Walking or standing still—that for support
I sometimes lean on anything I may:
Then when he hath me, ease is none from him
Till he do out his strength with me; cold sweat
Comes o’er my body and on every limb;
My arm falls weak as from a fierce embrace;
And, ere he leaveth me, he will have set
A great eternal mark upon my face.
THE STORY OF THE KING.
THIS is the story of the King:
Was he not great in everything?

He built him dwelling-places three:


In one of them his Youth should be;
To make it fair for many a feast
He conquered the whole East;
He brought delight from every land,
And gold from many a river’s strand,
And all things precious he could find
In Perse, or utmost Ind.

There, brazen guarded were the doors;


And o’er the many painted floors
The captive women came and went;
Or, with bright ornament,
Sat in the pillared places gay,
And feasted with him every day,
And fed him with their rosy kiss:
O there he had all bliss!

Then afterward, when he did hear


There was none like him anywhere,
He would behold the sight so sweet
Of all men at his feet:
And, since he heard that certainly
Not like a man was he to die,
For all his lust that palace vast
It seemed too small at last.

Therefore, another house he made,


So wide that it might hold arrayed
The thousands peers of his domain
And last his godlike reign;
And here he was a goodly span,
While before him came every man
To kneel and worship in his sight:
O there he had all might!

And yet, most surely, it befel


He tired of this house as well:
Was it too mighty after all?
Or still perhaps too small?
Strangely in all men’s wonderment,
He left it for a tenement
He had all builded in one year:
Now he is dwelling there.

He took full little of his gold;


And of his pleasures manifold
He had but a small heed, they say,
That day he went away:
—O, the new dwelling he hath found
Is but a man’s grave in the ground,
And taketh up but one man’s space
In the burial place.

And now, indeed, that he is dead,


The nations have they no more dread?
Lo, is not this the King they swore
To worship evermore?
Will no one Love of his come near
And kiss him where he lieth there,
And warm his freezing lips again?
—Is this then all his reign?

He must have longed ere this to rise


And be again in all men’s eyes;
For the place where he dwelleth now
Lonely it is I trow:
Lonely it is I trow:
But, just to stand in his own hall
And feel the warmth there once for all—
O would he not give crowns of gold?
For the place is so cold!

But over him a tomb doth stand,


The costliest in all the land;
And of the glory that he bore
It telleth evermore.—
So these three dwellings he hath had,
And mighty he hath been and glad,
O hath he not been sad as well?
Perhaps—but who can tell?

This is the story of the King:


Was he not great in everything?
PALM FLOWERS.
IN a land of the sun’s blessing,
Where the passion-flower grows,
My heart keeps all worth possessing;
And the way there no man knows.

—Unknown wonder of new beauty!


There my Love lives all for me;
To love me is her whole duty,
Just as I would have it be.

All the perfumes and perfections


Of that clime have met with grace
In her body, and complexions
Of its flowers are on her face.

All soft tints of flowers most vernal,


Tints that make each other fade:
In her eyes they are eternal,
Set in some mysterious shade.

Full of dreams are the abysses


Of the night beneath her hair;
But an open dawn of kisses
Is her mouth: O she is fair.

And she has so sweet a fashion


With her languid loving eyes,
That she stirs my soul with passion,
And renews my breath with sighs.

Now she twines her hair in tresses


With some long red lustrous vine;
Now she weaves strange glossy dresses
From the leafy fabrics fine:

You might also like