Java Studio Creator Field Guide Anderson instant download
Java Studio Creator Field Guide Anderson instant download
download
https://ebookgate.com/product/java-studio-creator-field-guide-
anderson/
https://ebookgate.com/product/android-studio-bumble-bee-essentials-
java-edition-neil-smyth/
ebookgate.com
https://ebookgate.com/product/java-illuminated-an-active-learning-
approach-5th-edition-julie-anderson/
ebookgate.com
https://ebookgate.com/product/field-guide-to-illumination-spie-field-
guide-series-angelo-v-arecchi/
ebookgate.com
https://ebookgate.com/product/field-guide-to-diffractive-optics-spie-
field-guide-vol-fg21-yakov-soskind/
ebookgate.com
Java Pocket Guide 1st Edition Liguori
https://ebookgate.com/product/java-pocket-guide-1st-edition-liguori/
ebookgate.com
https://ebookgate.com/product/microsoft-xna-game-studio-creators-
guide-1st-edition-stephen-cawood/
ebookgate.com
https://ebookgate.com/product/nikon-d3200-digital-field-guide-hess/
ebookgate.com
https://ebookgate.com/product/traditions-of-gamelan-music-in-java-
musical-pluralism-and-regional-identity-1st-edition-r-anderson-sutton/
ebookgate.com
https://ebookgate.com/product/a-guide-to-programming-in-java-
java-2-platform-standard-edition-5-beth-brown/
ebookgate.com
JAVA STUDIO
TM
FIELD GUIDE
SECOND EDITION
JAVA TECHNOLOGY
OVERVIEW
1.1 Introduction
Creator depends on multiple technologies, so it’s worthwhile touching on them
in this chapter. If you’re new to Java, many of its parts and acronyms can be
daunting. Java technologies are divided into related packages containing
classes and interfaces. To build an application, you might need parts of one sys-
tem and parts of another. This chapter provides you with a road map of Java
3
4 Chapter 1 Java Technology Overview
technologies and documentation sources to help you design your web applica-
tions with Creator.
We’ll begin with an overview of the Java programming language. This will
help you get comfortable writing Java code to customize your Creator applica-
tions. But before we do that, we show you how to find the documentation for
Java classes and methods. This will help you use them with confidence in your
programs.
Most of the documentation for a Java Application Program Interface (API)
can be accessed through Creator’s Help System, located under Help in the
main menu. Sometimes all you need is the name of the package or the system
to find out what API a class, interface, or method belongs to. Java consists of
the basic language (all packages under java) and Java extensions (all packages
under javax). Once you locate a package, you can explore the interfaces and
classes and learn about the methods they implement.
You can also access the Java documentation online. Here’s a good starting
point for the Java API documentation.
http://java.sun.com/docs/
This page contains links to the Java 2 Platform Standard Edition, which con-
tains the core APIs. It also has a link to all of the other Java APIs and technolo-
gies, found at
http://java.sun.com/reference/docs/index.html
Creator is also built on the technology of JavaServer Faces (JSF). You can
find the current JSF API documentation at
http://java.sun.com/j2ee/javaserverfaces/1.0/docs/api/
index.html
http://java.sun.com/j2ee/1.4/docs/tutorial/doc/index.html
These are all important references for you. We’ve included them at the
beginning of this book so it’s easy to find them later (when you’re deep in the
challenges of web application development). For now, let’s begin with Java as a
programming language. Then we’ll look at some of the other supporting tech-
nologies on which Creator is built.
1.2 The Java Programming Language 5
Object-Oriented Programming
Languages like C and Basic are procedure-oriented languages, which means
data and functions are separated. To write programs, you either pass data as
arguments to functions or make your data global to functions. This arrange-
ment can be problematic when you need to hide data like passwords, customer
identification codes, and network addresses. Procedure-oriented designs work
fine when you write simple programs but are often not suitable to more com-
plex tasks like distributed programming and web applications. Function librar-
ies help, but error handling can be difficult and global variables may introduce
side effects during program maintenance.
Object-oriented programming, on the other hand, combines data and func-
tions into units called objects. Languages like Java hide private data (fields) from
user programs and expose only functions (methods) as a public interface. This
concept of encapsulation allows you to control how callers access your objects. It
allows you to break up applications into groups of objects that behave in a sim-
ilar way, a concept called abstraction. In Java, you implement an object with a
Java class and your object’s public interface becomes its outside view. Java has
inheritance to create new data types as extensions of existing types. Java also
has interfaces, which allow objects to implement required behaviors of certain
classes of objects. All of these concepts help separate an object’s implementa-
tion (inside view) from its interface (outside view).
All objects created from the same class have the same data type. Java is a
strongly typed language, and all objects are implicitly derived from type
Object (except the built-in primitive types of int, boolean, char, double,
long, etc.). You can convert an object from one type to another with a converter.
Casting to a different type is only allowed if the conversion is known by the
compiler. Creator’s Java editor helps you create well-formed statements with
dynamic syntax analysis and code completion choices. You’ll see how this
works in Chapter 2.
Error handling has always been a tough problem to solve, but with web
applications error handling is even more difficult. Processing errors can occur
6 Chapter 1 Java Technology Overview
on the server but need to propagate in a well-behaved way back to the user.
Java implements exception handling to handle errors as objects and recover
gracefully. The Java compiler forces programmers to use the built-in exception
handling mechanism.
And, Java forbids global variables, a restriction that helps program mainte-
nance.
Creating Objects
Operator new creates objects in Java. You don’t have to worry about destroying
them, because Java uses a garbage collection mechanism to automatically
destroy objects which are no longer used by your program.
Operator new creates an object at run time and returns its address in memory to
the caller. In Java, you use references (p and q) to store the addresses of objects so
that you can refer to them later. Every reference has a type (Point), and objects
can be built with arguments to initialize their data. In this example, we create
two Point objects with x and y coordinates, one with a default of (0, 0) and the
other one with (10, 20).
Once you create an object, you can call its methods with a reference.
As you can see, you can do a lot of things with Point objects. It’s possible to
move a Point object to a new location, or make it go up or to the right, all of
which affect one or more of a Point object’s coordinates. We also have getter
methods to return the x and y coordinates separately and setter methods to
change them.
Why is this all this worthwhile? Because a Point object’s data (x and y coor-
dinates) are hidden. The only way you can manipulate a Point object is through
its public methods. This makes it easier to maintain the integrity of Point
objects.
1.2 The Java Programming Language 7
Classes
Java already has a Point class in its API, but for the purposes of this discussion,
let’s roll our own. Here’s our Java Point class, which describes the functionality
we’ve shown you.
// Constructors
public Point(double x, double y) { move(x, y); }
public Point() { move(0, 0); }
// Instance Methods
public void move(double x, double y) {
this.x = x; this.y = y;
}
public void up() { y++; }
public void down() { y--; }
public void right() { x++; }
public void left() { x--; }
// getters
public double getX() { return x; }
public double getY() { return y; }
// setters
public void setX(double x) { this.x = x; }
public void setY(double y) { this.y = y; }
}
The Point class is divided into three sections: Fields, Constructors, and
Instance Methods. Fields hold internal data, constructors initialize the fields,
and instance methods are called by you with references. Note that the fields for
x and y are private. This enforces data encapsulation in object-oriented pro-
gramming, since users may not access these values directly. Everything else,
however, is declared public, making it accessible to all clients.
The Point class has two constructors to build Point objects. The first con-
structor accepts two double arguments, and the second one is a default con-
structor with no arguments. Note that both constructors call the move()
method to initialize the x and y fields. Method move() uses the Java this key-
8 Chapter 1 Java Technology Overview
word to distinguish local variable names in the method from class field names
in the object. The setX() and setY() methods use the same technique.1
Most of the Point methods use void for their return type, which means the
method does not return anything. The ++ and -- operators increment or decre-
ment their values by one, respectively. Each method has a signature, which is
another name for a function’s argument list. Note that a signature may be
empty.
Packages
The Point class definition lives in a file called Point.java. In Java, you must
name a file with the same name as your class name. This makes it convenient
for the Java run-time interpreter to find class definitions when it’s time to
instantiate (create) objects. When all classes live in the same directory, it’s easy
to compile and run Java programs.
In the real world, however, classes have to live in different places, so Java
has packages that allow you to group related classes. A package in Java is both a
directory and a library. This means a one-to-one correspondence exists between
a package hierarchy name and a file’s pathname in a directory structure.
Unique package names are typically formed by reversing Internet domain
names (com.mycompany). Java also provides access to packages from class paths
and JAR (Java Archive) files.
Suppose you want to store the Point class in a package called MyPack-
age.examples. Here’s how you do it.
package MyPackage.examples;
class Point {
. . .
}
Package names with dot (.) delimiters map directly to path names, so
Point.java lives in the examples directory under the MyPackage directory. A
Java import statement makes it easy to use class names without fully qualifying
their package names. Import statements are also applicable to class names from
any Java API.
1. The this reference is not necessary if you use different names for the argu-
ments.
1.2 The Java Programming Language 9
The first import statement provides the Date class name to our Java program
from the java.util package. The second import uses a wildcard (*) to make
all class definitions available from javax.faces.context. The last import
brings our Point class into scope from package MyPackage.examples.
Exceptions
We mentioned earlier that one of the downfalls of procedure-oriented lan-
guages is that subroutine libraries don’t handle errors well. This is because
libraries can only detect problems, not fix them. Even with libraries that sup-
port elaborate error mechanisms, you cannot force someone to check a func-
tion’s return value or peek at a global error flag. For these and other reasons, it
has been difficult to write distributed software that gracefully recovers from
errors.
Object-oriented languages like Java have a built-in exception handling
mechanism that lets you handle error conditions as objects. When an error
occurs inside a try block of critical code, an exception object can be thrown
from a library method back to a catch handler. Inside user code, these catch
handlers may call methods in the exception object to do a range of different
things, like display error messages, retry, or take other actions.
The exception handling mechanism is built around three Java keywords:
throw, catch, and try. Here’s a simple example to show you how it works.
class SomeClass {
. . .
public void doSomething(String input) {
int number;
try {
number = Integer.parseInt(input);
}
catch (NumberFormatException e) {
String msg = e.getMessage();
// do something with msg
}
. . .
}
}
All that’s left is to show you how the exception gets thrown. This is often
called a throw point.
class Integer {
public static int parseInt(String input)
throws NumberFormatException {
. . .
// input string has bad chars
throw new NumberFormatException("illegal chars");
}
. . .
}
Inheritance
The concept of code reuse is a major goal of object-oriented programming.
When designing a new class, you may derive it from an existing one. Inherit-
ance, therefore, implements an “is a” relationship between classes. Inheritance
also makes it easy to hook into existing frameworks so that you can take on
2. Inside class Integer, the static keyword means you don’t have to instan-
tiate an Integer object to call parseInt(). Instead, you call the static
method with a class name rather than a reference.
3. The match doesn’t have to be exact. The exception thrown can match the
catch handler’s object exactly or any exception object derived from it by
inheritance. To catch any possible exception, you can use the superclass
Exception. We discuss inheritance in the next section.
1.2 The Java Programming Language 11
new functionalities. With inheritance, you can retain the existing structure and
behavior of an existing class and specialize certain aspects of it to suit your
needs.
In Java, inheritance is implemented by extending classes. When you extend
one class from another, the public methods of the “parent” class become part of
the public interface of the “child class.” The parent class is called a superclass
and the child class is called a subclass. Here are some examples.
4. Creator uses this same feature by providing methods that are called at dif-
ferent points in the JSF page request life cycle. You can override any of these
methods and thus provide your own code, “hooking” into the page request
life cycle. We show you how to do this in Chapter 6 (see “The Creator-JSF
Life Cycle” on page 151).
12 Chapter 1 Java Technology Overview
is delayed until you run a program. In web applications and other types of dis-
tributed software, dynamic binding plays a key role in how objects call meth-
ods from different machines across a network or from different processes in a
multitasking system.
Interfaces
In Java, a method with a signature and no code body is called an abstract
method. Abstract methods must be overridden in subclasses and help define
interfaces. A Java interface is like a class but has no fields and only abstract pub-
lic methods. Interfaces are important because they specify a contract. Any new
class that implements an interface must provide code for the interface’s meth-
ods.
Here’s an example of an interface.
interface Encryptable {
void encode(String key);
String decode();
}
Why are JavaBeans components important? First and most important, they
are accessible to Creator. When you write a JavaBeans component that con-
forms to the specified design convention, you may use it with Creator and bind
JSF components to bean properties. Second, JavaBeans components can encap-
sulate business logic. This helps separate your design presentation (GUI com-
ponents) from the business data model.
In subsequent chapters, we show you several examples of JavaBeans compo-
nents. We’ll use a LoginBean to handle users that login with names and pass-
words and show you a LoanBean that calculates mortgage payments for loans.
The Point class in Listing 1.1 on page 7 is another example of a JavaBeans com-
ponent.
NetBeans is an Open Source project. You can view more information on its
history, structure, and relationship with Sun Microsystems at its web site
http://www.netbeans.org/
NetBeans and Creator are related because Creator is based on the NetBeans
platform. In building Creator, Sun is offering an IDE aimed specifically at cre-
ating web-based applications. Thus, the IDE integrates page design with gener-
ated JSP source and page bean components. NetBeans provides features such
as source code completion, workspace manipulation of windows, expandable
tree views of files and components, and debugging facilities. Because NetBeans
is extensible, the Creator architects included Java language features such as
inheritance to adapt components from NetBeans into Creator applications with
the necessary IDE functions.
<faces-config>
<managed-bean>
<managed-bean-name>LoanBean</managed-bean-name>
<managed-bean-class>asg.bean_examples.LoanBean
</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
</faces-config>
Every XML file has opening tags (<tag>) and closing tags (</tag>) that
define self-describing information. Here, we specify a managed-bean element
1.6 The J2EE Architecture 15
to tell Creator what it needs to know about the LoanBean component. This
includes its name (LoanBean), class name and package (asg.bean-
_examples.LoanBean), and the scope of the bean (session). When you add your
own JavaBeans components to Creator as managed beans, Creator generates
this configuration information for you.
Creator maintains and updates its XML files for you, but it’s a good idea to
be familiar with XML syntax. This will allow you to customize the Creator
XML files if necessary.
Web
Presentation Tier Database
Tier Tier
Business
Tier
The J2EE server machine is the center of the architecture. This middle tier
contains web components and business objects managed by the application
server. The web components dynamically process user requests and construct
responses to client applications. The business objects implement the logic of a
business domain. Both components are managed by a J2EE application server
that provides these components with important system services, such as secu-
rity, transaction management, naming and directory lookups, and remote con-
nectivity. By placing these services under control of the J2EE application server,
client components focus on either presentation logic or business logic. And,
business objects are easier for developers to write. Furthermore, the architec-
ture encourages the separation of business logic from presentation logic (or
model from view).
The database server machine handles the database back end. This includes
mainframe transactions, databases, Enterprise Resource Planning (ERP) sys-
tems, and legacy code. Another advantage of the three-tier architecture is that
older systems can take on a whole new “look” by using the J2EE platform. This
is the approach many businesses are taking as they integrate legacy systems
into a modern distributed computing environment and expose application ser-
vices and data to the web.
Creator uses JavaServer Faces (JSF), which is built on both the servlet and
JSP technologies. However, by using Creator, you are shielded from much of
the details of not only JSP and servlet programming, but JSF details as well.
tion of model and presentation. The JSF API is also layered directly on top of
the Servlet API.
1.14 Portlets
A portlet is an application that runs on a web site managed by a server called a
portal. A portal server manages multiple portlet applications, displaying them
on the web page together. Each portlet consumes a fragment of the page and
manages its own information and user interaction. Portlet application develop-
ers will typically target portlets to run under portals provided by various por-
tal vendors.
You can use Creator to develop portlets. Creator builds JSF portlets. This
means your design-time experience in building portlet web application using
the visual, drag-and-drop features of Creator will be familiar. Most of the inter-
action with the IDE is exactly the same as it is for non-portlet JSF projects. We
show you how to create portlets in Chapter 12.
• Java Servlets let you define HTTP-specific servlet classes that accept data
from clients and pass them on to business objects for processing.
• A JSP page is a text-based document interspersed with Java code that allows
you to create dynamic web pages.
• JDBC is an API for database access from servlets, JSP pages, or JSF. Creator
uses data providers to introduce a level of abstraction between Creator UI
components and sources of data.
• JavaServer Faces (JSF) helps you develop web applications using a server-
side user interface component framework. Creator generates and manages
all of the configuration files required by JSF.
• A JavaBeans component is a Java class with a default constructor and setter
and getter methods to manipulate its properties.
• NetBeans is a standards-based IDE and platform written in the Java
programming language. Java Studio Creator is based on the NetBeans
platform.
• XML is a self-describing, text-based language that documents data and
makes it easy to transport between systems.
• Ant is a Java build tool that helps you compile and deploy web applications.
• Web services are software APIs that are accessible over a network in a
heterogeneous environment.
• EJBs are server-side components written in Java that implement business
logic and serve as building blocks for enterprise systems.
• Portlets are applications that consume a portion of a web page. They run on
web sites managed by a portal server and execute along with other portlets
on the page.
• Portlets help divide web pages into smaller, more manageable fragments.
CREATOR BASICS
http://developers.sun.com/prodtech/javatools/jscreator/
23
24 Chapter 2 Creator Basics
Creator for your system, the examples you build here should run the same on
your system.
Download Examples
You can download the examples for this book at the Sun Creator web site. The
examples are packed in a zip file. When you unzip the file, you’ll see the
FieldGuide2/Examples directory and subdirectories for the various chapters
and projects. As each chapter references the examples, you will be instructed
on how to access the files.
You’re now ready to start the tour of Creator.
Welcome Window
The Welcome window lets you create new projects or work on existing ones.
Figure 2–2 shows the Welcome window in more detail. It lists the projects
you’ve worked on recently and offers selection buttons for opening existing
projects or creating new projects. If you hover with the mouse over a recently
opened project name, Creator displays the full pathname of the project in a
tooltip.
To demonstrate Creator, let’s open a project that we’ve already built. The
project is included in the book’s download bundle, in directory FieldGuide2/
Examples/Navigation/Projects/Login1.
Creator Tip
We show you how to build this project from scratch in Chapter 5 (see
“Dynamic Navigation” on page 206). For our tour of the IDE, however, we’ll
use the pre-built project from the examples download.
2.2 Creator Views 25
1. Select the Open Existing Project button and browse to the FieldGuide2/
Examples/Navigation/Projects directory.
2. Select Login1 (look for the projects icon) and click Open Project Folder. This
opens the Login1 project in the Creator IDE.
3. Page1 should display in the visual editor, as shown in Figure 2–3. If Page1
does not open in the design editor, find the Projects view (its default posi-
tion is on the right, under the Properties view).
4. In the Projects view, expand node Login1, then Web Pages. Double-click
Page1.jsp. Page1 should now appear in the design editor.
26 Chapter 2 Creator Basics
Design Editor
Figure 2–3 shows a close-up of the design canvas (the visual design editor) of
Page1. You see the design grid and the components we’ve placed on the can-
vas. The design editor lets you visually populate the page with components.
Page1 contains a “virtual form.” Virtual forms are accessible on a page by
selecting the Show Virtual Forms icon on the editing toolbar, as shown in
Figure 2–3. Virtual forms let you assign different components to different
actions on the page. We show you how to use virtual forms in “Configure Vir-
tual Forms” on page 216 (for project Login1 in Chapter 5) and in “Virtual
Forms” on page 419 (for project MusicAdd in Chapter 9).
Select the text field component. The design canvas marks the component
with selection and resizing handles. Now move the text field component
around on the grid. You’ll note that it snaps to the gird marks automatically
when you release the mouse. You can temporarily disable the snap to grid fea-
ture by moving the component and pressing the <Shift> key at the same time.
You can also select more than one component at a time (use <Shift-Click>) and
2.2 Creator Views 27
Message
Password Field
Design Canvas
Figure 2–4 Creator’s View Menu allows you to select specific views of your project
workspace. Make it visible again by moving the cursor over its docked posi-
tion. Toggling the pushpin icon undocks the window. Figure 2–5 shows the
Properties view with both the Projects and Files windows docked.
Properties
As you select individual components, their properties appear in the Properties
window. Select the text field component on the design canvas. This brings up
its Properties window, as shown in Figure 2–5.
Creator lets you configure the components you use by manipulating their
properties. When you change a component’s properties, Creator automatically
updates the underlying JSP source for you. Let’s look at several properties of
the text field component. If you hold the cursor over any property value, Cre-
ator displays its setting in a tooltip.
Components have many properties in common; other properties are unique
to the specific component type. The id property uniquely identifies the compo-
nent on the page. Creator generates the name for you, but you can change it (as
we have in this example) to more easily work with generated code. The label
property enables you to specify a textual label associated with the text field.
The red asterisk next to the label in the design view indicates that input is
2.2 Creator Views 29
Style Attributes
Property Customizer
Box
input is required
Event Handler
Method
toolTip text
JavaScript
Settings
required for this component. Property text holds the text that the user sub-
mits. You can use the style property to change a component’s appearance. The
style property’s position tag reflects the component’s position on the page.
When you move the component in the design view, Creator updates this for
you.
Property styleClass takes previously defined CSS style classes (you can
apply more than one). File stylesheet.css (under Web Pages > resources in the
Projects window) is the default style sheet for your projects. We cover style,
styleClass and using Creator’s preconfigured Themes in Chapter 7.
Text field components can take a converter (specified in property con-
verter) and a validator (property validator). The validate and valueChange
properties (under Events) expect method names and are used to provide cus-
tom validation or to process input when the component’s text value changes.
30 Chapter 2 Creator Basics
Click on the text field component (again) in the design canvas until Creator
displays a gray outline around the component. Now type in some text and fin-
ish editing with <Enter>. The text you type appears opposite property text in
the Properties window. To reset the property, click the customizer box opposite
property text. Creator pops up a Property Customizer dialog, as shown in
Figure 2–6. Select Unset Property. This is a handy way to return a property
value to its unset state.
Palette
Creator provides a rich set of basic components, as well as special-function
components such as Calendar, File Upload, Tab Set, and Tree. The palette is
divided into sections that can be expanded or collapsed. Figure 2–8 shows the
Basic Components palette, which includes all of the components on Page1 of
project Login1. In Figure 2–8 you also see the Layout and Composite Compo-
nents palette.
The palette lets you drag and drop components on the page of your applica-
tion. Once a component is on a page, you can reposition it with the mouse or
configure it with the Properties window.
Figure 2–9 shows the Validators and Converters palette. Creator’s converters
and validators let you specify how to convert and validate input. Because con-
2.2 Creator Views 31
version and validation are built into the JSF application model, developers can
concentrate on providing event handling code for valid input.
You select converters and validators just like the UI components. When you
drag one to the canvas and drop it on top of a component, the validator or con-
verter binds to that component. To test this, select the Length Validator and
drop it on top of the userName text field component. You’ll see a length valida-
tor lengthValidator1 defined for the text field’s validator property in the
Properties window.
Note that components, validators, and converters all have associated icons
in the palette. Creator uses these icons consistently so you can easily spot what
kind of component you’re working with. For example, select the Login button
component on the design canvas and examine the Outline view. You’ll see that
the icon next to the button components (Login and Reset) matches component
Button in the Basic Components palette.
Outline
Figure 2–10 is the Page1 Outline view for project Login1. (Its default placement
is in the lower-left portion of the display.) The Outline window is handy for
showing both visual and nonvisual components for the page that’s currently
2.2 Creator Views 33
displayed in the design canvas. You can select the preconfigured managed
beans, RequestBean1, SessionBean1 and ApplicationBean1. These JavaBeans
components hold your project’s data that belong in either request (page), ses-
sion or application scope, respectively. (We discuss scope issues for web appli-
cation objects in “Scope of Web Applications” on page 224.)
Projects
Figure 2–11 shows the Projects window for project Login1. Its default location
is in the lower-right corner. Whereas the Outline view displays components for
individual pages and managed beans, the Projects window displays your
entire project, organized in a logical hierarchy. (Since Creator lets you open
more than one project at a time, the Projects window displays all currently
opened projects.) Project Login1 contains three JSP pages under the Web Pages
node: Page1.jsp, LoginGood.jsp, and LoginBad.jsp. Double-click any one of
34 Chapter 2 Creator Basics
them to bring it up in the design canvas. When the page opens, Creator dis-
plays a file name tab so you can easily switch among different open files in the
design canvas.
When you create your own projects, each page has its own Java component
“page bean.” These are Java classes that conform to the JavaBeans structure we
mention in Chapter 1 (see “JavaBeans Components” on page 13). To see the
Java files in this project, expand the Source Packages node (click on the ‘+’),
then the login1 folder. When you double-click on any of the Java files, Creator
brings it up in the Java source editor. (We’ll examine the Java source editor
shortly.) Without going to the editor, you can also see Java classes, fields, con-
structors, and methods by expanding the ‘+’ next to each level of the Java file.
The Projects view displays Creator’s “scoped beans.” These are pre-config-
ured JavaBeans components that store data for your project in different scopes.
You can use request scope (Request Bean), application scope (Application
Bean), or session scope (Session Bean). Many of the projects in this text add
properties to these beans. We discuss JSF scoping issues in Chapter 6 (see “Pre-
defined Creator Java Objects” on page 226).
2.2 Creator Views 35
The Projects view also lists the resources node, which lives under the Web
Pages node. The resources node typically holds file stylesheet.css and any
image files. Creator uses the libraries listed in the Libraries node to display,
build, and deploy your application. These class files (compiled Java classes) are
stored in special archive files called JAR (Java Archive) files. You can see the
name, as well as the contents (down to the field and method names) of any JAR
file by expanding the nodes under Libraries. We show you how to add a JAR
file to your project in Chapter 13 (see “Add the asg.jar Jar File” on page 595).
Files
The Projects window shows you a logical view of your project. Sometimes you
may need to access a configuration file that is not included in the Projects view.
In such a case, use the Files view, as shown in Figure 2–12.
The Files view shows all of the files in your project. For example, expand
node web > WEB-INF and double-click file web.xml. Creator brings up file
web.xml in a specialized Creator-configuration XML editor, as shown in
Figure 2–13.
36 Chapter 2 Creator Basics
JSP Editor
As you drop components on the page and configure them with the Properties
window, Creator generates JSP source code for your application. You can view
the JSP representation of a page by clicking the JSP button in the editing tool-
bar, as shown in Figure 2–14.
Normally, you will not need to edit this page directly, but studying it is a
good way to understand how Creator UI components work and how to man-
age their properties. You’ll see a close correspondence between the JSP tags
and the components’ properties as shown in the Properties window. If you do
edit the JSP source directly, you can easily return to the design view. Creator
always keeps the design view synchronized with the JSP source.
Tags in the JSP source use a JSF Expression Language (EL) to refer to meth-
ods and properties in the Java page bean. For example, the login button’s
action property is set to #{Page1.login_action}, which references method
login_action() in class Page1.java.
Creator also generates and maintains code for the “page bean,” the Java
backing code generated for each page. Let’s look at the Java source for
Page1.java now.
2.2 Creator Views 37
JSP
button
Creator
UI
Components
Java
Button
Login
Button
Event
Handler
Reset
Button
Event
Handler
Code
Folding
Handle
component corresponds to a private variable and has a getter and setter. This
allows the JSF EL expression to access properties of the page bean.
All of Creator’s editors are based on NetBeans. The Editor Module is a full-
featured source editor and provides code completion (we show an example
shortly), a set of abbreviations, and fast import with <Alt-Shift-I>. The editor
also has several useful commands: Reformat Code (handy when pasting code
from an external source), Fix Imports (adds needed import statements as well
as removes unused ones), and Show Javadoc (displays documentation for
classes and methods). There are more selections in the context menu (right-
click inside the editor to see the menu). Sections of the Creator-generated code
are folded by default to help keep the editing pane uncluttered. You can unfold
(select ‘+’) or fold (select ‘-’) sections as you work with the source code.
To see the set of abbreviations for the Java editor, select Tools > Options from
the main menu bar. The Options dialog pops up. Under Options, select Editing
> Editor Settings > Java Editor. On the right side of the display, click the small
2.2 Creator Views 39
The window lists the abbreviations in effect for your Java editor. (You can
edit, add, or remove any item.) For example, to place a for loop in your Java
source file, type the sequence fora (for array) followed by <Space>. The editor
generates
and places the cursor in front of .length so that you can add an array name.
(.length refers to the length of the array object. This code snippet lets you eas-
ily loop through the elements of the array.)
The Java source editor also helps you with Java syntax and code completion.
All Java keywords are bold, and variables and literal Strings have unique col-
ors.
40 Chapter 2 Creator Basics
When you add statements to your Java source code, the editor dynamically
marks syntax errors (in red, of course). The editor also pops up windows to
help with code completion and package location for classes you need to refer-
ence (press <Ctrl-Space> to activate the code completion window). If available,
code completion includes Javadoc help. For example, Figure 2–17 shows the
code completion mechanism as you highlight method equals() and press
<Ctrl-Space>.
When you use the down-arrow to select the second method, equalsIgnore-
Case(), the help mechanism displays its Javadoc documentation. (To retrieve
Javadoc documentation on any class in your source file, select it and press
<Ctrl-Shift-Space>.) The Java Source editor is discussed in more detail in Chap-
ter 4 (see “Using the Java Source Editor” on page 136).
When the Java source editor is active, Creator also activates the Navigator
window, as shown in Figure 2–18. The Navigator window lets you go to a
method or field within the Java source editor by clicking its name in the win-
dow. In Figure 2–18, the cursor hovers over method destroy(), displaying
help in a tooltip.
2.2 Creator Views 41
Figure 2–18 Navigator view and help for method destroy() displayed
1. From the top of the Java source window, select the Design button. This
returns you to the design canvas for this page.
2. Now right-click in the design canvas and select Page Navigation from the
context menu. Creator brings up the Page Navigation editor for project
Login1, as shown in Figure 2–21.
There are three pages in this project. The Page Navigation editor displays
each page and indicates page flow logic with labeled arrows. The two labels
originating from page Page1.jsp correspond to the return Strings in action
method login_action().
Chapter 5 shows you how to specify navigation in your applications (see
“Page Navigation” on page 188). The Page Navigation editor is also a handy
way to bring up any of the project’s pages: just double-click inside the page.
Once you’ve visited the Page Navigation editor, Creator displays a file tab
called Page Navigation so you can easily return to it.
44 Chapter 2 Creator Basics
Before we explore our project any further, let’s have you deploy and run the
application. From the menu bar, select Run > Run Main Project. (Or, click the
green Run arrow on the icon toolbar, which also builds and runs your project.)
Output Window
Figure 2–22 shows the output window after building and deploying project
Login1. Creator uses the Ant build tool to control project builds. This Ant build
process requires compiling Java source files and assembling resources used by
the project into an archive file called a WAR (Web Archive) file. Ant reads its
instructions from a Creator-generated XML configuration file, called
build.xml, in the project’s directory structure.
Figure 2–22 Output window after building and deploying project Login1
If problems occur during the build process, Creator displays messages in the
Output window. A compilation error with the Java source is the type of error
that causes the build to fail. When a build succeeds (the window shows BUILD
SUCCESSFUL, as you see Figure 2–22), Creator tells the application server to
deploy the application. If the application server is not running, Creator starts it
for you. If errors occur in this step, messages appear in the Outline window
from the application server.
Finally, it’s possible that the deployment is successful but a runtime error
occurs. In this situation, the system throws an exception and displays a stack
trace on the browser’s web page. Likely sources for these errors are problems
with JSF tags on the JSP page, resources that are not available for the runtime
class loader, or objects that have not been properly initialized.
2.2 Creator Views 45
http://localhost:28080/Login1/
You use localhost if you’re running the application server on your own
machine; otherwise, use the Internet address or host name where the server is
running. The port number 28080 is unique to Sun’s bundled J2EE application
server. Other servers will use a different port number here.
Note that the Context Root is /Login1 for this application. The application
server builds a directory structure for each deployed application; the context
root is the “base address” for all the resources that your application uses.
Figure 2–23 shows the Login1 project deployed and running in a browser.
The Password field’s tooltip is displayed. Both the User Name and Password
input fields have asterisks, indicating required input. Type in some values for
User Name and Password. If you leave the User Name field empty or type less
than 3 characters or more than 10, you’ll get a validation error. (The minimum
and maximum number of characters only apply if you added a length validator
earlier.) The correct User Name and Password is “rave4u” for both fields.
If you supply the correct values and click the Login button, the program dis-
plays page LoginGood.jsp. Incorrect values display LoginBad.jsp.
46 Chapter 2 Creator Basics
It’s time now to explore the Servers window, located in the upper-left por-
tion of your Creator display. Click the tab labeled Servers to see this window.
Servers
Figure 2–24 shows the Servers window after you’ve deployed project Login1.
Various categories of servers are listed here, including Data Sources, Enterprise
JavaBeans, Web Services, Deployment Server, Remote Deployment Servers,
and Bundled Database Server.
It is strange how some event towards which you have been working,
and which seemed to fill earth and sky till you reached it, at once
then sinks down and becomes hardly distinguishable from the plain.
So passed by the examination to Magnus Kindred.
In fact everybody is so fagged out by the 12th of June, tired with
work, with gaiety and excitement, that feeling seems swallowed up
of high pressure. This may be one reason why the bad success of
other men affects so little those who have won through.
Exceptionally strong as class feeling is at West Point, the dropped
names seem to make very slight impression. And in some cases, of
course, there is no surprise. When a man bones nothing but
mischief, and tries to crowd into the three weeks before examination
the study which should have filled six months, June is not always
kind to him. Unless, indeed, he be one of those men who are pure
mathematics—and even then the discipline column may cut him
down. So it was with small surprise that Magnus heard Chapman's
name among the "found deficient." Chapman did not whimper, but
he took it hard.
"It's that beastly calculus!" he confided to Magnus, in the hurried
moments of parting. "Oh, yes! I know what you mean by raising
your eyebrows, but a man couldn't live here if he didn't run it now
and then."
"But you see a man can't always live here if he does," said Magnus.
"Bosh! Yes, he can. Only they don't all run against old Towser every
time, as I did. No, it wasn't that at all, it was the calculus."
And doubtless, in great measure, it was. Another boy, from far away,
fairly came to tears.
"I don't see how I am to go home!" he said. "I don't know what my
mother will say!"
While another, who had got a turn-back, liked so little what his
mother did say that he gave her a sharp little lecture on the
Graduation ground.
"I can't tell what makes you go on so!" he burst forth. "I'm only
turned back. Lots of men are sent away altogether. Why do you talk
like that? What's the matter?"
Poor mothers! It is often pathetic to hear them explain the case to
other people.
"He's a good boy, Miss Smith; but you know he has always been
delicate. Hard study never agreed with him." (True, this last.)
"You see, Mrs. Brown, he has had such trouble with his eyes that I
wonder he has kept up at all. I really must speak to the
Superintendent about the study lights. Then these early recitations.
Why, at home we never thought of waking him up till eight o'clock,
and then gently, you know, and by degrees. And now he says that
gun just goes through his head without a word of preparation. I
suppose, really, that is what ails his eyes."
"Everything here is so wretchedly mismanaged!" commented a wise
and sympathetic damsel. "The cadets are abused at every turn. I
don't see how they stand it. It is the meanest place!"
"Well, I've done what I could to straighten things," said a beaming
matron. "Look at this bag,—absolutely worn out in the service. It has
brought Tom everything—from cigars up. And when he wants
money, he has only to say so."
Strange, that with such care Tom should ever grumble at anything—
especially regulations.
But graduation has come and gone, the graduates have scattered;
some for home, some for Europe, some to be married "on
graduation leave." For three months they have "the world before
them, where to choose."
The furlough men, too, are scattered, yet more widely and
individually, speeding away on the spider's web of railways that
covers the country. Class supper was over, changed from a gay revel
to a less brilliant memory, and Magnus Kindred went whirling along
towards home. And the great question of taking them all by surprise
was still unsettled.
The home folks, however, had their own ideas on the subject, and
for at least two days before Magnus could possibly come, they had
met every train from the East; Mrs. Kindred, Rose, and Violet. Cherry
went the first time, but after that absented herself on one plea or
another. And so on that sweet June afternoon, when the train
slowed up to let off the one passenger and the one trunk, the three
were in hiding behind the station.
No one could ever describe what that first home-coming was to
Magnus. For miles and hours the excitement in the boy's heart had
been working itself up to white heat, as point after point rose up to
give him welcome. Here a cliff and there a hill; the schoolhouse near
by, the church further off; if he had only had a dozen straw hats, I
think eleven of them would have gone out of the window, for pure
joy.
But the little platform was empty, save of officials; not a creature got
out of the train but Magnus, and not one was waiting to get in. Not
a figure broke the broad June sunlight that filled the old road
towards home. But when he had hurriedly tramped down the steps,
he found himself in his mother's arms, with the two girls sobbing for
joy on either side.
Of the next few minutes, I think no one of them could afterwards
give much account. Then Magnus, with one arm round his mother,
gave that hand to Violet, and the other to Rose, and so they walked
along. How they talked!—with tongues once set free; but most of all,
how they looked at each other. Mother and son had met within the
year, but the two girls gazed at their handsome brother with a
surprised delight that could never have enough.
"But I had forgotten that you were so brown, Magnus," said Rose.
"Drills."
"You always were straight," said Violet, "but now——"
"Bracing up."
"And your hair is so short," said Rose.
"Regulations."
Then how they all laughed and hugged each other over again, for
there were only the wild birds to see.
"Well, certainly, if brevity be the soul of wit, you have improved in
one line," said Rose.
"They teach it out there," said Magnus. "'Mr. Kindred, your head is
on one side, sir!'—'Yes, sir. Which side, sir?'"
"And what did you get for being so saucy?" asked the mother, as the
laugh died away.
"Nothing that time. Even Towser can't skin a man unless he gets
hold of him. But wherever is Cherry? When you all came out of the
first bush, I thought she would jump out of the second."
"She's at home," said Rose. "We wanted her to come, and she
wouldn't."
"But she did the first time," said Violet eagerly; "the first day we
thought you might come."
"Oh, ho!—and as I didn't show up then she put on her high-heeled
shoes," said Magnus. "Girls are all just alike the world over."
"No, they are not!" cried both the charming specimens then present.
"And you shall not say that of Cherry. She is like nobody else—and
nobody else is like her."
And privately, Magnus thought his own two sisters very unlike most
other girls. With their fresh, unjaded faces, undoctored complexions,
untrammelled feet and waists, and unspoiled minds, they made a
wonderful sweet contrast to Miss Dashaway and Miss Flirt. Magnus
had not known how his estimate of women had run down among
the crowd till he found it mounting up again, ten degrees at a time.
Even Cherry's absenting herself—it provoked him heartily, and he felt
himself much injured, but it was after all a refreshing change after
Miss Dangleum's ways. Yes, demonstrations were the man's
business, and in his present mood Magnus felt quite equal to them,
could he but get hold of the right person.
No half-grown girl in half-long dresses appeared, however, as they
reached the house, but for a few minutes Magnus had all he could
manage. The old dog (prudently left at home) was nearly as wild
over the meeting as his young master; jumped upon him, clung to
him, danced round him, whimpered, whined, and barked for joy. It
was not five minutes before the two were rolling down the grass
slope together, then running a sharp race, and then flying all over
the old house from room to room. Magnus shouldered his trunk and
rushed upstairs with it, and Plato dashed after him, wakening all the
echoes that were anywhere about. The two girls, putting rolls in the
oven and setting on cream and butter, almost danced in their tiptoe
joy; the mother in the small sitting-room hid her face in her hands,
and cried and gave thanks. Just to hear that boy's step overhead,
what was it like? And then to have the pair come racing down the
old stairs when supper was ready, Plato barking in a perfect scream
of delight;—do you wonder that the prayer for a blessing was
spoken low and falteringly? or that a hush filled all the room for
some moments thereafter?
Then the three busied themselves earnestly about their boy's supper,
and the boy also lent his assistance; Plato lying on the floor and
winking at him. The old dog was afraid to really go to sleep lest he
should lose sight of his young master.
"I suppose her High Mightiness expects me to put on my war paint
to-morrow, and to go and ca—ll," said Magnus, drawling out the last
word with ridiculous intonation.
"Who? Cherry? Now, Magnus, you shall not call her that," said Rose.
"Shall not, hey? I will call her anything I like," said Magnus.
"Well, go on, then, and do it," cried Violet, with a laugh, "for here
she is."
And in more confusion than he expected from himself, after this
bravado, Cadet Kindred started up from the table and found himself
face to face with his old playmate.
Cherry had the advantage of him; she had seen the photograph, and
was partly prepared for what she saw now—not quite. But to
Magnus, with eyes full of the gleesome, outspoken girl of sixteen,
this vision of a tall, slender maiden of eighteen summers, with
something of a woman's shy reserve floating round her like the
daintiest filmy veil, was altogether new. He had seen nothing like it.
She was so lovely, so dainty, so sweet—if any epithets presented
themselves, they died on his tongue.
And the girl, too, had caught her breath; the living presence is
always so far beyond the picture. All her nicely prepared words of
welcome took to their heels, and Cherry held out her hand and said
simply:
"How do you do?"
Magnus got hold of the hand, and kept it; held it fast while he
pushed and pulled chairs about to give her a place by himself. The
hand was something tangible—especially as it was not quite ready to
be held.
"How do I do?" he repeated, as she took her seat: "you don't care.
Why didn't you come to meet me?"
"I think you had enough at the station."
"And you had enough at home, I suppose."
"Enough to do—yes."
"Well, how can you spare the time to be here now?" said Mr.
Kindred, pursuing his inquiries. A girl who did not wear even the
semblance of a heart upon her sleeve was something new of late,
and exasperating. "It is very frivolous work to sit by and see me eat
supper."
"It will be less so, when I get something to eat myself," Cherry
answered demurely. "But I can wait still longer, if it is not certain the
supply will hold out."
"There! now you have got it," cried Rose, clapping her hands; "and
good for you, too. Hectoring her in that style! Give her some berries,
Magnus, before you eat another one. Cherry picked two thirds of
them with her own fingers."
"She did!" said Magnus, reddening in spite of himself under Cherry's
fire; second classman on furlough and presumptive first sergeant
though he was. "That explains why I've had to empty the sugar
bowl. I'm sorry I have made such a raid, Cherry, but you shall have
what is left."
And swiftly he drew everything as near the girl's plate as the dishes
could find room. Bread plate and butter plate, cake basket, cheese,
cream pitcher, water pitcher, and the wreck of the broiled chicken.
Then seizing the berry bowl Magnus began to pile the sweet wild
strawberries upon her plate, adding slowly and skilfully till they ran
down to the very edge and rose up in the middle a red fragrant
cone.
"How will that do to begin?" he said. "Will you have some sugar?—
but I suppose not, as you picked them yourself and put all the
tartness into mine."
The other three looked on, laughing and interested; but now Cherry
was out of her depth. She looked down at the strawberry hill, at the
dishes, then glanced round at Magnus. What did he mean? Was he
really vexed? Could he really think? It was the fairest kind of a look,
so earnest and questioning. What do you mean? it said.
I think Cadet Kindred knew very promptly what he meant, and saw
some things clearly which had been hanging about in a sort of
uncertain haze. And thus in answer to her shy questioning, Cherry
met a look so keen and merry and full of mischief, full of she hardly
knew what, that her eyes fell and the pink flushes came hurrying
over her face.
Then Magnus laughed. He had the vantage now which belonged to
him, and he felt better.
"Cherry," he said, "you are a transparent humbug! Mother, will you
give me a cup of tea?"
"I think you are an extremely rude boy," said Mrs. Kindred, putting in
an extra lump of sugar the while. "If these are your West Point
manners, you will need a few terms at some other school."
"West Point manners are all packed away with my dress coat. This is
the original Magnus variety."
"It is good to know," said Rose. "Here we have all been rubbing our
manners up, to receive you properly."
"Oh, that's it, is it?" said Magnus, turning to gaze at Cherry. "Good to
know, as you say. I did suspicion it was something got up for my
express benefit."
"Let her alone, and finish your supper," said Mrs. Kindred. "That is, if
you ever intend to finish."
"Emphatically I do!" said Magnus. "If I didn't, I could never begin
again, and that would be a loss out here. Cherry, give me just a few
berries off your plate. I am bashful about taking any more out of the
dish. The sugar has given out, too," he added, dropping his voice;
"and these will not want any."
Poor Cherry!—she literally found not a word to say, but sat looking
down at her plate in helpless silence, as the hands she remembered
so well conveyed away part of its contents. Then Rose came with a
replenished sugar-bowl and set it down by him. But Magnus waved it
away.
"Thank you, no," he said. "These are too sweet for sugar. How do
you suppose Cherry worked it, to get them all on her plate?"
"Crazy boy!" said Rose, "you put them there yourself. Magnus, is
your dress coat here?"
"Truly. Had to bring it along, lest a war should break out before I get
back. May need it yet——" with an indescribable inflection which
only Cherry caught.
"Then if you have done, as mother says," said Violet, "go straight
upstairs and put it on, and come down and show yourself."
"Put on my dress coat, after such a supper," quoth Magnus. "I think
I will!"
"Don't be foolish," said Rose. "Go at once, if you want pancakes for
breakfast."
"Make it waffles——"
"Very well, then, waffles," cried both the girls, laughing at him. "Now
Magnus, go! While your hair is short."
XXVI
CHERRY
'Tis the middle watch of a summer night.
The earth is dark, but the heavens are bright;
Naught is seen in the vault on high,
But the moon and the stars and the cloudless sky,
And the flood that rolls its milky hue,
A river of light, in the welkin blue.
—Culprit Fay.
And thus it was, that in ten minutes or so there entered upon the
scene a fine presentation of a West Point cadet: short hair, white
collar, bell buttons, and all the rest.
Just inside the door Magnus paused, drew himself up, and gave a
comprehensive military salute; then came on with quick, regulation
step, halted in front of Cherry, and took off his cap with the true
cadet swing.
"Thought you'd be out, Miss Reserve. I saw you clear across the
plain. Now Cherry, you must ask how I could possibly see so far."
"What would you answer if I did?" Cherry said diplomatically. This
photograph in person was not easy to talk to.
"I should remark that I can always see some people, across the
world. Then you must put your head on one side and say: 'But you
know you have such eyes, Mr. Kindred!'"
"Well, I certainly shall not say that," Cherry declared, venturing a
look.
"Magnus, you are a young peacock," said his mother.
"Fine feathers, mammy. How do you like West Point, Miss Reserve?
Is this your first visit? Very warm, isn't it? What do think of our
view?"
Oh, how they laughed at him, Cherry and all! Magnus kept a grave
face.
"Will you walk with me after supper?" he went on. And Cherry's
sweet eyes opened full on him, to see what he meant.
"That is not the way at all," said Magnus (approving it highly, all the
same). "You must put your head on the other side now and say:
'Really, Mr. Kindred—he! he!—I'm awfully sorry—but I've given all my
walks away.' Then I shall answer fiercely: 'Tell me one of the men,
and I'll go fight him and get it back.' Now, Cherry, clasp your hands
and say pleadingly: 'Oh, no! Please don't, Mr. Kindred! I remember
now—there is one walk just before breakfast. Would that be too
early for you?' And I answer practically: 'Nothing is too early for me,
Miss Reserve, after you have opened your eyes.' And then you must
give me an admiring glance and say: 'Oh, don't talk of my eyes, Mr.
Kindred!' Then the drum-beats, and I double-time it into camp."
"You need not say 'you'—I should never say such things," Cherry
declared; this vision of other girls acting as a tonic, though she
laughed with the rest.
"Of course not! You do not say anything to me," retorted Magnus.
"She is too polite to interrupt you," said Rose. "Do you mean to say
that West Point girls talk like that?"
"Some of the girls. Cherry will when I have walked with her a few
times."
Cherry glanced up in quick denial, meeting then the aforesaid eyes
looking so handsome and competent and full of frolic and power that
her own beat a hasty retreat.
"And you walk with such girls?" demanded Violet.
"Oh, yes—" Magnus said easily. "One cannot be uncivil just because
they are complimentary."
"But before breakfast!" said Rose. "Is there no other half hour in the
day that would do?"
"My dear girl, it's not that half hour in particular; it is every half hour
they can get. You wouldn't have them pink and white their cheeks
for nothing."
"Pink their cheeks?"
"Why, yes," said Magnus. "Pink them—frost them. I'm sure I don't
know how it's done."
"You are telling traveller's tales," said Mrs. Kindred gravely.
"Well, I like that!" said Magnus. "Why, mammy, they all do it. Clinker
says so. At least not all, I suppose. Of course, there are exceptions."
"Charlemagne"—began Mrs. Kindred. But at this word Magnus
turned to her and "stood attention," bracing up to the fullest extent,
and saluting with such profound gravity and respect that the rest all
shouted, and the mother's face gave way.
"There is no doing anything with you," she said. "You must give
them no end of trouble at West Point. Go upstairs and take off that
toggery, and see if you can be a reasonable boy."
"I've got to give Cherry her walk first," said Magnus. "She has never
walked with a real live cadet; and she may as well practise on me
before she undertakes the rest of the Corps next summer."
"I look like that," said Cherry, with some scorn.
"Very much like it, I should say," responded Magnus. "I know how it
will be. 'Say, Kindred, who's that awfully nice girl you've got on
hand? Introduce me, won't you? Your sister, aint she? Well, don't let
her promise all her walks to those spoony fellows. You want her to
have a good time, you know.'"
Magnus hit it off with excellent mimicry, and the room was in a buzz
of amusement.
"Then I shall say," he went on, "that my sisters are in quite another
package, and that to ensure her having a good time, she has
promised all her walks to me."
"She hasn't at all," said Violet.
"She will—by that time," said Magnus confidently; enjoying the
pulsating colour in Cherry's face, and comparing it with the unmoved
tinting of poppy leaves. "Why, even to-night she'll not walk home
with anybody but Cadet Kindred, in full canonicals."
"Magnus!" said his mother, "I think you are absolutely beside
yourself."
"Do cadets all talk in that style?" demanded Rose.
"Not all so brilliantly as I do, by any means, but in the same general
way."
"Then I think they need a professor of common sense at West
Point."
"And I think you had better go to bed and to sleep," said Violet.
"We'll walk home with Cherry. Your brain is getting overexcited."
"Silence and solitude will calm it down," said Magnus. "If you all go,
there will be a chatter, but Cherry and I know each other so well that
there is no need to speak. She will not try to keep me, mammy; I'll
be right back."
There is no doubt but Cherry was laughing when they set out, partly
for nervousness, but also in part for the mere infectious atmosphere
of frolic. She gave no sign, however, being much under the spell of
the tall, erect figure at her side. Whenever she looked up and tried
to throw off the glamour, one glint of the bell buttons brought it on
worse than before.
"Aren't we walking very fast?" said Magnus mildly.
"But you told your mother you would be right back," said Cherry.
"From your front door—not from ours." The laugh rippled out at
that, as Cherry moderated her pace.
"No use, you see," said Magnus, falling into an easy saunter. "I can
do the double faster than you can. I knew you meant to scoot away
by yourself, the minute I went to change myself into a cit."
"Who told you?" said Cherry.
"You."
Silence fell upon this; then Magnus began again:
"You see, I really wanted to have you alone awhile—I wanted to ask
tidings of an old friend of mine. I thought perhaps you could tell me
where to find her; girls always seem to know about girls."
"Oh, I do not!" said Cherry hastily, running over in her mind all the
girls she had ever heard of. "You should ask Rose."
"Rose doesn't know everything. I dare say you can tell me if she has
moved off. I thought so much of her!" said Magnus pensively, gazing
up at the stars. "We used to be very intimate. I left my heart in her
keeping—whatever she did with it. Why—you will hardly believe me
—but she used to live here, in your house. And when I was going
away to West Point she kissed me right at this very gate."
"She didn't!" cried Cherry hotly, and then hung her head.
"Oh, you do know her then?" said Magnus. "Why didn't you say so
before? And where do you suppose she probably is now?"
Cherry resolutely stopped and faced him; what though the full
moonlight effect well nigh swept off her self-possession.
"Magnus," she said, "you are talking great nonsense. It may be the
West Point fashionable way of talking sense, but we are plain folks
out here and have not had your advantages."
And here Magnus made a bow so profound that it sent Cherry's
words to the right-about.
"What next?" said Magnus. "That is all more or less true, so far, but
well begun is only half done."
"Oh, it is no use to talk to you!" said Cherry. "And it never was, for
that matter."
"My talking is of some use, however," said Magnus. "I have quite
succeeded in bringing myself back to your recollection. What more
did you want to say, pretty girl?"
"That you are extremely silly," said Cherry, with the laugh getting
into her voice.
"There is no contenting these women of sense!" said Magnus. "If I
fib, she scolds: if I tell truth, she flouts me. If Derby drill will only
handle this line of approaches, I shall learn how, in time. Don't walk
so fast, wise damsel."
"Will you come in and see papa to-night?" said Cherry, not
slackening her pace in the least.
"Well, hardly," said Magnus. "I like to make it all safe with the
daughter before I rush into the paternal presence."
If Cherry had been that sort of a girl, I think she would have lent
him a very earnest and hearty little cuff. As it was, she gave him one
hopeless glance and slipped through the little gate, as her next
neighbour would have said, "spryer'n an eel."
But quick steps were play to Magnus, and before Cherry's foot had
touched the doorstone he was beside her. His hands met round but
not touching her, putting the girl in a charmed circle of space; and
the strong, clear voice chanted out an old playtime couplet:
It was just like the cross grain of human nature that without a sound
but the singing of birds to rouse him, our young soldier should wake
up at precisely reveille gun time. In fact he did it for three days, to
his great disgust; and then, as he said of himself, learned to know
how happy he was.
Of course, this first morning at home, with everything before him
except drills and regulations, going to sleep again was impossible.
So with the sublime unconsciousness of other people's slumbers
which marks young men of his age, Magnus lay still and began to
whistle. And with that other line of forgetfulness which shows the
inferiority of the feminine mind, there was not a woman in the house
but would have given her best sleep to hear him.
They were not asleep, however, but up and stirring; and it was
perhaps some closing door or opening window, or the long unheard
voice of the coffee mill, which reminded Cadet Kindred that in these
regions there was no preparatory drum; and that such a noise as he
had been making would quite rule out the thought of any private
suggestions at his door. Wherefore, he had better get up. But what
fun—to dress as he liked, in what he liked, and be as long as he
liked about it.
With these thoughts came another to hasten his motions: would
Cherry come to breakfast? And if she did, then just when would she
come? And here Magnus paused before a piquant illustration of the
young lady herself, drawn from memory—or, as the real novelists put
it, "which had been photographed on his heart in one brief
moment." And thus it seemed:
A tall, delicately formed girl, with dark hair, which did not crinkle and
curl like his own, but parted in shining waves and rings; a
complexion colourless in general, but where the rosy tints came and
went like a pink cloud, in swift pulsations. The eyes—no, Mr. Kindred
thought he had not a fair look at her eyes last night, and that was
one thing to do to-day. Also her hand was a soft and fresh thing to
touch. And at this point Magnus opened his door and passed out.
On the way downstairs he peeped into his mother's room, but no
one was there, and he went straight on to a small room on the first
floor which was a sort of offshoot from the house, and hardly bigger
than a good-sized bay window.
But the picture he found there Magnus never forgot.
The room had been his father's summer study. Too cold for winter
use, but in June perfection, with every window open to the air. Roses
and honeysuckles climbed up and ran across and strayed in; amid
the tangle birds sang and twittered and builded. Further off were
cattle and chickens, with an old drum major of a turkey cock
strutting before the barnyard throng. The scent of hayfields was
mingled with the yet rarer fragrance of new-mown grass.
If the room had been larger, the minister's old library would have
made small show; but as it was, the strips of wall between the
windows were quite well covered. It was a very old affair in every
way; leather covers much worn with handling, shutting in truths that
were but the brighter for much believing. Very old-fashioned books.
You could not find a copy of "Why I am a Doubter"; nor a single
treatise on "The Eternal Equilibrium of Things." The glad toiler in
Christ's vineyard had had no use for "The Trammels of Faith, and
Welcome to Our Bookstore - The Ultimate Destination for Book Lovers
Are you passionate about books and eager to explore new worlds of
knowledge? At our website, we offer a vast collection of books that
cater to every interest and age group. From classic literature to
specialized publications, self-help books, and children’s stories, we
have it all! Each book is a gateway to new adventures, helping you
expand your knowledge and nourish your soul
Experience Convenient and Enjoyable Book Shopping Our website is more
than just an online bookstore—it’s a bridge connecting readers to the
timeless values of culture and wisdom. With a sleek and user-friendly
interface and a smart search system, you can find your favorite books
quickly and easily. Enjoy special promotions, fast home delivery, and
a seamless shopping experience that saves you time and enhances your
love for reading.
Let us accompany you on the journey of exploring knowledge and
personal growth!
ebookgate.com