To edit or add content to this Wiki, you can simply create a new account at http://wocommunity.org/account.
Contents |
---|
In the left pane entitled WO Package Explorer, you will see a folder icon with your applications name. Click on the triangle next to your application's folder to see the organization of your project.
This group contains initially contains two packages your.app and your.app.components. The your.app package contains .java files for the Application, Session, and DirectAction classes. You can customize your application by putting your own code in these files. You can also add other classes to your project. The your.app.components package contains the .java for the Main component that was automatically generated. Component classes are used to define the behavior of each component.
Without doing anything else, you have a WebObjects application ready to run. Select Run as... WOApplication by right-clicking on your Project folder or clicking on your project folder and then selecting Run from the menu bar.
After a moment a dialog window appears "Select Java Application." Select Application - your.app and then click OK. (After you do this the first time in a project, you can just click Run. It will keep track of which application you want to run.) A couple of quick moments should pass and your browser should open a new window with "Hello World".
Congratulations! You just created and run your first WebObjects Application. Cool, huh?
As a note, when you are done testing an app, make sure you stop it by clicking the red square in the console window at the bottom of the Eclipse window. If you forget and try to run the app again you may get errors.
Well "Hello World" is about as boring a web page as one can make. So feel free to change it. In your project's Components window, you can edit the HTML of your component by double-clicking the component itself or it's related HTML file. You can even change the default editor that Eclipse uses the edit your HTML file so you can instead use the Aptana's editor if you plan on adding a lot of Javascript or and external editor such as the brilliant TextMate. In this tutorial, we will stick to the WOLips default editor so that we have instant access to the WOD file.
Well, there are certainly easier ways of making static web pages and using WebObjects for that purpose would defeat the purpose of developing using WebObjects. So let's start to learn how to make our pages a little more dynamic.
As mentioned before, the looks and functionality of a WebObjects component are defined by several files:
XCode's one redeeming feature regarding WebObjects was the WebObjects Builder. It allowed, in my opinion, the developer to quickly "wire-up" the HTML file. While editing, the HTML file, you could easily access methods and variables in the related Java file including the getter and setter methods, and quickly bind them to the component in the HTML document by clicking and dragging. In WOLips, this must all be done a bit more manually. As of OS X 10.5, WOBuilder is longer supported, but there is a movement to get an WOBuilder replacement project started.
Every WebObjects application includes a Main component. The HTML file is mostly empty except for "Hello World." Likewise, the Java file contains very little. We will learn how to add methods and variables to the component by building a very basic calculator.
Let's start by editing the Main.java file.
WORK IN PROGRESS - More content and screenshots to be added.