Practical Vaadin: Developing Web Applications in Java 1st Edition Alejandro Duarte download
Practical Vaadin: Developing Web Applications in Java 1st Edition Alejandro Duarte download
https://ebookmeta.com/product/practical-vaadin-developing-web-
applications-in-java-1st-edition-alejandro-duarte/
https://ebookmeta.com/product/quantum-entanglement-engineering-
and-applications-f-j-duarte/
https://ebookmeta.com/product/practical-laravel-develop-clean-
mvc-web-applications-1st-edition-daniel-correa-paola-vallejo/
https://ebookmeta.com/product/primary-mathematics-3a-hoerst/
https://ebookmeta.com/product/the-pucking-wrong-number-a-hockey-
romance-1st-edition-c-r-jane/
Tracing the Politicisation of the EU: The Future of
Europe Debates Before and After the 2019 Elections 1st
Edition Palgrave
https://ebookmeta.com/product/tracing-the-politicisation-of-the-
eu-the-future-of-europe-debates-before-and-after-
the-2019-elections-1st-edition-palgrave/
https://ebookmeta.com/product/data-visualization-with-python-and-
javascript-2nd-edition-eighth-early-release-kyran-dale/
https://ebookmeta.com/product/anthropocene-antarctica-
perspectives-from-the-humanities-law-and-social-sciences-
routledge-environmental-humanities-1st-edition-elizabeth-leane-2/
https://ebookmeta.com/product/in-the-shadow-of-my-country-1st-
edition-tennu-mbuh/
https://ebookmeta.com/product/becoming-a-visible-man-2nd-edition-
jamison-green/
Once Taken Blake Pierce
https://ebookmeta.com/product/once-taken-blake-pierce/
Alejandro Duarte
Practical Vaadin
Developing Web Applications in Java
1st ed.
Alejandro Duarte
Turku, Finland
This work is subject to copyright. All rights are solely and exclusively
licensed by the Publisher, whether the whole or part of the material is
concerned, specifically the rights of translation, reprinting, reuse of
illustrations, recitation, broadcasting, reproduction on microfilms or in
any other physical way, and transmission or information storage and
retrieval, electronic adaptation, computer software, or by similar or
dissimilar methodology now known or hereafter developed.
The publisher, the authors and the editors are safe to assume that the
advice and information in this book are believed to be true and accurate
at the date of publication. Neither the publisher nor the authors or the
editors give a warranty, expressed or implied, with respect to the
material contained herein or for any errors or omissions that may have
been made. The publisher remains neutral with regard to jurisdictional
claims in published maps and institutional affiliations.
Audience
This book is for software developers with a basic or higher knowledge
of the Java programming language who want to build on their Java skills
to create web graphical user interfaces. It’s tailored to those who want
to create web applications without having to code in JavaScript and
HTML and, instead, leverage the power of Java and its ecosystem in the
presentation layer. It’s also a good resource for developers preparing to
take and pass the Vaadin certification exams or who want to strengthen
their expertise with the framework.
Figure 1-1 shows the type of CRUD views that can be created with
this library.
The fact that Vaadin allowed me to code the web user interface
using Java running on the server side was the main reason I decided to
adopt it in many of my future projects. Being able to use the same
programming language in all the layers of the application removed the
associated efforts in context shifting. Similarly, the learning curve that
developers had to go through when they joined a project was almost
flat—if they knew Jvava, they were productive with Vaadin almost
instantly.
The same will happen to you as you go through this book—you’ll
quickly be able to implement web UIs for your Java projects as you
learn Vaadin. By the end of the book, you’ll have the skills to implement
and maintain Vaadin applications and, why not, create and publish your
own reusable libraries like I did with the CRUD library.
Note If you are curious, the CRUD library is open source and
available for free at
https://vaadin.com/directory/component/crud-ui-
add-on.
HTML
HTML (Hypertext Markup Language ) is what browsers use as the
source when they render a web page. Hypertext means text with
hyperlinks. You have probably clicked many hyperlinks before when
you navigated from one page to another. When you see a web page, you
are seeing the rendered version of an HTML document. An HTML
document is a file (in memory or in a hard drive) that consists of tags
and text and, since HTML5, starts with a Document Type Declaration:
<!DOCTYPE html>
<h1>It works!</h1>
In this example, <h1> is the opening tag, and </h1> the closing tag.
The text between the tags is the content of the tag and can also contain
other HTML tags. In the previous example, the text The Web platform is
rendered by browsers using a heading style. There are several levels of
headings, for example, <h2>, <h3>, etc.
HTML tags not only format code but render UI controls like buttons
and text fields. The following snippet of code renders a button:
<html lang="en"></html>
If we put together the previous snippets of code inside the <body>
element, we can form a complete and valid HTML document that all
browsers can render. Listing 1-1 shows a complete and valid HTML
document.
<!DOCTYPE html>
<html lang="en">
<head>
<title>The Web platform</title>
<link rel="stylesheet" href="browser-time.css">
</head>
<body>
<h1>It works!</h1>
<button>Time in the client</button>
</body>
</html>
Listing 1-1 A complete HTML document
Note You can find a comprehensive list of all the tags in HTML on
the Mozilla Developer Network (MDN) website at
https://developer.mozilla.org/en-
US/docs/Web/HTML/Element. In fact, the MDN is an excellent
source for learning everything about the technologies of the Web
platform.
<!DOCTYPE html>
<html>
...
<body>
...
<script>
... JavaScript code goes here ...
</script>
</body>
</html>
I like to have the JavaScript code in separate files. An alternative way
to add JavaScript is by leaving the content of the <script> tag empty
and using the src attribute to specify the location of the file:
<script src="time-button.js"></script>
let buttons =
document.getElementsByTagName("button");
buttons[0].addEventListener("click", function() {
let paragraph = document.createElement("p");
paragraph.textContent = "The time is: " +
Date();
document.body.appendChild(paragraph);
});
CSS
CSS (Cascading Style Sheets ) is a language that allows to configure
fonts, colors, spacing, alignment, and other styling features that dictate
how an HTML document should be rendered. One easy way to add CSS
code to an HTML document is to use a <style> tag in the <head>
element:
<!DOCTYPE html>
<html>
<head>
...
<style>
... CSS code goes here ...
</style>
</head>
...
</html>
<head>
<link rel="stylesheet" href="browser-time.css">
<head>
Tip <link> is one of the tags that doesn’t have an end tag
(</link>). In HTML5, the end tag is not allowed; however,
browsers just ignore </link> or the cargo cult practice of adding a
/ before > when rendering a page.
CSS rules apply styles to the HTML document. Each CSS rule is written
as a selector that targets HTML elements and declarations with the
styles to apply to those elements. For example, the following CSS rule
changes the font of the entire HTML document:
html {
font: 15px Arial;
}
The html part is the selector. Inside braces are the declarations.
There’s only one declaration in this rule, but it’s possible to define
multiple declarations as well. The following CSS rule changes all <h1>
elements to have a full width (100%), a semi-transparent blue
background color, and a padding (space around the element text) of 10
pixels:
h1 {
width: 100%;
background-color: rgba(22, 118, 243, 0.1);
padding: 10px;
}
.time-button {
font-size: 15px;
padding: 10px;
border: 0px;
border-radius: 4px;
}
This rule changes the size of the font to 15 pixels, adds a padding of
10 pixels around the text in the button, removes the border, and makes
its corners slightly rounded. Combining these concepts, it’s possible to
style the full HTML document in a separate browser-time.css file:
html {
font: 15px Arial;
}
body {
margin: 30px;
}
h1 {
width: 100%;
background-color: rgba(22, 118, 243, 0.1);
padding: 10px;
}
.time-button {
font-size: 15px;
padding: 10px;
border: 0px;
border-radius: 4px;
}
Figure 1-5 shows the previous CSS rules applied to the HTML
document.
Web Components
Web Components are a set of technologies that allows creating reusable
custom HTML elements. In this section, I’ll introduce you to the main
technology: custom elements. This should be enough for you to
understand the key Web platform concepts and see there’s no magic
really.
A Web Component is a reusable and encapsulated custom tag. The
“Time in the client” button of the example is a good candidate for this
kind of component. It’d be handy to be able to use the component in
multiple HTML documents via a custom tag:
<time-button></time-button>
constructor() {
super();
...
}
}
customElements.define("time-button",
TimeButtonElement);
button.addEventListener("click", function () {
let paragraph = document.createElement("p");
paragraph.textContent = "The time is: " +
Date();
document.body.appendChild(paragraph);
});
this.appendChild(button);
button.textContent = this.getAttribute("text");
With this, the button can be used as follows:
<!DOCTYPE html>
<html lang="en">
<head>
<title>The Web platform</title>
<link rel="stylesheet" href="browser-time.css">
</head>
<body>
<h1>It works!</h1>
<time-button text="Time in the client"></time-
button>
<time-button text="What time is it?"></time-
button>
<script src="time-button.js"></script>
</body>
</html>
Listing 1-2 An HTML document reusing a custom element
constructor() {
super();
let button = document.createElement("button");
button.textContent =
this.getAttribute("text");
button.classList.add("time-button");
button.addEventListener("click", function () {
let paragraph = document.createElement("p");
paragraph.textContent = "The time is: " +
Date();
document.body.appendChild(paragraph);
});
this.appendChild(button);
}
}
customElements.define("time-button",
TimeButtonElement);
Listing 1-3 A custom element implemented in JavaScript (time-button.js)
You only need a text editor and a browser to try this out. I
recommend doing so if you are new to web development. Try creating
these files, placing them in the same directory, and opening the HTML
file in a web browser. Make sure you understand what’s going on before
continuing. The client-side step of the journey ends with Figure 1-6
which shows a screenshot of the final pure HTML/JavaScript
application developed so far.
Figure 1-6 The final pure client-side web application
Server-Side Technologies
With the fundamentals of the Web platform in place, you can now
approach the not-less-exciting server side of the equation. In short, this
means understanding what a web server is, how to add custom
functionality to a web server, and how to connect the client (browser)
with the web server.
Web Servers
The term web server is used to refer to both hardware and software
entities. In the hardware realm, a web server is a machine that contains
web server software and resources such as HTML documents,
JavaScript files, CSS files, images, audio, video, and even Java programs.
In the software realm, a web server is the software that serves the
resources in the host machine (the hardware web server) to clients
(web browsers) through HTTP (the protocol that browsers
understand). This book uses the software definition of the term web
server. Figure 1-7 shows the main components in a client-server
architecture and the flow of data through requests and responses over
HTTP.
You can request HTML documents using a URL from any device
connected to your network or even the Internet (granted that the
firewall and other security mechanisms don’t prevent access to your
web server). Figure 1-8 shows the example HTML document when I
requested it from my phone (the result you get might be slightly
different depending on the browser and operating system you use).
Notice how I used my IP address to access the file instead of opening it
directly in the browser.
CGI
CGI (Common Gateway Interface ) is one of the simplest ways to serve
dynamic content from a web server. I’ll avoid the discussion on whether
CGI is dead or whether it’s good or not. My aim is to make you take one
step forward toward server-side technologies, and this technology is
easy to understand from a practical point of view.
CGI defines a way to allow web servers to interact with external
programs in the server. These programs can be implemented in any
programming language. CGI maps URLs to these programs. The
external programs communicate with the client using the standard
input (STDIN) and standard output (STDOUT), which in Java are
available through the System.in and System.out objects. The main
difference between a standard program and a CGI program is that the
output should start with a line containing a Content-Type header.
For example, to serve plain text, the output must start with Content-
Type: text/html followed by an empty line followed by the content
of the file to serve.
The Python HTTP server module includes CGI. To enable it, start the
server using the --cgi argument:
#!/usr/bin/java --source 11
public class ServerTime {
public static void main(String[] args) {
System.out.println("Content-Type:
text/plain\n");
System.out.println("It works!");
}
}
#!/usr/bin/java --source 11
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Date;
System.out.println("Content-Type:
text/html\n");
System.out.println(output);
}
}
This program takes the cgi-bin/template.html file, reads its content,
and replaces {{placeholder}} with a string that contains the time
calculated in the server. The template file could be something like this:
<!DOCTYPE html>
<html lang="en">
<head>
<title>CGI Example</title>
</head>
<body>
<h1>It works!</h1>
{{placeholder}}
</body>
</html>
Servlets
Jakarta Servlet (previously known as Java Servlet) is an API
specification for Java that allows developers to extend the capabilities
of a server using the Java programming language. Although I showed
you how to do so with Java in the previous section, CGI has several
disadvantages when compared to Java servlets. The main challenges
with CGI are related to the fact that the server starts a new process
every time the user requests a page (or CGI program in the server). This
slows requests to the server, potentially consumes more memory,
makes it harder to use in-memory data caches, and makes programs
less portable.
Servlets are the Java solution for web development and provide an
object-oriented abstraction of request-response protocols such as
HTTP through a solid and battle-tested API. A servlet is a Java program
(or a class) that you implement and that a software component called
servlet container manages. A servlet container is a concrete
implementation of the Jakarta Servlet API. There are web servers that
include a servlet container implementation out of the box. The most
popular ones are Apache Tomcat and Eclipse Jetty.
Tip How to decide between Tomcat and Jetty? I don’t have a good
answer here but a quick guideline to help you start your own
research. Both are production-ready and have been tested by many
serious projects. Tomcat is more popular and incorporates latest
versions of the specifications quicker. Jetty seems to be used in
projects where high performance is key and gives priority to
incorporating fixes required by the community over supporting the
latest versions of the specifications.
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebServlet("/*")
public class ServletExample extends HttpServlet {
private String replace;
response.setContentType("text/plain");
response.getWriter().println("It works!");
}
}
This class uses the servlet API to write plain text to the response,
similarly to how CGI programs write the response to STDOUT. The
@WebServlet annotation configures the URL that the server uses to
dispatch requests to this servlet. In this case, all requests to the
application will be sent to an instance of the ServletExample class
created and managed by the servlet container.
To compile this class, you need to add the servlet API to the JVM
class path (the next chapter shows how to do this with Maven). Java
servers come with this API. For example, download Apache Tomcat 9.0
as a ZIP and extract its contents. You can download the server at
http://tomcat.apache.org. You will find a servlet-api.jar file
which contains the servlet API in the lib directory inside your Tomcat
installation. Copy the full path to this file and compile the
ServletExample class as follows (change the location of your own
JAR file):
You can also serve static HTML, CSS, and JavaScript files using the
Java server. As an exercise, try copying the example files developed in
previous sections to the root directory of your application. You’ll need
to map the servlet to a different URL to make the files available (e.g.,
@WebServlet("/example")), recompile, and restart the server. You
can stop the server by running shutdown.sh or shutdown.bat.
Summary
By teaching you the very fundamentals of web development, this
chapter put you in a good position to start learning the specifics of
Vaadin. You saw how the Web platform allows you to render web pages
using HTML documents that can be styled with CSS rules and
dynamically modified with JavaScript. You learned what web servers
are and how to add functionality to them not only by using CGI
programs that can be written in any programming language but also by
creating servlets deployed to servlet containers that implement the
Jakarta Servlet API. You also got a glimpse of how Vaadin includes a
servlet implementation that communicates with a client-side engine to
render Web Components in the browser.
The next chapter will teach you how to set up your development
environment and how to create and debug Vaadin applications. All this
while you learn the key fundamental concepts in the framework.
Random documents with unrelated
content Scribd suggests to you:
“What does this mean?” I exclaimed in a rage. “Has he taken leave
of his senses?”
“I do not know, your lordship,” replied the sergeant-major. “Only his
Highness has ordered that your lordship should be taken to prison,
and her ladyship conducted into his presence, your lordship!”
I dashed up the steps. The sentinel did not think of detaining me,
and I made my way straight into the room, where six Jiussar officers
were playing at cards. The major was dealing. What was my
astonishment when, looking at him attentively, I recognized Ivan
Ivanovitch Zourin, who had once beaten me at play in the Simbirsk
tavern.
“Is it possible?” I exclaimed. “Ivan Ivanovitch! Is it really you?”
“Zounds! Peter Andreitch! What chance has brought you here?
Where have you come from? How is it with you, brother? Won’t you
join in a game of cards?”
“Thank you, but I would much rather you give orders for quarters to
be assigned to me.”
“What sort of quarters do you want? Stay with me.”
“I cannot: I am not alone.”
“Well, bring your comrade with you.”
“I have no comrade with me; I am with a—lady.”
“A lady! Where did you pick her up? Aha, brother mine!”
And with these words, Zourin whistled so significantly that all the
others burst out laughing, and I felt perfectly confused.
“Well,” continued Zourin: “let it be so. You shall have quarters. But it
is a pity.... We should have had one of our old sprees.... I say, boy!
Why don’t you bring in Pougatcheff’s lady friend? Or is she
obstinate? Tell her that she need not be afraid, that the gentleman is
very kind and will do her no harm—then bring her in by the collar.”
“What do you mean?” said I to Zourin. “What lady-friend of
Pougatcheff’s are you talking of? It is the daughter of the late
Captain Mironoff. I have released her from captivity, and I am now
conducting her to my father’s country seat, where I am going to
leave her.”
“What! Was it you then who was announced to me just now? In the
name of Heaven! what does all this mean?”
“I will tell you later on. For the present, I beg of you to set at ease
the mind of this poor girl, who has been terribly frightened by your
hussars.”
Zourin immediately issued the necessary orders. He went out himself
into the street to apologize to Maria Ivanovna for the involuntary
misunderstanding, and ordered the sergeant-major to conduct her to
the best lodging in the town. I remained to spend the night with
him.
We had supper, and when we two were left together, I related to
him my adventures. Zourin listened to me with the greatest
attention. When I had finished, he shook his head, and said:
“That is all very well, brother; but there is one thing which is not so;
why the devil do you want to get married? As an officer and a man
of honour, I do not wish to deceive you; but, believe me, marriage is
all nonsense. Why should you saddle yourself with a wife and be
compelled to dandle children? Scout the idea. Listen to me: shake
off this Captain’s daughter. I have cleared the road to Simbirsk, and
it is quite safe. Send her to-morrow by herself to your parents, and
you remain with my detachment. There is no need for you to return
to Orenburg. If you should again fall into the hands of the rebels,
you may not escape from them so easily a second time. In this way
your love folly will die a natural death, and everything will end
satisfactorily.”
Although I did not altogether agree with him, yet I felt that duty and
honour demanded my presence in the army of the Empress. I
resolved to follow Zourin’s advice: to send Maria Ivanovna to my
father’s estate, and to remain with his detachment.
Savelitch came in to help me to undress; I told him that he was to
get ready the next day to accompany Maria Ivanovna on her
journey. He began to make excuses.
“What do you say, my lord? How can I leave you? Who will look after
you? What will your parents say?”
Knowing the obstinate disposition of my follower, I resolved to get
round him by wheedling and coaxing him.
“My dear friend, Arkhip Savelitch!” I said to him: “do not refuse me;
be my benefactor. I do not require a servant here, and I should not
feel easy if Maria Ivanovna were to set out on her journey without
you. By serving her you will be serving me, for I am firmly resolved
to marry her, as soon as circumstances will permit.”
Here Savelitch clasped his hands with an indescribable look of
astonishment.
“To marry!” he repeated: “the child wants to marry! But what will
your father say? And your mother, what will she think?”
“They will give their consent, without a doubt, when they know
Maria Ivanovna,” I replied. “I count upon you. My father and mother
have great confidence in you; you will therefore intercede for us,
won’t you?”
The old man was touched.
“Oh, my father, Peter Andreitch!” he replied, “although you are
thinking of getting married a little too early, yet Maria Ivanovna is
such a good young lady, that it would be a pity to let the opportunity
escape. I will do as you wish. I will accompany her, the angel, and I
will humbly say to your parents, that such a bride does not need a
dowry.”
I thanked Savelitch, and then lay down to sleep in the same room
with Zourin. Feeling very much excited, I began to chatter. At first
Zourin listened to my remarks very willingly; but little by little his
words became rarer and more disconnected, and at last, instead of
replying to’ one of my questions, he began to snore. I stopped
talking and soon followed his example.
The next morning I betook myself to Maria Ivanovna. I
communicated to her my plans. She recognized the reasonableness
of them, and immediately agreed to carry them out. Zourin’s
detachment was to leave the town that day. There was no time to be
lost. I at once took leave of Maria Ivanovna, confiding her to the
care of Savelitch, and giving her a letter to my parents.
Maria burst into tears.
“Farewell, Peter Andreitch,” said she in a gentle voice. “God alone
knows whether we shall ever see each other again or not; but I will
never forget you; till my dying day you alone shall live in my heart!”
I was unable to reply. There was a crowd of people around us, and I
did not wish to give way to my feelings before them. At last she
departed. I returned to Zourin, silent and depressed. He
endeavoured to cheer me up, and I tried to divert my thoughts; we
spent the day in noisy mirth, and in the evening we set out on our
march.
It was now near the end of February. The winter, which had
rendered all military movements extremely difficult, was drawing to
its close, and our generals began to make preparations for combined
action. Pougatcheff was still under the walls of Orenburg, but our
divisions united and began to close in from every side upon the rebel
camp. On the appearance of our troops, the revolted villages
returned to their allegiance; the rebel bands everywhere retreated
before us, and everything gave promise of a speedy and successful
termination to the campaign.
Soon afterwards Prince Golitzin defeated Pougatcheff under the walls
of the fortress of Tatischtscheff, routed his troops, relieved
Orenburg, and to all appearances seemed to have given the final
and decisive blow to the rebellion. Zourin was sent at this time
against a band of rebellious Bashkirs, who, however, dispersed
before we were able to come up with them. The spring found us in a
little Tartar village. The rivers overflowed their banks, and the roads
became impassable. We consoled ourselves for our inaction with the
thought that there would soon be an end to this tedious petty
warfare with brigands and savages.
But Pougatcheff was not yet taken. He soon made his appearance in
the manufacturing districts of Siberia, where he collected new bands
of followers and once more commenced his marauding expeditions.
Reports of fresh successes on his part were soon in circulation. We
heard of the destruction of several Siberian fortresses. Then came
the news of the capture of Kazan, and the march of the impostor to
Moscow, which greatly disturbed the leaders of the army, who had
fondly imagined that the power of the despised rebel had been
completely broken. Zourin received orders to cross the Volga.
I will not describe our march and the conclusion of the war. I will
only say that the campaign was as calamitous as it possibly could
be. Law and order came to an end everywhere, and the land-holders
concealed themselves in the woods. Bands of robbers scoured the
country in all directions; the commanders of isolated detachments
punished and pardoned as they pleased; and the condition of the
extensive territory in which the conflagration raged, was terrible....
Heaven grant that we may never see such, a senseless and
merciless revolt again!
Pougatcheff took to flight, pursued by Ivan Ivanovitch Michelson. We
soon heard of his complete overthrow. At last Zourin received news
of the capture of the impostor, and, at the same time, orders to halt.
The war was ended. At last it was possible for me to return to my
parents. The thought of embracing them, and of seeing Maria
Ivanovna, again, of whom I had received no information, filled me
with delight. I danced about like a child. Zourin laughed and said
with a shrug of his shoulders:
“No good will come of it! If you get married, you are lost!”
In the meantime a strange feeling poisoned my joy: the thought of
that evil-doer, covered with the blood of so many innocent victims,
and of the punishment that awaited him, troubled me involuntarily.
“Emelia, Emelia!”[1] I said to myself with vexation, “why did you not
dash yourself against the bayonets, or fall beneath the bullets? That
was the best thing you could have done.”[2]
And how could I feel otherwise? The thought of him was inseparably
connected with the thought of the mercy which he had shown to me
in one of the most terrible moments of my life, and with the
deliverance of my bride from the hands of the detested Shvabrin.
Zourin granted me leave of absence. In a few days’ time I should
again be in the midst of my family, and should once again set eyes
upon the face of my Maria Ivanovna.... Suddenly an unexpected
storm burst upon me.
On the day of my departure, and at the very moment when I was
preparing to set out, Zourin came to my hut, holding in his hand a
paper, and looking exceedingly troubled. A pang went through my
heart. I felt alarmed, without knowing why. He sent my servant out
of the room, and said that he had something to tell me.
“What is it?” I asked with uneasiness.
“Something rather disagreeable,” replied he, giving me the paper.
“Read what I have just received.”
I read it: it was a secret order to all the commanders of
detachments to arrest me wherever I might be found, and to send
me without delay under a strong guard to Kazan, to appear before
the Commission instituted for the trial of Pougatcheff.
The paper nearly fell from my hands.
“There is no help for it,” said Zourin, “my duty is to obey orders.
Probably the report of your intimacy with Pougatcheff has in some
way reached the ears of the authorities. I hope that the affair will
have no serious consequences, and that you will be able to justify
yourself before the Commission. Keep up your spirits and set out at
once.”
My conscience was clear, and I did not fear having to appear before
the tribunal; but the thought that the hour of my meeting with Maria
might be deferred for several months, filled me with misgivings.
The telega[3] was ready. Zourin took a friendly leave of me, and I
took my place in the vehicle. Two hussars with drawn swords seated
themselves, one on each side of me, and we set out for our
destination.
CHAPTER XIV.
THE SENTENCE.
The next day, early in the morning, Maria Ivanovna awoke, dressed
herself, and quietly betook herself to the palace garden. It was a
lovely morning; the sun was gilding the tops of the linden trees,
already turning yellow beneath the cold breath of autumn. The
broad lake glittered in the light. The swans, just awake, came sailing
majestically out from under the bushes overhanging the banks.
Maria Ivanovna walked towards a delightful lawn, where a
monument had just been erected in honour of the recent victories
gained by Count Peter Alexandrovitch Roumyanzoff.[3] Suddenly a
little white dog of English breed ran barking towards her. Maria grew
frightened and stood still. At the same moment she heard an
agreeable female voice call out:
“Do not be afraid, it will not bite.”
Maria saw a lady seated on the bench opposite the monument.
Maria sat down on the other end of the bench. The lady looked at
her attentively; Maria on her side, by a succession of stolen glances,
contrived to examine the stranger from head to foot. She was attired
in a white morning gown, a light cap, and a short mantle. She
seemed to be about forty years of age. Her face, which was full; and
red, wore an expression of calmness and dignity, and her blue eyes
and smiling lips had an indescribable charm about them. The lady
was the first to break silence.
“You are doubtless a stranger here?” said she.
“Yes, I only arrived yesterday from the country.”
“Did you come with your parents?”
“No, I came alone.”
“Alone! But you are very young to travel alone.”
“I have neither father nor mother.”
“Perhaps you have come here on some business?”
“Yes, I have come to present a petition to the Empress.”
“You are an orphan: probably you have come to complain of some
injustice.”
“No, I have come to ask for mercy, not justice.”
“May I ask you who you are?”
“I am the daughter of Captain Mironoff.”
“Of Captain Mironoff! the same who was Commandant of one of the
Orenburg fortresses?”
“The same, Madam.”
The lady appeared moved.
“Forgive me,” said she, in a still kinder voice, “for interesting myself
in your business; but I am frequently at Court; explain to me the
nature of your request, and perhaps I may be able to help you.”
Maria Ivanovna arose and thanked her respectfully. Everything about
this unknown lady drew her towards her and inspired her with
confidence. Maria drew from her pocket a folded paper and gave it
to her unknown protectress, who read it to herself.
At first she began reading with an attentive and benevolent
expression; but suddenly her countenance changed, and Maria,
whose eyes followed all her movements, became frightened by the
severe expression of that face, which a moment before had been so
calm and gracious.
“You are supplicating for Grineff?” said the lady in a cold tone. “The
Empress cannot pardon him. He went over to the usurper, not out of
ignorance and credulity, but as a depraved and dangerous
scoundrel.”
“Oh! it is not true!” exclaimed Maria.
“How, not true?” replied the lady, her face flushing.
“It is not true; as God is above us, it is not true! I know all, I will tell
you everything. It was for my sake alone that he exposed himself to
all the misfortunes that have overtaken him. And if he did not justify
himself before the Commission, it was only because he did not wish
to implicate me.”
She then related with great warmth all that is already known to the
reader.
The lady listened to her attentively.
“Where are you staying?” she asked, when Maria had finished her
story; and hearing that it was with Anna Vlassievna, she added with
a smile:
“Ah, I know. Farewell; do not speak to anybody about our meeting. I
hope that you will not have to wait long for an answer to your letter.”
With these words she rose from her seat and proceeded down a
covered alley, while Maria Ivanovna returned to Anna Vlassievna,
filled with joyful hopes.
Her hostess scolded her for going out so early; the autumn air, she
said, was not good for a young girl’s health. She brought an urn, and
over a cup of tea she was about to begin her endless discourse
about the Court, when suddenly a carriage with armorial bearings
stopped before the door, and a lackey entered with the
announcement that the Empress summoned to her presence the
daughter of Captain Mironoff.
Anna Vlassievna was perfectly amazed.
“Good Lord!” she exclaimed: “the Empress summons you to Court.
How did she get to know anything about you? And how will you
present yourself before Her Majesty, my little mother? I do not think
that you even know how to walk according to Court manners....
Shall I conduct you? I could at any rate give you a little caution. And
how can you go in your travelling dress? Shall I send to the nurse for
her yellow gown?”
The lackey announced that it was the Empress’s pleasure that Maria
Ivanovna should go alone and in the dress that she had on. There
was nothing else to be done: Maria took her seat in the carriage and
was driven off, accompanied by the counsels and blessings of Anna
Vlassievna.
Maria felt that our fate was about to be decided; her heart beat
violently. In a few moments the carriage stopped at the gate of the
palace. Maria descended the steps with trembling feet. The doors
flew open before her. She traversed a large number of empty but
magnificent rooms, guided by the lackey. At last, coming to a closed
door, he informed her that she would be announced directly, and
then left her by herself.
The thought of meeting the Empress face to face so terrified her,
that she could scarcely stand upon her feet. In about a minute the
door was opened, and she was ushered into the Empress’s boudoir.
The Empress was seated at her toilette-table, surrounded by a
number of Court ladies, who respectfully made way for Maria
Ivanovna. The Empress turned round to her with an amiable smile,
and Maria recognized in her the lady with whom she had spoken so
freely a few minutes before. The Empress bade her approach, and
said with a smile:
“I am glad that I am able to keep my word and grant your petition.
Your business is arranged. I am convinced of the innocence of your
lover. Here is a letter which you will give to your future father-in-
law.”
Maria took the letter with trembling hands and, bursting into tears,
fell at the feet of the Empress, who raised her up and kissed her
upon the forehead.
“I know that you are not rich,” said she; “but I owe a debt to the
daughter of Captain Mironoff. Do not be uneasy about the future. I
will see to your welfare.”
After having consoled the poor orphan in this way, the Empress
allowed her to depart. Maria left the palace in the same carriage that
had brought her thither. Anna Vlassievna, who was impatiently
awaiting her return, overwhelmed her with questions, to which Maria
returned very vague answers. Although dissatisfied with the
weakness of her memory, Anna Vlassievna ascribed it to her
provincial bashfulness, and magnanimously excused her. The same
day Maria, without even desiring to glance at St. Petersburg, set out
on her return journey.
The memoirs of Peter Andreitch Grineff end here. But from a family
Tradition we learn that he was released from his imprisonment
towards the end of the year 1774 by order of the Empress, and that
he was present at the execution of Pougatcheff, who recognized him
in the crowd and nodded to him with his head, which, a few
moments afterwards, was shown lifeless and bleeding to the people.
[4] Shortly afterwards, Peter Andreitch and Maria Ivanovna were
married. Their descendants still flourish in the government of
Simbirsk. About thirty versts from ----, there is a village belonging to
ten landholders. In the house of one of them, there may still be
seen, framed and glazed, the autograph letter of Catherine II. It is
addressed to the father of Peter Andreitch, and contains the
justification of his son, and a tribute of praise to the heart and
intellect of Captain Mironoff’s daughter.
DOUBROVSKY.
CHAPTER I.
“Gracious Sir!
“I do not intend to return to Pokrovskoe until you send the dog-
feeder Paramoshka to me with an apology: I shall retain the
liberty of punishing or for forgiving him. I cannot put up with
jokes from your servants, nor do I intend to put up with them
from you, as I am not a buffoon, but a gentleman of ancient
family. I remain your obedient servant,
“ANDREI DOUBROVSKY.”
CHAPTER II.
Several days passed, and the animosity between the two neighbours
did not subside. Andrei Gavrilovitch returned no more to Pokrovskoe,
and Kirila Petrovitch, feeling dull without him, vented his spleen in
the most insulting expressions, which, thanks to the zeal of the
neighbouring nobles, reached Doubrovsky revised and augmented. A
fresh incident destroyed the last hope of a reconciliation.
One day, Doubrovsky was going the round of his little estate, when,
on approaching a grove of birch trees, he heard the blows of an axe,
and a minute afterwards the crash of a falling tree; he hastened to
the spot and found some of the Pokrovskoe peasants stealing his
wood. Seeing him, they took to flight; but Doubrovsky, with the
assistance of his coachman, caught two of them, whom he brought
home bound. Moreover, two horses, belonging to the enemy, fell into
the hands of the conqueror.
Doubrovsky was exceedingly angry. Before this, Troekouroff’s
people, who were well-known robbers, had never dared to play
tricks within the boundaries of his property, being aware of the
friendship which existed between him and their master. Doubrovsky
now perceived that they were taking advantage of the rupture which
had occurred between him and his neighbour, and he resolved,
contrary to all ideas of the rules of war, to teach his prisoners a
lesson with the rods which they themselves had collected in his
grove, and to send the horses to work and to incorporate them with
his own cattle.
The news of these proceedings reached the ears of Kirila Petrovitch
that very same day. He was almost beside himself with rage, and in
the first moment of his passion, he wanted to take all his domestics
and make an attack upon Kistenevka (for such was the name of his
neighbour’s village), raze it to the ground, and besiege the
landholder in his own residence. Such exploits were not rare with
him; but his thoughts soon took another direction. Pacing with heavy
steps up and down the hall, he glanced casually out of the window,
and saw a troika in the act of stopping at his, gate. A man in a
leather travelling-cap and a frieze cloak stepped out of the telega
and proceeded towards the wing occupied by the bailiff. Troekouroff
recognized the assessor Shabashkin, and gave orders for him to be
sent in to him. A minute afterwards Shabashkin stood before Kirila
Petrovitch, and bowing repeatedly, waited respectfully to hear what
he had to say to him.
“Good day—what is your name?” said Troekouroff: “Why have you
come?”
“I was going to the town, Your Excellency,” replied Shabashkin, “and
I called on Ivan Demyanoff to know if there; were any orders.”
“You have come at a very opportune moment—what is your name? I
have need of you. Take a glass of brandy and listen to me.”
Such a friendly welcome agreeably surprised the assessor: he
declined the brandy, and listened to Kirila Petrovitch with all possible
attention.
“I have a neighbour,” said Troekouroff, “a small proprietor, a rude
fellow, and I want to take his property from him.... What do you
think of that?”
“Your Excellency, are there any documents—?”
“Don’t talk nonsense, brother,[1] what documents are you talking
about? The business in this case is to take his property away from
him, with or without documents. But stop! This estate belonged to
us at one time. It was bought from a certain Spitsin, and then sold
to Doubrovsky’s father. Can’t you make a case out of that?”
“It would be difficult, Your Excellency: probably the sale was
effected in strict accordance with the law.”
“Think, brother; try your hardest.”
“If, for example, Your Excellency could in some way obtain from your
neighbour the contract, in virtue of which he holds possession of his
estate, then, without doubt—”
“I understand, but that is the misfortune: all his papers were burnt
at the time of the fire.”
“What! Your Excellency, his papers were burnt? What could be
better? In that case, take proceedings according to law; without the
slightest doubt you will receive complete satisfaction.”
“You think so? Well, see to it, I rely upon your zeal, and you can rest
assured of my gratitude.”
Shabashkin, bowing almost to the ground, took his departure; from
that day he began to devote all his energies to the business
intrusted to him and, thanks to his prompt action, exactly a fortnight
afterwards Doubrovsky received from the town a summons to
appear in court and to produce the documents, in virtue of which he
held possession of the village of Kistenevka.
Andrei Gavrilovitch, greatly astonished by this unexpected request,
wrote that very same day a somewhat rude reply, in which he
explained that the village of Kistenevka became his on the death of
his father, that he held it by right of inheritance, that Troekouroff
had nothing to do with the matter, and that all adventitious
pretensions to his property were nothing but the outcome of
chicanery and roguery. Doubrovsky had no experience in litigation.
He generally followed the dictates of common sense, a guide rarely
safe, and nearly always insufficient.
This letter produced a very agreeable impression on the mind of
Shabashkin; he saw, in the first place, that Doubrovsky knew very
little about legal matters; and, in the second, that it would not be
difficult to place such a passionate and indiscreet man in a very
disadvantageous position.
Andrei Gavrilovitch, after a more careful consideration of the
questions addressed to him, saw the necessity of replying more
circumstantially. He wrote a sufficiently pertinent paper, but in the
end this proved insufficient also.
The business dragged on. Confident in his own right, Andrei
Gavrilovitch troubled himself very little about the matter; he had
neither the inclination nor the means to scatter money about him,
and he began to deride the mercenary consciences of the scribbling
fraternity. The idea of being made the victim of treachery never
entered his head. Troekouroff, on his side, thought as little of
winning the case he had devised. Shabashkin took the matter in
hand for him, acting in his name, threatening and bribing the judges
and quoting and interpreting the ordinances in the most distorted
manner possible.
At last, on the 9th day of February, in the year 18—, Doubrovsky
received, through the town police, an invitation to appear at the
district court to hear the decision in the matter of the disputed
property between himself—Lieutenant Doubrovsky, and General-in-
Chief Troekouroff, and to sign his approval or disapproval of the
verdict. That same day Doubrovsky set out for the town. On the
road he was overtaken by Troekouroff. They glared haughtily at each
other, and Doubrovsky observed a malicious smile upon the face of
his adversary.
Arriving in town, Andrei Gavrilovitch stopped at the house of an
acquaintance, a merchant, with whom he spent the night, and the
next morning he appeared before the Court. Nobody paid any
attention, to him. After him arrived Kirila Petrovitch. The members of
the Court received him with every manifestation of the deepest
submission, and an armchair was brought to him out of
consideration for his rank, years and corpulence. He sat down;
Andrei Gavrilovitch stood leaning against the wall. A deep silence
ensued, and the secretary began in a sonorous voice to read the
decree of the Court.
When the secretary had ceased reading, the assessor arose and,
with a low bow, turned to Troekouroff, inviting him to sign the paper
which he held out to him. Troekouroff, quite triumphant, took the
pen and wrote beneath the decision of the Court his complete
satisfaction.
It was now Doubrovsky’s turn. The secretary handed the paper to
him, but Doubrovsky stood immovable, with his head bent down.
The secretary repeated his invitation: “To subscribe his full and
complete satisfaction, or his manifest dissatisfaction, if he felt in his
conscience that his case was just, and intended to appeal against
the decision of the Court.”
Doubrovsky remained silent ... Suddenly he raised his head, his eyes
sparkled, he stamped his foot, pushed back the secretary, with such
force, that he fell, seized the inkstand, hurled it at the assessor, and
cried in a wild voice:
“What! you don’t respect the Church of God! Away, you race of
Shem!”
Then turning to Kirila Petrovitch:
“Has such a thing ever been heard of, Your Excellency?” he
continued. “The huntsmen lead greyhounds into the Church of God!
The dogs are running about the church! I will teach them a lesson
presently!”
Everybody was terrified. The guards rushed in on hearing the noise,
and with difficulty overpowered him. They led him out and placed
him in a sledge. Troekouroff went out after him, accompanied by the
whole Court Doubrovsky’s sudden madness had produced a deep
impression upon his imagination; the judges, who had counted upon
his gratitude, were not honoured by receiving a single affable word
from him. He returned immediately to Pokrovskoe, secretly tortured
by his conscience, and not at all satisfied with the triumph of his
hatred. Doubrovsky, in the meantime, lay in bed. The district doctor
—not altogether a blockhead—bled him and applied leeches and
mustard-plasters to him. Towards evening he began to feel better,
and the next day he was taken to Kistenevka, which scarcely
belonged to him any longer.
CHAPTER III.
CHAPTER IV.
A few days after his arrival, young Doubrovsky wished to turn his
attention to business, but his father was not in a condition to give