An Introduction to WebObjectsby Josh Paul
WebObjects is most often referred to as an application server; however, it's much more. WebObjects consists of a set of frameworks that allow you to write cross-platform, server-distributed applications, and a set of tools to help you write them. The tools include WebObjects Builder, EOModeler, Rule Editor, and WebServices Assistant. You'll also use Project Builder and sometimes even Interface Builder.
The applications must be written in Java, but can be distributed in a variety of ways, including HTML, Java Client, or even via Web Services. Since WebObjects is Java-based, you can actually use other tools to create WO Applications, such as Eclipse, an open source Java IDE led by IBM. However, I'm going to concentrate on using Apple's tools for creating and distributing an HTML application.
Why Use WO?
WebObjects allows you to create a wide variety of applications. It's a mature suite of frameworks and tools that were obtained by Apple in its acquisition of NeXT.
WebObjects was a crown jewel at NeXT. Companies like Disney, Deutch Bank, and AAA all use(d) WebObjects to create cutting edge web applications (heck, even Dell used it). Even today, WebObjects is being used to create new and compelling applications, like the Apple Music Store.
Session by Daniel Steinberg:
Developers committed to only developing for Mac OS X benefit from learning Objective C. If you want to develop for other platforms while also creating apps that look and feel almost native on the Mac, then Java is your choice. In this session we'll look at how to tune your cross platform app for the Mac and how to take advantage of features only available on the Mac.
O'Reilly Mac OS X Conference
For $700, you get the complete WebObjects package. In the package, you'll find a developers license and a deployment license, along with a few manuals. You will be able to deploy on almost every J2EE application server or on any system running J2SE (1.3.1 or higher). However, Apple only supports deployment on Mac OS X Server, Windows 2000, or Solaris 8. As you'll discover, WebObjects is an amazing deal at almost any price. (The deployment license used to cost $50,000 just three years ago!)
What is EnterpriseObjects?
If you read about WebObjects, you're bound to come across the terms EnterpriseObjects (EOs), EOF, and EOModel. I'm sure you're wondering "What the heck is all this EO stuff?" In my opinion, EO is the greatest thing since sliced bread. However, since this is a technically sophisticated audience, I'll go into little greater detail. Also, it would be a crime to not mention EOF while talking about WO. (This is even a felony in some parts of the world.)
The Enterprise Objects Framework (EOF) helps you manage the persistence of objects. Most often, this persistence relates to a database. EOF is wonderfully database-independent, so it doesn't matter if you initially use MySQL, only to discover you've won the lottery and can grab a copy of Oracle. Of course, the more likely scenario is that your company has decided to develop against MySQL and use Oracle for deployment. In either case, a simple flip of the JDBC switch and your application has migrated from MySQL to Oracle.
Why Use EOs?
EOF allows you to store information in a database and access the information in an object-oriented manner. EOF provides a persistence layer to maintain information over an indefinite period of time, even if you turn your server off. There are a few products similar to EOF on the market, and they fall under the Object-Relational Mapping banner.
Let's Get to Work: Create a Simple Login Page
In order for you to create the next Big Thing, you'll need to learn how to use WebObjects. The first step in learning WO is to get a copy. If you're a member of the Apple Developer Connection, you should be able to download a demo version. If you're not a member, you can either join ADC or purchase a copy of WebObjects. Below, I'm going to walk you through creating a simple login page.
As a side note, I want to mention that I've been using WO/EOF since late 1999 and am still learning new features. The set of frameworks is rich and deep, so don't be surprised if you're still discovering features a few years after working with the product. As a programmer, I love this fact.
Simple Login Window using WebObjects
Create a New Project
Go ahead and launch ProjectBuilder and create a new Project. You'll notice that WO provides you with templates for nine different types of projects. You should select the WebObjects Application template.
You will need to name your Project, and then go through a series of configuration options. You can safely click on the Next button each time without changing any options.
In your new Project, you'll find a group called Web Components. When you open the Web Components group, you'll find another group called Main. Within Main you'll find:
- Main.wo: the View to be presented to the client; don't worry about Main.wo's contents.
- Main.java: the source code for your Main component.
- Main.api: a configuration file. You don't need to currently concern yourself with it.
Using WebObjects Builder
When you double-click on Main.wo, the WebObjects Builder (WOB) application will launch. Using WOB, you will be able to design your web page. You will also be able to generate Java code, which is placed into the Main.java file of your Project.
Okay, so now you have a blank web page. It's time to get going.
You'll want add a Table, to make the Login area look nice and clean. You will find the Table button in the toolbar, on the upper right-hand side; it looks like an old window. You should configure the Table to have three rows and two columns.
Since this is a Login page, you can merge the top row of the Table and
put "Please Log In..." to let the user know this is a Login
area. You also need to allow the user to enter their
password. You can merge the top two cells by using
the Merge Cells button by click-dragging across the two top cells ...
... and then clicking on the Merge Cells button, located in the Inspector panel. It looks like an X. If your Inspector panel is not visible, click on the Inspector button in the toolbar.
Once the cells are merged, you should design the table to indicate where
the user is to input the
You'll also want to add a couple of WOTextFields into the table.
Without a couple of variables, your page is pretty useless. So you need
to add them. On the bottom left side of your Main you will
see two objects,
in the Object Browser. If you control-click (or right-click) in this
area, you will get a pop-up list of options. The two items to pay attention
to are the "Add Key to ..." and "Add Action to ..."
Select the "Add Key to Main" option and name the variable
Select the Type as a String and also have WOB generate source code for
you. Java purists can select to prepend
get to their variable
returning method name.
You should also do this for the