Changes for page Hello World - Your First WebObjects Application
Last modified by Denis Frolov on 2012/01/21 22:03
From version 15.1
edited by Quinton Dolan
on 2007/07/08 22:50
on 2007/07/08 22:50
Change comment:
There is no comment for this version
To version 18.1
edited by Pascal Robert
on 2010/09/12 03:09
on 2010/09/12 03:09
Change comment:
There is no comment for this version
Summary
-
Page properties (3 modified, 0 added, 0 removed)
Details
- Page properties
-
- Title
-
... ... @@ -1,1 +1,1 @@ 1 - Programming__WebObjects-Hands On___Hello World - Your First WebObjects Application1 +Hello World - Your First WebObjects Application - Author
-
... ... @@ -1,1 +1,1 @@ 1 -XWiki. qdolan1 +XWiki.probert - Content
-
... ... @@ -1,8 +1,13 @@ 1 -=== CreateaNewWebObjectsProject1 +=== Note for those using WOLips or WebObjects 5.4 === 2 2 3 -Launch Xcode (found in Developer->Applications). Choose 'New Project...' from the 'File' menu to display to 'New Project' Assistant. 4 -Scroll to the bottom of the list of project types and choose 'WebObjects Application'. 3 +The following tutorial has been graciously adapted for WOLips by J. Nugent. The modified version may be found at http:~/~/people.bath.ac.uk/jen20/WebObjects-GettingStarted.pdf 5 5 5 +Perhaps the community will consent to updating this excellent page originally written by S. McCraw to include the revisions made by J. Nugent. 6 + 7 +=== Create a New WebObjects Project === 8 + 9 +Make sure that Eclipse and WOLips are [[installed>>WOL:Install WOLips with Eclipse Update Manager]]. Launch Eclipse, chosse //New//>//WebObjects Application// from the //File// menu. 10 + 6 6 Click 'Next'. 7 7 Type 'HelloWorld' as the 'Project Name' and click on the 'Set...' button to specify that you'd like to save your project to the desktop, or where ever you'd like to save your project. Note that earlier versions of WebObjects had problems building projects if their path had any spaces. 8 8 ... ... @@ -9,7 +9,7 @@ 9 9 Click 'Next' lots more times until you come to a 'Finish' button, and click it (we'll cover all those other screens later). 10 10 If you did everything right, you'll end up with something that looks like this (depending on how you've configured Xcode). 11 11 12 -=== Edit the 'Main' Component 17 +=== Edit the 'Main' Component === 13 13 14 14 You should now be looking at a brand-new WebObjects project. This is your 'blank canvas' if you're fond of analogies. 15 15 It may seem a little complicated if you're used to creating web sites that consist only of HTML files and images, but it isn't too much more complicated. The main files we're interested in are in the 'Web Components' group. ... ... @@ -16,7 +16,6 @@ 16 16 17 17 When you first create a WebObjects project, you will have just one 'Component', the 'Main' one. 18 18 A WebObjects component consists of a folder and a bunch of files, but at this stage we're really only interested in 2: 19 - 20 20 21 21 * Main.wo - which contains the interface 22 22 * Main.java - where we'll put the logic for the Main.wo page. ... ... @@ -30,7 +30,7 @@ 30 30 Finally, add a place-holder String2 by selecting 'String' from the 'WebObject' menu bar item. 31 31 You now have a finished interface: a heading inviting visitors to your web application to enter their name, a text field where they can type their name, a button so they can submit the form and a place-holder for the string of characters that you want to display in response. 32 32 33 -=== Add an Action and a Key 37 +=== Add an Action and a Key === 34 34 35 35 Now that you have an interface, you need to write the logic of your first WebObjects application. This application allows a user to type their name in to a form and displays a message in response. In order to achieve this, we're going to write a little Java code. 36 36 Each WebObjects component has a Java file that contains the logic for the component. Java is an object-oriented programming language so if you're not familiar with object-oriented programming the next section might introduce some new concepts. At this stage you don't need to know the gory details of object-oriented programming, but it might help to understand some basic terminology. ... ... @@ -68,7 +68,7 @@ 68 68 69 69 {{/code}} 70 70 71 -=== Connect the Interface to the Logic 75 +=== Connect the Interface to the Logic === 72 72 73 73 Now you've created the interface and added a variable and method to the underlying Java code, all that we need to do is 'hook-up' the interface to the logic. 74 74 We need to specify that the 'sayHello' method should happen when the button is clicked and that the value for the 'visitorsName' variable should come from the text field. To do this we need to switch back to WebObjects Builder. ... ... @@ -76,10 +76,9 @@ 76 76 Click and drag from the space next to 'visitorsName' in the bottom half of the window to the text field and choose 'value' from the drop-down menu to indicate that you want the 'visitorsName' variable to get its value from the text field. 77 77 Repeat this step to bind the 'value' of the dynamic String to the 'message' variable and the 'action' of the 'Submit' button to the 'sayHello' method in the underlying Java class. 78 78 79 - 80 80 Once you've hooked up the interface to the logic, the only thing left to do is write a line (or two) of Java code to compose a custom message in response to the click of the button. 81 81 82 -=== Edit the Java Code 85 +=== Edit the Java Code === 83 83 84 84 Open the 'Main.java' file by double-clicking on it. 85 85 Fill out the details of the sayHello method like the example below. Basically, when this method is executed we want to construct a custom message based on the variable 'visitorsName' which will contain the name of the person we want to greet. ... ... @@ -89,7 +89,7 @@ 89 89 public class Main extends WOComponent { 90 90 public String visitorsName; 91 91 public String message; 92 - 95 + 93 93 public Main(WOContext context) { 94 94 super(context); 95 95 } ... ... @@ -103,5 +103,3 @@ 103 103 {{/code}} 104 104 105 105 Congratulations - you've just written your first WebObjects application. Make sure you've saved both the Main.wo file in WebObjects Builder and the Main.java file in XCode and you're ready to compile your code and run the application. Click on the 'Build and Go' button in XCode to test your application. 106 - 107 -Category:WebObjects