-
WebObjects Overview January 2002
-
Apple Computer, Inc. © 2000–2002 Apple Computer, Inc. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, mechanical, electronic, photocopying, recording, or otherwise, without prior written permission of Apple Computer, Inc.
-
Contents Figures and Tables Chapter 1 7 About This Book 9 Why Read This Book 9 Further Investigations 10 Installed Developer Documentation Online Documentation 11 Chapter 2 What Is WebObjects? 11 13 Dynamic HTML Publishing 13 Web-Enabled Client-Server Applications 16 HTML-Based WebObjects Applications 16 Java Client Applications 17 Rapid Development 19 Direct to Web 19 Direct to Java Client 20 The WebObjects Advantage 20 Streamlined Database Access 20 Separation of Presentation, Logic, and Data 21
-
C O N T E N T S WebObjects Support for Enterprise-Object Instances The Enterprise Objects Advantage 34 Chapter 4 HTML-Based Applications 31 37 A Programmer’s View of WebObjects 37 Separating Presentation Code from Event-Handling Logic Dynamic Elements 39 Reusing Components 40 Maintaining State 41 Separating Presentation Code from Business Logic 41 The WebObjects Architecture 43 Developing a WebObjects HTML Application 44 Project Builder 45 WebObjects Builder 46 Guidelines for Choosing the HTML-Based A
-
C O N T E N T S Two Approaches to Java Client 71 Choosing an Approach 74 Java Client Architecture 76 Managing the User Interface 79 Data Synchronization Between Client and Server Dynamic User Interface Generation 81 Java Client and Other Three-Tier Systems 81 Development Tasks and Tools 83 Designing Enterprise Objects for Java Client 83 Creating the User Interface (Non-Direct) 84 Customizing the User Interface (Direct Approach) Chapter 7 J2EE Integration Enterprise JavaBeans JSP and Servlets 89 JNDI 89
-
-
Figures and Tables Chapter 2 What Is WebObjects? Figure 2-1 Figure 2-2 Figure 2-3 Figure 2-4 Chapter 3 Chapter 4 Connecting enterprise objects to data and the user interface Mapping between an enterprise object class and a single table Mapping relationships 31 Implementing business logic in enterprise objects 34 Implementing business logic in the user interface application Implementing business logic in the database 36 27 30 35 37 The files of a WebObjects component 39 How enterprise objects relate
-
F I G U R E S Figure 5-5 Figure 5-6 Figure 5-7 Figure 5-8 Figure 5-9 Figure 5-10 Figure 5-11 Figure 5-12 Figure 5-13 Figure 5-14 Figure 5-15 Chapter 6 T A B L E S An inspect page 52 An edit page 53 An edit relationship page 53 The menu header 54 An example Neutral look page 54 An example Basic look page 55 Determining attributes from the entity 56 The Direct to Web rule system 57 The Direct to Web Assistant 59 The Entities pane of the Direct to Web Assistant The Rule Editor 61 WebObjects Desktop Applic
-
C H A P T E R 1 1 About This Book WebObjects is an application server with tools, technologies and capabilities to create Internet and intranet applications. It has an object-oriented architecture that promotes quick development of reusable components. WebObjects is extremely scalable and supports high transaction volumes. This book introduces the architecture, technologies, development tools, and development approaches of WebObjects to developers and others interested in how WebObjects works.
-
C H A P T E R 1 About This Book Because WebObjects provides four distinct approaches to developing applications, this book discusses them one by one, and compares their pros and cons to help you decide which approach is appropriate for your application. This book has the following chapters: ■ “What Is WebObjects?” (page 13) introduces the technologies of WebObjects and how they fit together.
-
C H A P T E R 1 About This Book Installed Developer Documentation When you install the WebObjects Developer package on your computer, the Installer puts developer documentation into the following locations: ■ Frameworks. Information inextricably associated with a framework is usually installed in a localized subdirectory of the framework. This method of packaging ensures that the documentation moves with the framework when it is moved (or is copied) to another location.
-
-
C H A P T E R 2 2 What Is WebObjects? From an information technology perspective, WebObjects is a scalable, high-availability, high-performance application server. From the viewpoint of a developer, though, WebObjects is an extensible object-oriented platform upon which you can rapidly develop and deploy Web applications that integrate existing data and systems.
-
C H A P T E R 2 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 HTTP 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 code. Using the HTML tags embedded within the file received from the HTTP server, the browser renders the page.
-
C H A P T E R 2 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 HTTP server detects that the request is to be handled by WebObjects, it passes the request to an HTTP adaptor. The adaptor packages the incoming request in a form the WebObjects application can understand and forwards it to the application.
-
C H A P T E R 2 What Is WebObjects? This type of WebObjects application is referred to as “HTML-based,” since the result is a series of dynamically generated HTML pages. Instead of using an HTTP adaptor, you can deploy applications through servlet containers. This approach allows you take advantage of your servlet server’s application deployment facilities. For more information on this approach, see “JSP and Servlets” (page 89).
-
C H A P T E R 2 What Is WebObjects? buttons, checkboxes, and tables) to complex ones (for example, toolbars). The set of components that you can use with WebObjects is extensible, so you can create components that can be reused across all of your Web applications. Your application isn’t entirely built out of components. You create WebObjects applications from a combination of components and Java classes. You put your application-specific business logic in some of these classes.
-
C H A P T E R 2 What Is WebObjects? Figure 2-3 A website running Java Client applications WebObjects application WebObjects application WebObjects application (client portion) (client portion) (client portion) HTTP Web server
. . .
-
C H A P T E R 2 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.
-
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 rules (which you can customize), are the essential elements of your Direct to Web application. Direct to Web is highly customizable.
-
C H A P T E R 2 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 datasource. You can modify schemas, add or change databases, or even use totally a different storage mechanism without needing to rewrite your application.
-
C H A P T E R 2 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 Project Builder, an integrated development environment (IDE) that manages your Java business logic and tracks all the supporting models and components.
-
C H A P T E R 2 What Is WebObjects? Figure 2-4 Multiple instances, multiple applications Web server WebObjects adaptor Application 1 Instance 2 Application 2 Instance 3 Application 1 Instance 4 Application 2 Instance 5 Application 1 Instance 1 Application 2 Instance 2 Application 1 Instance 3 Application 1 Instance 4 Application 1 Instance 1 Application server 2 Application server 1 The WebObjects Advantage Apple Computer, Inc.
-
-
C H A P T E R 3 3 Enterprise Objects As mentioned in “What Is WebObjects?” (page 13), WebObjects applications gain much of their usefulness by interacting with a persistent data store, that is, a datasource, which is usually a database. In WebObjects, database tables are represented as collections of Java classes called enterprise objects. Enterprise objects contain the bulk of your application’s business logic, the part of the application you write regardless of which of the four approaches you take.
-
C H A P T E R 3 Enterprise Objects In addition to providing classes that manage a set of enterprise-object instances in memory, WebObjects defines an API to which enterprise objects must conform, as well as default implementations for this API. As a result, you only need to concentrate on the parts of your enterprise-object classes specific to your application.
-
C H A P T E R 3 Enterprise Objects Figure 3-1 Connecting enterprise objects to data and the user interface Model WebObjects Enterprise objects Relational database WebObjects provides a database-to-objects mapping, called a model, so your objects are independent of the database. WebObjects also provides an objects-to-interface mapping so they are independent of the user interface.
-
C H A P T E R 3 Enterprise Objects many applications as you need, with any user interface, and with any database server. Therefore, you can concentrate on coding the logic of your business while WebObjects takes care of the rest. For example, you could create an enterprise object called Customer that defines such business rules as customers must have a work or home phone number, or customers cannot spend more than their credit limit.
-
C H A P T E R 3 Enterprise Objects 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 model 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.
-
C H A P T E R 3 Enterprise Objects Figure 3-2 Mapping between an enterprise object class and a single table Talent TALEN T _ID TALENT L A S T _N A M E 1 028 Farina 1132 Feldman lastName "Farina" firstName "Dennis" FIRST_NA Den nis ME Core y In actual practice, the mapping is more flexible than this. For example: ■ You can map an entity to a single table, a subset of a table, or to more than one table.
-
C H A P T E R 3 Enterprise Objects Figure 3-3 Mapping relationships movieRoles NSMutableArray movie Movie movie TALEN T 1 028 1132 MovieRole MO VIE M O VIE _ R O LE _ I D M O VIE _ R OLE MovieRole IT L E MOVIE_ID MOVIE_ID T R iple y 501 501 A sh 501 703 Alien o Toy St WebObjects Support for Enterprise-Object Instances After your program has accumulated changes to enterprise-object instances, WebObjects analyzes the instances, generates the necessary database operations (SQL code), and
-
C H A P T E R 3 Enterprise Objects in-memory enterprise-object instances. WebObjects has mechanisms for ensuring the integrity of your data is maintained between your application and the datasource without sacrificing performance or flexibility: 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).
-
C H A P T E R 3 Enterprise Objects Locking WebObjects offers three types of locking: pessimistic, optimistic, and on-demand. Pessimistic locking 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 enterprise-object instance at the same time.
-
C H A P T E R 3 Enterprise Objects The Enterprise Objects Advantage A hallmark feature of WebObjects, especially in comparison to other solutions, is the separation of the business logic from the datasource and the user interface. In WebObjects, you put the business logic in the enterprise objects, as shown in Figure 3-4. Figure 3-4 Implementing business logic in enterprise objects Application ....... WebObjects ...... ....... ... .... .......
-
C H A P T E R 3 Enterprise Objects ■ 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.
-
C H A P T E R 3 Enterprise Objects ■ It improves back-end portability. Database vendors have different ways of implementing logic. If you have to support more than one database and you’re using WebObjects, you don’t have to implement the logic multiple times and thus suffer maintenance problems. ■ Java is a good development language. With WebObjects, you program in Java, an industrial-strength language designed from the ground up to be object-oriented.
-
C H A P T E R 4 4 HTML-Based Applications The HTML-based application approach allows you to create applications that dynamically generate HTML pages. WebObjects provides graphical tools and a set of flexible frameworks with which you can develop elaborate applications. This chapter describes how a WebObjects HTML application works, the parts of a WebObjects application the programmer sees, the advantages of using this approach, and what the development process is like.
-
C H A P T E R 4 HTML-Based Applications These advantages are discussed in more detail in the sections that follow. Separating Presentation Code from Event-Handling Logic In WebObjects, a Web page is represented by a component, an object that has both content and behavior. A component can also represent a portion of a page but usually represents an entire page, so the word page is used interchangeably with the word component.
-
C H A P T E R 4 HTML-Based Applications Figure 4-1 The files of a WebObjects component Component (Greeting.wo) Template (Greeting.html)
Greeting Hello ! Code (Greeting.java) import com.webobjects.appserver.
-
C H A P T E R 4 HTML-Based Applications Some dynamic elements have no HTML counterpart; WORepetition and WOConditional are examples. Table 4-1 lists some of the more commonly used dynamic elements.
-
C H A P T E R 4 HTML-Based Applications subcomponent. Like dynamic elements, reusable components appear in the template as a tag with a corresponding closing tag, allowing you to extend WebObjects’s repertoire of dynamic elements. The WOExtensions framework provided with WebObjects contains many useful reusable components like tables, radio button matrices, tab panels, and collapsible content.
-
C H A P T E R 4 HTML-Based Applications component’s bindings file relates the component’s enterprise-object instances to the attributes of its dynamic elements. Figure 4-2 shows how enterprise objects relate to a component in a WebObjects application. Figure 4-2 How enterprise objects relate to a WebObjects component Server Component Template ..... partNum ........ Bindings 42 . ....... ..... Code A Programmer’s View of WebObjects Apple Computer, Inc.
-
C H A P T E R 4 HTML-Based Applications The WebObjects Architecture When you run a WebObjects application, it communicates with the Web browser using the process illustrated in Figure 4-3. Figure 4-3 WebObjects HTML-based application communication chain Web browser Web server WebObjects adaptor WebObjects application WebObjects Data SQL Relational database The WebObjects Architecture Apple Computer, Inc.
-
C H A P T E R 4 HTML-Based Applications Here is a brief description of the elements involved in the communication process: ■ A Web browser. WebObjects supports all Web browsers that conform to HTML 3.2. Of course, if your application uses more advanced features like JavaScript or QuickTime, the users’ browsers must support these features. ■ A Web server.
-
C H A P T E R 4 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 assistant helps you create new WebObjects components.
-
C H A P T E R 4 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.
-
C H A P T E R 4 HTML-Based Applications Guidelines for Choosing the HTML-Based Approach The WebObjects HTML approach has the following advantages: ■ Portability. Any user with a Web browser can access a WebObjects HTML application. ■ Flexibility. You can create intricate HTML-based applications with relative ease. ■ Reduced system administration.
-
-
C H A P T E R 5 5 Direct to Web 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. Direct to Web applications have a particular structure. Every Direct to Web application begins on a login page (Figure 5-1).
-
C H A P T E R 5 Direct to Web Applications 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).
-
C H A P T E R 5 Direct to Web Applications Figure 5-3 A query page 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. Apple Computer, Inc.
-
C H A P T E R 5 Direct to Web Applications Figure 5-4 A list page 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.
-
C H A P T E R 5 Direct to Web Applications Figure 5-6 An edit page The user edits a relationship using an edit-relationship page (Figure 5-7), which edits to-many and to-one relationships. Figure 5-7 An edit relationship page 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. Apple Computer, Inc.
-
C H A P T E R 5 Direct to Web Applications Figure 5-8 The menu header 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)). Figure 5-9 54 An example Neutral look page Apple Computer, Inc.
-
C H A P T E R 5 Direct to Web Applications Figure 5-10 An example Basic look page How Direct to Web Works 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.
-
C H A P T E R 5 Direct to Web Applications 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). Figure 5-11 Determining attributes from the entity Product entity .. . ... ... Product attributes Name External type partNum VARCHAR2 color VARCHAR2 size VARCHAR2 retail NUMBER ... . .. ... Server . .... . . . . ..
-
C H A P T E R 5 Direct to Web Applications 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.
-
C H A P T E R 5 Direct to Web Applications Developing a Direct to Web Application There are four steps to creating a Direct to Web application: ■ Create a Direct to Web project using Project Builder. ■ Create a model using EOModeler. ■ 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.
-
C H A P T E R 5 Direct to Web Applications Figure 5-13 The Direct to Web Assistant With the assistant, you can designate which entities are read-write, read-only, or hidden, as shown in Chapter Figure 5-14 (page 60). 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.
-
C H A P T E R 5 Direct to Web Applications Figure 5-14 The Entities pane of the Direct to Web Assistant 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-15 shows the Rule Editor.
-
C H A P T E R 5 Direct to Web Applications Figure 5-15 The Rule Editor Further Customizing Your Direct to Web Application If you need to customize your application beyond what you can do with the Direct to Web Assistant, you can use these methods: ■ 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.
-
C H A P T E R 5 Direct to Web Applications 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.
-
C H A P T E R 5 Direct to Web Applications ■ It allows you to focus on business logic instead of on the user interface. Also, Direct to Web applications are constructed using well-tested Apple technology, which increases the stability of applications and reduces the time required to test applications before deploying them. Limitations Direct to Web is an HTML-based technology. As a result, Direct to Web user interfaces are highly portable but suffer the limited interactivity provided by HTML forms.
-
C H A P T E R 5 Direct to Web Applications Guidelines for Choosing Direct to Web If your application requires a fast graphical user interface similar to that of a desktop application, you need to use one of the Java Client approaches (Java Client or Direct to Java Client). Direct to Web produces HTML-based applications.
-
C H A P T E R 6 6 WebObjects Desktop Applications WebObjects recognizes the need for distributed, three-tier application solutions with more complex, rich, and responsive user interfaces than HTML allows. So, in addition to HTML-based WebObjects applications, you can also write Java-based WebObjects desktop applications which use Swing for the user interface.
-
C H A P T E R 6 WebObjects Desktop Applications Figure 6-1 A sample Java Client application WebObjects Java Client is a three-tier network application solution that allows you to develop platform-agnostic desktop applications with database access and rich user interfaces.
-
C H A P T E R 6 WebObjects Desktop Applications Better User Experience Java Client applications differ from HTML-based WebObjects applications in that the user interface is built on Sun's JFC/Swing classes, rather than on HTML. This allows Java Client applications to take advantage of the rich user interface elements the Swing toolkit offers.
-
C H A P T E R 6 WebObjects Desktop Applications reverting, undoing, adding objects, editing objects, and more. Furthermore, Java Client's integration with Enterprise Objects abstracts development above the need to ever write a line of SQL. And the development tools you use to build Java Client applications let you build complex user interfaces in Swing without writing any code.
-
C H A P T E R 6 WebObjects Desktop Applications When To Choose Java Client Java Client is a great technology for developing and deploying desktop applications with powerful database access in controlled network environments where the end users are known and are willing to install parts of the client application. It is not suitable, however, for use in uncontrolled Internet environments, or for mass markets.
-
C H A P T E R 6 WebObjects Desktop Applications In WebObjects 5.1, the Java Client Class Loader eases applet deployment and improves usability. Likewise, future enhancements to the JDK such as Java Web Start will ease application deployment and usability by providing caching and other mechanisms to ease client-side class management.
-
C H A P T E R 6 WebObjects Desktop Applications ■ Client-side processing: Web applications do the majority of their processing on the server, while Java Client moves much of an application’s processing to the client. This reduces the amount of client-server communication considerably, making Java Client applications much snappier than their Web counterparts. ■ User experience: These criteria all affect user experience in some way.
-
C H A P T E R 6 WebObjects Desktop Applications ■ Rule Editor ■ freezing XML ■ freezing .nib files ■ using custom controller classes ■ using factory delegates The user interfaces for the two approaches to Java Client development each have a particular character. However, keep in mind that it’s possible to customize each type of interface to look like the other.
-
C H A P T E R 6 WebObjects Desktop Applications Figure 6-2 A typical Java Client application The dynamic user interface generation provided in Direct to Java Client applications yields interfaces which resemble (page 69). However, advanced Direct to Java Client applications will likely include other, non-dynamically generated user interfaces such as custom controller classes or frozen interface files (either built in Interface Builder or in raw Swing).
-
C H A P T E R 6 WebObjects Desktop Applications Figure 6-3 A typical Direct to Java Client application Choosing an Approach Direct to Java Client simplifies many parts of the development process, and facilitates the addition of features such as localization, data access, and data model synchronization. The direct approach to Java Client is a great way to start developing Java Client applications.
-
C H A P T E R 6 WebObjects Desktop Applications techniques work at a higher level than raw Swing. You’ll also save time by learning the Direct to Java Client customization techniques rather than rolling your own Java Client interfaces in Interface Builder or in raw Swing. Table 6-1 Comparison of Java Client and Direct to Java Client Task Java Client Direct to Java Client Customization options Interface Builder and raw Swing.
-
C H A P T E R 6 WebObjects Desktop Applications Java Client Architecture 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-4. The server-side portion interacts with a database server as in HTML-based WebObjects applications, and the client-side portion, in addition to providing the application’s user interface, can also contain non-sensitive business logic.
-
C H A P T E R 6 WebObjects Desktop Applications Figure 6-5 (page 77) elaborates the architecture of Java Client applications. Figure 6-5 Architecture of a Java Client application Client JFC Custom code WebObjects Web server Server Model Custom code WebObjects JDBC Relational database The architecture of Direct to Java Client applications is slightly more complex than that of non-direct Java Client applications, as illustrated in Figure 6-6 (page 78).
-
C H A P T E R 6 WebObjects Desktop Applications Figure 6-6 Architecture of a Direct to Java Client application Client JFC Custom code WebObjects Web server Server Model Custom code WebObjects Rules JDBC Relational database 78 Java Client Architecture Apple Computer, Inc.
-
C H A P T E R 6 WebObjects Desktop Applications 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.
-
C H A P T E R 6 WebObjects Desktop Applications 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. Figure 6-7 Client Data flow in a Java Client application Client side user interface ..... partNum ........
-
C H A P T E R 6 WebObjects Desktop Applications 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.
-
C H A P T E R 6 WebObjects Desktop Applications Client JDBC applications use a fat-client architecture. Custom code invokes JDBC on the client, which in turn goes through a driver to communicate with a JDBC proxy on the server. This proxy makes the necessary client-library calls on the server. The shortcoming of this architecture are typical of all fat-client architectures.
-
C H A P T E R 6 WebObjects Desktop Applications Development Tasks and Tools 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. ■ Create your application’s user interface with Interface Builder (non-direct approach). ■ Customize your application’s user interface (Direct to Java Client approach) ■ Write source code for any application-level logic.
-
C H A P T E R 6 WebObjects Desktop Applications Creating the User Interface (Non-Direct) A Java Client WebObjects application gives you considerable flexibility in how you compose its user interface. Ideally you provide an application’s entire user interface in a single Java application that runs on the client. But you can also combine Java Client applets and static and dynamic (WebObjects) HTML elements in various ways.
-
C H A P T E R 6 WebObjects Desktop Applications Figure 6-8 Composing a user interface with Interface Builder Customizing the User Interface (Direct Approach) Writing custom rules is another way to customize your Direct to Java Client application. It’s very similar to writing custom rules for Direct to Web applications. As with Direct to Web applications, all the information about how to configure a Direct to Java Client application is stored in the form of rules.
-
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.
-
C H A P T E R 7 7 J2EE Integration Sun’s J2EE (Java 2, Enterprise Edition) platform aims at laying out an infrastructure on which solutions (components or applications) from different vendors can work together and share resources. In addition, it provides a framework on with n-tier applications can be seamlessly deployed. Enterprise JavaBeans (EJB) is an important part of J2EE. It provides an environment in which components from several manufacturers can be assembled into a working application.
-
C H A P T E R 7 J2EE Integration Enterprise JavaBeans Enterprise JavaBeans (EJB) is a specification that provides an infrastructure through which vendors can develop solutions that can be used by other vendors. The major part of these solutions are enterprise beans. Enterprise beans are business objects that contain logic used to perform specific tasks. They are similar to enterprise objects in WebObjects, but can be used in application servers by multiple vendors.
-
C H A P T E R 7 J2EE Integration JSP and Servlets Servlets are generic server extensions that expand the functionality of a server. By deploying WebObjects applications as servlets running inside servlet containers, you can take advantage of the features that your servlet container offers. Alternatively, you can deploy your applications using an HTTP adaptor that talks to your HTTP server. Deploying applications as servlets can be more efficient that using HTTP adaptors.
-
-
C H A P T E R 8 8 Choosing Your Approach Choosing between the four WebObjects approaches is the first task you face as a WebObjects programmer.
-
C H A P T E R 8 Choosing Your Approach 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.
-
C H A P T E R 8 Choosing Your Approach 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.
-
C H A P T E R 8 Choosing Your Approach 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.
-
C H A P T E R 8 Choosing Your Approach Adding Rapid Development The WebObjects HTML-based and Direct to Web approaches can be combined in many ways. You can start with a Direct to Web application, freeze and customize pages, and add your own pages. You can also start with a HTML-based application and link its components with Direct to Web pages. Direct to Web also provides reusable components, of which the edit and list components are used the most.
-
C H A P T E R 8 Choosing Your Approach 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. Where to Go From Here Once you have decided upon an approach, you can go to companion documents that cover the creation of WebObjects applications for each approach.
-
9 Glossary adaptor, WebObjects A process (or a part of one) that connects WebObjects applications to an HTTP server. same types of instance variables and have access to the same methods belong to the same class. application object An object (of the WOApplication class) that represents a single instance of a WebObjects application. The application object’s main role is to coordinate the handling of HTTP requests, but it can also maintain application-wide state information.
-
G L O S S A R Y Direct to Web template A component used in Direct to Web applications that can generate a web page for a particular task (for example, a list page) for any entity. faulting A mechanism used by WebObjects to increase performance whereby destination objects of relationships are not fetched until they are explicitly accessed. dynamic element A dynamic version of an HTML element. WebObjects includes a list of dynamic elements with which you can build your component.
-
G L O S S A R Y Java Client A WebObjects development approach that allows you to create graphical user interface applications that run on the user’s computer and communicate with a WebObjects server. Java Foundation Classes A set of graphical user interface components and services written in Java. The component set is known as Swing. JDBC Informally stands for “Java Database Connectivity.” An interface between Java platforms and databases.
-
G L O S S A R Y referential integrity The rules governing the consistency of relationships. row In a relational database, the dimension of a table that groups attributes into records. relational database A database designed according to the relational model, which uses the discipline of Entity-Relationship modeling and the data design standards called normal forms.
-
G L O S S A R Y Glossary uniquing A mechanism to ensure that, within a given context, only one object is associated with each row in the database. validation A mechanism to ensure that user-entered data lies within specified limits. WebObjects Builder A tool used to graphically edit WebObjects components. Apple Computer, Inc.
-
G L O S S A R Y Glossary 102 Apple Computer, Inc.
-
Index A adaptor (WebObjects) 15, 41, 44 Apache API 44 Apple documentation 11 applet 56, 83 applets 69 application object 41 application process 44 attribute editing 52 B batch 51 bean framework 88 stub 88 beans 88 bindings file 38, 42 business logic 25, 67 in enterprise object 34 implementing 34–36 separating from interface code 41 business object 21 business objects 69 business rules 67 bytecodes 81 C client 88 client code 92 Client JDBC applications 81 client-server communication 17, 70, 78 Client-sid
-
INDEX Direct to Java Client application advantages of 91–96 combining with HTML-based approach 94 creating 68–85 disadvantages of 91–96 extending classes of 85 Direct to Web 19–20 reusable components of 41 Direct to Web application 49–64 advantages of 62, 91–96 combining with WebObjects 95 configuring 56 customizing 61 developing 58–60 disadvantages of 91–96 dynamically generated pages of 50 fixed structure 55 guidelines for choosing 64 limitations of 63 modifying single page of 61 overview 49 reusable com
-
INDEX Java Client 17, 64 user interface of 20 Java Client application 16–18, 65–85 advantages of 91–96 applets 83 architecture of 75–80 combining with HTML-based approach 94 creating user interface of 83 data flow in 78–79 database access 78 designing enterprise objects for 82 developing 82–83 disadvantages of 91–96 managing user interface of 78 Java Client Class Loader 69 Java Foundation Classes (JFC) 16, 78 Java source file 38 Java Virtual Machine 65 Java virtual machine (JVM) 94 Java Web Start 69 JavaBe
-
INDEX primary key 32 Project Builder 22, 45, 82, 88 properties 25 displaying 55 values for 50 prototype 64, 93 proxy 81 Pure Java 22 state management 21 static element 37 static HTML publishing 14 Swing 65, 66, 74 T query page 51 query-all page 50, 51 task 20, 61 template 20 template file 38–39, 46 thread 89 Three-tier 66 transaction management 32 R U referential integrity 32 relationship editing 53 referential integrity of 32 request-response cycle 41 reusability 26, 28 reusable component 40–41, 64
-
architecture of 43–44 combining with Direct to Web 95 combining with Java Client 94 developing 44–46 disadvantages of 91–96 HTML-based 16–17, 64 instances of 22 overview 13–23 processes of 43 server 22 sessions of 41 WebObjects Builder 38, 46, 62 WebObjects framework 44 WebObjects look page 55 WebStart 69 Windows 70 WOExtensions Framework 41 X, Y, Z XML 74 107
-