100% found this document useful (1 vote)
41 views

Get Professional BlazeDS Creating Rich Internet Applications with Flex and Java 1st Edition Shashank Tiwari free all chapters

The document promotes the ebook 'Professional BlazeDS: Creating Rich Internet Applications with Flex and Java' by Shashank Tiwari, available for download at ebookfinal.com. It includes links to additional related ebooks and provides details about the book's content, author, and publication information. The book covers various topics related to developing rich internet applications using BlazeDS, Flex, and Java.

Uploaded by

oismaaedryan
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 (1 vote)
41 views

Get Professional BlazeDS Creating Rich Internet Applications with Flex and Java 1st Edition Shashank Tiwari free all chapters

The document promotes the ebook 'Professional BlazeDS: Creating Rich Internet Applications with Flex and Java' by Shashank Tiwari, available for download at ebookfinal.com. It includes links to additional related ebooks and provides details about the book's content, author, and publication information. The book covers various topics related to developing rich internet applications using BlazeDS, Flex, and Java.

Uploaded by

oismaaedryan
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/ 77

Visit https://ebookfinal.

com to download the full version and


explore more ebooks

Professional BlazeDS Creating Rich Internet


Applications with Flex and Java 1st Edition
Shashank Tiwari

_____ Click the link below to download _____


https://ebookfinal.com/download/professional-blazeds-
creating-rich-internet-applications-with-flex-and-
java-1st-edition-shashank-tiwari/

Explore and download more ebooks at ebookfinal.com


Here are some suggested products you might be interested in.
Click the link to download

Professional NoSQL 1st Edition Shashank Tiwari

https://ebookfinal.com/download/professional-nosql-1st-edition-
shashank-tiwari/

Learning Flex 3 getting up to speed with rich Internet


applications 1st ed Edition Alaric Cole

https://ebookfinal.com/download/learning-flex-3-getting-up-to-speed-
with-rich-internet-applications-1st-ed-edition-alaric-cole/

JavaFX Developing Rich Internet Applications 1st Edition


Jim Clarke

https://ebookfinal.com/download/javafx-developing-rich-internet-
applications-1st-edition-jim-clarke/

Professional WebObjects with Java 1st Edition Thomas


Termini

https://ebookfinal.com/download/professional-webobjects-with-java-1st-
edition-thomas-termini/
Java and Flex Integration Bible 1st ed Edition Matthew
Keefe

https://ebookfinal.com/download/java-and-flex-integration-bible-1st-
ed-edition-matthew-keefe/

AJAX Rich Internet Applications and Web Development for


Programmers 1st Edition Paul J. Deitel

https://ebookfinal.com/download/ajax-rich-internet-applications-and-
web-development-for-programmers-1st-edition-paul-j-deitel/

Frameworks Methodologies and Tools for Developing Rich


Internet Applications 1st Edition Giner Alor-Hernández

https://ebookfinal.com/download/frameworks-methodologies-and-tools-
for-developing-rich-internet-applications-1st-edition-giner-alor-
hernandez/

Graphene Materials Fundamentals and Emerging Applications


1st Edition Ashutosh Tiwari

https://ebookfinal.com/download/graphene-materials-fundamentals-and-
emerging-applications-1st-edition-ashutosh-tiwari/

Digital Animation Bible Creating Professional Animation


with 3ds max LightWave and Maya 1st Edition George
Avgerakis
https://ebookfinal.com/download/digital-animation-bible-creating-
professional-animation-with-3ds-max-lightwave-and-maya-1st-edition-
george-avgerakis/
Professional BlazeDS Creating Rich Internet Applications
with Flex and Java 1st Edition Shashank Tiwari Digital
Instant Download
Author(s): Shashank Tiwari
ISBN(s): 9780470464892, 0470464895
Edition: 1
File Details: PDF, 5.74 MB
Year: 2009
Language: english
Join the discussion @ p2p.wrox.com Wrox Programmer to Programmer™

Professional

BlazeDS
Creating Rich Internet Applications with Flex® and Java®

Shashank Tiwari
Programmer to Programmer™

Get more out of


WROX.com
Interact Chapters on Demand
Take an active role online by participating in Purchase individual book chapters in pdf
our P2P forums format

Wrox Online Library Join the Community


Hundreds of our books are available online Sign up for our free monthly newsletter at
through Books24x7.com newsletter.wrox.com

Wrox Blox Browse


Download short informational pieces and Ready for more Wrox? We have books and
code to keep you up to date and out of e-books available on .NET, SQL Server, Java,
trouble! XML, Visual Basic, C#/ C++, and much more!

Contact Us.
We always like to get feedback from our readers. Have a book idea?
Need community support? Let us know by e-mailing [email protected]
Download from Library of Wow! eBook <www.wowebook.com>
Professional BlazeDS
Foreword . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxi
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxiii
Chapter 1: Flex for Java Developers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Chapter 2: Introducing BlazeDS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
Chapter 3: Using BlazeDS as a Server-Side Proxy . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
Chapter 4: Remoting between Flex and POJOs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
Chapter 5: Accessing Spring Beans . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
Chapter 6: Communicating Real-Time via Messages . . . . . . . . . . . . . . . . . . . . . . 137
Chapter 7: Leveraging JPA and Hibernate with Flex . . . . . . . . . . . . . . . . . . . . . . . . 169
Chapter 8: Testing and Debugging Flex and BlazeDS Applications . . . . . . . . . 215
Chapter 9: Extending BlazeDS with Custom Adapters . . . . . . . . . . . . . . . . . . . . . 253
Chapter 10: Making BlazeDS Applications Scalable . . . . . . . . . . . . . . . . . . . . . . . 271
Chapter 11: CRUD Applications and More . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293
Appendix A: Introducing Flex 4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337

Download from Library of Wow! eBook <www.wowebook.com>


Download from Library of Wow! eBook <www.wowebook.com>
Professional
BlazeDS

Download from Library of Wow! eBook <www.wowebook.com>


Download from Library of Wow! eBook <www.wowebook.com>
Professional
BlazeDS
Creating Rich Internet Applications with Flex® and Java®

Shashank Tiwari

Download from Library of Wow! eBook


<www.wowebook.com>

Wiley Publishing, Inc.

Download from Library of Wow! eBook <www.wowebook.com>


Professional BlazeDS: Creating Rich Internet Applications
with Flex® and Java®
Published by
Wiley Publishing, Inc.
10475 Crosspoint Boulevard
Indianapolis, IN 46256
www.wiley.com
Copyright © 2009 by Wiley Publishing, Inc., Indianapolis, Indiana

Published simultaneously in Canada

ISBN: 978-0-470-46489-2
Manufactured in the United States of America

10 9 8 7 6 5 4 3 2 1

No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any
means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections
107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or
authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood
Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 646-8600. Requests to the Publisher for permission should be
addressed to the Permissions Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, (201)
748-6011, fax (201) 748-6008, or online at http://www.wiley.com/go/permissions.

Limit of Liability/Disclaimer of Warranty: The publisher and the author make no representations or warranties with
respect to the accuracy or completeness of the contents of this work and specifically disclaim all warranties, including
without limitation warranties of fitness for a particular purpose. No warranty may be created or extended by sales or
promotional materials. The advice and strategies contained herein may not be suitable for every situation. This work
is sold with the understanding that the publisher is not engaged in rendering legal, accounting, or other professional
services. If professional assistance is required, the services of a competent professional person should be sought.
Neither the publisher nor the author shall be liable for damages arising herefrom. The fact that an organization or
Web site is referred to in this work as a citation and/or a potential source of further information does not mean that
the author or the publisher endorses the information the organization or Web site may provide or recommendations
it may make. Further, readers should be aware that Internet Web sites listed in this work may have changed or
disappeared between when this work was written and when it is read.

For general information on our other products and services please contact our Customer Care Department within the
United States at (877) 762-2974, outside the United States at (317) 572-3993 or fax (317) 572-4002.
Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be
available in electronic books.
Library of Congress Control Number: 2009932709

Trademarks: Wiley, the Wiley logo, Wrox, the Wrox logo, Wrox Programmer to Programmer, and related trade dress
are trademarks or registered trademarks of John Wiley & Sons, Inc. and/or its affiliates, in the United States and
other countries, and may not be used without written permission. Flex is a registered trademark of Adobe Systems
Incorporated. Java is a registered trademark of Sun Microsystems, Inc. All other trademarks are the property of their
respective owners. Wiley Publishing, Inc., is not associated with any product or vendor mentioned in this book.

Download from Library of Wow! eBook <www.wowebook.com>


My efforts on this book are dedicated to my wife Caren and sons Ayaan and Ezra. Thanks for always
encouraging and supporting me in my endeavors, like writing this book or starting the new venture.
Without your support and love I could have never completed this book.

Download from Library of Wow! eBook <www.wowebook.com>


