Wiki source code of Create a new WO Component
Version 10.1 by Mike Schrag on 2005/11/19 11:42
Hide last authors
author | version | line-number | content |
---|---|---|---|
![]() |
3.1 | 1 | Let's add a new WO Component to our project. |
2 | |||
![]() |
6.1 | 3 | ~1. Right-Click/Ctrl-Click on the project and select "New" => "WOComponent" |
![]() |
3.1 | 4 | |
![]() |
6.1 | 5 | [[image:Picture 25.png]] |
6 | |||
![]() |
3.1 | 7 | ---- |
8 | |||
![]() |
6.1 | 9 | 2. The "New WebObjects Component" dialog opens. The only required field is the WOComponent name. Let's just use the default "MyComponent" as the component name. I generally deselect "Create body tag" and "Create api file", but you can leave them if you'd like. Click "Finish" to continue. |
![]() |
3.1 | 10 | |
![]() |
6.1 | 11 | [[image:Picture 26.png]] |
![]() |
3.1 | 12 | |
13 | ---- | ||
14 | |||
![]() |
6.1 | 15 | 3. You should now have a new MyComponent.java in your source folder, a MyComponent.wo folder at the project root (or whereever you decide to add the component), a wod, woo, html, and optional api file, and the Component Editor should now open to show your new component. |
![]() |
3.1 | 16 | |
![]() |
6.1 | 17 | [[image:Picture 27.png]] |
![]() |
3.1 | 18 | |
19 | ---- | ||
20 | |||
![]() |
6.1 | 21 | 4. Switch to the "Java" tab and add the "greeting" method as defined in the picture below and save. |
![]() |
3.1 | 22 | |
![]() |
6.1 | 23 | [[image:Picture 28.png]] |
![]() |
3.1 | 24 | |
25 | ---- | ||
26 | |||
![]() |
6.1 | 27 | 5. Now switch to the "Component" tab, add a <webobject> tag in the HTML and save, then the WOD definition and save. Note that you must save each of the editors individually for changes to be visible ~-~- even in the split view. If your file is unsaved, you will see a "**" next to the filename in the tab at the top of the editor.** |
![]() |
3.1 | 28 | |
![]() |
6.1 | 29 | [[image:Picture 29.png]] |
![]() |
3.1 | 30 | |
31 | ---- | ||
32 | |||
![]() |
6.1 | 33 | 6. Now switch to your Main.wo Component Editor "Component" tab and add a <webobject> tag named "Greeting" and save. Switch to the WOD editor and add a Greeting element that is of type "MyComponent" (you'll notice that code completion now shows MyComponent in the list, because it is a subclass of WOElement). |
![]() |
3.1 | 34 | |
![]() |
6.1 | 35 | [[image:Picture 30.png]] |
![]() |
3.1 | 36 | |
37 | ---- | ||
38 | |||
![]() |
6.1 | 39 | 7. Adding a new Java file technically is not a violation of Hot Code Replacement, however, WO seems to not like a new HTML template appearing in your bundle that it doesn't know about. So go ahead and stop your app if it's running and then re-debug it (from the previous instructions). You should now have a "Hello!" in Main.wo is generated by the embedded MyComponent component. |
![]() |
3.1 | 40 | |
![]() |
6.1 | 41 | [[image:Picture 31.png]] |
42 | |||
![]() |
3.1 | 43 | ---- |
44 | |||
![]() |
8.1 | 45 | 8. Continue on to see how to [[Add a Framework Dependency]] to your project. |