WebObjects Overview
WebObjects Overview
WebObjects Overview
May 2001
Apple Computer, Inc. Simultaneously published in the
© 2000-2001 Apple Computer, Inc. United States and Canada
All rights reserved.
No part of this publication may be Even though Apple has reviewed this
reproduced, stored in a retrieval manual, APPLE MAKES NO
system, or transmitted, in any form or WARRANTY OR REPRESENTATION,
by any means, mechanical, electronic, EITHER EXPRESS OR IMPLIED, WITH
photocopying, recording, or RESPECT TO THIS MANUAL, ITS
otherwise, without prior written QUALITY, ACCURACY,
permission of Apple Computer, Inc., MERCHANTABILITY, OR FITNESS
with the following exceptions: Any FOR A PARTICULAR PURPOSE. AS A
person is hereby authorized to store RESULT, THIS MANUAL IS SOLD “AS
documentation on a single computer IS,” AND YOU, THE PURCHASER, ARE
for personal use only and to print ASSUMING THE ENTIRE RISK AS TO
copies of documentation for personal ITS QUALITY AND ACCURACY.
use provided that the documentation IN NO EVENT WILL APPLE BE LIABLE
contains Apple’s copyright notice. FOR DIRECT, INDIRECT, SPECIAL,
The Apple logo is a trademark of INCIDENTAL, OR CONSEQUENTIAL
Apple Computer, Inc. DAMAGES RESULTING FROM ANY
Use of the “keyboard” Apple logo DEFECT OR INACCURACY IN THIS
(Option-Shift-K) for commercial MANUAL, even if advised of the
purposes without the prior written possibility of such damages.
consent of Apple may constitute
THE WARRANTY AND REMEDIES SET
trademark infringement and unfair
FORTH ABOVE ARE EXCLUSIVE AND
competition in violation of federal
IN LIEU OF ALL OTHERS, ORAL OR
and state laws.
WRITTEN, EXPRESS OR IMPLIED. No
No licenses, express or implied, are Apple dealer, agent, or employee is
granted with respect to any of the authorized to make any modification,
technology described in this book. extension, or addition to this warranty.
Apple retains all intellectual property
rights associated with the technology Some states do not allow the exclusion or
described in this book. This book is limitation of implied warranties or
intended to assist application liability for incidental or consequential
developers to develop applications damages, so the above limitation or
only for Apple-labeled or exclusion may not apply to you. This
Apple-licensed computers warranty gives you specific legal rights,
and you may also have other rights which
Every effort has been made to ensure
vary from state to state.
that the information in this document
is accurate. Apple is not responsible
for typographical errors.
Apple Computer, Inc.
1 Infinite Loop
Cupertino, CA 95014
408-996-1010
Apple, the Apple logo, Mac, and
WebObjects are trademarks of Apple
Computer, Inc., registered in the
United States and other countries.
Enterprise Objects and Enterprise
Objects Framework are trademarks of
NeXT Software, Inc., registered in the
United States and other countries.
Contents
3
Apple Computer, Inc. May 2001
C O N T E N T S
4
Apple Computer, Inc. May 2001
C O N T E N T S
The Basics 76
Direct to Java Client Architecture 76
Development Tasks and Tools 78
The Direct to Java Client Assistant 78
Further Customizing Your Application 79
Advantages of the Direct to Java Client Approach 80
Limitations 80
Guidelines for Choosing Direct to Java Client 81
5
Apple Computer, Inc. May 2001
C O N T E N T S
Glossary 89
Index 95
6
Apple Computer, Inc. May 2001
Figures and Tables
Figure 3-1 Connecting enterprise objects to data and the user interface 27
Figure 3-2 Mapping between an enterprise object class and a single table 30
Figure 3-3 Mapping relationships 31
Figure 3-4 Implementing business logic in enterprise objects 34
Figure 3-5 Implementing business logic in the user interface application 35
Figure 3-6 Implementing business logic in the database 36
7
Apple Computer, Inc. May 2001
F I G U R E S A N D T A B L E S
8
Apple Computer, Inc. May 2001
C H A P T E R 1
WebObjects System Overview is written for developers who want to start using
WebObjects. However, anyone interested in WebObjects technology will get
something out of this book.
For the most part, this book does not assume you have a background in
object-oriented programming. However, WebObjects is based on object-oriented
frameworks written in Java, an object-oriented language. You should be familiar
with object-oriented programming if you intend to write WebObjects applications.
There are many books available on the subject if you aren’t.
Further Investigations
10 Further Investigations
Apple Computer, Inc. May 2001
C H A P T E R 1
After you choose an approach, you should read the appropriate document (when it
becomes available). Regardless of the approach you use, you should read Creating
Enterprise Objects as the material pertains to all approaches.
With the exception of Discovering WebObjects HTML, which is available now, these
documents are in preparation at the time of this writing. You can obtain other
documents in this series (as they become available) using the publish-on-demand
arrangement Apple has with Fatbrain.com.
To obtain a printed copy of one of these documents, use your Web browser to access
the page at www1.fatbrain.com/documentation/apple. Then follow the directions.
The document should be delivered to you within a few business days.
Further Investigations 11
Apple Computer, Inc. May 2001
C H A P T E R 1
12 Further Investigations
Apple Computer, Inc. May 2001
C H A P T E R 2
2 What Is WebObjects?
WebObjects allows you to take the next logical step. With it, you can produce
full-fledged Web-accessible applications, for use either across the Internet or within
a corporate intranet. These applications can be HTML-based, and thus accessible
through a Web browser, or can have the full interactivity of a stand-alone
application.
Much of the content on the Web is textual or graphical material that doesn’t change
much over time. However, there is increasing demand for sites that publish
ever-changing data: breaking news stories, up-to-the-minute stock quotes, or the
current weather are good examples.
What Is WebObjects?
A typical website is organized like Figure 2-1. A user’s Web browser requests pages
using URLs (Uniform Resource Locators). These requests are sent over the network
to the Web server, which analyzes each request and selects the appropriate Web
page to return to the user’s browser. This Web page is simply a text file that contains
HTML. Using the HTML tags embedded within the file received from the Web
server, the browser renders the page.
Request
http://www.apple.com
Response
HTML page
<HTML>
<Head>
.
Web server .
.
Static publishing sites are easy to maintain. There are a number of tools on the
market that allow you to create HTML pages with a relatively small amount of
effort, and as long as the page content doesn’t change too often, it isn’t that difficult
to keep them up-to-date. Dynamic publishing sites, however, are a different story.
Without WebObjects it could take a small army to keep a breaking news site up to
date.
WebObjects was designed from the beginning to allow you to quickly and easily
publish dynamic data over the Web. You create HTML templates that indicate
where on the Web page the dynamic data is to be placed, and a WebObjects
application fills in the content when your application is accessed. The process is
much like a mail merge. The information your Web pages publish can reside in a
database, it can reside in some other permanent data storage (files, perhaps), or it
can even be calculated or generated at the time a page is accessed. The pages are
also highly interactive—you can fully specify the way the user navigates through
them.
What Is WebObjects?
Figure 2-2 shows a WebObjects-based dynamic publishing site. Again, the request
(in the form of a URL) originates with a client browser. If the Web server detects that
the request is to be handled by WebObjects, it passes the request to a WebObjects
adaptor. The adaptor packages the incoming request in a form the WebObjects
application can understand and forwards it to the application. Based upon
templates you’ve defined and the relevant data from the data store, the application
generates an HTML page that it passes back through the adaptor to the Web server.
The Web server sends the page to the client browser, which renders it.
Request
http://store.apple.com/...
Response
HTML page
WebObjects Templates
application
Relational database
What Is WebObjects?
Although the majority of websites primarily publish static data, the number of sites
that publish dynamic content is growing rapidly. Many corporations use intranets,
the Internet, or both to provide easy access to internal applications and data. An
online store selling books, music, or even computers is one example of a
Web-enabled client-server application.
What Is WebObjects?
Java Client distributes the objects of your WebObjects application between the
application server and one or more clients—typically Java applications. It is based
on a distributed multi-tier client-server architecture where processing duties are
divided between a client, an application server, a database server, and a Web server.
With a Java Client application, you can partition business objects containing
business logic and data into a client side and a server side. This partitioning can
improve performance and at the same time help to secure legacy data and business
rules.
Figure 2-3 (page 18) illustrates a Java Client application in which the client portion
is running as an application installed on the user’s computer. As with an
HTML-based WebObjects application, the application can communicate with the
server side using HTTP. In addition, Java Client passes objects between a portion of
your application residing on the user’s computer and the portion of your
application that remains on the application server.
What Is WebObjects?
HTTP
<HTML>
<Head>
Web server .
.
.
Relational database
Java Client allows your application to look and feel like a traditional desktop
application and still take full advantage of the power of WebObjects.
What Is WebObjects?
Rapid Development
WebObjects is both powerful and flexible. With that power and flexibility, however,
comes a certain degree of complexity. For many applications, whether HTML-based
or Java Client–based, it’s more important to develop the application quickly than
strive for maximum flexibility or polish. As an example, a simple data-browsing
and editing application, intended only for internal use by a system administrator,
probably wouldn’t warrant the same degree of effort you would put into an
Internet-enabled application accessible by the general public. To simplify the
development of applications like the former, WebObjects includes a set of
rapid-development technologies: Direct to Web and Direct to Java Client.
Direct to Web and Direct to Java Client are similar in approach. Their primary
difference is in how the application interacts with the end user. Direct to Web
creates HTML-based WebObjects applications, whereas Direct to Java Client creates
WebObjects applications that employ Java Client to partition the application
between server and client. Both are useful not only for “quick and dirty”
applications, but in many situations can also serve as rapid prototyping tools.
Because Direct to Web and Direct to Java Client both allow customization on
various levels, they are well-suited for bootstrapping and creating your
mission-critical applications.
Direct to Web
Direct to Web is a configurable system for creating HTML-based WebObjects
applications that access a database. All Direct to Web needs to create the application
is a model for the database, which you can build using EOModeler.
Direct to Web applications are not a set of static Web pages. Instead, Direct to Web
uses information from the model available at runtime to dynamically generate the
pages. Consequently, you can modify your application’s configuration at runtime—
using the Direct to Web Assistant—to hide objects of a particular class, hide their
properties, reorder the properties, and change the way they are displayed without
recompiling or relaunching the application.
Rapid Development 19
Apple Computer, Inc. May 2001
C H A P T E R 2
What Is WebObjects?
Out of the box, Direct to Web generates Web pages for nine common database tasks,
including querying, editing, and listing. To do this, Direct to Web uses a
task-specific component called a template that can perform the task on any entity.
The templates, in conjunction with a set of developer-configurable rules, are the
essential elements of your Direct to Web application.
Direct to Web is highly customizable. For example, you can change the appearance
of the standard templates, mix traditional HTML-based WebObjects components
with Direct to Web pages, and create custom components and templates that
implement specialized behavior.
What Is WebObjects?
mechanism for cleanly instantiating business objects directly from database tables.
WebObjects handles all the interactions with the database including fetching,
caching, and saving. This allows you to write your business logic against actual
objects independent of the underlying data source. You can modify schemas, add
or change databases, or even use totally a different storage mechanism without
needing to rewrite your application.
WebObjects applications can access any database with a JDBC 2.0 driver. JDBC is an
interface between Java platforms and databases.
State Management
The HTTP protocol used on the Web is inherently stateless; that is, each HTTP
request arrives independently of earlier requests, and it’s up to Web applications to
recognize which ones come from an individual user or session. Therefore, most
Web applications of consequence—as well as some of the more interesting dynamic
publishing sites—need to keep state information, such as login information or a
shopping basket, associated with each user session.
Without using cookies, WebObjects provides objects that allow you to maintain
information for the life of a particular client session, or longer. This makes it
particularly easy to implement an application like a Web-based online store: you
don’t have to do anything special to maintain the contents of the user’s shopping
cart or other data over the life of the session. In addition, your online store could
even monitor individual customer buying patterns and then highlight items they’re
more likely to be interested in the next time they visit your site.
What Is WebObjects?
Modular Development
The power of WebObjects comes from a tightly integrated set of tools and
frameworks, facilitating the rapid assembly of complex applications. At the heart of
this system is the Project Builder Integrated Development Environment (IDE),
which manages your Java business logic and tracks all the supporting models and
components. As mentioned above, WebObjects also includes powerful assistants
and frameworks that allow the rapid creation of HTML or Java Client applications
directly from the database. Advanced developers can tap into the object-oriented
Java APIs underlying all the different frameworks, allowing virtually unlimited
customization and expandability.
Pure Java
WebObjects applications are 100% Pure Java, which means they can be deployed on
any platform with a certified Java 2 virtual machine.
The WebObjects application server is both efficient and scalable. With WebObjects,
if more power, reliability, or failover protection is needed, you can run multiple
instances of your application, either on one or on multiple application servers (see
Figure 2-4 (page 23)). You can choose from one of several load-balancing algorithms
(or create your own) that determine which instance each new user should connect
to. And, either locally or from a remote location, you can analyze site loads and
usage patterns and then start or stop additional application instances as necessary.
Load balancing is a very powerful feature of WebObjects that allows you to add
more server capacity as the need arises without needing to implement a
load-balancing algorithm yourself.
What Is WebObjects?
Web server
WebObjects
adaptor
Application server 2
Application 1
Instance 1
Application server 1
What Is WebObjects?
3 Enterprise Objects
This chapter introduces enterprise objects, describes how they map to a database,
outlines how WebObjects supports and interacts with them, and enumerates the
advantages of the enterprise objects approach over other approaches available in
the industry. The reader may wish to read the first section, “What Is an Enterprise
Object?” (page 25), and the last section, “The Enterprise Objects Advantage”
(page 34), and skip the rest of the chapter, which is written for those familiar with
relational databases.
An enterprise object is like any other object in that it couples data with the methods
for operating on that data. However, an enterprise object class has certain
characteristics that distinguish it from other classes:
■ It has properties that map to stored or persistent data; an enterprise object
instance typically corresponds to a single row or record in a database.
■ It knows how to interact with other parts of WebObjects to give and receive
values for its properties. This is done through a mechanism known as key-value
coding, which enables the setting and getting of these properties.
Enterprise Objects
To maximize the reusability and extensibility of your objects, they shouldn’t embed
knowledge of the user interface or database alongside the business logic. For
example, if you embed knowledge of your user interface, you can’t reuse the objects
because each application’s user interface is different. Similarly, if you embed
knowledge of your database, you’ll have to update your objects every time you
modify the database.
If not in the business objects, then where does this knowledge go? It’s handled by
WebObjects as shown in Figure 3-1 (page 27).
Enterprise Objects
Figure 3-1 Connecting enterprise objects to data and the user interface
Model
WebObjects
Enterprise objects
Relational database
Enterprise Objects
For example, you could create a class of enterprise objects called Customer that
defines such business rules as “customers must have a work or home phone
number,” or “the customer cannot spend more than his credit limit.” Without
rewriting your business logic, you could use these objects in a public web-based
application and an internal customer service application. You could also switch the
database that serves the customer data.
Model objects represent special knowledge and expertise. For example, model
objects can hold a company's data and define the logic that manipulates that data.
Model objects are not directly displayed. They often are reusable, distributed,
persistent, and portable to a variety of platforms.
Note: WebObjects uses the term “model” differently from MVC. In WebObjects,
a model establishes and maintains a correspondence between an enterprise object
class and data stored in a relational database. In MVC, model objects represent the
special knowledge of the application.
View objects represent things visible on the user interface (windows, for example,
or buttons). A View object is “ignorant” of the data it displays. View objects tend to
be very reusable and so provide consistency between applications.
Because of the Controller's central mediating role, Model objects need not know
about the state and events of the user interface, and View objects need not know
about the programmatic interfaces of the Model objects.
Enterprise Objects
From the perspective of this paradigm, enterprise objects are Model objects.
However, WebObjects also extends the MVC paradigm. Enterprise objects are also
independent of their persistent storage mechanism. Enterprise objects do not need
to know about the database that holds their data, and the database doesn’t need to
know about the enterprise objects formed from its data.
Enterprise Objects
Figure 3-2 Mapping between an enterprise object class and a single table
lastName "Farina"
Talent
firstName "Dennis"
TALENT
TALEN ME
T _I D L A S T _N A M E FIRST_NA
1 028 Dennis
Farina
1 132 Corey
Feldman
In actual practice, the mapping is more flexible than this. For example:
■ You can map an enterprise object class to a single table, a subset of a table, or to
more than one table. For instance, a Person object can get its first and last names
from a PERSON table but get its street address, city, state and zip code from an
ADDRESS table.
■ Generally an enterprise object instance variable maps to a single column, but the
column-to-instance variable correspondence is similarly flexible. You can map
an instance variable to a derived column, such as “price * discount” or “salary *
12”.
■ You can map an enterprise object class inheritance hierarchy to one or more
database tables.
Enterprise Objects
to-ones and to-manys—which are both illustrated in Figure 3-3. The relationship a
MovieRole has to its Movie is a to-one relationship, while the relationship a Movie
has to its MovieRoles is a to-many.
movieRoles
NSMutableArray
movie
Movie MovieRole
movie
MovieRole
M O VIE _ R O LE MOVIE
TALEN
T _ I D M O VIE _ R IT L E
OLE MOVIE_ID MOVIE_ID T
1 028
R iple y 501 501 Alien
o
1132
A sh 501 703 Toy St
Enterprise Objects
Validation
A good part of your application’s business logic is usually validation—
for example, verifying that customers don’t exceed their credit limits,
return dates don’t come before their corresponding check-out dates, and
so on. In your enterprise object classes, you implement methods that
check for invalid data, and WebObjects automatically invokes them
before saving anything to the database.
Referential integrity enforcement
In your model you can specify rules governing the relationships
between objects, such as whether a to-one relationship is optional or
mandatory. You can also specify delete rules—actions that should occur
when an enterprise object is deleted. For example, if you have a
“department” object you can specify that when it is deleted all the
employees in that department are also deleted (a cascading delete), all
the employees in that department are updated to have no department
(nullify), or the department deletion is rejected if it has any employees
(deny).
Automatic primary and foreign key generation
You needn’t maintain database artifacts such as database primary and
foreign key values in your application; WebObjects keeps track of them
for you. Database primary and foreign keys aren’t usually meaningful
parts of a business model; rather, they’re attributes created in a
relational database to express relationships between entities. Key values
can be generated and propagated automatically.
Enterprise Objects
Transaction management
Most transactions are handled for you, using the native transaction
management features of your database to group database operations
that correspond to the changes that have been made to enterprise objects
in memory. You don’t have to worry about beginning, committing, or
rolling back transactions unless you want to fine-tune transaction
management behavior. WebObjects also provides a separate in-memory
transaction management feature that allows you to create nested
contexts in which a child context’s changes are folded into the parent
context only upon successful completion of an in-memory operation.
Locking
WebObjects offers three types of locking. “Pessimistic” uses your
database server’s native locking mechanism to lock rows as they’re
fetched and prevents update conflicts by never allowing two users to
look at the same object at the same time. “Optimistic” doesn’t detect
update conflicts until you try to save an object’s changes to the database;
if the corresponding database row has changed since it was originally
fetched, the save is aborted. “On-Demand” is a mixture of the other two:
it locks an object after you fetch it but before you attempt to modify it.
The lock can fail for one of two reasons: either the corresponding
database row has changed since you fetched the object (optimistic
locking), or because someone else already has a lock on the row
(pessimistic locking).
Faulting
When WebObjects fetches an object, it creates objects representing the
destinations of the fetched object’s relationships. By default WebObjects
doesn’t immediately fetch data for the destination objects of
relationships, however. Fetching is fairly expensive, and further, if
WebObjects fetched objects related to the one explicitly asked for, it
would also have to fetch the objects related to those, and so on, until all
of the interrelated rows in the database had been retrieved. For many
applications, this would be a waste of time and resources. To avoid this,
WebObjects creates empty destination objects, called faults, that fetch
their data the first time they’re accessed. This process, known as
“faulting,” is automatic.
Uniquing
In marrying relational databases to object-oriented programming, one
of the key requirements is that a row in the database be associated with
only one enterprise object in a given context in your application.
WebObjects maintains the mapping of each enterprise object to its
Enterprise Objects
Application
.......
.......
...
WebObjects Business logic
.....
..... .......
Relational database
Enterprise Objects
Another approach (Figure 3-5) is to implement business logic in the web or desktop
application. The WebObjects approach betters this approach in the following ways:
■ It offers greater reuse. In WebObjects, you code your business logic once, and
each application that accesses your database can use it. You don’t have to recode
your business logic into each screen or web page.
■ It’s more maintainable. With WebObjects, you don’t have to duplicate your
business logic. Thus you can easily make substantial changes to your rules
without resorting to finding and fixing every affected page in every affected
application. You can also easily track changes to your schema.
■ It improves data integrity. In WebObjects, you don’t need to rely on all
application developers to implement the business rules correctly. If one
application has an error, it is less likely to corrupt your database.
■ It scales better. In WebObjects, you can improve your application’s
performance without having to provide your users with faster systems. Instead,
you can simply move some computation-intensive processing to fast server
machines.
Application
Business logic
Relational database
Enterprise Objects
Application
Relational
Business logic
Database
4 HTML-Based Applications
HTML-Based Applications
These advantages are discussed in more detail in the sections that follow.
Components consist of
■ a template in HTML that specifies how the component looks. This file can be
edited by any HTML editor or text editor.
■ code that specifies how the component acts. You specify this with a standard
Java source file.
■ bindings that associate the component’s template with its code. These are
stored in a text file.
Separating the template, code, and bindings makes it much easier to maintain a
website. A graphic artist can modify a template, thus modifying the appearance of
the page, without breaking the code. A programmer can completely rearrange the
code without accidentally changing the layout.
You do not need to edit all three files separately. WebObjects Builder, a graphical
component editing tool provided with WebObjects, edits the template, bindings,
and code files simultaneously, relieving you of having to manually synchronize
them. WebObjects Builder is described in more detail in “WebObjects Builder”
(page 46).
Figure 4-1 (page 39) shows the three files in an example component.
HTML-Based Applications
Component (Greeting.wo)
Template (Greeting.html)
<HTML>
<HEAD><TITLE>Greeting</TITLE></HEAD>
<BODY>
Hello <WEBOBJECT NAME=String1></WEBOBJECT>!
<P></BODY>
</HTML>
Code (Greeting.java)
import com.webobjects.appserver.*;
Bindings (Greeting.wod)
String1 : WOString {
value = userName;
}
HTML-Based Applications
Reusing Components
You can embed a component within another component. For example, a component
might represent only a header or footer of a page; you can nest it inside of a
component that represents the rest of the page. A component designed to be nested
within another component is called a reusable component, shared component, or
subcomponent. Like dynamic elements, reusable components appear in the
HTML-Based Applications
Maintaining State
In addition to the components, each WebObjects application has a number of
sessions and an application object.
Session variables can be used in shopping cart applications to represent the items in
the shopping cart. Email applications can use session variables to keep track of
whether the user has logged in or not.
HTML-Based Applications
Server
Component
Template
..... partNum W4378
........
Bindings color Red
size XL
..... retail 48.99
... .....
Code
HTML-Based Applications
WebObjects Architecture
When you run a WebObjects application, it communicates with the Web browser
through the chain of processes shown in Figure 4-3.
Web
browser
Web server
WebObjects
adaptor
WebObjects
application
WebObjects
SQL Data
Relational database
WebObjects Architecture 43
Apple Computer, Inc. May 2001
C H A P T E R 4
HTML-Based Applications
You have already been introduced to EOModeler. Project Builder and WebObjects
Builder are discussed in the following sections.
HTML-Based Applications
Project Builder
As its name implies, Project Builder manages all of the constituent parts of your
application, including source code files, WebObjects components, frameworks,
makefiles, graphics and sound files, and the like. You use Project Builder to edit
your code files, compile, debug, and launch your application for development
testing. Project Builder’s assistants help you create new WebObjects components.
You also can launch the other development tools from within Project Builder.
HTML-Based Applications
WebObjects Builder
You use WebObjects Builder to edit your application’s components. WebObjects
Builder allows you to graphically edit a component’s HTML template. If you prefer,
you can switch to the source view from which you can edit the template as an
HTML text file. WebObjects Builder also allows you to graphically bind the
dynamic elements on your template to variables and methods within your code;
you simply drag from a variable to the dynamic element as shown in Figure 4-5
(page 46).
HTML-Based Applications
In some cases, you can use the Direct to Web rapid development system to create
your HTML-based application for you. Direct to Web works particularly well for
data-driven applications, prototypes, and internal applications. See “Direct to Web
Applications” (page 49) for more information.
HTML-Based Applications
Direct to Web is a technology that creates HTML-based Web applications that use
enterprise objects and consequently access databases. All you need to provide is the
model that specifies the database-to-objects mapping and Direct to Web instantly
creates an application.
49
Apple Computer, Inc. May 2001
C H A P T E R 5
After the user logs in, Direct to Web displays its first dynamically generated page:
a query-all page (Figure 5-2). This page allows the user to specify the enterprise
objects he or she wants to work with. The user can query for any type of enterprise
object that is visible in the application (the developer decides which types are visible
and which are not).
If the query-all page is not specific enough, the user can click one of the hyperlinks
labeled “more..”, which brings up a query page specific to the corresponding type
of enterprise object (Figure 5-3). In this page, the user can specify the values for
several properties at the same time. The resulting query is the logical “and” of the
individual queries for the properties.
50
Apple Computer, Inc. May 2001
C H A P T E R 5
When the user clicks the Query button on the query page or the magnifying glass
icon on the query-all page, Direct to Web displays the enterprise objects matching
the query on a list page (Figure 5-4). This page presents the enterprise objects in
batches; the user can change the batch size and navigate from batch to batch.
51
Apple Computer, Inc. May 2001
C H A P T E R 5
Note that each Movie enterprise object on the list page in Figure 5-4 has an Edit
button, which indicates that Movie objects are read-write. The developer can
configure whether a type of enterprise object is read-only or read-write.
If the Movie objects are read-only, an Inspect button appears on each row instead of
an Edit button. If the user clicks the Inspect button next to one of the enterprise
objects, Direct to Web displays an inspect page for the object (Figure 5-5) that
reveals more detailed information about the object.
If the objects displayed on the list page are writable and the user clicks the Edit
button next to one of them, Direct to Web displays an edit page for the object (Figure
5-6). On the edit page, the user can edit the attributes for the object or click the Edit
button next to one of the relationships to edit the relationship.
52
Apple Computer, Inc. May 2001
C H A P T E R 5
The user edits a relationship using an edit-relationship page (Figure 5-7), which
edits to-many and to-one relationships.
With the exception of the login page, every Direct to Web page has an area
containing a menu and buttons that assist in navigating around the application
(Figure 5-8). This is called the menu header.
53
Apple Computer, Inc. May 2001
C H A P T E R 5
Every Direct to Web application appears in one of three looks. A look is a visual
theme, and affects the layout and appearance of the pages. The example pages you
have seen are in the Basic look. Direct to Web also supports two other looks: the
Neutral look (Figure 5-9) and the WebObjects look (Figure 5-10 (page 55)).
54
Apple Computer, Inc. May 2001
C H A P T E R 5
As you have seen, Direct to Web applications have a fixed structure. They consist of
a set of task pages (for example, query, list, and edit pages) that work for any type
of enterprise object. These task pages are created using special WebObjects
components called Direct to Web templates.
A Direct to Web template uses information from the entities of the enterprise objects
it displays. An entity is the piece of the model that specifies how a table maps to a
specific enterprise object. The Direct to Web template takes advantage of the entity’s
property information (that is, information about the entity’s attributes and
relationships) and determines the properties it needs to display. For example, a
Direct to Web template displaying a list page for Movie objects can determine that
it needs to display the title, release date, category, and other attributes for each
movie on the page (Figure 5-11).
Server
...
partNum W4378
...
Product attributes color Red
.. . size XL
.. .
Name External type
. ..
retail 48.99
...
partNum VARCHAR2 ..
color VARCHAR2 . . . ....
..
size VARCHAR2
retail NUMBER
Product entity Product objects
Direct to Web applications can be configured using a Java applet called the Direct
to Web Assistant. The configuration information is stored as a database of rules.
Rules say something like “if the task page is a list page and the entity is the Movie
entity, do not display the banner.” Each rule has a priority and rules with higher
priority override rules with lower priority. Direct to Web defines a set of default
rules that define the basic application behavior. You can define higher priority rules
that override the default rules for special cases. This is exactly what the Direct to
Web Assistant does. Figure 5-12 shows the relationship between the Direct to Web
template, the rule system, the rule database, and the Direct to Web Assistant.
Web Assistant
Server
Direct to Web
template
Template Rules
Code
Note that when you configure your application with the Direct to Web Assistant,
you don’t need to recompile your code to try your changes. Direct to Web is not a
code generation wizard. It generates Web pages at runtime based on the templates
and the rules.
■ Customize your Direct to Web application using the Direct to Web Assistant
(optional).
■ Further customize your Direct to Web application (optional).
Of the four steps, the last two are unique to Direct to Web and are discussed in more
detail below.
With the assistant, you can designate which entities are read-write, read-only, or
hidden. You can also set appearance parameters for most of the pages that Direct to
Web generates. For example, you can control whether or not the page displays with
a banner. You can also change the background color for the table the page displays,
if applicable. The assistant also permits you to configure the way properties
(attributes and relationships) appear on list, edit, and inspect pages.
As mentioned earlier, the assistant defines a set of rules that override the default
Direct to Web rules. Thus, the assistant is the preferred way to modify rules.
However, sometimes you need to change the default rules or override the default
rules in ways the assistant can’t. You can use an application called the Rule Editor
to edit the rules directly. Figure 5-14 shows the Rule Editor.
■ Freeze a page. When you want to change the appearance or function of a single
page in your Direct to Web application, you can freeze the page with the Direct
to Web Assistant. The page becomes a WebObjects component in your project
with a HTML template, a Java source file, and a bindings file. You can edit it
with WebObjects Builder just as you would any other component. The
downside is that you can’t customize frozen pages with the Direct to Web
Assistant.
■ Generate a Direct to Web template. Sometimes you need to change the way
every page for a particular task appears in your application. For example, you
might want to put an extra hyperlink at the bottom of every list page. To do so,
you instruct the Direct to Web Assistant to generate a Direct to Web template,
modify the template, and tell the assistant to use your customized template
instead of the standard one. As mentioned earlier, a Direct to Web template is an
ordinary WebObjects component and can be edited using WebObjects Builder.
Unlike frozen pages, Direct to Web pages based your custom template can be
customized with the assistant.
■ Modify the page wrapper and menu header. The page wrapper component is
included in your project and determines the text and elements that are common
to every page in your application except the login page. It contains the menu
header appropriate for the look. Figure 5-8 (page 54) shows the menu header for
the Basic look. The menu header is another component in your project.
■ Mix WebObjects and Direct to Web pages. You can navigate to a Direct to Web
page from a WebObjects page and vice versa. You can also embed certain Direct
to Web functions within a WebObjects page. These capabilities extend the
flexibility of Direct to Web considerably.
■ Perform other customizations. You can change almost anything in a Direct to
Web application because it is just a WebObjects application with some extra
functionality. However, you need to know the details of the Direct to Web
architecture.
is the ability to dynamically generate all of the Web pages, relieving you of
designing and coding them yourself. As a consequence, Direct to Web has the
following advantages over the HTML-based WebObjects approach:
■ It flattens the learning curve for developing applications.
■ It reduces the time required to develop applications.
■ It reduces the likelihood of errors.
■ It increases the maintainability and adaptability of applications.
■ It increases prototyping capabilities.
■ It allows you to focus on business logic instead of on the user interface.
Limitations
Because Direct to Web generates your applications for you, the applications have a
number of additional limitations.
First, the programming model is indirect. You provide a model and Direct to Web
assembles the application for you. The Web page generation is performed by a
“magic box.” You don’t have to know what’s going on. This makes it really easy to
get started programming with Direct to Web. But for certain customizations, the
learning curve gets very steep very fast.
The machinery for generating Web pages is an entirely new layer on top of the
WebObjects HTML-based application technology. This layer adds complexity that
regular HTML-based applications don’t have, and you might have to learn the
details of it to get certain results. In fact, making fundamental changes to a Direct to
Web application can be a lot of work. Note, however, that you can typically reuse
this work in later applications.
Limitations 61
Apple Computer, Inc. May 2001
C H A P T E R 5
Once you are familiar with how Direct to Web works, you can also use the Direct to
Web reusable components in a standard WebObjects HTML-based website. This
technique can dramatically reduce the development time for certain types of pages
like forms and list pages.
The Java Client approach allows you to replace the HTML user interface of a
WebObjects application with a much more interactive and flexible one written in
Java. In the sample Java Client application shown in Figure 6-1, the user interface is
like the interfaces you see in traditional desktop applications.
63
Apple Computer, Inc. May 2001
C H A P T E R 6
The Java Client architecture differs from the HTML-based WebObjects architecture
in that it’s distributed across client and server systems as shown in Figure 6-2. The
server-side portion interacts with a database server and the client-side portion
provides all or part of the application’s user interface.
Client
computer WebObjects
(user’s system)
application
(client-side)
Web server
Application
server WebObjects
application
(server-side)
Relational database
The client and server applications have duties other than merely providing the user
interface and database access—for example, each can contain business logic and
each communicates with the other through a Web server. However, the database
access/user interface division is significant because it provides a richness of user
interface without compromising security or performance. Sensitive business logic
and database connection logic is provided only by the server application. Because
compiled Java on the client side can be decompiled, the client application is limited
to user interface code and nonsensitive business logic. At the same time, the ability
to put some of the business logic on the client (any nonsensitive logic) improves
performance. By performing as much processing as possible on the client (such as
field validation), round trips to the server are limited.
Client
JFC
Custom code
WebObjects
Web server
Server
Model Custom code
WebObjects
JDBC
Relational database
The user interface itself is implemented using Java Foundation Classes (JFC). This
is what gives a Java Client application the appearance and functionality of a
traditional desktop application. WebObjects maps data between the application’s
user interface and the graph of enterprise objects. Changes to the object graph are
automatically synchronized with the user interface and user-entered data is
automatically reflected in the object graph.
Starting in the upper left of the diagram and working down, when the client
application initiates a fetch, the client application forwards the corresponding fetch
specification to the server application. From there the normal mechanisms take over
and an SQL query is performed in the database server.
Working back up the diagram on the right side, the database server returns the rows
of requested data and, as usual, this data is converted to enterprise objects. The
server then sends copies of the requested objects to the client. When the client
receives the objects, it updates its user interface with values from the requested
objects.
Client
Client side user interface
Web server
Server .
. . ...... partNum W4378
Model .. . . . color Red
WebObjects size XL
.. retail 48.99
.. . . . .. ... whole 25.00
..
Relational database
Although requested objects are copied from the server to the client, and these
objects exist in parallel object graphs on both server and client, the enterprise objects
on the client usually do not exactly mirror the enterprise objects on the server. The
objects on the client usually have a subset of the properties of the objects on the
server. You can partition your application’s enterprise objects so the objects that
exist on the client have a restricted set of data and behaviors. This ability allows you
to restrict sensitive data and business logic to the server. For example, in Figure 6-4,
the client side enterprise objects don’t have the “whole” property, the price the
seller paid to the manufacturer.
Once the client has fetched data, this data is cached and is represented internally by
the client’s object graph. As users modify the data (or delete or add “rows” of data),
the client application updates the client’s object graph to reflect the new state. When
the client application initiates a save, the changed objects are “pushed” to the server.
If the business logic on the server validates these changes, the changes are
committed to the database.
Note that Java Client automatically updates the client with changes that have
occurred on the server. Whenever the client makes a request, the server passes
updates along to the client with whatever information the client requested.
Similarly, Java Client has the opportunity to update the client before client-side
objects remotely invoke methods on server-side objects.
Other Architectures
There are other Java-based architectures besides Java Client that are also distributed
and mutiltier. This section describes how Java Client compares with the Client
JDBC and JDBC three-tier architectures.
Java Client has none of these problems. Sensitive data and business rules can be
confined to the server, so the server doesn’t have to allow indiscriminate access to
data and operations. Additionally, because the client part of a Java Client
application contains nonsensitive data and business logic, it doesn’t make nearly as
many round trips to the server or move as much data back and forth.
Other Architectures 69
Apple Computer, Inc. May 2001
C H A P T E R 6
Java Client addresses these problems as well. First, instead of using proxy business
objects on the client, the Java Client application makes use of “copies” of the objects.
Second, WebObjects provides all of the database access and user interface
synchronization with its enterprise objects technology. Finally, it provides
application server functionality and HTML integration.
The most basic tasks of creating a Java Client application are as follows:
■ Create a project using Project Builder.
■ Create a model using EOModeler.
■ Write source code for enterprise object classes.
The tasks have much in common with those for developing HTML-based
WebObjects applications. The major differences are the way you design your
enterprise object classes and the way you create your application’s user interface.
Usually, client objects have the more restricted set of data and behaviors, but it is
really up to you to decide based on the requirements of the application and your
business. As noted earlier, the primary criteria for partitioning are performance and
security.
If your application’s user interface uses static and dynamically generated HTML,
you create those parts of the user interface in the normal way with WebObjects
Builder (as described in “HTML-Based Applications” (page 37)). The process is
Note: If you’re familiar with Cocoa development, the process for creating a Java
Client user interface is nearly the same as the one for creating a Cocoa user
interface for Mac OS X applications.
Limitations
The client portion of a Java Client application can take the form of an application or
an applet. The trade-offs are different with each. Providing the client portion as an
application requires more system administration than using an HTML-based
approach. HTML-based Web applications require no software installations on
client systems. Users need only a Web browser to access the applications. With Java
Client applications, however, the application should usually be pre-installed on
client machines.
Some applications simply require the flexibility and interactivity of a Java Client
user interface—an HTML-only solution just isn’t acceptable. However, Java Client
is rarely appropriate for mass markets and highly visible websites. Typically it’s
practical only in intranet environments.
As mentioned in the last section, Java Client applications have special deployment
requirements because part of the application runs on the user’s machine. You either
need to install the client-side application on the user’s machine, which requires
system administration, or the user needs to download the client-side application,
which can take a long time if the network is slow. If neither solution is acceptable,
you need to use the WebObjects HTML-based approach or the Direct to Web
approach.
The Direct to Java Client approach provides the richness of a Java Client application
without as much work. Direct to Java Client is an add-on to Java Client that
dynamically generates user interfaces. Instead of designing a user interface for your
application, Direct to Java Client does it for you. Figure 7-1 shows the user interface
of a typical Direct to Java Client application.
75
Apple Computer, Inc. May 2001
C H A P T E R 7
The Basics
There are numerous ways to customize the default user interface Direct to Java
Client generates, so you can achieve almost any user interface you need.
Direct to Java Client applications have the same basic architecture as Java Client
applications do. The main difference is the addition of rule files that determine how
Direct to Java Client assembles a user interface for your application.
76 The Basics
Apple Computer, Inc. May 2001
C H A P T E R 7
Client
JFC
Custom code
WebObjects
Web server
Server
Model
Custom code
WebObjects
Rules
JDBC
Relational database
The tasks of creating a Direct to Java Client application are similar to writing a
Direct to Web application. There are four steps:
■ Create a Direct to Java Client project using Project Builder.
■ Create a model using EOModeler.
■ Customize your application using the Direct to Java Client Assistant (optional).
■ Further customize your application (optional).
Further information about the last two optional steps is given below.
There are also some more specialized ways to change the way Direct to Java Client
works. For example, you can get the precise user interface layout for a particular
window by freezing the interface and supplying a nib file (created in Interface
Builder the way you do for regular Java Client applications). As another example,
Direct to Java Client provides hooks you can use to introduce custom commands
into an application’s main menu. Additionally, you can also subclass Direct to Java
Client classes to change the way an application performs a particular task or to add
new functionality to the default set.
Direct to Java Client was designed to be flexible and extensible, so there are
numerous customization approaches. There are simple approaches that are
code-free and maintainable (using the assistant and writing custom rules), there are
more specialized approaches that are complex and require a lot of work, and there’s
everything in between. You can achieve almost any effect that you need. It’s
generally simply a question of which technique to use and what trade-offs you’re
willing to make.
A Direct to Java Client application is really just a specialized Java Client application,
so it has the same advantages: a rich user interface, portability, and security.
In addition, Direct to Java Client creates your application like Direct to Web does.
Thus you get the Direct to Web’s advantages as well: reduced time to develop
applications, increased stability, improved prototyping capabilities, reduced
testing requirements, and the freedom to focus on the business logic instead of the
user interface.
Limitations
Direct to Java Client applications share both the advantages and limitations of Java
Client applications. Thus, Direct to Java Client applications have the disadvantage
of requiring more system administration than HTML-based Web applications.
In addition, Direct to Java Client applications have the advantages and limitations
of Direct to Web. The learning curve is flat until you need to customize your
application; then it becomes very steep. You need to understand the layer of Direct
to Java Client that generates the user interface in addition to the Java Client
technology. Also, detailed widget placement (moving a text field three pixels to the
right, for example) is harder to do with Direct to Java Client than it is with regular
Java Client and Interface Builder.
Finally, Direct to Java Client applications are a little slower than static user
interfaces. When you start up the application or open a new type of window, Direct
to Java Client has to make round trips to the server to get the information it needs
to assemble the user interface. It has numerous optimizations to make user interface
generation fast, but it does incur a performance hit.
Once you’ve decided an application will have a Java Client user interface, try to use
Direct to Java Client to build the user interface. Direct to Java Client’s advantages
generally outweigh its disadvantages. At least prototype new applications with
Direct to Java Client, and slowly transition to regular Java Client only as needed.
The only time you might choose not to use Direct to Java Client is when you know
that your final application will have a significantly different user interface
paradigm than the one Direct to Java Client uses by default.
Choosing between the four WebObjects approaches is the first task you face as a
WebObjects programmer. To make the choice you need to consider the following
issues:
■ Are you planning to deploy over the internet or an intranet?
■ What are your user interface requirements?
■ How quickly do you need to develop the application?
The following sections, “Internet and Intranet Deployment” (page 83), “User
Interface Requirements” (page 84), and “Rapid Development Considerations”
(page 85) explore the approaches in more detail from the perspective of each of
these issues. You can also combine approaches as described in “Combining
Approaches” (page 86).
The WebObjects HTML approach is the best approach for deploying internet
applications, especially those for highly visible websites. A user on any
internet-enabled computer with a Web browser can access a WebObjects HTML
application.
You can also use Direct to Web to create your application, but the user interface is
generally not flexible enough for public websites. If you’re familiar with
WebObjects and Direct to Web, you can use Direct to Web reusable components to
accelerate the development process. See “Combining Approaches” (page 86) for
more information.
Java Client and Direct to Java Client applications are generally unsuitable for public
websites because they contain client code that runs on the user’s computer. Not only
must the user wait for this code to download, but also the quality of the user’s Java
Virtual Machine determines whether the application runs correctly, efficiently, and
attractively.
The WebObjects development approaches differ in the richness and response times
of the user interfaces and the ease in which you can make user interfaces with
specific layout and flow requirements.
When you need fast response times from your user interface (if you’re displaying
and updating real time data, for example), you should use the Java Client or Direct
to Java Client approaches. The user’s computer manages the highly interactive user
interface.
The drawback of the Java Client approaches is you need to be sure the client code is
on the user’s computer when the user runs your application. You can either install
it on the user’s computer in advance like a standalone application, which can be
inconvenient, or download it as an applet, which can take a long time.
interface’s flexibility. Direct to Web is highly customizable, but you need to have a
strong understanding of WebObjects before you can effectively customize the flow
of a Direct to Web application.
Your decision is similar if your application needs the rich and fast user interface the
Java Client approaches offer. If the user interface has specific layout and flow
requirements, you should use the Java Client approach over the Direct to Java
Client approach.
Keep in mind that the Direct to Java Client approach—including the user interface
it generates—is designed expressly for viewing and editing databases, especially
large ones. If your application requires this capability, you will probably find Direct
to Java Client’s user interface extremely well-suited for the task.
Using the Direct to Web and Direct to Java Client approaches, you can build an
application with far less time and effort than the WebObjects HTML and Java Client
approaches. You only need to provide the database-to-enterprise objects mapping
(the model) and WebObjects creates your application from it. However, the rapid
development approaches also impose a user interface on your application and you
must be adept at WebObjects and Direct to Web to override it.
There are several types of applications at which the rapid development approaches
excel because their user interface limitations aren’t an issue:
■ Database maintenance tools. These approaches create user interfaces optimized
for administering databases and are therefore well-suited for this type of
application.
■ Prototypes. You can quickly and easily test a model by creating a Direct to Web
or Direct to Java Client application based on the model. Using this application,
you can test whether the relationships and database integrity rules are correct.
■ Internal data driven applications. Direct to Web has been used to develop
in-house applications for bug and feature tracking, customer account
management, and writing online help. Direct to Java Client can be used for such
applications as well. For internal applications, the user interface polish is not as
important as development time, making these applications ideal candidates for
the WebObjects rapid development approaches.
Combining Approaches
WebObjects does not confine you to a single approach. You can switch your
approach as you develop your application or combine it with another approach.
This is possible in WebObjects because the business logic is encapsulated in
enterprise objects and not in the application.
86 Combining Approaches
Apple Computer, Inc. May 2001
C H A P T E R 8
Direct to Web also provides reusable components, of which the edit and list
components are used the most. If your application employs forms and lists that
work with enterprise objects, these components can save you a tremendous amount
of time.
You can also mix Java Client and Direct to Java Client applications. If you’re
developing a Java Client application and you need a Direct to Java Client controller
(a window that edits an enterprise object, for example), you can easily instantiate
one. Also, you can freeze an interface in Direct to Java Client and edit it with
Interface Builder.
Summary
Direct to Web has the same advantages and limitations of the WebObjects
HTML-based approach. However, it also allows you to develop data-driven
applications extremely quickly. The downside of Direct to Web is that it generates
a particular user interface that may not be suitable for your application.
Java Client applications provide the rich and fast user interfaces of client-server
desktop applications. The disadvantage of this approach is portability. You need to
install or download the application on the user’s computer.
Summary 87
Apple Computer, Inc. May 2001
C H A P T E R 8
Direct to Java Client allows you to quickly develop data-driven Java Client
applications and therefore has the advantages and disadvantages of Java Client.
However, like Direct to Web, Direct to Java Client imposes a particular user
interface that may not be suitable for your application.
Once you have decided upon an approach, you can go to companion documents
that cover the creation of WebObjects applications for each approach. These
documents are
■ Discovering WebObjects HTML
■ Discovering Java Client
■ Discovering Direct to Web
■ Discovering Direct to Java Client
The last three books are in preparation at the time of this writing.
adaptor, WebObjects A process (or a part same types of instance variables and have
of one) that connects WebObjects access to the same methods belong to the
applications to an HTTP server. same class.
89
Apple Computer, Inc. May 2001
G L O S S A R Y
enterprise object A Java object that foreign key An attribute in an entity that
conforms to the key-value coding protocol gives it access to rows in another entity. This
and whose properties (instance data) can attribute must be the primary key of the
map to stored data. An enterprise object related entity. For example, an Employee
brings together stored data with methods for entity can contain the foreign key deptID,
operating on that data. See also key-value which matches the primary key in the entity
coding; property. Department. You can then use deptID as the
source attribute in Employee and as the
entity In Entity-Relationship modeling, a destination attribute in Department to form a
distinguishable object about which data is relationship between the entities. See also
kept. For example, you can have an primary key; relationship.
Employee entity with attributes such as
lastName, firstName, address, and so on. An HTML-based application approach A
entity typically corresponds to a table in a WebObjects development approach that
relational database; an entity’s attributes, in allows you to create HTML-based Web
turn, correspond to a table’s columns. See applications.
also attribute; table.
inheritance In object-oriented
Entity-Relationship modeling A programming, the ability of a superclass to
Discipline for examining and representing pass its characteristics (methods and instance
the components and interrelationships in a variables) on to its subclasses.
database system. Also known as E-R
modeling, this discipline factors a database instance In object-oriented languages such
system into entities, attributes, and as Java, an object that belongs to (is a member
relationships. of) a particular class. Instances are created at
runtime according to the specification in the
EOModeler A tool used to create and edit class definition.
models.
Interface Builder A tool used to create and
edit graphical user interfaces like those used
in Java Client applications.
90
Apple Computer, Inc. May 2001
G L O S S A R Y
locking A mechanism to ensure that data Project Builder A tool used to manage the
isn’t modified by more than one user at a development of a WebObjects application or
time and that data isn’t read as it is being framework.
modified.
property In Entity-Relationship modeling,
look In Direct to Web applications, one of an attribute or relationship. See also
three user interface styles. The looks differ in attribute; relationship.
both layout and appearance.
record The set of values that describes a
method In object-oriented programming, a single instance of an entity; in a relational
procedure that can be executed by an object. database, a record is equivalent to a row.
model An object (of the EOModel class) referential integrity The rules governing
that defines, in Entity-Relationship terms, the the consistency of relationships.
mapping between enterprise object classes
and the database schema. This definition is
typically stored in a file created with the
91
Apple Computer, Inc. May 2001
G L O S S A R Y
relational database A database designed rule In the Direct to Web and Direct to Java
according to the relational model, which uses Client approaches, a specification used to
the discipline of Entity-Relationship customize the user interfaces of applications
modeling and the data design standards developed with these approaches.
called normal forms.
Rule Editor A tool used to edit the rules in
relationship A link between two entities Direct to Web and Direct to Java Client
that’s based on attributes of the entities. For applications.
example, the Department and Employee
entities can have a relationship based on the session A period during which access to a
deptID attribute as a foreign key in WebObjects application and its resources is
Employee, and as the primary key in granted to a particular client (typically a
Department (note that although the join browser). Also an object (of the WOSession
attribute deptID is the same for the source class) representing a session.
and destination entities in this example, it
doesn’t have to be). This relationship would table A two-dimensional set of values
make it possible to find the employees for a corresponding to an entity. The columns of a
given department. See also to-one; to-many; table represent characteristics of the entity
many-to-many; primary key; foreign key. and the rows represent instances of the
entity.
reusable component A component that can
be nested within other components and acts template In a WebObjects component, a file
like a dynamic element. Reusable containing HTML that specifies the overall
components allow you to extend the appearance of a web page generated from the
WebObject’s selection of dynamically component.
generated HTML elements.
to-many relationship A relationship in
request A message conforming to the which each source record has zero to many
Hypertext Transfer Protocol (HTTP) sent corresponding destination records. For
from the user’s Web browser to a Web server example, a department has many employees.
that asks for a resource like a Web page. See
to-one relationship A relationship in
also response.
which each source record has exactly one
response A message conforming to the corresponding destination record. For
Hypertext Transfer Protocol (HTTP) sent example, each employee has one job title.
from the Web server to the user’s Web
transaction A set of actions that is treated
browser that contains the resource specified
as a single operation.
by the corresponding request. The response
is typically a web page. See also request. uniquing A mechanism to ensure that,
within a given context, only one object is
row In a relational database, the dimension
associated with each row in the database.
of a table that groups attributes into records.
92
Apple Computer, Inc. May 2001
G L O S S A R Y
93
Apple Computer, Inc. May 2001
G L O S S A R Y
94
Apple Computer, Inc. May 2001
Index
A D
adaptor (WebObjects) 15, 41, 44 database
Apache API 44 access to 20–21
Apple documentation 10 maintenance tools 87
applet 56, 73 modifying 21
application object 41 synchronizing Java Client data 69
application process 44 tasks 20
attribute database table
editing 52 mapping to enterprise object class 29–31
database-to-objects mapping 49
database-to-objects mapping. See model
developer documentation 11–12
B Direct to Java Client 20, 62
Direct to Java Client application 77–83
batch 51 advantages of 82, 85–90
bindings file 38, 42 architecture of 78
business logic 25 combining with HTML-based approach 88
in enterprise object 34 components of 79
implementing 34–36 creating 80–82
separating from interface code 41 disadvantages of 85–90
business object 21 guidelines for choosing 83
limitations of 82–83
subclassing classes of 82
Direct to Java Client Assistant 80
C Direct to Web 19–20
client code 86 reusable components of 41
Client JDBC architecture 71 Direct to Web application 49–62
client-server communication 17, 67, 75 advantages of 60, 85–90
code file 38–39 combining with WebObjects 89
Common Gateway Interface (CGI) 16, 44 configuring 56
component 21, 37–42 customizing 59
See also page developing 57–59
creating 45 disadvantages of 85–90
editing of 38, 46 dynamically generated pages of 50
persistence of 41 fixed sructure of 55
reusable 40–41, 62, 85 guidelines for choosing 62
separating 38 limitations of 61–62
task-specific 20 modifying single page of 60
Controller object 28 overview 49
95
© Apple Computer, Inc. May 2001
INDEX
J
E
Java Client 17, 62
Edit button 52 user interface of 20
edit page 53 Java Client application 16–18, 65–76
edit-relationship page 53 advantages of 75, 85–90
enterprise object 25–36, 41–42 applets 73
advantages of 34–36 as application or applet 76
in batch 51 architecture of 66–71
configuring on list page 52 combining with HTML-based approach 88
designing for Java Client 73 creating user interface of 73–74
entity of 55 data flow in 69–70
extensibility of 26 database access 67
mapping to database table 29–31 designing enterprise objects for 73
overview 25–26 developing 72–74
reusability of 26 disadvantages of 85–90
WebObjects support for 32–34 guidelines for choosing 76
Enterprise Objects 20 limitations of 75–76
entity 55 managing user interface of 67
entity-relationship (E-R) model 29 portability of 75
EOModeler application 29, 72, 80 security in 75
Java Foundation Classes (JFC) 16, 68
Java source file 38
Java virtual machine (JVM) 88
F, G Java virtual machine (VM) 75
JDBC 2.0 driver 21
faulting 33 JDBC three-tier architecture 72
fetching 21, 33–34
foreign key 32
freeze (a page) 60
K
key-value coding 25
H
HTTP protocol 21
HTTP server 44
96
© Apple Computer, Inc. May 2001
INDEX
Q
M query page 51
query-all page 50, 51
mapping 29–31
memory usage 34
menu header 53, 60
model 27, 29 R
Model object 28
Model-View-Controller (MVC) 28 referential integrity 32
relationship
editing 53
referential integrity of 32
N request-response cycle 41
reusability 26, 28
Netscape Server API (NSAPI) 44 reusable component 40–41, 62, 85
Neutral look page 54 Rule Editor 59, 81
nib file 82 rule file 78
rules 56–57, 59, 81
O
S
object graph 67–68
on-demand locking 33 scalability 22
optimistic locking 33 security 75
server performance 22
session 41
maintaining state of 41
P SQL (Structured Query Language) 20
state management 21
page 38 static element 37
See also component static HTML publishing 14
page wrapper 60
pessimistic locking 33
portability 75
primary key 32
97
© Apple Computer, Inc. May 2001
INDEX
T overview 13–23
processes of 43
task 20, 60 server 22
task pages 55 sessions of 41
template 20 WebObjects Builder 38, 46–47, 60
template file 38–39, 46 WebObjects framework 44
transaction management 33 WebObjects look page 55
WOExtensions Framework 41
U
uniquing 33
URL (Uniform Resource Locator) 14
user interface 20
dynamically generated 77–78
requirements of 86–87
V
validation 32
variable 41, 46
View object 28
W, X, Y, Z
Web browser 43, 88
Web server 67
Web-enabled client-server application 16–18
WebObjects adaptor 15, 41, 44
WebObjects additional resources 10–12
WebObjects application 37–48
advantages of 20–23, 85–90
application object of 41
application process of 44
architecture of 43–44
combining with Direct to Web 89
combining with Java Client 88
developing 44–47
disadvantages of 85–90
HTML-based 16–17, 62
instances of 22
98
© Apple Computer, Inc. May 2001