Download from Library of Wow! eBook <www.wowebook.com>
About the Author
Shashank Tiwari is a technology entrepreneur, speaker, author, and inno-
vator. He is currently a Managing Partner & CTO at Treasury of Ideas
(http://www.treasuryofideas.com), a technology-driven innovation and
value optimization company. As an experienced software developer and
architect, he is adept in a multitude of technologies. He is an internationally
recognized speaker, author, and mentor. As an expert group member on a
number of JCP (Java Community Process) specifications, he has been actively
participating in shaping the future of Java. He is also an Adobe Flex Cham-
pion and a common voice in the RIA community. Currently, he passionately
builds rich, high-performance scalable applications and advises many on
RIA and SOA adoption. His clients range from large financial service corpo-
rations to brilliant startups, for whom he helps translate cutting edge ideas
into reality. He is also actively engaged in training and mentoring developers
and architects in leading edge technology. He is the author of a number of books and articles, including
Advanced Flex 3 (Apress, 2008). He lives with his wife and two sons in New York. More information about
him can be accessed at his website: http://www.shanky.org.

Download from Library of Wow! eBook <www.wowebook.com>


Download from Library of Wow! eBook <www.wowebook.com>
Credits
Acquisitions Editor Vice President and Executive
Scott Meyers Group Publisher
Richard Swadley
Project Editor
Tom Dinse
Vice President and Executive
Publisher
Technical Editor
Barry Pruett
Yakov Fain

Production Editor Associate Publisher


Eric Charbonneau Jim Minatel

Copy Editor Project Coordinator, Cover


Foxxe Editorial Services Lynsey Stanford

Editorial Director Proofreader


Robyn B. Siesky Jen Larsen, Word One

Editorial Manager Indexer


Mary Beth Wakefield Johnna VanHoose Dinse

Production Manager Cover Photo


Tim Tate ©Thinkstock/Punchstock

Download from Library of Wow! eBook <www.wowebook.com>


Download from Library of Wow! eBook <www.wowebook.com>
Acknowledgments

This book represents the efforts of many people and I sincerely thank them for their contribution.

Many thanks to the entire team at Wrox/Wiley. You made this book possible! Scott Meyers took this
book from a proposal to a real project. Tom Dinse diligently and patiently reviewed the manuscript and
managed the schedule. Many others worked seamlessly behind the scenes to make things happen.

Thanks much to Yakov Fain for meticulously reviewing and validating the manuscript for its technical
correctness. He deserves special praise for his attention to detail and valuable insight.

I sincerely appreciate all of you (everyone at Wiley and Yakov) for working extra hard against tight
timelines to make things happen on schedule.

Special thanks to the folks at Adobe. Thanks to Jeff Vroom for his early encouragement and support.
Thanks to James Ward for the encouraging words he wrote in the forward to this book. Many thanks to
Jeremy Grelle, the lead of the Spring BlazeDS project at SpringSource, for his help.

Thanks to Jerry Bezdikian for my About the Author photo.

Above all, thanks to my friends and family for their assistance and encouragement. My wife, Caren,
and sons, Ayaan and Ezra, were extremely loving and accommodating while I took out time on many
evenings, early mornings, and nights in the last many months to finish the book. They were very involved
in the project. My five year old, Ayaan, continuously knew how I was progressing through the book,
often encouraging me to finish a chapter sooner than I would otherwise have. My three year old, Ezra,
was quieter than his normal naughty self when I was working hard typing away on my keyboard. My
wife, Caren, planned the last many weekdays and weekends solely around my writing schedule. She fed
me with delicious food as she always does and helped me stay focused all along, even when the task
looked too difficult. Without their affection, I would have never been able to write this book.

Thanks also to my parents (Mandakini and Suresh), my in-laws (Cissy and Frank), and all other near and
dear ones for their continuing support and encouragement.

My sincere thanks and gratitude to all of you who contributed towards this book.

Download from Library of Wow! eBook <www.wowebook.com>


Download from Library of Wow! eBook <www.wowebook.com>
Contents

Foreword xxi
Introduction xxiii

Chapter 1: Flex for Java Developers 1


Introducing Flex through Its Controls and Containers 1
Tip to Remember 3
Getting to Know the Controls 5
Laying Out the Controls 19
Leveraging Services to Access External Data 27
Using Simple HTTP and REST Style Invocations 28
Communicating via Web Services 30
Making Remote Procedure Calls 32
Making User Interfaces Engaging and Effective 33
Exploring Effects 33
Validating User Input 34
Customizing the Look and Feel 35
Extending Flex 36
Creating Custom Components 36
Creating and Propagating Custom Events 38
Summary 39

Chapter 2: Introducing BlazeDS 41


An Overview of BlazeDS 41
Viewing Integration from 30,000 feet 43
Viewing Integration from 10,000 feet 45
Viewing It Closely from 1,000 Feet 45
Getting and Installing BlazeDS 47
Downloading BlazeDS 47
Installing the Compiled Distributions 49
Compiling from Source 53
Surveying the Configuration Options 54
First Look at services-config.xml 55
Remoting, Proxy and Messaging Configuration 57
Yet Another Hello to the World 58
Summary 64

Download from Library of Wow! eBook <www.wowebook.com>


Contents
Chapter 3: Using BlazeDS as a Server-Side Proxy 65
HTTP Service Proxy 66
An HTTP Proxy Service Example 69
Advanced Configuration Options of an HTTP Proxy Adapter 70
Intercepting for Control and Management 73
Web Service Proxy 76
Configuring a Web Service Proxy 79
Summary 80

Chapter 4: Remoting between Flex and POJOs 83


Essentials of Remoting 84
Remoting Communication Flow 84
Remoting-Related Classes, Components, and Modules 86
Configuring a Remoting Service and a Destination 89
Securing Destinations 91
Intercepting and Logging Calls to a Remoting Service 94
Talking AMFX 96
Using HTTPS 96
Diving into Serialization — AS3 to Java and Back 98
Running through a Complete Example 102
Java-Based Data Service 104
Client-Side Flex Code 107
Value Additions for Simple Remoting 108
Custom Security Implementation 108
An Interceptor for the JavaAdapter 110
Summary 111

Chapter 5: Accessing Spring Beans 113


Basic Bootstrapping 113
Using BlazeDS MessageBroker with the Spring DispatcherServlet 114
Serving Flex and Non-Flex Clients 117
Remoting to Spring Beans 119
Message Service Integration 124
Native BlazeDS AMF Messaging 124
JMS Messaging Using Spring-Specific JMS Components 126
Using the Special Integration Adapter 129
Leveraging Spring Security 131
Securing Remote Spring Bean Access 133
Using Custom Adapters 134
Summary 135
xvi
Download from Library of Wow! eBook <www.wowebook.com>
Contents
Chapter 6: Communicating Real-Time via Messages 137
Data Push Essentials 138
Data Push Usage Scenarios 138
The Alternatives 138
Messaging Domains 142
Point-to-Point 143
Publish-Subscribe 143
JMS 145
JMS Architecture 145
JMS Programming Model and the API 146
A BlazeDS-Powered Messaging Application 148
The Application Use Case 148
The First Few Steps 149
Sprucing Up the Client Code 153
The Simulated Feed Program 156
The Chat Window 159
The Simple Chat Application 160
The Adapters at Work 163
The ActionScriptAdapter 163
The JMSAdapter 164
Advanced Extensions to BlazeDS Data Push 164
Comet Inclusion with BlazeDS in Jetty 7 165
Summary 167

Chapter 7: Leveraging JPA and Hibernate with Flex 169


Object Relational Mismatch 170
Coarse-Grained or Fine-Grained 170
The Cases of Inheritance and Polymorphism 171
Entity Relationships 172
What Defines Identity? 174
Introducing JPA 174
Primary Key 175
Entity Relationships 176
Interacting with a Persistence Context 178
Hibernate EntityManager 3.4.0.GA Distribution 179
Set Up the Database 180
Create an Eclipse JPA project 180
Program the Entities and specify metadata 185
Bare Essentials of Hibernate 188
A Rudimentary Approach to Integration with JPA and Hibernate 191
Setting Up 191
Programming the Flex and JPA/Hibernate Application 195
xvii
Download from Library of Wow! eBook <www.wowebook.com>
Contents
Flex and Hibernate Integration Expectations 199
BlazeDS Adapter for JPA and Hibernate 201
Aspect-Oriented Programming (AOP) 203
JPA and Hibernate Adapters for BlazeDS 204
dpHibernate 204
Gilead 208
Managed Entities for Flex Applications 211
Summary 212

Chapter 8: Testing and Debugging Flex and BlazeDS Applications 215


Testing 215
FlexUnit 216
JUnit 224
Functional and Interface Testing 227
Debugging 243
Logging 243
Profiling 246
Summary 251

Chapter 9: Extending BlazeDS with Custom Adapters 253


Contextual Overview 253
The API 255
A Sample Custom Adapter 259
Custom Factories 264
Extending the Messaging Adapter 268
Advanced Strategies for Custom Adapter Creation 269
Summary 270

Chapter 10: Making BlazeDS Applications Scalable 271


Clustering 271
Channel Failover 272
Clustering Powered by JGroups 274
Data Compression 276
Data Format Optimization 278
Robust Connection 280
Service Orientation 282
Concurrent Contracts 282
Cross-Domain Utility Layer 283
Functional Decomposition 283

xviii
Download from Library of Wow! eBook <www.wowebook.com>
Contents
Rules Centralization 283
State Repository 283
Caching 283
Signed Framework RSL 285
Resource Pooling 287
JDBC Connection Pooling 287
JMS Resource Pooling 289
Bind Messaging to the Beans Using Camel 290
Using Spring’s Support for Message Listener Containers 291
Workload Distribution 291
Summary 292

Chapter 11: CRUD Applications and More 293


CRUD with Flash Builder 4 294
CRUD with RESTful Endpoints 294
Generating Client Code for WebService Consumption 300
Generating CRUD with Remoting Service Destinations 303
Generating AS3 Model Objects 312
Using Gas3 312
Auto-Populating AS3 Model Objects with XML Based on an XSD 320
Summary 323
Appendix A: Introducing Flex 4 325
What Is Flex 4? 325
What’s New? 326
Flex 4 and Before 327
Leveraging the New Framework 331
Development Workflows 331
Flex 4 Says Hello 332
Summary 335

Index 337

xix
Download from Library of Wow! eBook <www.wowebook.com>
Download from Library of Wow! eBook <www.wowebook.com>
Foreword

As with many interactions between developers these days, I first met Shashank Tiwari online via his
blog. He was writing thoughtfully about Java and Flex back in the days when this was mostly uncharted
territory where only a handful of brave developers had ventured. Through those interactions we began
making plans to lead more Java developers to the blissful world of Java and Flex.

Having been a professional software developer for more than ten years, I’ve met developers from a
wide variety of backgrounds, including hackers, scientists, teachers, plumbers, and athletes. There is
no better way to know what a developer is like than to write code and articles with them. Over the
past few years Shashank and I have co-authored a number of articles and code samples together. From
these experiences, I know that Shashank is a top notch Java developer and a Flex master. What makes
Shashank’s books stand out, however, is that he is not only a superb developer but also an excellent
teacher.

I was very excited when I heard that Shashank was working on a new book focused on integrating Java
and Flex through BlazeDS. So many Java developers I interact with want to build better software but
are reluctant to learn a new technology stack. Flex and BlazeDS provide a great path for Java developers
to build better software that users love to use. The wealth of out-of-the-box and community-built Flex
components enables developers to rapidly assemble great applications. But there is a learning curve
for the typical Java developer who must understand and navigate the intricacies of a thick-client UI
framework, data marshalling mechanisms, and a new tool chain. Shashank makes that learning curve
smooth and fun.

This book provides much needed practical knowledge for assembling production applications using
Java and Flex. The extensions Shashank has built to BlazeDS, his examples of real-world Spring inte-
gration, and his detailed explanations regarding Hibernate data access provide readers with end-to-end
instructions for building great UIs on Java back-ends.

I’ve had the great privilege of working with and learning from Shashank. He has helped me to be a better
developer and to gain a more complete understanding of new technologies. I’m sure that Professional
BlazeDS will do the same for you.

James Ward
www.jamesward.com
Co-author of First Steps in Flex with Bruce Eckel
www.firststepsinflex.com

Download from Library of Wow! eBook <www.wowebook.com>


Download from Library of Wow! eBook <www.wowebook.com>
Introduction

Java easily ranks among the most popular enterprise computing platforms. Adobe Flex is a leading Rich
Internet Application (RIA) development framework. The combination of Java and Flex is one of the most
compelling propositions for enterprises to create rich and engaging applications to enhance productivity
and increase customer satisfaction.

An effective integration of Java and Flex implies that you can leverage robust scalable Java server side
applications in conjunction with the superior rendering capabilities of the Flash player. It also means
that your investments in Java server back-ends can be reused and leveraged in your new generation
applications.

Looking at the integration from the other side, an effective combination of Java and Flex means that your
clunky old web 1.0 interfaces and old-style interaction models can be replaced with their more effective
new-generation counterparts.

In addition to all the benefits listed above, an effective plumbing between Java and Flex promises Flex’s
reach to all enterprise resources, including databases, enterprise resource planning systems, authentica-
tion systems and organization-wide messaging systems.

Java and Flex integration is achieved with the help of a number of products and tools, including LifeCycle
Data Services (LCDS) and BlazeDS from Adobe. LCDS is a commercial product and BlazeDS is an open
source alternative to LCDS.

This book is all about combining Java and Flex. The book covers the integration story with BlazeDS as
the protagonist. It explores all aspects of BlazeDS and explains its extension points that allow it to be
stretched beyond its off-the-shelf capabilities.

This is one of the first few books that addresses the topic of Java and Flex integration using BlazeDS.
From the very first draft proposal I have seen a lot of excitement around this topic and this book (at least
among all involved in its creation). As I was writing this book over the last few months, BlazeDS and
Flex saw a lot of rapid changes and inclusion of newer features and capabilities. It was also the time
Spring BlazeDS emerged as a SpringSource and Adobe supported initiatives to integrate Spring and Flex
using BlazeDS. I have made every attempt to keep the content up-to-date and relevant. However, some
of the pieces of software are in beta phase and will continue to evolve as we work hard to make this book
available in your hands. Even though this makes the book susceptible to being outdated on a few rare
instances, I am confident the content remains useful and relevant through the next versions of the Flex
framework, Java, and BlazeDS.

The book at all times attempts to balance between theory and practice, giving you enough visibility into
the underlying concepts and providing you with the best practices and practical advice that you can
apply at your workplace right away.

Download from Library of Wow! eBook <www.wowebook.com>


Introduction

Who This Book Is For


This book is best suited for those developers and architects who leverage Java and Flex to create rich
internet applications. Such developers are likely to come from either the Java or the Flex backgrounds, or
from a background that includes neither of the two technologies.

For those who are Java experts the book teaches the details of BlazeDS and its applicability in using it to
plumb Java and Flex applications together. I understand that some such experts may not have sufficient
knowledge of the Flex framework. Therefore I explicitly introduce Flex 3 in Chapter 1 and provide a peek
into the upcoming Flex 4 version in the appendix.

For those who are Flex developers and architects the book provides explanations and examples of how
they can effectively include BlazeDS in their application stack. I assume much of the conceptual content
would be accessible to such developers. It’s possible though that some advanced topics on persistence,
Spring integration and custom extensions could be difficult for a developer who has little or no knowl-
edge of Java. This book does not attempt to teach Java fundamentals, which is outside its scope. Tools for
learning the essentials of Java are widely available and I encourage you take advantage of them to get
the most out of this book.

I advise that you read the book from start to finish for an initial understanding and then return to specific
chapters to apply detailed and specific recommendations.

What This Book Covers


This book covers Java version 5 and above, Flex version 3.x, BlazeDS version 3.x and 4 beta and Flash
Builder version 3.x and 4 beta. The book also introduces Flex 4 beta minimally. The content in this book
should be relevant through Flex 4, BlazeDS 4 and Flash Builder 4.

Version 1.0 of Spring BlazeDS and FlexMonkey, JMS 1.1 and Hibernate 3.3.2.GA are covered.

How This Book Is Structured


This book consists of 11 chapters and an appendix. The 11 chapters gradually start from the fundamentals
and progress to cover increasingly complex topics. The first chapter introduces the Flex 3 framework. The
appendix minimally introduces Flex 4 beta. The rest of the chapters cover the different aspects of BlazeDS,
its existing features, and its custom extensions. A majority of the chapters illustrate the proxy, remoting,
and messaging capabilities of BlazeDS. For a holistic treatment, chapters on testing and scalability are
also included.

As mentioned previously, I recommend that you read the book sequentially from the first to the last
chapter. That way your learning curve will be smooth and gradual.

Chapter by chapter, this book covers:

❑ Flex for Java Developers (Chapter 1) — A brief primer to Flex for Java developers. The chapter
teaches Flex fundamentals, providing a few examples in context.
❑ Introducing BlazeDS (Chapter 2) — This chapter gently introduces BlazeDS. It explains the
BlazeDS architecture, its core features, configuration files and the deployment infrastructure.
In addition, the chapter explains the installation processes and peeks into the underlying core.
xxiv
Download from Library of Wow! eBook <www.wowebook.com>
Introduction
❑ Using BlazeDS as a Server-side Proxy (Chapter 3) — Flex applications can access data and
web services from remote destinations if the remote destinations define an appropriate security
definition, in a file called crossdomain.xml. The Flash player debars access from sources that
lack such a security definition. However, BlazeDS provides server side proxy capabilities to
access these sources. The focus here is on the role of BlazeDS as a server-side proxy.
❑ Remoting between Flex and POJOs (Chapter 4) — This chapter illustrates the details of remote
procedure calls between Flex and Java objects and explains how objects can be streamed between
the two using a binary protocol called AMF (Action Message Format).
❑ Accessing Spring Beans (Chapter 5) — SpringSource, the makers of the Spring Framework, and
Adobe, makers of Flex, combined efforts to create Spring BlazeDS that helps integrate Spring and
Flex applications using BlazeDS effectively. This chapter covers the features of this new integra-
tion project.
❑ Communicating Real-time via Messages (Chapter 6) — BlazeDS supports real-time messaging
and data push. In this chapter I start with the essentials of messaging between Flex and Java and
highlight the important aspects like AMF long polling and the JMS adapter.
❑ Leveraging JPA and Hibernate with Flex (Chapter 7) — Hibernate is the most popular Java per-
sistence framework and JPA is the standard that defines Java EE persistence architecture. Both
the product (Hibernate) and the associated specification (JPA) bring benefits of Object relational
mapping to the world of Java. This chapter explains how the same features can be extended to
Flex applications using BlazeDS.
❑ Testing and Debugging Flex and BlazeDS Applications (Chapter 8) — This chapter explains
the nuts and bolts of logging, testing, and debugging Flex and BlazeDS applications.
❑ Extending BlazeDS with Custom Adapters (Chapter 9) — BlazeDS is a great product off-the-
shelf, but the most valuable aspect of its design is that it can be extended easily to adapt to varied
server side resources. This chapter will explain the available API and the approach to creating,
deploying and using custom adapters.
❑ Making BlazeDS Applications Scalable (Chapter 10) — This chapter explains how you could
scale BlazeDS using the concepts that involve clustering, data compression, data format opti-
mization, robust connection, service orientation, caching, resource pooling, and workload distri-
bution.
❑ CRUD Applications and More (Chapter 11) — This chapter illustrates CRUD application gener-
ation using Flash Builder 4 beta. It also illustrates the use of Gas3 for automatic translation from
Java to AS3 and auto-population of AS3 objects based on XML content that support XML schema
definitions.
❑ Introducing Flex 4 (Appendix) — The appendix introduces the fundamentals of Flex 4, the next
version of the Flex framework. Currently, Flex 4 is in beta. It will be released only in early 2010.
The appendix provides a sneak peek into what’s brewing.

What You Need to Use This Book


This book requires that you have the following software installed on your machine:

❑ JRE version 5 or above


❑ Flex SDK version 3
❑ BlazeDS version 3 or above

xxv
Download from Library of Wow! eBook <www.wowebook.com>
Introduction
❑ Flex Builder version 3 (not a necessity but convenient)
❑ Flash Builder 4 beta (especially to follow along the directions in Chapter 11)
❑ JBoss AS or Tomcat (when using Tomcat, please install an external JMS provider like ActiveMQ)

In addition, for specific chapters, you will need the following:

❑ Spring BlazeDS
❑ FlexMonkey
❑ JMS provider (like ActiveMQ)
❑ Hibernate
❑ JGroups
❑ Ruby and FunFX

Conventions
To help you get the most from the text and keep track of what’s happening, we’ve used a number of
conventions throughout the book.

Boxes like this one hold important, not-to-be forgotten information that is directly
relevant to the surrounding text.

Notes, tips, hints, tricks, and asides to the current discussion are offset and placed in italics like this.

As for styles in the text:

❑ We highlight new terms and important words when we introduce them.


❑ We show keyboard strokes like this: Ctrl+A.
❑ We show file names, URLs, and code within the text like so: persistence.properties.
❑ We present code in two different ways:

We use a monofont type with no highlighting for most code examples.


We use gray highlighting to emphasize code that is of particular importance in
the present context.

Source Code
As you work through the examples in this book, you may choose either to type in all the code manually or
to use the source code files that accompany the book. All of the source code used in this book is available
for download at www.wrox.com. Once at the site, simply locate the book’s title (either by using the Search
box or by using one of the title lists) and click the Download Code link on the book’s detail page to obtain
all the source code for the book.

xxvi
Download from Library of Wow! eBook <www.wowebook.com>
Introduction
Because many books have similar titles, you may find it easiest to search by ISBN; this book’s ISBN is
978-0-470-46489-2.

Once you download the code, just decompress it with your favorite compression tool. Alternately, you
can go to the main Wrox code download page at www.wrox.com/dynamic/books/download.aspx to see
the code available for this book and all other Wrox books.

Errata
We make every effort to ensure that there are no errors in the text or in the code. However, no one is
perfect, and mistakes do occur. If you find an error in one of our books, like a spelling mistake or faulty
piece of code, we would be very grateful for your feedback. By sending in errata you may save another
reader hours of frustration and at the same time you will be helping us provide even higher quality
information.

To find the errata page for this book, go to www.wrox.com and locate the title using the Search box or one
of the title lists. Then, on the book details page, click the Book Errata link. On this page you can view all
errata that has been submitted for this book and posted by Wrox editors. A complete book list including
links to each book’s errata is also available at www.wrox.com/misc-pages/booklist.shtml.

If you don’t spot ‘‘your’’ error on the Book Errata page, go to www.wrox.com/contact/techsupport.
shtml and complete the form there to send us the error you have found. We’ll check the information and,
if appropriate, post a message to the book’s errata page and fix the problem in subsequent editions of
the book.

p2p.wrox.com
For author and peer discussion, join the P2P forums at p2p.wrox.com. The forums are a Web-based
system for you to post messages relating to Wrox books and related technologies and interact with other
readers and technology users. The forums offer a subscription feature to e-mail you topics of interest of
your choosing when new posts are made to the forums. Wrox authors, editors, other industry experts,
and your fellow readers are present on these forums.

At http://p2p.wrox.com you will find a number of different forums that will help you not only as you
read this book, but also as you develop your own applications. To join the forums, just follow these steps:

1. Go to p2p.wrox.com and click the Register link.


2. Read the terms of use and click Agree.
3. Complete the required information to join as well as any optional information you wish to
provide and click Submit.
4. You will receive an e-mail with information describing how to verify your account and com-
plete the joining process.

You can read messages in the forums without joining P2P but in order to post your own messages, you
must join.

xxvii
Download from Library of Wow! eBook <www.wowebook.com>
Introduction
Once you join, you can post new messages and respond to messages other users post. You can read
messages at any time on the Web. If you would like to have new messages from a particular forum
e-mailed to you, click the Subscribe to this Forum icon by the forum name in the forum listing.

For more information about how to use the Wrox P2P, be sure to read the P2P FAQs for answers to
questions about how the forum software works as well as many common questions specific to P2P and
Wrox books. To read the FAQs, click the FAQ link on any P2P page.

xxviii
Download from Library of Wow! eBook <www.wowebook.com>
Flex for Java Developers
This book is a comprehensive resource on leveraging Flex and Java together to create robust
enterprise-grade Rich Internet Applications (RIAs). The book chooses the popular open source
data services product from Adobe, BlazeDS, as the critical integration layer that makes Flex and
server-side Java work together. BlazeDS is a piece of Java code and works within a Java virtual
machine (JVM). More precisely, it’s a web application that can be successfully deployed in a
Java application server or even in a minimalist Servlet container like Apache Tomcat. The book,
therefore, talks more Java than Flex and focuses on how BlazeDS can be configured, customized,
and extended to integrate with all things Java. However, it’s not practical that integration be
studied without looking at both sides of the puzzle. Therefore, in this chapter, we start by talking
about Flex, Java’s counterpart in the context of this book. It’s not a comprehensive treatment of the
subject. It can’t be in mere 40-odd pages. It’s just enough information to help you understand the
basics and to present to you the interfaces and integration points. The illustration and discussion
is biased toward addressing the Java developer more than anybody else, although nothing in this
chapter really requires knowledge of Java itself.

Let’s begin exploring and understanding the fundamentals of Flex.

Introducing Flex through Its Controls


and Containers
Flex is an RIA development framework. It provides a set of controls, services, and utilities, which
can be readily used together to create rich and engaging applications. Developers programming in
Flex use ActionScript 3 (AS3) and MXML to create user interfaces, consume data, provide interac-
tivity, and maintain state.

AS3 is an object-oriented programming language that has a close resemblance to the Java and
JavaScript programming languages. MXML is an XML-based declarative language, which makes
programming intuitive and easy. All MXML code is translated automatically to AS3 before it’s com-
piled. This intermediate AS3 representation of the MXML code is often deleted unless a developer

Download from Library of Wow! eBook <www.wowebook.com>


Chapter 1: Flex for Java Developers
specifies that that it be saved. Generated AS3 representations of MXML can be saved by explicitly speci-
fying the ‘‘-keep’’ option to the Flex compiler. AS3 compiles to a byte code format called ‘‘swf,’’ that runs
within the Flash Player virtual machine.

Figure 1-1 shows the essential parts of the Flex framework in a diagram. A Flex application, on com-
pilation, can output a swf file that is ready to run in a Flash Player, or it can output a swc file that can
be consumed as a library and made part of a swf file. A swf file can be dropped into a web server and
accessed over the web using the standard HTTP protocol. When accessed by a user, the swf is down-
loaded locally to the user’s machine and played in the local browser that hosts the Flash Player. Figure 1-2
depicts the accessing of a swf file in a diagram.

Flex SDK

Flex Library
(Controls, Services & Helpers)

MXML
ActionScript 3
(AS3)
AS3

SWC

SWF

Figure 1-1

This book is written for the Flex 3.2 software development kit (SDK) and the Flex 4 SDK. Every attempt
is made to cover the entire set of features in Flex 3.2 and Flex 4 relevant to the integration of Flex and
Java. However, at the time of writing Flex 4 is still in the oven and its final form is still unknown. I will
try and keep close pace with the development of Flex 4 as I write this book. Even then, it’s possible that a
few things may change by the time you get hold of this book. Despite this possible small caveat, I am still
certain that almost all the content of this book will be useful and relevant.

Web Browser
Flash
Player

Web Server
“swf”
file

Figure 1-2

2
Download from Library of Wow! eBook <www.wowebook.com>
Chapter 1: Flex for Java Developers
At this point, let’s write a simple example application to reinforce the basics you have learned so far.
The sample application has two visual interface components: a text input and a text display area. Each of
these components has a label attached to it. The labels help the user understand what to input and what
sense to make of the display. The source for the visual controls alone is:

<mx:Label text="What’s your name?"/>


<mx:TextInput id="textInput"/>
<mx:Button id="button" label="Submit" click="clickHandler(event)"/>
<mx:Label text="{yourName}"/>

Adobe likes to refer to Flex user interface components as controls. In addition to user interface com-
ponents, Flex contains classes that act as services, utilities, and helpers. These classes help with the
following:
❑ Maintain data collections
❑ Bind data from source to destinations
❑ Control event propagation and handling
❑ Connect to external sources of data and services
❑ Actualize effects and transitions
❑ Affect the appearance of the controls
❑ Validate and format data
❑ Facilitate data visualization
❑ Support accessibility requirements
❑ Test, log, tune, and structure applications

The visual controls code suggests the presence of an event handler that is invoked on the click of the
button labeled ‘‘Submit.’’ The code for the click handler is:

[Bindable]
public var yourName:String;

public function clickHandler(evt:Event):void {


yourName = "Hello, " + textInput.text + " !";
}

Next, the source needs to be compiled. For now, I compile this code simply by pressing the Run button in
Flex Builder (which is now called Flash Builder), the official Eclipse based Flex integrated development
environment (IDE) from Adobe. Unlike the Flex SDK, which is an open source and freely available tool
set, Flash Builder is a purchased, but inexpensive, product. IntelliJ IDEA is an emerging alternative to
Flash Builder, as it now supports Flex development. IntelliJ IDEA does not support the Flash Builder
style ‘‘design’’ mode though. No IDE at all is also an option. The Flex SDK can be used without any IDE
to compile the code successfully. The compiled output using any of the preceding methods produces the
same program in a swf file format.

Tip to Remember
When not using Flash Builder or IntelliJ IDEA, leverage the Flex ANT Tasks, which are bundled with
the free Flex 3.2 SDK, to compile Flex applications. When using ANT Tasks, you can avoid tediously
specifying all necessary parameters on the command line.

3
Download from Library of Wow! eBook <www.wowebook.com>
Chapter 1: Flex for Java Developers
When this compiled swf is accessed via a web browser (which hosts a Flash Player plug-in of version 9
and above), the initial screen shows up, as in Figure 1-3.

Figure 1-3

In the screen, I put in my name and click the Submit button, and I see the application greeting me by my
name, as was expected. Figure 1-4 depicts this output.

Figure 1-4

Next, we refactor this simple application a bit just to emphasize the flexible data-binding aspects of Flex.
The Submit button and the click handler are actually superfluous code and can be gotten rid of. The
TextInput control can directly be bound to the Label that displays the output. The refactored code for
the visual control takes the following form:

<mx:Label text="What’s your name?"/>


<mx:TextInput id="textInput"/>
<mx:Label text="Hello, {textInput.text} !"/>

Actually, this code does not just represent the visual control but is pretty much the entire code. The
only thing missing is the enclosing Application tags, which form the essential container that houses all
Flex applications. The Application class also works as the entry point for Flex applications in a manner
analogous to the main method in an executable Java or C++ program.

In the refactored code, none of the click handlers or the extra variables is required. This was possible
because the Flex framework under the hood is implicitly triggering and handling events when we bind
the text property of the TextInput control to the text property of the display Label.

On the contrary, an intermediate variable was used earlier to pass the value from the TextInput control
to the display Label. This intermediate variable was declared Bindable to make sure that its value was
propagated through whenever it changed. A variable, when annotated as Bindable, implicitly creates
an underlying set of events and event handlers, which facilitate the data update from the source of the
data to the destination at which it is consumed. Destination variables are wrapped in curly braces that
represent data binding.

Before we move forward to surveying the list of available controls, let’s see the new output of the refac-
tored application in Figure 1-5.

4
Download from Library of Wow! eBook <www.wowebook.com>
Chapter 1: Flex for Java Developers

Figure 1-5

I guess the simple example has whetted your appetite and gotten you curious to learn more. Next, we
dive into the set of controls that come off the shelf with Flex.

Getting to Know the Controls


Controls, or UI controls, are the user interface components in the Flex framework. On the basis of func-
tionality they could be classified into the following bundles:

❑ Buttons and clickable links


❑ Menus
❑ Lists
❑ Grids and tabular representations
❑ Data entry and user input controls
❑ Tree
❑ Progress and range indicators
❑ Image, SWF Loader, and video display
❑ Alert

In the following subsections, we dig in a bit deeper into each of these controls and see them in use.

Buttons and Clickable Links


Buttons and links are typically suited for triggering an action. In some cases, this can facilitate navigation
within and without the application. Six different types of buttons and clickable links are available in Flex
for ready use. More such controls can be created by combining and extending these available compo-
nents. In addition, you have the choice to create some from scratch by extending the UIComponent class,
which, by the way, lies at the root of the entire set of Flex user interface classes’ hierarchy.

The seven different prebuilt button and clickable link controls are:

❑ Button
❑ LinkButton
❑ ButtonBar
❑ ToggleButtonBar
❑ LinkBar
❑ TabBar
❑ PopUpButton

5
Download from Library of Wow! eBook <www.wowebook.com>
Chapter 1: Flex for Java Developers
To demonstrate the capabilities of these controls and understand their usage pattern, let’s build an appli-
cation showcase that puts them together in one place. It’s aptly called the ButtonShowcase and its code
corresponds to an MXML file by the same name. You will find this and all other code in the downloadable
bundle of code associated with this book.

The first of the seven button types is a Button. A Button is a clickable control that all of us are familiar
with. Creating a Button using Flex is simple and involves only a line or two of code, as follows:

<mx:Button id="button" label="Just a Button! You can click me."


click="buttonClickHandler(event)"/>

Clicking a Button triggers a click event. A function could be defined as an event handler for this click
event. This function is invoked every time the click event is triggered. In the button showcase, the click
handler function merely pops up an alert on-screen, but you are likely to do more useful things within
this function in a real application. The event handler for the simple button is:

public function buttonClickHandler(event:Event):void {


Alert.show("The button click handler called me!", "Button Click
Alert",Alert.OK,this);
}

A traditional button could be replaced with a link, which could demonstrate the same set of features as
that of a button. Using the LinkButton class, you can quickly create a link that behaves like a button.
Here is the code for it:

<mx:LinkButton id="linkButton" label="I am a Link! You can click me too."


click="linkButtonClickHandler(event)"/>

Once you have two or more buttons, you may desire to group them together, especially if they are related.
The ButtonBar class comes handy in grouping a bunch of buttons. For our button showcase, we will
create four buttons labeled Flex, AIR, Flash, and Acrobat, respectively, and add them together to a bar of
buttons. The process of creating this aggregation is quite simple. In our code, we don’t really create each
of these four buttons individually and add them one by one. Instead, we use the dataProvider property
of the ButtonBar. An Array of strings is defined and bound to a bar of buttons by assigning it as the
value of the bar’s data provider. Here is the code for your reference:

<mx:ButtonBar id="buttonBar1" itemClick="itemClickHandler(event);">


<mx:dataProvider>
<mx:Array>
<mx:String>Flex</mx:String>
<mx:String>AIR</mx:String>
<mx:String>Flash</mx:String>
<mx:String>Acrobat</mx:String>
</mx:Array>
</mx:dataProvider>
</mx:ButtonBar>

The dataProvider property allows for a loosely coupled architecture that facilitates the separation of
data and its view in the context of a control.

Data providers further the purpose of separating sources of data from the ways they are manipulated and
consumed within user interface controls.

6
Download from Library of Wow! eBook <www.wowebook.com>
Chapter 1: Flex for Java Developers
Buttons in a ButtonBar are laid out horizontally by default. Setting the direction property of the
ButtonBar control to vertical lays out the constituent buttons vertically. On clicking any of the but-
tons in the bar, an itemClick event is dispatched. An item click handler function can be defined and
bound as the event handler for this event. Our example application itemClick handler is programmed
to pop up an alert dialog box, showing the selected index and the associated label. Here is the source
code for it:

public function itemClickHandler(event:ItemClickEvent):void {


Alert.show("The item click handler at index " + String(event.index) + " with label "
+ event.label + " called me!",
"Item Click Alert",Alert.OK,this);
}

The ButtonBar stacks constituent buttons together and acts as a convenient navigation aid. It does not
maintain state though. This means it does not remember the current selection. However, another control
called ToggleButtonBar comes to your rescue in situations where you need to remember the last selec-
tion. A ToggleButtonBar allows only one button from the group to be selected at a time. Making a new
selection deselects the last choice and sets the new choice as the selected one. Setting the toggleOnClick
property to true deselects a selected item on clicking it.

Like buttons, link buttons can be grouped in a LinkBar. Doing it is easy. Here is some code that demon-
strates how to do it:

<mx:LinkBar id="linkBar" itemClick="itemClickHandler(event)">


<mx:dataProvider>
{dataArray}
</mx:dataProvider>
</mx:LinkBar>

Like buttons and links, tabs are a common artifact used for navigation. Typically, different independent
views of an application are navigated to using tabs. A TabBar control lets you define a set of tabs, where
each tab is effectively an element, like a button or a link. The TabBar control has a data provider property,
which helps attach data elements to the control.

So far, you have seen buttons, links, and the bars that can contain buttons and links. In addition to these
Flex also includes a unique button, which has two parts, the first of which is the standard button and
the second of which can be used to pop up any UIComponent. Such a button is called a PopUpButton. The
typical use case is to pop up a list or menu and have the selection in the list or menu update the first
button label. For our example, though, we don’t show this use case. We pop up a date chooser instead.
Figure 1-6 shows the date chooser popping up on clicking the second button.

Figure 1-6

7
Download from Library of Wow! eBook <www.wowebook.com>
Chapter 1: Flex for Java Developers
The PopUpButton can be created in a line or two of code, as follows:

<mx:PopUpButton id="popUpButton" label="First Button"


click="firstButtonClickHandler(event)"
creationComplete="initDateChooser()"/>

The click handler for the first button just brings up an alert component, while that of the second button
pops the date chooser component. Here is the code for it:

private function initDateChooser():void {


var dateChooser:DateChooser = new DateChooser();
dateChooser.yearNavigationEnabled = true;
popUpButton.popUp = dateChooser;
}

public function firstButtonClickHandler(event:Event):void {


Alert.show("The first button click handler called me!",
"First Button Click Alert",Alert.OK,this);
}

To reinforce what has been stated about the seven button controls so far, they are put together in one
place in Figure 1-7.

Button
LinkButton
ButtonBar
(horizontal)

ButtonBar
(vertical)

ToggleButtonBar

LinkBar
TabBar
PopUpButton

Figure 1-7

A pictorial representation always helps when talking about user interface components.

Next, we look at menu controls, which are another useful set of controls for navigation and triggering
actions.

Menus
A Menu navigation control, in Flex, pops up in response to a user’s action. It has a set of selectable units
or items within it. A menu may have any number of nested submenus inside it.

8
Download from Library of Wow! eBook <www.wowebook.com>
Chapter 1: Flex for Java Developers
Once a user selects a menu item, the Menu, by default, becomes invisible. In addition a Menu also becomes
invisible when the Menu.hide method is explicitly called or a user clicks outside of the Menu component
or selects another component in the application. Figure 1-8 shows what a Menu looks like.

Figure 1-8

The menu can include other controls such as radio buttons, as shown in the example in Figure 1-8. Here
is the data that defines the menu items:

<mx:XML format="e4x" id="menuData">


<root>
<menuitem label="MenuItem 1">
<menuitem label="SubMenuItem 1-A"/>
<menuitem label="SubMenuItem 1-B"/>
</menuitem>
<menuitem label="MenuItem 2">
<menuitem label="SubMenuItem 2-A" type="radio"groupName=
"radioMenuItemGroup1" toggled="true"/>
<menuitem label="SubMenuItem 2-B" type="radio"groupName=
"radioMenuItemGroup1"/>
<menuitem label="SubMenuItem 2-C" type="radio"groupName=
"radioMenuItemGroup1"/>
</menuitem>
<menuitem label="MenuItem 3" type="check" toggled="false"/>
<menuitem label="MenuItem 4" type="check" toggled="true"/>
</root>
</mx:XML>

Remember that this menu pops when you click a button. It’s standard practice not to paint the menu
upfront but to bring it up on some user-initiated action. This practice is one of the main reasons why you
will not find an MXML component for a menu. The only way to create a menu is to do so programmati-
cally using AS3.

An alternative to popping up a menu dynamically is to assemble it statically within a menu bar. A


MenuBar component lays out the top-level menu items in a row horizontally. Again, each of the menus
can have nested submenus. Figure 1-9 shows the earlier menu example within a menu bar.

Figure 1-9

To reuse the data from the Menu control in a MenuBar control you need to collate the menu items as an
XMLList, which is a list of XML objects or elements. The Menu data exists as an XML document or object.

9
Download from Library of Wow! eBook <www.wowebook.com>
Chapter 1: Flex for Java Developers
In an XML document there is a single element at the root node and that does not accommodate multiple
members at the main level. A MenuBar can have multiple members at the primary level. All top-level
elements in an XMLList are added as primary members on the menu bar.

Menus can also appear within a PopUpMenuButton. A PopUpMenuButton is a PopUpButton that pops up
a menu when its secondary button is clicked. When a menu item is selected, the primary button label
is updated with the label of the selected item. The popped-up menu cannot contain submenus in it.
Listing 1-1 shows the code for a PopUpMenuButton.

Listing 1-1: A PopUpMenuButton


<?xml version="1.0"?>
<!-- APopUpMenuButton.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
import mx.controls.Menu

private function init():void {


Menu(popUpMenuButton.popUp).selectedIndex=0;
}
]]>
</mx:Script>

