Changes for page Your First Rest Project

Last modified by Steve Peery on 2013/09/06 11:02

From version 41.1
edited by Pascal Robert
on 2012/08/09 05:07
Change comment: There is no comment for this version
To version 51.1
edited by Steve Peery
on 2023/11/13 11:54
Change comment: Renamed from xwiki:WEB.Your First Rest Project

Summary

Details

Page properties
Parent
... ... @@ -1,0 +1,1 @@
1 +Getting Started
Author
... ... @@ -1,1 +1,1 @@
1 -XWiki.probert
1 +XWiki.speery
Tags
... ... @@ -1,0 +1,1 @@
1 +tutorials
Content
... ... @@ -1,4 +1,4 @@
1 -{{toc}}{{/toc}}
1 +{{toc/}}
2 2  
3 3  = Introduction =
4 4  
... ... @@ -10,7 +10,7 @@
10 10  
11 11  = Create a new project =
12 12  
13 -You will need to create a new project for this tutorial. In Eclipse, open the **File** menu, select **New** and select **Wonder REST Application**. Name your project as //BlogRest//.
13 +You will need to create a new project for this tutorial. In Eclipse, open the **File** menu, select **New** and select **Wonder REST Application** (or **ERRest Application**, according to //your// WOLips version). Name your project as //BlogRest//.
14 14  
15 15  = Create the database model =
16 16  
... ... @@ -20,20 +20,93 @@
20 20  
21 21  BlogEntry will have the following columns:
22 22  
23 -|= Column name |= Type |= Constraints
24 -| id | integer | primary key
25 -| title | string(255) |
26 -| content | string(4000) |
27 -| creationDate | timestamp |
28 -| author | integer | relation with Author
23 +|=(((
24 +Column name
25 +)))|=(((
26 +Type
27 +)))|=(((
28 +Constraints
29 +)))
30 +|(((
31 +id
32 +)))|(((
33 +integer
34 +)))|(((
35 +primary key
36 +)))
37 +|(((
38 +title
39 +)))|(((
40 +string(255)
41 +)))|(((
42 +
43 +)))
44 +|(((
45 +content
46 +)))|(((
47 +string(4000)
48 +)))|(((
49 +
50 +)))
51 +|(((
52 +creationDate
53 +)))|(((
54 +timestamp
55 +)))|(((
56 +
57 +)))
58 +|(((
59 +lastModified
60 +)))|(((
61 +timestamp
62 +)))|(((
63 +
64 +)))
65 +|(((
66 +author
67 +)))|(((
68 +integer
69 +)))|(((
70 +relation with Author
71 +)))
29 29  
30 30  Author will have the following columns:
31 31  
32 -|= Column name |= Type |= Constraints
33 -| id | integer | primary key
34 -| firstName | string(50) |
35 -| lastName | string(50) |
36 -| email | string(100) | unique
75 +|=(((
76 +Column name
77 +)))|=(((
78 +Type
79 +)))|=(((
80 +Constraints
81 +)))
82 +|(((
83 +id
84 +)))|(((
85 +integer
86 +)))|(((
87 +primary key
88 +)))
89 +|(((
90 +firstName
91 +)))|(((
92 +string(50)
93 +)))|(((
94 +
95 +)))
96 +|(((
97 +lastName
98 +)))|(((
99 +string(50)
100 +)))|(((
101 +
102 +)))
103 +|(((
104 +email
105 +)))|(((
106 +string(100)
107 +)))|(((
108 +unique
109 +)))
37 37  
38 38  == Creating the EOModel ==
39 39  
... ... @@ -41,16 +41,34 @@
41 41  
42 42  An EOModel consists of entities, attributes and relationships. When using it in a RDBMS context, an entity is a table (or a view), an attribute is a table column and a relationship is a join between two tables.
43 43  
44 -To create the EOModel, in the project right-click on the project name and select **New** > **EOModel**.
117 +To create the EOModel, in the project right-click on the project name and select **New** -> **EOModel**.
45 45  
46 46  Name it **BlogModel** and in the plugin list, select **H2**. Click **Finish**.
47 47  
48 48  The model should show up in a window that looks like this:
49 49  
123 +[[image:attach:EOModeler.png]]
124 +
50 50  If it didn't show up, the window might have opened behind the main Eclipse window. If that's the case, open the **Window** menu and select the windows that have //Entity Modeler// in its name.
51 51  
52 -In the Entity Modeler window, click on **Default**, and for the **URL** field, type {{code}}jdbc:h2:~/BlogTutorial{{/code}}. When the database will be created, it will be stored in your home directory (/Users/youruser/ on OS X).
127 +In the Entity Modeler window, click on **Default**, and for the **URL** field, type
53 53  
129 +{{code}}
130 +jdbc:h2:~/BlogTutorial
131 +{{/code}}
132 +
133 +. When the database will be created, it will be stored in your home directory (/Users/youruser/ on OS X).
134 +
135 +You can also specify an absolute path where to store in you h2 database files. For example on Windows OS **URL** field can be like this:
136 +
137 +{{code}}
138 +jdbc:h2:C:/Users/ ... /BlogTutorial
139 +{{/code}}
140 +
141 +//Notice, in the path, *nix like file separator "/" instead of Windows like// "\" (as you can read [[here>>url:http://www.h2database.com/html/faq.html||shape="rect"]]).
142 +
143 +
144 +
54 54  Now, right-click on **BlogModel** and select **New Entity**.
55 55  
56 56  Type the following details in the **Basic** tab:
... ... @@ -71,35 +71,97 @@
71 71  
72 72  Now, repeat the last two steps to create the other attributes for the **BlogEntry** entity, with the following values:
73 73  
74 -|= Attribute name |= Column |= Prototype
75 -| content | content | longtext
76 -| creationDate | creationDate | dateTime
165 +|=(((
166 +Attribute name
167 +)))|=(((
168 +Column
169 +)))|=(((
170 +Prototype
171 +)))
172 +|(((
173 +content
174 +)))|(((
175 +content
176 +)))|(((
177 +longtext
178 +)))
179 +|(((
180 +creationDate
181 +)))|(((
182 +creationDate
183 +)))|(((
184 +dateTime
185 +)))
186 +|(((
187 +lastModified
188 +)))|(((
189 +lastModified
190 +)))|(((
191 +dateTime
192 +)))
77 77  
78 78  If you did everything well, the list of attributes should look like this:
79 79  
196 +[[image:attach:list_wlock.png]]
197 +
80 80  You will notice that the attributes have a column with a lock in it. When a lock is present, it will use the value of that attribute for //UPDATE ... WHERE attribute = ''// statement. This is to do optimistic locking, aka to prevent data conflict when the data object was modified by two different users. Using timestamps for optimistic locking is not a good idea because for certain RDBMS, the value can be different because of milliseconds, so remove the locks on the **creationDate** attribute. The final list should look like this:
81 81  
200 +[[image:attach:list.png]]
201 +
82 82  Next step is to create the **Author** entity. Create a new entity with **Author** at its name (and also as the table name), and for the class name, use **your.app.model.Author**. The attributes for this entity are:
83 83  
84 -|= Attribute name |= Column |= Prototype
85 -| firstName | firstName | varchar50
86 -| lastName | lastName | varchar50
87 -| email | email | varchar100
204 +|=(((
205 +Attribute name
206 +)))|=(((
207 +Column
208 +)))|=(((
209 +Prototype
210 +)))
211 +|(((
212 +firstName
213 +)))|(((
214 +firstName
215 +)))|(((
216 +varchar50
217 +)))
218 +|(((
219 +lastName
220 +)))|(((
221 +lastName
222 +)))|(((
223 +varchar50
224 +)))
225 +|(((
226 +email
227 +)))|(((
228 +email
229 +)))|(((
230 +varchar100
231 +)))
88 88  
89 89  Final list of attributes should look like this:
90 90  
235 +[[image:attach:author_list.png]]
236 +
91 91  Now, it's time to link the two entities together. An Author can have multiple blog entries, and a BlogEntry can only have one author. To create the relationship (the join), right-click on **Author** and select **New Relationship**. On your right, select **BlogEntry** in the list. On your left, select **to many BlogEntries**, and on your right, select **to one Author**. Now, in BlogEntry, we need to store the primary key of the author so that we can make the join. The relationship builder allow us to add that attribute, so make sure **and a new foreign key named** is checked (it is checked by default). The **Create Relationship** pane should look like this:
92 92  
239 +[[image:attach:relationship.png]]
240 +
93 93  If you check in the **Outline** tab, you should see that **Author** now have a **blogEntries** relationship, and **BlogEntry** have a **author** relationship.
94 94  
95 -You are now ready to save the model. Save it (File > Save) and close the **Entity Modeler** window. If you open the **Sources** in the main Eclipse window, you will notice that the **Sources** folder contains a package named **your.app.model**.
243 +[[image:attach:outline_tab.png]]
96 96  
97 -That package have four Java classes: **Author**, **Author**, **BlogEntry** and **BlogEntry**. Those classes were generated by Veogen, a templating engine build on Velocity. The two classes that starts with a underscore are recreated every time you change the EOModel, so if you want to change something in those classes, you need to change the template (no need for that right now). But you can change freely the two classes that don't have the underscore, and this is what we will be doing.
245 +You are now ready to save the model. Save it (File -> Save) and close the **Entity Modeler** window. If you open the **Sources** in the main Eclipse window, you will notice that the **Sources** folder contains a package named **your.app.model**. (If this folder doesn't appear, you may need to set your preferences to automatically generate these source files; see the second suggestion on [[http:~~/~~/wiki.wocommunity.org/display/documentation/Useful+Eclipse+or+WOLips+Preferences>>url:http://wiki.wocommunity.org/display/documentation/Useful+Eclipse+or+WOLips+Preferences||rel="nofollow" shape="rect" class="external-link"]].)
98 98  
247 +
248 +
249 +That package have four Java classes: **_Author**, **Author**, **_BlogEntry** and **BlogEntry**. Those classes were generated by Veogen, a templating engine build on Velocity. The two classes that starts with a underscore are recreated every time you change the EOModel, so if you want to change something in those classes, you need to change the template (no need for that right now). But you can change freely the two classes that don't have the underscore, and this is what we will be doing.
250 +
251 +
252 +
99 99  What we are going to do is to write a simple method that returns the full name of an author, e.g. a method that simply concatenate the first name, a space and the last name of the author. To do so, double-click on **Author.java** and add the following methods:
100 100  
101 101  {{code}}
102 -
103 103  public String fullName() {
104 104   return this.firstName() + " " + this.lastName();
105 105   }
... ... @@ -109,16 +109,17 @@
109 109  Nothing fancy here. Now open **BlogEntry.java** and add the following method:
110 110  
111 111  {{code}}
112 -
113 -@Override
265 + @Override
114 114   public void awakeFromInsertion(EOEditingContext editingContext) {
115 - super.awakeFromInsertion(editingContext);
116 - this.setCreationDate(new NSTimestamp());
267 + super.awakeFromInsertion(editingContext);
268 + NSTimestamp now = new NSTimestamp();
269 + setCreationDate(now);
270 + setLastModified(now);
117 117   }
118 118  
119 119  {{/code}}
120 120  
121 -Why are we adding this? **awakeFromInsertion** is a very good way of setting default values when creating a new instance of a Enterprise Object (EO). In this case, we want to set automatically the creation date without having the user to add that value.
275 +Why are we adding this? **awakeFromInsertion** is a very good way of setting default values when creating a new instance of a Enterprise Object (EO). In this case, we want to set automatically the creation and last modification dates without having the user to add those values.
122 122  
123 123  Now, let's use migrations to actually create the database.
124 124  
... ... @@ -137,7 +137,6 @@
137 137  Remove the pound char in front of those two properties:
138 138  
139 139  {{code}}
140 -
141 141  #er.migration.migrateAtStartup=true
142 142  #er.migration.createTablesIfNecessary=true
143 143  
... ... @@ -146,16 +146,14 @@
146 146  After removing the pound char, the two properties should look like this:
147 147  
148 148  {{code}}
149 -
150 150  er.migration.migrateAtStartup=true
151 151  er.migration.createTablesIfNecessary=true
152 152  
153 153  {{/code}}
154 154  
155 -You are now ready to start the application so that it creates the database To do so, right-click on **Application.java** (in the **your.app** folder) and select **Run As** > **WOApplication**. In Eclipse's Console tab, you should see some output, including something similar to:
307 +You are now ready to start the application so that it creates the database! To do so, right-click on **Application.java** (in the **your.app** folder) and select **Run As** -> **WOApplication**. In Eclipse's Console tab, you should see some output, including something similar to:
156 156  
157 157  {{code}}
158 -
159 159  BlogRest[62990] INFO er.extensions.migration.ERXMigrator - Upgrading BlogModel to version 0 with migration 'your.app.model.migrations.BlogModel0@4743bf3d'
160 160  BlogRest[62990] INFO er.extensions.jdbc.ERXJDBCUtilities - Executing CREATE TABLE Author(email VARCHAR(100) NOT NULL, firstName VARCHAR(50) NOT NULL, id INTEGER NOT NULL, lastName VARCHAR(50) NOT NULL)
161 161  BlogRest[62990] INFO er.extensions.jdbc.ERXJDBCUtilities - Executing ALTER TABLE Author ADD PRIMARY KEY (id)
... ... @@ -166,7 +166,7 @@
166 166  
167 167  {{/code}}
168 168  
169 -If you see this and that the application is running (it should open a window in your favorite browser), migration worked and your database have been created, congratulations You can now stop the application (click the square red button in Eclipse's Console tab) and continue to the next step.
320 +If you see this and that the application is running (it should open a window in your favorite browser), migration worked and your database have been created, congratulations! You can now stop the application (click the square red button in Eclipse's Console tab) and continue to the next step.
170 170  
171 171  = Creating REST controllers and routes =
172 172  
... ... @@ -203,15 +203,14 @@
203 203  * **indexAction**: to list all (or a sublist) of the objects.
204 204  
205 205  {{info}}
206 -In Project Wonder, *Action* at the end of a method is a convention for REST and Direct Actions, when you call those methods from certain components, you don't need to add the *Action* part.
357 +In Project Wonder, **Action** at the end of a method is a convention for REST and Direct Actions, when you call those methods from certain components, you don't need to add the **Action** part.
207 207  {{/info}}
208 208  
209 -For this tutorial, we will implement the **createAction** and **indexAction** methods. But first, we need to create a key filter. A key filter will... filter the input and the output of REST request so that you don't have to send all attributes for a blog entry. For example, we want to show the details for an author, but we don't want to show the password for the author (in real-life, the password would be encrypted)
360 +For this tutorial, we will implement the **createAction** and **indexAction** methods. But first, we need to create a key filter. A key filter will... filter the input and the output of REST request so that you don't have to send all attributes for a blog entry. For example, we want to show the details for an author, but we don't want to show the password for the author (in real-life, the password would be encrypted)!
210 210  
211 211  Add this method in **BlogEntryController**:
212 212  
213 213  {{code}}
214 -
215 215  protected ERXKeyFilter filter() {
216 216   ERXKeyFilter personFilter = ERXKeyFilter.filterWithAttributes();
217 217   personFilter.setAnonymousUpdateEnabled(true);
... ... @@ -228,7 +228,6 @@
228 228  Now, let's implement the **createAction** method:
229 229  
230 230  {{code}}
231 -
232 232  public WOActionResults createAction() throws Throwable {
233 233   BlogEntry entry = create(filter());
234 234   editingContext().saveChanges();
... ... @@ -242,7 +242,6 @@
242 242  Last step in the controller: implementing the **indexAction** method. Again, the code is simple:
243 243  
244 244  {{code}}
245 -
246 246  public WOActionResults indexAction() throws Throwable {
247 247   NSArray<BlogEntry> entries = BlogEntry.fetchAllBlogEntries(editingContext());
248 248   return response(entries, filter());
... ... @@ -259,7 +259,6 @@
259 259  A route in ERRest is simply a way to define the URL for the entities and to specify which controller the route should use. When your controller extends from **ERXDefaultRouteController**, it's easy to register a controller and a route. In **Application.java**, in the **Application** constructor, add the following code:
260 260  
261 261  {{code}}
262 -
263 263  ERXRouteRequestHandler restRequestHandler = new ERXRouteRequestHandler();
264 264   restRequestHandler.addDefaultRoutes(BlogEntry.ENTITY_NAME);
265 265   ERXRouteRequestHandler.register(restRequestHandler);
... ... @@ -269,13 +269,13 @@
269 269  
270 270  The **addDefaultRoutes** method do all of the required magic, and use convention. That's why we had to name the controller **BlogEntryController**, because the convention is <EntityName>Controller.
271 271  
272 -We are now reading to add and list blog postings Start the application and take notice of the URL. It should be something like //[[http:~~/~~/yourip:someport/cgi-bin/WebObjects/BlogRest.woa>>http://yourip:someport/cgi-bin/WebObjects/BlogRest.woa_]]//
419 +We are now reading to add and list blog postings! Start the application and take notice of the URL. It should be something like _[[http:~~/~~/yourip:someport/cgi-bin/WebObjects/BlogRest.woa_>>url:http://youripsomeport||shape="rect"]]
273 273  
274 274  == Adding posts and authors with curl ==
275 275  
276 276  Since we didn't implement any HTML for our REST routes, we will create blog entries with //curl//, an open source HTTP client that is bundled with Mac OS X (you can use another client, like wget, if you like too). So let's create a blog entry.
277 277  
278 -To create a blog entry, you need to use the POST HTTP method. We will use JSON as the format since it's a bit less chatty than XML. So if the URL to the application is //[[http:~~/~~/192.168.0.102:52406/cgi-bin/WebObjects/BlogRest.woa>>http://192.168.0.102:52406/cgi-bin/WebObjects/BlogRest.woa_]], the full curl// command will be:
425 +To create a blog entry, you need to use the POST HTTP method. We will use JSON as the format since it's a bit less chatty than XML. So if the URL to the application is //[[http:~~/~~/192.168.0.102:52406/cgi-bin/WebObjects/BlogRest.woa_>>url:http://192.168.0.102:52406/cgi-bin/WebObjects/BlogRest.woa_||shape="rect"]], the full _curl// command will be:
279 279  
280 280  {{code}}
281 281  curl -X POST -v -d '{ "title": "First post", "content": "Some text", "author": { "firstName": "Pascal", "lastName": "Robert", "email": "probert@macti.ca" } }' http://192.168.0.102:52406/cgi-bin/WebObjects/BlogRest.woa/ra/blogEntries.json
... ... @@ -284,7 +284,6 @@
284 284  The response should look this:
285 285  
286 286  {{code}}
287 -
288 288  HTTP/1.0 201 Apple WebObjects
289 289  Content-Length: 249
290 290  x-webobjects-loadaverage: 0
... ... @@ -297,7 +297,6 @@
297 297  To get a list of blog entries:
298 298  
299 299  {{code}}
300 -
301 301  curl -X GET http://192.168.0.102:52406/cgi-bin/WebObjects/BlogRest.woa/ra/blogEntries.json
302 302  
303 303  {{/code}}
... ... @@ -309,7 +309,6 @@
309 309  Now, let's build a HTML view for blog posts (you don't want your readers to get your posts by JSON, right?). Again, we will use convention to make it work easily. Open up **BlogEntryController** and add the following method:
310 310  
311 311  {{code}}
312 -
313 313  @Override
314 314   protected boolean isAutomaticHtmlRoutingEnabled() {
315 315   return true;
... ... @@ -317,12 +317,11 @@
317 317  
318 318  {{/code}}
319 319  
320 -Switching the return value of this method says that we will follow a certain convention for HTML components. The convention for automatic HTML routing is that the component should be named <EntityName><Action>Page.wo. So in our case, the component will be **BlogEntryIndexPage**. Right-click on the project name in Eclipse and select **New** > **WOComponent**. Change the name to **BlogEntryIndexPage** and check the **Create HTML contents** button. Click **Finish**.
464 +Switching the return value of this method says that we will follow a certain convention for HTML components. The convention for automatic HTML routing is that the component should be named <EntityName><Action>Page.wo. So in our case, the component will be **BlogEntryIndexPage**. Right-click on the project name in Eclipse and select **New** -> **WOComponent**. Change the name to **BlogEntryIndexPage** and check the **Create HTML contents** button. Click **Finish**.
321 321  
322 322  The next step to get it to work is to make **BlogEntryIndexPage** to implement the **er.rest.routes.IERXRouteComponent** interface.
323 323  
324 324  {{code}}
325 -
326 326  import er.rest.routes.IERXRouteComponent;
327 327  
328 328  public class BlogEntryIndexPage extends WOComponent implements IERXRouteComponent {
... ... @@ -332,7 +332,6 @@
332 332  So now, the automatic HTML routing will send the request for **ra/blogEntries.html** to the **BlogEntryIndexPage** component. But we don't have any content in this component, so let's make a method to fetch all blog entries per creation date in descending order. So in **BlogEntryIndexPage.java**, add the following method:
333 333  
334 334  {{code}}
335 -
336 336  public NSArray<BlogEntry> entries() {
337 337   EOEditingContext ec = ERXEC.newEditingContext();
338 338   return BlogEntry.fetchAllBlogEntries(ec, BlogEntry.CREATION_DATE.descs());
... ... @@ -343,7 +343,6 @@
343 343  We need to use that method in a WORepetition, and for that loop, we need a BlogEntry variable to iterate in the list, so add the following code to **BlogEntryIndexPage.java**:
344 344  
345 345  {{code}}
346 -
347 347  private BlogEntry entryItem;
348 348  
349 349   public BlogEntry entryItem() {
... ... @@ -359,7 +359,6 @@
359 359  The Java part is done, so let's add the loop inside the component. Open **BlogEntryIndexPage.wo** (it's located in the **Component** folder) and right after the <body> tag, add:
360 360  
361 361  {{code}}
362 -
363 363  <wo:loop list="$entries" item="$entryItem">
364 364   <p><wo:str value="$entryItem.title" /></p>
365 365   <p><wo:str value="$entryItem.author.fullName" /></p>
... ... @@ -369,14 +369,13 @@
369 369  
370 370  That component code will loop over the blog entries and display the title of the entry + the name of the author. Save everything and run the application.
371 371  
372 -If you go to [[http://192.168.0.102:52406/cgi-bin/WebObjects/BlogRest.woa/ra/blogEntries.html]], you will see the list of blog entries
512 +If you go to [[http:~~/~~/192.168.0.102:52406/cgi-bin/WebObjects/BlogRest.woa/ra/blogEntries.html>>url:http://192.168.0.102:52406/cgi-bin/WebObjects/BlogRest.woa/ra/blogEntries.html||shape="rect"]], you will see the list of blog entries!
373 373  
374 374  Now that we have a list of blog entries, let's make a page to show the content of a blog entry. Create a new component named **BlogEntryShowPage**.
375 375  
376 -Open **BlogEntryShowPage.java** and make sure the class implements&nbsp;**er.rest.routes.IERXRouteComponent**.
516 +Open **BlogEntryShowPage.java** and make sure the class implements **er.rest.routes.IERXRouteComponent**.
377 377  
378 378  {{code}}
379 -
380 380  import er.rest.routes.IERXRouteComponent;
381 381  
382 382  public class BlogEntryShowPage extends WOComponent implements IERXRouteComponent {
... ... @@ -386,7 +386,6 @@
386 386  We need to add other methods to receive the BlogEntry object from the controller. In **BlogEntryShowPage.java**, add:
387 387  
388 388  {{code}}
389 -
390 390  private BlogEntry blogEntry;
391 391  
392 392   @ERXRouteParameter
... ... @@ -405,7 +405,6 @@
405 405  The Java part of the work is done, so save the Java class. It's time to work on the component part. Open **BlogEntryShowPage.wo** and between the <body></body> part, add:
406 406  
407 407  {{code}}
408 -
409 409  <h1><wo:str value="$blogEntry.title" /></h1>
410 410   <p><wo:str value="$blogEntry.content" /></p>
411 411   <p>Created on: <wo:str value="$blogEntry.creationDate" dateformat="%Y/%m/%d" /></p>
... ... @@ -416,7 +416,6 @@
416 416  Our view component is done, the only thing remaining is a link for the blog entry list (BlogEntryIndexPage) to the view page (BlogEntryShowPage). Save **BlogEntryShowPage.wo** and open **BlogEntryIndexPage.wo**. We are going to add a link on the title, you will replace to replace this:
417 417  
418 418  {{code}}
419 -
420 420  <p><wo:str value="$entryItem.title" /></p>
421 421  
422 422  {{/code}}
... ... @@ -424,11 +424,10 @@
424 424  with:
425 425  
426 426  {{code}}
427 -
428 428  <p><wo:ERXRouteLink entityName="BlogEntry" record="$entryItem" action="show"><wo:str value="$entryItem.title" /></wo:ERXRouteLink></p>
429 429  
430 430  {{/code}}
431 431  
432 -Save the component and run the app. Go to [[http://192.168.0.102:52406/cgi-bin/WebObjects/BlogRest.woa/ra/blogEntries.html]] to get the list of posts, and you should see a link on the title. Click on it, and now you get the full details of the blog entry
567 +Save the component and run the app. Go to [[http:~~/~~/192.168.0.102:52406/cgi-bin/WebObjects/BlogRest.woa/ra/blogEntries.html>>url:http://192.168.0.102:52406/cgi-bin/WebObjects/BlogRest.woa/ra/blogEntries.html||shape="rect"]] to get the list of posts, and you should see a link on the title. Click on it, and now you get the full details of the blog entry!
433 433  
434 -The REST part of this tutorial is now complete, [[you can now move to the next part of the tutorial>>Your First Framework]].
569 +The REST part of this tutorial is now complete, [[you can now move to the next part of the tutorial>>doc:WEB.Home.Getting Started.Your First Framework.WebHome]].
EOModeler.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.XWikiGuest
Size
... ... @@ -1,0 +1,1 @@
1 +34.6 KB
Content
author_list.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.XWikiGuest
Size
... ... @@ -1,0 +1,1 @@
1 +8.4 KB
Content
list.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.XWikiGuest
Size
... ... @@ -1,0 +1,1 @@
1 +9.6 KB
Content
list_wlock.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.XWikiGuest
Size
... ... @@ -1,0 +1,1 @@
1 +11.1 KB
Content
outline_tab.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.XWikiGuest
Size
... ... @@ -1,0 +1,1 @@
1 +10.6 KB
Content
relationship.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.XWikiGuest
Size
... ... @@ -1,0 +1,1 @@
1 +23.2 KB
Content
XWiki.XWikiComments[0]
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.franc
Comment
... ... @@ -1,0 +1,5 @@
1 +In "Creating the EOModel"
2 +
3 +"You are now ready to save the model. Save it (File -> Save) ???? ( where is this ?) and close the **Entity Modeler** window. If you open the **Sources** in the main Eclipse window, you will notice that the **Sources** folder contains a package named **your.app.model**."
4 +
5 +Using a new Golipse install, should this automatic sources creation just work after saving the Model or is there something to configure before ? (Automatically run EOGenerator in WOLips is checked)
Date
... ... @@ -1,0 +1,1 @@
1 +2012-05-23 17:14:53.92
XWiki.XWikiComments[1]
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.cdvalverdeg
Comment
... ... @@ -1,0 +1,28 @@
1 +**When i executed this: **
2 +
3 +(% style="color: rgb(0,0,0);" %)//curl -X POST -v -d '{ "title": "First post", "content": "Some text", "author": { "firstName": "Pascal", "lastName": "Robert", "email": "[[(% style="color: rgb(0, 0, 0); color: rgb(0, 0, 0)" %)probert@macti.ca>>mailto:probert@macti.ca||shape="rect"]](%%)" } }' [[(% style="color: rgb(0, 0, 0); color: rgb(0, 0, 0)" %)http:~~/~~/127.0.0.1:60530~~/~~/cgi-bin/WebObjects/BlogRest.woa/ra/blgEntries.json>>url:http://127.0.0.1:60530//cgi-bin/WebObjects/BlogRest.woa/ra/blgEntries.json||shape="rect"]]//
4 +
5 +**And i get this message in terminal:**
6 +
7 +//* About to connect() to 127.0.0.1 port 60530 (#0)//
8 +//* Trying 127.0.0.1... connected//
9 +//* Connected to 127.0.0.1 (127.0.0.1) port 60530 (#0)//
10 +//> POST ~/~/cgi-bin/WebObjects/BlogRest.woa/ra/blgEntries.json HTTP/1.1//
11 +//> User-Agent: curl/7.19.7 (universal-apple-darwin10.0) libcurl/7.19.7 OpenSSL/0.9.8r zlib/1.2.3//
12 +//> Host: 127.0.0.1:60530//
13 +//> Accept: */*//
14 +//> Content-Length: 138//
15 +//> Content-Type: application/x-www-form-urlencoded//
16 +//> //
17 +//* HTTP 1.0, assume close after body//
18 +//< HTTP/1.0 400 Apple WebObjects//
19 +//< x-webobjects-loadaverage: 0//
20 +//< content-type: application/json//
21 +//< content-length: 53//
22 +//< //
23 +//A <b>Blg Entry</b> must have a <b>To Blg Author</b>.//
24 +//* Closing connection #0//
25 +
26 +(% style="line-height: 1.4285715;" %)**I'm new using ERRest and maybe i forgot to configure something.**
27 +
28 +**Any help would be appreciated.**
Date
... ... @@ -1,0 +1,1 @@
1 +2013-07-04 19:53:39.835
XWiki.XWikiComments[2]
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.cdvalverdeg
Comment
... ... @@ -1,0 +1,1 @@
1 +I found the problem, "(% style="color: rgb(0,0,0);" %)//author//(%%)" is not the name of the relationship in my blog model 
Date
... ... @@ -1,0 +1,1 @@
1 +2013-07-05 13:23:14.677
Reply To
... ... @@ -1,0 +1,1 @@
1 +1
XWiki.XWikiComments[3]
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.larean
Comment
... ... @@ -1,0 +1,8 @@
1 +Hi, I am trying to run this example and I get an error message. In particular, I cannot use curl. I added the records manually and when I try to display them I get this on the console:
2 +\\
3 +
4 +(% class="typ" %)Request(% class="pln" %) start (% class="kwd" %)for(% class="pln" %) URI (% class="pun" %)/(% class="pln" %)cgi(% class="pun" %)-(% class="pln" %)bin(% class="pun" %)/(% class="typ" %)WebObjects(% class="pun" %)/(% class="typ" %)BlogTutorial(% class="pun" %).(% class="pln" %)woa(% class="pun" %)/(% class="pln" %)ra(% class="pun" %)/(% class="pln" %)blogEntries(% class="pun" %).(% class="pln" %)json (% class="typ" %)Headers(% class="pun" %){(% class="pln" %)accept (% class="pun" %)=(% class="pln" %) (% class="pun" %)((% class="str" %)"*/*"(% class="pun" %));(% class="pln" %) host (% class="pun" %)=(% class="pln" %) (% class="pun" %)((% class="str" %)"127.0.0.1:45743"(% class="pun" %));(% class="pln" %) user(% class="pun" %)-(% class="pln" %)agent (% class="pun" %)=(% class="pln" %) (% class="pun" %)((% class="str" %)"curl/7.38.0"(% class="pun" %));(% class="pln" %) (% class="pun" %)}(% class="pln" %) (% class="pun" %)[(% class="lit" %)2015(% class="pun" %)-(% class="lit" %)8(% class="pun" %)-(% class="lit" %)14(% class="pln" %) (% class="lit" %)17(% class="pun" %):(% class="lit" %)20(% class="pun" %):(% class="lit" %)19(% class="pln" %) CEST(% class="pun" %)](% class="pln" %) (% class="pun" %)<(% class="typ" %)WorkerThread14(% class="pun" %)>(% class="pln" %) (% class="pun" %)<(% class="pln" %)er(% class="pun" %).(% class="pln" %)rest(% class="pun" %).(% class="pln" %)routes(% class="pun" %).(% class="typ" %)ERXRouteRequestHandler(% class="pun" %)>:(% class="pln" %) (% class="typ" %)Exception(% class="pln" %) (% class="kwd" %)while(% class="pln" %) handling action named (% class="str" %)"index"(% class="pln" %) on action (% class="kwd" %)class(% class="pln" %) (% class="str" %)"your.app.rest.controllers.BlogEntryController"(% class="pln" %) (% class="pun" %):(% class="pln" %)com(% class="pun" %).(% class="pln" %)webobjects(% class="pun" %).(% class="pln" %)foundation(% class="pun" %).(% class="typ" %)NSForwardException(% class="pln" %) (% class="pun" %)[(% class="pln" %)java(% class="pun" %).(% class="pln" %)lang(% class="pun" %).(% class="pln" %)reflect(% class="pun" %).(% class="typ" %)InvocationTargetException(% class="pun" %)](% class="pln" %) (% class="kwd" %)null(% class="pun" %):(% class="pln" %)java(% class="pun" %).(% class="pln" %)lang(% class="pun" %).(% class="pln" %)reflect(% class="pun" %).(% class="typ" %)InvocationTargetException(% class="pln" %) _ignoredPackages(% class="pun" %)::(% class="pln" %) (% class="pun" %)((% class="str" %)"com.webobjects"(% class="pun" %),(% class="pln" %) (% class="str" %)"java.applet"(% class="pun" %),(% class="pln" %) (% class="str" %)"java.awt"(% class="pun" %),(% class="pln" %) (% class="str" %)"java.awt.datatransfer"(% class="pun" %),(% class="pln" %) (% class="str" %)"java.awt.event"(% class="pun" %),(% class="pln" %) (% class="str" %)"java.awt.image"(% class="pun" %),(% class="pln" %) (% class="str" %)"java.beans"(% class="pun" %),(% class="pln" %) (% class="str" %)"java.io"(% class="pun" %),(% class="pln" %) (% class="str" %)"java.lang"(% class="pun" %),(% class="pln" %) (% class="str" %)"java.lang.reflect"(% class="pun" %),(% class="pln" %) (% class="str" %)"java.math"(% class="pun" %),(% class="pln" %) (% class="str" %)"java.net"(% class="pun" %),(% class="pln" %) (% class="str" %)"java.rmi"(% class="pun" %),(% class="pln" %) (% class="str" %)"java.rmi.dgc"(% class="pun" %),(% class="pln" %) (% class="str" %)"java.rmi.registry"(% class="pun" %),(% class="pln" %) (% class="str" %)"java.rmi.server"(% class="pun" %),(% class="pln" %) (% class="str" %)"java.security"(% class="pun" %),(% class="pln" %) (% class="str" %)"java.security.acl"(% class="pun" %),(% class="pln" %) (% class="str" %)"java.security.interfaces"(% class="pun" %),(% class="pln" %) (% class="str" %)"java.sql"(% class="pun" %),(% class="pln" %) (% class="str" %)"java.text"(% class="pun" %),(% class="pln" %) (% class="str" %)"java.util"(% class="pun" %),(% class="pln" %) (% class="str" %)"java.util.zip"(% class="pun" %))(% class="pln" %) (% class="typ" %)Headers(% class="pun" %){(% class="pln" %)cache(% class="pun" %)-(% class="pln" %)control (% class="pun" %)=(% class="pln" %) (% class="pun" %)((% class="str" %)"private"(% class="pun" %),(% class="pln" %) (% class="str" %)"no-cache"(% class="pun" %),(% class="pln" %) (% class="str" %)"no-store"(% class="pun" %),(% class="pln" %) (% class="str" %)"must-revalidate"(% class="pun" %),(% class="pln" %) (% class="str" %)"max-age=0"(% class="pun" %));(% class="pln" %) expires (% class="pun" %)=(% class="pln" %) (% class="pun" %)((% class="str" %)"Fri, 14-Aug-2015 15:20:19 GMT"(% class="pun" %));(% class="pln" %) content(% class="pun" %)-(% class="pln" %)type (% class="pun" %)=(% class="pln" %) (% class="pun" %)((% class="str" %)"text/html"(% class="pun" %));(% class="pln" %) content(% class="pun" %)-(% class="pln" %)length (% class="pun" %)=(% class="pln" %) (% class="pun" %)((% class="str" %)"9296"(% class="pun" %));(% class="pln" %) pragma (% class="pun" %)=(% class="pln" %) (% class="pun" %)((% class="str" %)"no-cache"(% class="pun" %));(% class="pln" %) x(% class="pun" %)-(% class="pln" %)webobjects(% class="pun" %)-(% class="pln" %)loadaverage (% class="pun" %)=(% class="pln" %) (% class="pun" %)((% class="str" %)"1"(% class="pun" %));(% class="pln" %) date (% class="pun" %)=(% class="pln" %) (% class="pun" %)((% class="str" %)"Fri, 14-Aug-2015 15:20:19 GMT"(% class="pun" %));(% class="pln" %) set(% class="pun" %)-(% class="pln" %)cookie (% class="pun" %)=(% class="pln" %) (% class="pun" %)();(% class="pln" %) (% class="pun" %)}
5 +
6 +{{code language="none"}}{{/code}}
7 +
8 +{{{}}}
Date
... ... @@ -1,0 +1,1 @@
1 +2015-08-17 08:04:44.506