<mx:XML format="e4x" id="menuData">


<root>
<menuitem label="MenuItem 1"/>
<menuitem label="MenuItem 2"/>
<menuitem label="MenuItem 3" type="check" toggled="false"/>
<menuitem label="MenuItem 4" type="check" toggled="true"/>
</root>
</mx:XML>

<mx:PopUpMenuButton id="popUpMenuButton"
dataProvider="{menuData}"
labelField="@label"
showRoot="false"
creationComplete="init();"/>
</mx:Application>

That briefly covers the menus; now we move on to lists.

Lists
There are three types of lists available as a part of the Flex controls. These are List, HorizontalList, and
TileList. A List is a vertical display of a list of items. A user can select one or more of these items. The
allowMultipleSelection property value governs if multiple selections are allowed or not. A List could
be created as follows:

<mx:Model id="listItems">
<technologies>
<technology label="Flex" data="1"/>
<technology label="AIR" data="2"/>

10
Download from Library of Wow! eBook <www.wowebook.com>
Exploring the Variety of Random
Documents with Different Content
pienellä kaupalla, metsästyksellä, kalastuksella ja huoneitten
salvamisella, — kulkee ohi.

"Ääh, Uula-vietävä!" sanoo hän hienosesti tullen väkeville, joita on


saanut insinööriltä. "Ääh, Uula-poika! Älä mieti suotta, älä mieti
suotta!"

"Anna minullekin ryyppy!" sanoo Uula äkisti, tuntien että hänen


ajatuksensa sekoavat.

"En anna! Hullummaksi vain tulisi. Älä usko naisväkeen!"

"Anna vaan. Rahassa maksan. Kaksinkertaisen hinnan."

"Hullu! Mikä viinakauppias minä olen. Kullakin omat murheensa."

Kylmänen lonkuttelee tiehensä Mutkaan päin. Asioilleen minne


menee.

Mutta Uula jää istumaan paikalleen kiinteästi ja taukoamatta


ajatellen
Elna-nimistä tyttöä, joka oli kuin taivaasta viskattu hänen tielleen.

Illansuussa tulevat saattomiehet Mutanivan kylästä insinööriä


hakemaan, neljä laukunkantajaa ja yksi, joka kuului olevan nuorempi
insinööri, pitkä, tummaverinen miehenroikale. Heti ensi näkemältä
tuntee Uula vihaa miestä kohtaan ja pahoja aavistuksia. Pieni ja
mitätön tuntee hän olevansa tuon pitkän roikaleen rinnalla.

"Lähdöksikö se nyt heti panee?" kysyy isä-Niila.

"Lähdöksipä tietenkin. Yötä myöten on helpompi kulkea."

"Niinpä vainkin. Ei ahdista kuumuus."


Uula katselee ajatuksettomasti, kun vieraat säälivät tavaroitaan
kokoon. Menoa se nyt on, menoa pitkiksi ajoiksi. Hänen sydäntään
alkaa ahdistaa, ja tuntuu kuin kurkkuun nousisi itkuntapaista.

Suurin, kuivin silmin tarkkaa Uula pakkaamistoimitusta. Ei puutu,


ei pukahda. Tuntuu niinkuin pitäisi hänen jotakin puhua, sanoa
jotakin leikkisää, niinkuin tapa on, mutta hän ei keksi mitään, katsoo
vain, ja ajatukset tekevät mitä tahtovat. Se nuorempi insinööri
puhelee Elnalle, ja tämä vastailee, milloin ylimalkaisesti ja
ohimennen, milloin pysähtyen ja nauraa puuskahtaen.

Viimein Uula huomaamatta hiipii ulos. Ei tahdo olla sitä lähtöä


näkemässä.

Mutta samassa on siinä se tyttökin.

"Oikein ikävä täältä on lähteä", sanoo hän.

"Aika on sentään kulunut niin hyvin."

Uulalla ei ole mitään sanomista.

"Aika on kulunut niin hyvin", jatkaa tyttö ja naurahtaa sitten:


"Myönnä pois, että sinunkin tulee ikävä!"

"Mikä ettei tulisi", tokaisee Uula karusti.

"Kas vaan, kun olet rehellinen. Mutta sillähän siitä pääset, kun
tulet katsomaan."

"Ei kehtaa."

"Kyllä kehtaa. Ja hyvästi nyt! Näkemiin!" Hän tarttuu Uulan


vastahakoiseen, tottumattomaan käteen ja puristaa sitä niin, että
toisen kasvoille nousevat veret.

"Et sinä osaa kunnollisesti puristaa kättä-, naurahtaa hän taas ja


tarttuu molemmin käsin Uulan käsiin.

"Näin sen pitää tapahtua", sanoo hän. "Ja muista nyt sitten."

Uulasta tuntuu, kuin hän sulaisi siihen paikkaan. Silmiin nousee


ikäänkuin kimmeltävä verho, sydän takoo, ja kun hän havahtuu, on
tyttö poissa ja edessä aurinkoinen, laakea pihamaa ja
valkosalvoksinen talo. Uula kirahtaa itsekseen ylläpitääkseen
miehuuttaan ja kävelee sitten hitaasti poispäin, metsään.

Neljässä päivässä ehtii siis tapahtua paljon asioita, ja tästä


kaikesta on nyt kulunut kaksi viikkoa. Ja aika on vieläkin sellainen,
ettei aurinko mene mailleen.

Niilan pirtissä nukutaan, mutta poika, Uula, vaeltelee teillä, joista


hän ei soisi jälkeenpäin mainittavan.

Hän on miettinyt ja palanut kaksi viikkoa, nyt hän vaeltelee, tosin


levottomuus sydämessä, mutta määrätietoisesti.

"Niinhän sinä kuljet kuin unissasi, poika", oli isä sanonut.

Uula oli miettinyt, miettimästä päästyäänkin miettinyt. Mikä hän


oikein oli? Mitä hän suotta ajatteli ja vaivasi itseään? Jos joku arvaisi,
niin nauraisi. Veneenkin oli Paulus jo ehtinyt tervata. — Mutta
ajatuksistaan hän ei päässyt minnekään, vaan vietti unettomia öitä
ja turtuneita päiviä.

Niilan talosta vie kaltainen polku Mutanivan kylään. Pihamaalta se


painuu kiveliöön, jota ei käsi eikä leimauskirves vielä ole koskettanut,
katkaisee sitten Sorkojan, jonka yli pääsee kahlaamalla, nousee
vaaralle, pudotakseen heti Päiväsen niitylle, ja kulkee pitkin tunturin
rinnettä, kunnes aavan ja metsikön takaa pilkistävät Mutanivan talot.

Tätä tietä vaeltaa Uula Niilanpoika, milloin kiihkeästi ajatellen ja


kuvitellen, milloin havahtuen, milloin tahdottomasti kuin
unissaankulkija. Hänen täytyi näillä tuntein kulkea tämä tie, että
sekin oli suoritettu.

Tuntuu kuin suuri luonto olisi pysähtynyt katsomaan Uulan kulkua.


Aurinko on vetäytynyt jonnekin tunturin taa, se valaisee, mutta se ei
lämmitä, sen olemassaolon tuntee, mutta paljain silmin sitä ei saata
katsella. Keskiyö on jo sivuutettu. Sääskien kesän kestävä surina
sulautuu luontoon, korva on siihen jo niin tottunut, että se havahtuu
vasta kun surina hetkeksi taukoaa. Puiden latvat kimmeltävät
auringon valossa, mutta maajalassa on kosteata ja tuoksuvaa,
jotakin kalmalta tulevaa ja aavistelevaa.

Ja Uula painaltaa eteenpäin, luuvartinen leuku pompahtelee


kupeella ja helat välkähtelevät, kun auringonvalo aukeoilla niihin
sattuu. Askeleet risahtelevat, risut taittuvat, silloin tällöin sipaisee
neljäntuulen lakki, punasinikeltainen, riippuvaa oksaa, ja kulkija
vetää kärsimättömästi päänsä syrjään. Merkillisillä teillä kulkee Niilan
perillinen.

Yksinäinen hairahtunut poro risahduttaa puita metsikössä. Uula


havahtuu ja kuuntelee, vaistomaisesti käsi tapaa leukunvartta, mutta
silloin tömähtelevät ja napsahtelevat poronkoparat jo kaukana
kankaalla, yhä ja alati edeten.

Yksinäinen poro pysähdyttää hetkeksi Uulan ja ravistelee hänen


ajatuksiaan. Hän huomaa hommansa hulluuden, mutta jatkaa
kuitenkin matkaansa.

"Saahan tuota mennä", sanoo hän itsekseen.

"Siihen ei kukaan pysty sanomaan mitään."

Sillä hänen silmissään väikkyy eräs kuva, joka kiihdyttää hänen


vauhtiaan, ja hän on tuntevinaan erään kädenpuristuksen, joka
ajatellessakin pyörryttää. Saahan mennä, kukaan ei ole kieltänyt.
Mutta käsketty on. Ylösnousun ajaksi hän ehtii perille, jos näin
jatkaa.

Aurinko alkaa jo säteillä ja levittää lämpöä. Sääsket käyvät


virkeämmiksi ja ahdistelevat kasvoja ja käsiä, mutta Uula ei sitä
huomaa. Hän vain kulkee kulkemistaan niinkuin jonkun alkuvoiman
liikkeellepanemana.

Metsässä alkaa elää ja soida. Aamutuuli humisee puiden latvoissa,


siellä täällä alkavat linnut liverrellä, ja valo- ja varjopaikat käyvät
syvemmiksi. Tuntuu, niinkuin olisi seuraa, vaikka kulkeekin yksin.
Päiväsen kohdalla ei seeskulkijan muisto vistota eikä herätä
kaukaista kammoa. Sivuilleen katsahtamatta hän kulkee sen ohi.
Hiukan sivu puolimatkan alkaa polku tehdä nousua tunturin rinteelle,
nousee hitaasti, verkalleen ja kierrellen koivuvyöhykkeeseen ja
jatkuu sitten eteenpäin pysytellen vyöhykkeen ja kaljun rajoilla,
tuontuostakin tehden pienen syrjähypyn puolelle ja toiselle.

Näillä tienoin on matkamiehen tapa levätä, mutta Uulalla ei ole


aikaa sellaiseen. Kenties siihen on syynä pelko, että matka
keskeytyy, että hän siinä istuessaan alkaisi järkevästi harkita asioita.
Tai kenties muut vaistot, jotka vain toinen luonnonlapsi kykenee
tajuamaan.
Uula jatkaa siis matkaansa. Raitis tuuli virkistää hänen hiestyneitä
kasvojaan ja antaa lisää vauhtia hänen askelilleen. Minne hän
katsookin, leviää vain silmänkantamattomia aapoja ja metsiä,
jokiuoma tuolla ja täällä, tuntureita, joista etäisimmät ikäänkuin
häipyvät sinervään savuun.

Viimein hän saavuttaa korkeimman kohdan, polku alkaa hiljalleen


viettää, ja kaukana etäisyydessä näyttää Mutaniva uivan
päivänpaisteessa.

Silloin Uula viimeisen kerran pysähtyy ja empii. Silmät harrillaan


tuijottaa hän niittyjen keskellä välkähtelevää kylää ja vakuuttaa
itselleen, ettei hänellä ole siellä mitään tekemistä. Mutta samalla
kylän näkeminen häntä myöskin kiihoittaa ja hän tuntee, että vaikka
hän onkin syöksymäisillään kuiluun, ei hän kuitenkaan saata olla sitä
tekemättä. Vielä tunti, kenties hiukan enemmän, ja hän saattaa
nähdä sen tytön ja haastella hänen kanssaan.

Uula ei rupea erittelemään, mikä tunne se on, joka juoksuttaa


häntä pitkin metsiä, ja tuskinpa hän osaisi sitä tehdäkään, mutta kun
hänen on pakko mennä, niin hän menee. Kylläpähän sitten selviää.

Mutanivan kylässä ovat aikaisimmat jo jalkeilla, ja Uula


pakottautuu huolettoman näköiseksi, kun saapuu kylätielle ja
lähestyy taloja. Insinööri kuuluu asuvan Keski-Mellassa.

"Aikaisinpa sitä Niilan-Uulaa pyöritellään", sanoo


kahvinkeittopuuhissa oleva emäntä, kun Uula asettuu penkille. "Yötä
myötenkö tulit?"

"Yötä."
"No mikä se niin juoksutti?"

Uula ei vastaa. Yksi ja toinen mies ilmestyy rankisesta ja alkaa


äänettömänä kenkiä.

Viimein Ville, talon poika, saa itsensä valmiiksi ja sytyttää tupakan.

"Niin että sulhasmiehenäkö se Uula oikein", sanoo hän hymyillen


ja vetää pitkän sauhun.

Uula punastuu korvalehtiä myöten, murahtaa jotakin ja katselee


kenkiensä kärkiä, mutta emäntä purskahtaa nauramaan.

"Mikäpä siinä on", puhuu hän sitten, "vaikk'ei se insinööri taida


siitä oikein tykätä".

Uula kuuntelee joka hermo vireessä, ja hänen sisimpäänsä hiipii


hiljainen ilo.

"Tyttö täällä vikisi ja valitti sitä ikäväänsä” jatkaa emäntä


tietämättä Uulan mielenailahteluista, vikisi ja valitti, kun ei ollut
samanikäisiä, — mistäpä niitä, kun kaikki meidänkin pojat linjalla, —
mikään ei kelvannut, ja viimein insinööri kyllästyi ja antoi
metsäherran mukana palata veneellä alas. Toissa päivänä kai se oli
tai maanantaina. Sanoi se röökynä, että teillä oli kuulemma niin
mukava olla, mutta insinööri sanoi, että kyllä hän ne konstit tuntee
vanhastaan."

Siinä nyt istui Uula Mellan pirtin penkillä. Kahvi kuohuu yli,
sekoittaen lemullaan ummehtuneen hien hajun, ja aurinko paistaa
korkealla.
SUURTEN JOKIEN VARSILTA

Jokihulluutta.

Kevätaurinko sulattelee jo talven lumia, räystäät tippuvat,


pihamaille muodostuu pieniä pälvipaikkoja, ja lumipeitteisellä,
jäätyneellä joella kuultaa lumen alta esiin sininen.

Ilmassa on kevään uhoa ja lemua, auringonpaisteinen seinä


hohtaa lämpimältä, metsän havut tuoksahtelevat kaukaisesti, sulava
lumi välkkyy ja kimmeltää vaarojen laella auringon hohteessa. On
kevättä ja on uhoa, kerrakseenkin. Mutta pihamaa ja ometan tienoo
alkaa näyttää ikävän likaiselta ja ruskealta, pieninkin jalan askel
jättää ruskeahkon jäljen valkoiseen lumeen, ja lannan haju
sekaantuu voimakkaasti kevään puhtaisiin lemuihin.

Körkön Heikki, kaksikymmenvuotias, astuu pirtin portaille uudet


pieksusaappaat toisessa ja tervapötsikkä toisessa kädessä. Portailla
hän hetkeksi pysähtyy ja siristää silmiään, sillä auringon valo on
odottamattoman voimakas, mutta sitten hän istuutuu ja alkaa
tervata saappaitaan.

Terva tuoksuu, aurinko paistaa, ja viimein Körkön Heikki alkaa


itsekseen hyräillä.
— Lähden minä, lähden vaikka mikä olisi, ainakin täksi kesäksi, —
ajattelee hän. — Sittenpähän on sekin nähtynä.

Ajattelee vähän niinkuin uhmamielisesti, sivelee taitavasti tervaa


ensin teriin, sitten varsiin ja hyräilee tervatessaan. Mikä on, ettei
saisi lähteä, rahaakin tulee, eikä raha koskaan pahaa tee. Saattaa
tapahtua, että sitä Körkössäkin vielä tarvitaan.

Touhussaan ei Heikki huomaa, kuinka isä, karkeasänkinen,


matalakasvuinen, ilmestyy hänen taakseen pirtin ovesta, painaa lakin
syvemmin otsalleen ja katselee poikansa puuhia.

— No sinä vain puuhaat sitä lähtöä? — kysyy hän viimein.

Heikki vavahtaa, mutt’ei keskeytä työtään.

— Niin, — vastaa hän, — mikä siinä sitten olisi.

Isä lähtee kävelemään tallia kohti.

— Kiire sinullakin on synnin teille, — virkahtaa hän mennessään,


— aivan niinkuin ei sitä kaiken maailman pahuutta ennättäisi
vähemmälläkin oppia…

Heikki ei vastaa mitään eikä rupea mielessäänkään kumoamaan


isänsä sanomia. Koko kevättalven on hän kuullut puhuttavan
maailman riettaudesta ja pahuudesta, kuullut siitä asti kuin joelle
lähdöstä ensi kerran tuli kysymys. Alussa se puhe oli hiukan
vaivannut, ja hän oli pitänyt haluansa joelle synnillisenä ja
häpeällisenä, mutta vähitellen oli alituinen puhe ja saarnaaminen
ruvennut antamaan vain lisää virikettä mielihalulle.
Synnintuntoa, seurojen pitoa, liikutuksiin tulemista, saarnaamista
ja syntien anteeksi todistamista, — kerkesipähän niitten kanssa
sitten taas talvella.

— No, ei nyt sellaisia!

Heikki vavahti, huomatessaan ruvenneensa mielessäänkään


arvostelemaan asioita, joiden ympärillä lepäsi pyhyyden ja
koskemattomuuden sädekehä. Körkön vanhempi Heikki, isä, oli
lestadiolainen ja suuri saarnamies…

*****

Aurinko paistoi, lumi suli, terva tuoksui.

Halu joelle oli tullut oikeastaan jo tammikuulla, puheen ollessa


yhtiön suurista ensikesäisistä uitoista.

Jokkalan vieressä oli lanssimaa, ja siihen oli pitkin talvea vedätetty


valtavia tukkiläjiä. Jokkalan pojat puuhasivat kaikki joelle lähtöä.

— Lähde mukaan, — oli Jokkalan Kunnari yht’äkkiä sanonut.

— Mitäpä minä siellä, kotonakin tarvitaan…

— Tarvitaan!

Jokkalan Kunnari oli ollut vähän viinoissa ja lyönyt nauraen olalle.

Mitäs hiivattia! Lähdet mukaan vain, rahan sinä saat niinkuin


muutkin. Ja me kun sanomme, että tässä nyt on sitten se Körkön
Heikin ainoa poika, jätkänä niinkuin mekin, niin sanon minä, että
ovet on auki röökynää myöten…
Oli tuntunut pientä vihlaisua sydänalassa, pientä huimausta, ja
mielikuvitus oli alkanut toimia.

Mitä nuo nyt kotonakin sanonevat…

— Arvaa kai sen jo ulkoakin. Mutta kyllä sinä ennätät seuroissa


istua, kilvoitella ja olla synnintunnossa talveltakin. Ja toisekseen on
isäsi siksi rahantunteva mies, että kun muutaman satasen tuot
kotiisi, niin on naama hyvinkin mujullaan.

Oh perh… Olihan siinä sekin puoli, eihän tuonne pelaamaan ja


menettämään mennyt, vaan ansaitsemaan. Eikä mielikuvitus siitä
asti antanut rauhaa.

*****

— Etteiköhän olisi viisainta, että vielä kerran miettisi asiaa.

Isä oli nyt palaamassa tallista ja seisahtui, ennenkuin nousi


portaille.

— Mitäpä hänestä enää miettii. Koko talvihan siitä on puhuttu.

Isä ei rupea väittämään vastaan, ottaa tervaamattoman saappaan,


tarkastelee sitä arvostellen joka puolelta, suoristaa viimein varren ja
katsoo suoraan suusta sisään. Sitten hän viskaa saappaan takaisin
portaalle, huokaisee ja alkaa mennä sisään.

— Tiedä niistä ansioista ja tienesteistäkään, — sanoo hän


portaiden yläpäähän päästyään, mikä tulee, se meneekin.

*****
Körkön Heikki ei kuule isänsä sanoja, tai jos kuuleekin, niin ei ole
kuulevinaan. Kyllä kai sitä juttua riittäisi, loppumattomiin, ja aina
uusia metkuja, koukkuja ja käänteitä. Kun on mennäkseen, niin
menee, sittenpähän näkee mitä tulee.

Heikki on jo tuudittautunut siihen ajatukseen, että ennenkuin


huominen ilta hämärtää, niin lähtö tulee. Ei siinä enää auta mikään.
Nyt hän viimeistelee itseään, tervaa vasiten teetettyjä saappaitaan…

Veret ovat käynnissä, mielikuvitus askartelee. Hän on rehellinen


jätkä, hänellä on sininen pusero, sinnihousut ja tuppihoito vyöllä,
eikä kukaan tiedä, että hän on Körkön Heikin ainoa poika. Jokivarsi,
tuntematon, selittämätön, monikymmenpeninkulmainen, on
tulvillaan aavistamattomia mahdollisuuksia. Lauantai-iltana lyö
kasööri viikon tilin kouraan: "Siin' on, mene pitämään sabattiasi…" —
Joella, siellä on ilma täynnä aavistuksia ja mahdollisuuksia, tänään ei
voi sanoa mitä huomenna tulee, aamu ei tiedä illasta. Mies on vapaa
vaikka lentämään niinkuin taivaan lintu.

Ettäkö työ olisi raskasta ja ettäkö usein saisi kokea märkyyttä ja


vilua! Kestäväthän sen muutkin, onhan öitä ja lomahetkiä välissä ja
onhan, lopuksi, kesän kuluessa sentään enemmän auringonpaistetta
kuin sadetta. Iltaisin, illan viiletessä, on kyläpaikoissa tanssia ja
hanurinsoittoa, joku tyttö voi ohimennen vilkaista häneen: "Siinä on
Körkön Heikki… On kuultu puheita…" Niinpä on, Körkön Heikki se on,
ja tanssin lopusta auringon nousuun, — niitä seikkoja ei kukaan vielä
ole selvitellyt.

Kuta vapaammin Körkön Heikki antaa mielikuvituksensa lentää,


sitä enemmän hän innostuu ja kiihtyy, ja haluun joelle sekaantuu
lopulta jotakin vavahduttavaa, melkein tuskallista ja pelonsekaista.
Hän ei rupea vertailemaan Körkön ummehtunutta, mutta turvallista
ja kodinomaista ilmakehää niihin tuntemattomuuksiin, mitkä ovat
odottamassa: edellinen tunnetaan jo liiankin hyvin, jälkimmäinen
viettelee tuntemattomuudellaan…

*****

Seuraavana aamuna isä ottaa vielä kerran asian puheeksi. Pirtin


ulkonaisessa elämässä ei mikään osoita, että jotakin tavallisuudesta
poikkeavaa on tekeillä, ja uudessa asussaan tuntee Heikki itsensä
hiukan orvoksi ja yksinäiseksi, tunne, joka melkein sivuaa
häpeilemisen tunnetta. Mutta se on vain sivutunne, joka
ohimenevänä välähdyksenä nostaa päätään, valtatunne vetää
kirkolle, sinne, missä on liikettä ja elämää. Kunhan tästä nyt
onnellisesti pääsisi taipaleelle.

— Se on sitten ensimmäinen kerta, kun Körköstä ruvetaan


jätkäksi, — sanoo isä.

Ollaan syöty aamiainen ja juodaan kahvia. Heikki ei vastaa mitään.

— Ja kun ei mitään puutu, — jatkaa isä. — Kotonakin töitä yllin


kyllin…

— No eihän tuonne iäksi, jos kesäksi, — vastaa Heikki.

— Mikä pakko sinne on kesäksikään!

Ei osaa Heikki selittää. Paras, kun nousee ja lähtee


mahdollisimman pian. Ja hän rupeaakin hiljalleen ja muina miehinä
säälimään kokoon tavaroitaan. Mitäpäs tässä kaiken lopuksi: kyllä kai
sen jokainen arvaa, ettei Körkön poika pakosta…

— No, hyvästi nyt sitten, — sanoo hän.


— Tuota… etkö sinä hevosta? — kysäisee isä melkein kuin
hätäytyneesti.

Nyt Heikki-poika naurahtaa keveästi.

— Mitäpä tuolla hevosellakaan, jätkämies, — vastaa hän hilpeästi.


— Saa sitä jalkaisin sieppoa pitempiäkin taipaleita…

— No niin sitten, — murahtaa isä, keventyneesti hänkin. —


Omasta halustasi menet, kun menet. Mutta saatpa välillä koettaa
muistella, että aikaa seuraa iankaikkisuus ja että yksi silmä seuraa
kaikkia meidän edesottamisiamme.

Heikki painelee talvitietä kirkolle päin. Alussa on mieli apea, mutta


askel askeleelta, kuta kauemmaksi kodista tullaan, se kevenee, ja
kun illalla tulet alkavat näkyä kirkonkylästä, on hän kuulevinaan
ensimmäisten tukkilaislaulujen soivan korvissaan.

Mutta kotiinjäänyt isä tuumiskelee itsekseen, että on sitä hulluutta


monenlaista. Rantamaissa kuuluvat poikaset joskus saavan
hullutuksen puoliväkisin mennä merille, täällä ne yhtä väkisin
pyrkivät tukkijoelle.

Ja useimmiten ajaa routa porsaan kotiin.

Kohtaus joella.

Herran pojat sentään, kuinka kansakoulun läpikäyminenkin voi


tehdä paljon asiaa! Niinkuin tämänkin Ojajärven Heikin kohdalla.
Viime vuonna tavallinen jätkä, nyt kymppi, oikein sellainen
konttorikymppi, joka nostaa suoraan konttorista palkkansa tai jolle
se lähetetään suljetussa kirjeessä puulaakin muun postin mukana.

Kirkkoniemen rannasta on laiva lähdössä Lusman kylään, ja Heikki


on menossa työmaalleen, jollekin suvannolle Javaruksen tienoilla. On
saatu pieniä ohjeita konttorista ja nyt sitä ollaan menossa. Ei ole
toista työnjohtajaa paikalla, mutt’eihän siellä olekaan kuin
parikymmentä miestä.

Laiva on siis lähdössä ja irtaantuu vähitellen laiturista. Lauantai-


illan aurinko paistelee, ja laivalla on herroja. Siinä on kirkonkylän
apteekkari ja siinä on metsäherra rouvineen, siinä on
kansakoulunopettaja prässätyissä housuissaan, ja siinä on pitäjän
apupappi. Ja sitten siinä on liuta kauniita, nuoria naisia. Apteekkari
on rakennuttanut majan Vartiosaareen, kaksi peninkulmaa kirkolta,
ja sinne kai nyt ollaan menossa. Nauretaan, ilakoidaan ja joku
hyräilee laulunpätkää. Sitäpaitsi laivassa on joukko tavallista kansaa,
kirkolla käymässä olleita talollisia emäntineen, jotka Lusmankylästä
jatkavat matkaansa veneillä.

Nyt laiva jo kyntää jokea vastavirtaan, ja ihmiset alkavat


ryhmittyä. Herrat pysyvät kiinteästi yhdessä, ja talolliset pitävät
pientä juttelua piippujen kärytessä. Emännät availevat nyyttejään ja
alkavat syödä.

Heikillä on yllään uuden uutukainen sadetakki, jaloissaan äsken


ostetut pieksut ja valkoluinen iso H-kirjain, markkinakojusta ostettu,
rintapielessään. Se on korea, monikoukeroinen H ja täydentää
oivallisesti kiiltävää selluloidikaulusta ja kirjavaa kravattia.

Ja onpa Ojajärven Heikki muutenkin varustettu. Hänellä on


seitsemäntuhatta markkaa palkanmaksurahoja vasemmassa
povitaskussaan ja vähän aloitettu pullo oikeassa. Tuli vähän
ryypätyksi Siljanterin, sen ukkoherran, kanssa ennen lähtöä.

Jumaliste, kyllä se elämä sentään on elämää. Viime vuonna


tavallinen jätkä, tuollainen joka oksalla kasvava huithapeli, tänä
vuonna konttorikymppi. Ja kun hän panee työt sujumaan, niin ensi
vuonna saattaa olla ukkoherra. Hän on semmoinen poika, että hänen
sakissaan souvit sujuvat kuin rasvattu. Ukkoherra, se on melkein
kuin hosmestari, vähän parempikin, ei kenelläkään ole niin paljon
komennettavia kuin ukkoherralla. Siljanterillakin alun viidettäsataa.

Ojajärven Heikin kasvot punoittavat ja silmät kiiluvat;


tavallisissakin oloissa hän tarkoin tuntee oman arvonsa, nyt hän
tuntee sen vieläkin paremmin. Ei ole tarvinnut hänen
muistikirjoistaan sanoa, että ne ovat suttuisia, töhryisiä ja ettei
hänen kraapustuksistaan vietäväkään ota selvää. Siljanterikin juuri
äsken sanoi konttorissa puhuttavan, että Ojajärven muistikirjoja
katselee oikein hauskuudekseen. Hm! Lieneekö Siljanteri itsekään
käynyt muuta kuin rippikoulun. Ylennyt vaan, kun on ollut kauan
aikaa puulaakissa, oppinut hyvin tuntemaan asiat ja osaa tehdä
itsensä krööniksi herrojen edessä. No, onhan se mies, Siljanterikin,
mutta kun hänkin, Ojajärven Heikki, oppii tarkemmin ja
perinpohjaisemmin tuntemaan asioita, niin silloin aletaan uusi virsi.

Herrojen ryhmä alkaa laulaa, ja opettaja huitoo pitkillä, laihoilla


käsivarsillansa.

"Mikähän se tuokin luulee olevansa", ajattelee Ojajärven Heikki,


pomo, katsellen opettajan huitelemista, "tavallinen hoikkasääri,
nälkäpalkkainen…"
Ja kun laulu loppuu, alkaa hän taputtaa käsiänsä. Ilman vain,
piruuksissaan! Mutta häneen yhtyy yksi ja toinen, ja opettaja
kääntyy ja kumartelee.

"Kyllä täällä osataan ja tiedetään", miettii Heikki ja tuntee


tulleensa jollakin tavalla lähemmäksi herroja.

Vaikka olihan sitä sen puolesta oltu lähellä muutenkin. Kerrankin


oli metsäherra saattomiehensä kanssa tullut jokirantaan, juuri
työmaan kohdalle. Yli piti päästä, ei venettä missään eikä auttanut
metsäherran muu kuin lakki kourassa tulla Heikin luo, jonka näki
valvovan työtä. "Voisikohan päästä teidän veneellänne toiselle
puolelle?" Heikki oli vilkaissut metsäherraan ja sitten huutanut
sumalla puuhaaville miehille:

"Hei! Soutakaa tämä herra yli!" — Mutta eipä ollut metsäherra nyt
näkevinäänkään ja kuitenkin taitaisi kuipotella siellä vieläkin, ellei
hän olisi antanut — hm — määräystä miehilleen, että soutakaa tämä
herra yli.

Ja kun kaikki kävi ympäri, niin ei se metsäherrakaan mikään


taivaankaato-pomo ollut. Kruununtorppareita ja leimausmiehiään
minkä komensi, mutta kun joutui yhtiön kanssa tekemisiin, niin oli
oksat poikki niinkuin suutarin joulukuusesta. Jos puulaaki jätti puut
ostamatta, niin kruunu otti rahansa mistä sai. Ei sitä veroistakaan
kovin paljoa kerry. Mutta siellä se vain istui metsäherrakin, niinkuin
mikäkin äksän merkki, posket pököllään.

Yksitellen ja vähitellen Heikki mielessään luokittelee ja lajittelee


koko herrasakin naisineen ja tulee siihen johtopäätökseen, etteivät
he ole ihmistä kummempia. Apupappi asuu nöyrästi pappilan
vinttikamarissa, ja ellei ihmiskunta sairastaisi, niin tuskinpa
apteekkarin auttaisi muu kuin vetää hampaat naulaan. Ja heidän
naisensa, — mikä talontyttö tahansa voi vetää päällensä yhtä koreat
vaatteet ja yhtä ruusuiset rimssut, jos vain tahtoo. Niin että turhia
pöyhistelevät ja tekeytyvät muita paremmiksi.

Laiva mennä juksuttelee hiljaa eteenpäin, sivuutetaan Niemenkylä,


sivuutetaan viimeiset talot, ja jokiranta alkaa käydä asumattomaksi.
Silloin Ojajärven Heikki muistaa, että laivan koneenkäyttäjä on
tuttava, ja painuu konehuoneeseen.

"Saako tässä sinun paatissasi enää kahvia ollenkaan?" kysyy hän.

"Saa kyllä", vastaa Lomsteri, koneenkäyttäjä, "menet vain


salonkiin".

"Niin, on mulla korkeimman taksan piletti."

"Niinpä tietenkin", myöntää Lomsteri asianymmärtävästi.

"Joo, vaikka muut ne parhaita paikkoja pitävät kuin omiaan.


Kelpaisiko sulle konjakki?"

"Älä kysykään!"

Juttu alkaa luistaa. Lomsteri on sitä mieltä, että jos tuosta


herrajoukosta ottaisi kenen tahansa ja panisi vaikkapa vain
esimerkiksi käyttämään tätä konetta, niin siihen jäisi.

"Siihen jäisi", vahvistaa Heikki. "Paitsi apteekkari ehkä, sillähän on


moottorivene."

"Särkenyt kai se on senkin, kalliin mööpelin, osaamattomuutensa


vuoksi.
Sillä kai se muuten majallensa reisailisi eikä tällä."

Niin loppuu äkkipikaa Ojajärven Heikin konjakki, ja pullo pistetään


tarvekalulaatikkoon. Olkoon nyt siellä muistona. Ja Heikki päättää
mennä kahville.

"Paina nappia vain, niin kyllä tulee!" neuvoo Lomsteri. "Ja morjes
nyt vain ja kiitoksia. Kylläpähän joskus kostan."

Herrassakkikin on kokoontunut salonkiin ja juo parhaillaan kahvia.


Heikin keinuva saapuminen herättää hetken hiljaisuuden, mutta
sitten jatkuu puhelu niinkuin ei mitään olisi tapahtunut. Heikkiä tämä
loukkaa, hän lyö lakkinsa samettipenkkiin ja tervehtii kovalla äänellä.

"Päivää!"

Apteekkari vilkaisee häntä ohimennen, apupappi tuijottaa hiukan


kauemmin, metsäherra ja opettaja kohauttavat lakkejaan ilman
muuta, aivan kuin tyhjälle, joka ei heitä suuresti liikuta. Ja taas
jatkuu keskustelu. Naiset kuiskailevat keskenään, ja yksi nauraa
tirskahtaa.

"Siellä on kaunis ilma", sanoo Heikki, "oikein hyvä matkailma".

Vain koneen jynkytys häiritsee hiljaisuutta. Heikki on


huomaavinaan, kuinka herrat vilkuilevat toisiaan salavihkaa.

"Työ-ilma on erinomainen", jatkaa hän. "Eivät pyydä miehet


rokulia."

"Eikä rokuli rahaa teekään", vastaa metsäherra asiallisesti, vaikka


nähtävästi vasten tahtoansa.
"Ei. Hosmestari sen hyvin tietää, joka itsekin joskus on jätkien
kanssa tekemisissä. — Tuota, — enkös minä kerran Ilusjoen
alajuoksulla soudattanut hosmestaria yli?"

"Taisi olla. Minä jo vähän muistelin naamataulusta, että tuttu on


mies."

"Joo, minähän se olin. Taisi loppumatka mennä hyvin?"

"Mikäs siinä, kun hyvin alkuun pääsi."

"Olisi hosmestari saanut ilmaisen kyydin ensimmäiseen kylään asti,


kun olisi hoksannut tahtoa. Ja pian se olisi käynyt, kyllä minun
jätkäni osaavat soutaa."

"Saako niitä niin vain yksityisasioissa soudattaa? Vaikka


kiitollinenhan minä olisin ollut, jos olisin saanut kyydin vaikkapa
maksustakin."

"Kyllä saa. Se on niin, että jätkän on pakko tehdä mitä käsketään."

"Niin kai se on."

"Joo. Nykyajan työmies ei tarvitse muuta kuin kuria. Ja jämttiyttä.


Siinä se on."

Herrat kuuntelevat, ja naiset kuuntelevat myöskin. Joskus


keskenään vähän supisevat.

Mutta opettaja hymyilee ja on ivallisen näköinen. Mitä vimottaa,


köyhäkaula? Pitääkö hänen mennä ja lyödä lompakkonsa sen nokan
edessä pöytään ja sanoa, että "siin' on, haista köyhä rahaa!" Taitaisi
vähemmän silloin virnistellä. Mutta olkoon rauhassaan, senkin
raukka.

Heikki saa kahvinsa, ja herrat menevät salongista ulos. Tuskin ovat


he sulkeneet oven jäljessään, kun jo purskahtavat äänekkääseen
nauruun. Mutta Ojajärven Heikki ei sitä huomaa. Hän juo
tyytyväisenä kahvinsa ja ajattelee, että pitipä kohdella kuin vertaista.
Metsäherrankin, vaikka niin istui posket pököllään. Ei tässä auta
kruusailla, jos haluaa pitää silmänsä auki.

Mutta, saakeli, eikö nyt olla Javaruksen selällä. Eikä puulaakin


tuttua, punakeulaista venettä vastassa, vaikka selvästi sovittiin tästä
päivästä.

Kasvot hohtaen ryntää Heikki horjuskellen kannelle. Ahaa, ne ovat


tuolla ylempänä. Katsotaanpa, kuka täällä on herra, oikein lopuksi
se, jolla on vähän käskemistä. Heikin koko olento vapisee innosta,
jännityksestä ja odotuksesta. Viimein on vene melkein kohdalla.

Silloin hän vilkaisee ympärilleen, menee perämiehen luo ja sanoo


arvokkaasti, mutta niin, että kaikki lähellä olevat kuulevat:

"Pysähdyttäkää kone. Minä jään tähän."

Ja kone pysähtyy. Katsokaa vain, kuinka koreasti pysähtyykin.

"Näkemiin nyt sitten, kapteeni!" sanoo Heikki perämiehelle ja


menee laidalle tehden uljaan eleen kädellään veneeseen päin.

Vene, kahden hengen soutamana, alkaa hiljaa lähestyä.

"Nopeammin!" karjaisee Heikki.


Mutta jätkä ei anna komentaa itseään eikä airojen tahti muutu. On
ennenkin ehditty kohtusoutamisella ja täytyy ehtiä nytkin.

"Kiiruhtakaa!" karjaisee Heikki toisen kerran.

Ei nytkään tahti muutu. Toinen soutajista alkaa päinvastoin korjata


hankavitsaa ja peränpitäjä nostaa melan vedestä. Heikin ympärille
kokoontuneiden ihmisten huulilla alkaa karehtia hymy, ja joku
Tapaninkylän isännistä naurahtaa:

"Eivätpä ne oikein ole tietääkseenkään."

Nyt Heikin sisu alkaa kiehua, naama käy kravunpunaiseksi, hän vie
kätensä torveksi suunsa eteen ja huutaa silmät pullollaan:

"Jumal'aut, jos ette, roikaleet, pääse nopeammin liikkeelle, niin


saatte tilin kouraanne joka sorkka."

Ei tahti nytkään muutu, ja ympärillä-olijat ovat yhtä iloisemman


näköisiä.

"Pirun orjat", sanoo Heikki kuin anteeksi pyydellen miestensä


puolesta, "niiden täytyy saada lisää opetusta".

Kukaan ei vastaa mitään. Vihdoin vene laskee laivan kylkeen, ja


kumea ääni sanoo veneestä:

"Kompuroihan alas sieltä."

Tukahdutettu naurunräjähdys, ja Heikkiä aletaan soutaa pois.


Veneestä hän vielä huiskuttaa nenäliinaansa laivaan päin, ja ehkäpä
joku vastaakin.

"Se oli morski mies!" sanoo apteekkari.


"Että se uskalsikin", ihmettelee joku naisista.

"Olkaa varmat siitä", lopettaa metsäherra, joka tuntee jätkänsä,


rauhallisesti, "olkaa varmat siitä, että hän vielä tänä iltana saa sen
kurituksen, jonka tarvitseekin".

Mikko Puuperä.

Mikko Puuperä, — mies, josta kaikki puhuvat, mutta jota kukaan ei


ole nähnyt, mies, joka samalla kertaa on suuri hyväntekijä ja suuri
pahantekijä, mies, joka on nostanut monta, mutta kaatanut vielä
useampia. Muualla hänen nimensä saattaa olla mikä tahansa,
suurten jokien varsilla ja napapiirin tuolla puolen hänet tunnetaan
Mikko Puuperän nimellä.

Sinä ihmettelet, kuinka Hokkas-Nikoteemuksella, puulaakin


pomolla, on ollut varaa hankkia itselleen tuollainen komea talo.
Eihän hän ollut puulaakin palveluksessa kuin vajaat viisitoista vuotta,
eikä suinkaan puulaakikaan mitään ylettömiä palkintoja ja palkkoja
maksa. Ei sillä ollut perinnöistä tietoa, köyhän ämmän poika se oli ja
akka samaa maata.

Näin sinä ihmettelet, ja kuuntelija kuuntelee sinua mielenkiinnolla


ja hartaudella. Sitten hän ruiskauttaa pitkän syljen, vilkauttaa
silmiään ja sanoo:

"Lykästäähän se muutamia, joo."

Ja vähän ajan kuluttua hän lisää:


"Eiköpä tuota liene Mikko Puuperä suurimmaksi osaksi koiville
auttanut."

Jonka jälkeen hän kävelee tiehensä.

Tänä keväänä näet miehen kävelevän turkeissa ja simseteissä.


Henki tulee vähän viinalle, sikari savuaa suussa, ja muistikirja pistää
esiin turkin taskusta. On siinä kävelijää kerrakseen ja sopiikin
kävellä, ei sitä jokainen mies tuollaisia varusteita ylleen vedä. Ja
miehen koko olemuksesta kuvastuu suuri itsetyytyväisyys ja rauha:
ollaan puulaakin pomoja, toistaiseksi kyllä siitä pienemmästä päästä,
ja mukava on olla.

Mutta ensi keväänä, kun hän tulee vastaasi, on hänen


olemuksensa hiukan arveluttava. Henki tulee kyllä nytkin viinalle,
mutta suupielessä ei enää käryä sikari, vaan siinä roikkuu paperossi,
ja jaloissa saattavat olla sikarilaatikot, sillä patiinit on menetetty
hoitopelissä tai "syykvetissä". Eikäpä ole tietoja turkeista, ulstereista
ja muista prameuksista, hyvä, kun takinreuhka päällä ja lossituvassa
saatu lihaliemiannos vatsassa.

"Kuinka", kysyt sinä närkästyneenä, "tällainen muodonvaihdos on


mahdollinen?"

Eikä sinun nytkään tarvitse odottaa selitystä. Selityksenantaja


siirtelee kyllä hiukan jalkojaan, siirtääpä vielä pikanellinkin toisesta
poskesta toiseen, tarkastelee maata ja vaaroja ja tarkastelee vielä
taivaan merkkejäkin, mutta selittää joka tapauksessa.

"Joo", sanoo hän, "se on niin, että kaipa hänenkin oli hyvä olla
puulaakissa ja hyvä kai hänellä oli palkkakin, mutta enemmän teki
mieli. Nähkääs kun sitä pitää pelata herraa. Ja sitten tuli Mikko
Puuperä ja hän sai lähteä kävelemään. Eivät viitsineet nostaa juttua,
summa kun oli niin pieni…"

"Kuinka pieni se sitten oli?"

"Mitä lienee ollut, tuhannen, toista. Mitäpä se sellainen puulaakin


varoissa."

Kas siinä meillä sankari, tässä Mikko Puuperässä. Tänään hän


esiintyy täällä, huomenna tuolla, kaataen ja nostaen, kaataen ja
nostaen. Puulaakit yrittävät valvoa, ettei hän saisi esiintyä, mutta
hän esiintyy kuitenkin. Sillä silloin kun luotiin yhtiö ja yhtiölle
tilinmaksukirjat, silloin myös luotiin Mikko Puuperä. Joskus hän on
osoittanut taipumusta siirtyä valtiolle, mutta toistaiseksi se on jäänyt.
Mikko Puuperällä on suurempi ja kiitollisempi työmaa yhtiöllä.

Näin tapahtuu muutamana kauniina heinä; kuun päivänä latvajoen


kaukaisimmalla työmaalla, tilinmaksupäivänä muuten. Kirjat ovat
valmiit, rahat valmiina, ei muuta kuin ala maksella. Mutta juuri
ratkaisevalla hetkellä ilmestyy joku konttorin läheteistä ja seuraa
palkanmaksua. Jopa jotakin: neljä miestä näkyy antavan palttua
palkalleen. Se on kovin ihmeellistä "Missä nämä neljä ovat?" kysyy
lähetti.

Selitetään, että ne ovat muualla nyt, tällä kertaa. Mutta kenties


huomiseksi tulevat.

"No odotetaan sitten."

Vaan miehiä ei kuulu huomenna, eikä vielä ylihuomennakaan.


Lähetti alkaa epäillä ja menee työmaille kyselemään miehiltä.

"Missä ne sen ja sen nimiset miehet ovat?"


Korvantauksen kynsimistä, sitten pientä kiroilua, — selvittäkööt
herrat, p—le, itse asiansa, — viimeksi leveä, ymmärtäväinen, hiukan
pahansuopa nauru:

"Ei täällä meidän aikanamme ole koskaan sellaisia ollutkaan."

Selvä juttu, — kysymyksessä on vanha tuttavamme Mikko


Puuperä, olematon mies. Ja asianomainen palkkalistantekijä saa
lähteä kävelemään.

Niin rikeeraa Mikko Puuperä suurten jokien varsilla. Toiset


käyttävät hänen apuaan viisaasti ja harkiten, ja heistä tulee
vakavaraisia kansalaisia ja kunnioitettuja ihmisiä, toiset ovat tyhmiä
ja varomattomia, ja heistä tulee yhteiskunnan mätämunia, varkaita
ja väärintekijöitä. Sama laki täällä kuin muuallakin. Ja niinkuin
muutamat karttavat pirun mainitsemista sen oikealla, laillisella
nimellä, niin puhutaan Mikko Puuperästäkin kuiskailemalla,
ympärilleen vilkuillen ja joskus pieni välke silmäkulmassa.

Vääryyttä, petostako? Mitä vielä! Juhlissa lauletaan hartaudella ja


antaumuksella:

"Ja kuinka vilppi, viekkaus,


siell' ompi outoa."

Ja metsien hongat huokailevat ja taitavat huoata täydestä


sydämestään.

Tiltu.
Hän ei ole mikään "Tukkijoen" Maija, hänen virkansa on aivan
toinen. Hän on ollut kaksi kertaa lasareetissa, mutta hänellä
kerrotaan olevan rahoja säästössä sen Huuhkajan ukon takana, —
tiedättehän, — joka on jollakin tavalla Tiltuun kiintynyt. Ukko on
lestadiolainen ja itkee usein hänen kovaa kohtaansa, mutta tallettaa
kuitenkin hänen synnillä ansaitut rahansa ja antaa hänelle tarpeen
tullen ruokaa ja yösijan. Pappi on siitä nuhdellut Huuhkajan ukkoa,
mutta ukko on vastannut, ettei hänellä ole sydäntä ajaa Tiltua
lankeemuksen tielle, sillä voihan tapahtua, että hän ottaa sanasta,
nuhteesta ja varoituksesta ojentuakseen. "Minkä te teette yhdelle
näistä pienimmistä…"

Ja Tiltu kulkee savotalta savotalle, työmaalta työmaalle, kesät


talvet. Kyläpaikoissa jokainen itseänsä vähänkään kunnioittava
ihminen häntä karttaa, mutta metsissä ja jokivarrella hän käy
täydestä. Siellä on eri laki ja eri asetukset.

Tiltu ei vielä ole vanha, papinkirjan mukaan on hän juur'ikään


sivuuttanut kolmekymmentä vuotta, mutta kun häntä tarkastelee
hänen omissa oloissaan, on hänessä jotakin raskasta, väsähtänyttä
ja kulunutta. Vähemmästäkin voi ihminen kulua.

Eikä Tiltu myöskään ole ruma. Eihän hän tietysti ole kauniskaan,
mutta hänen olentonsa aavistuttaa, että hän voisi olla hyvinkin
hyvän näköinen. Hänellä on sopusuhtainen vartalo, mutta hän ei
koskaan löydä sille oikein sopivia vaatteita. Hänellä on säännölliset
kasvonpiirteet, mutta silmien ympärillä on siniset renkaat ja huulet
ovat aina kosteat, niinkuin imisi hän karamellia. Ja käsistä näkee,
ettei hän koskaan ole tehnyt raskasta työtä, minkä joskus soutanut
itsensä työmaalta toiselle, kun muut ilkeydessään eivät ole ottaneet
häntä veneeseensä.
Entisaikaan, viisi, kymmenen vuotta sitten, Tiltu vielä oli ylpeä.
Eivät hänelle kelvanneet muut kuin herrat ja nuoret ja pulskat. Taisi
joskus ajatella rakkautta ja antautuakin rakkaudesta. Mutta sitten se
alkoi mennä alaspäin, piru tiesi, kuinka, — kenties se oli
ensimmäisen lasareetireisun jälkeen. Hän otti itselleen seuralaiseksi
ja "jarrumieheksi" Sieppi-Amalian, ikivanhan tukkilaislutkan, mutta
riitaantui hänen kanssaan ja liittyi Jokipekan Lauriin,
viinakauppiaaseen. Kunnes huomasi, että edullisinta oli sittenkin
kulkea yksin, pieni puukko rinnalla.

Nyttemmin ei Tiltu enää miettinyt, kuinka hän oli tälle tielle


joutunut, eikäpä se olisi mitään hyödyttänytkään, sillä eihän hän
ainoa sellainen ihminen ollut maailmassa. Ainoastaan joskus, kun
Tiltu oli loppuun suorittanut päivätyönsä ja miehet makailivat
nuotiolla, kun syystähdet vilkuttivat ja pimenevän metsän puut
huokailivat, kun tukit joessa kumahtivat toisiansa vastaan ja hanuri
alkoi soida, silloin tunsi Tiltu epämääräistä halua itkeä.

"Antakaas pojat viinaa", sanoi hän silloin.

Mutta pojat ovat sillä kertaa saaneet hänestä kyllikseen ja


vastaavat:

"Mistä sulle tässä viinat… Olethan jo saanut sen, minkä


tarvitsetkin."

"Kyllä te kans olette yksiä saatanoita", sanoo Tiltu ja voi lähteä


yötä myöten samoamaan kiitollisemmille maille.

Niin, Tiltu ei enää ajattele menneisyyttänsä, ja oikeastaan hänen


historiansa onkin niitä kaikkein tavallisimpia senlaatuisista
historioista. Se ensimmäinen oli kotikylän kauppiaan poika, jota hän
oli rakastanut. Ei siitä sen enempää. Toinen oli puulaakin kiertelevä
kasööri, mutta Tiltu oli jo oppinut tuntemaan miehiä eräältä puolen,
ja kasöörillä oli ollut pitkällinen työ ja vaivannäkö, ennenkuin pääsi
pyyteittensä perille. Kolmas, — Tiltu palveli silloin Joutsjärven
kievarissa, — oli ollut kauppamatkustaja, tukeva, lihava herra, joka
oli houkutellut ja hukutellut ja tarjonnut satasen. Siitä kai se vasta
oikeastaan oli alkanut: ilman edestä, rahasta, — kuinka kulloinkin
sattui. Ja viimein Tiltu oppi sanomaan:

"Raha ensin!"

Valmis. Suuria peräytymisen teitä ei enää ollut, eikä niitä


erikoisesti tarvittukaan.

Muuan pruuviherra oli kerran vienyt hänet mukanaan alamaihin, ja


hän oli huomannut, että täällä hänellä olisi suuret mahdollisuudet
ansaita. Häntä oli syötetty ja juotettu, hän oli ottanut osaa yöllisiin
kesteihin, hänellä oli ollut kauniita vaatteita. Mutta Tiltu oli pelännyt,
hänellä oli ollut auttamaton vetovoima sinne, mistä oli tullutkin, siellä
ei ollut sähkövaloja, pika-ajureita, automobiileja ja poliiseja. Siellä ei
tapahtunut niin, että joku surkutteli hänen tilaansa, puhui hänelle
myötätuntoisia sanoja ja sai hänet sitten halvemmalla. Siellä: otti ja
maksoi ja sillä hyvä. Sitten sai olla sitä mitä oli. Vaan ennenkuin Tiltu
sai palata sinne ylös, oli hänen oltava pari kuukautta sairaalassa ja
hän älysi, että hän oli jo kaupungissa "kirjoissa" ja ettei hänen enää
ollut hyvä sinne palata. Eikä hän sitä surrut, veri veti sittenkin
suurten jokien varsille ja tunturien juurelle.

Kolmen vuoden kuluttua Tiltu lopullisesti oppi olemaan


ajattelematta ja surematta, ja kun mietteitä joskus tuli, olivat ne
laadultaan tilapäisiä. Joskus hän saattoi jotakin kohtaan tuntea
rakkauden häivettä, mutta hän oli jo täysin tietoinen siitä, ettei häntä
kukaan omakseen ota. Ja niin hän kulki paikasta toiseen, työpaikkoja
myöten, ensin joku mukanaan, sitten yksin, rohkeammin.

Tuskinpa hän enää ajattelee vaatteitaankaan, saatikka sitten


puhtautta. Hän tietää, että hän kelpaa sellaisena kuin on ja että
hänellä on jotakin, joka merkitsee enemmän kuin koreat vaatteet.
Sitäpaitsi hän ei vielä ole niin vanha, että hän riippuisi ulkonaisen
pynttäyksen varassa.

Saattaa kuitenkin tapahtua, että joku Ruotsin puolella töissä ollut


rupeaa ronklaamaan, haukkumaan ja tekemään vaatimuksia. Silloin
Tiltu remsseästi nakkaa niskojaan ja menee tiehensä:

"Ei tässä reistailemaan ruveta. Kun ei kelpaa, niin ole ilman sitten."

Muuten on Tiltu reilu tyttö. Ei hän varastele miesten ollessa


pöhnässä ja heidän nukkuessaan, niinkuin jotkut kuuluvat tekevän,
ei varastele eikä paljon juksauttelekaan. Hän ihmettelee, kuinka
miehet voivat Raahen-Iitan ja Sieppi-Amalian pikku näpistyksille ja
muille konsteille vielä nauraakin. Kokonaisen tilinkin oli Raahen-Iita
kerran vienyt, ja mies oli vain kohmelopäissään murissut, että "niin
sitä käy, kun rupeaa sellaisten kanssa tekemisiin". Ja kerran oli
Sieppi-Amalia vienyt nukkuvalta saappaat, mutta mies oli
kimmastunut ja Sieppi-Amalia olisi päässyt linnaan, ellei olisi
oikeudessa saanut toteen, etteivät ne saappaat olleet
kahdenkymmenen markan arvoiset.

Ei Tiltu koskaan varasta eikä pelaa muutakaan pismarkkia. Mutta


jos hän tapaa rahattomana, kengättömänä ja kohmeloissaan
värjöttelevän vanhan tuttavan, niin hän kernaasti lainaa siksi, kunnes
asianomainen saa töitä. Ja harvoin ovat rahat kokonaan menneet.
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

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

Let us accompany you on the journey of exploring knowledge and


personal growth!

ebookfinal.com

You might also like