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
on 2012/08/09 05:07
Change comment:
There is no comment for this version
To version 44.1
edited by skcodes
on 2013/05/13 12:53
on 2013/05/13 12:53
Change comment:
There is no comment for this version
Summary
-
Page properties (2 modified, 0 added, 0 removed)
Details
- Page properties
-
- Author
-
... ... @@ -1,1 +1,1 @@ 1 -XWiki. probert1 +XWiki.skcodes - Content
-
... ... @@ -25,6 +25,7 @@ 25 25 | title | string(255) | 26 26 | content | string(4000) | 27 27 | creationDate | timestamp | 28 +| lastModified | timestamp | 28 28 | author | integer | relation with Author 29 29 30 30 Author will have the following columns: ... ... @@ -74,6 +74,7 @@ 74 74 |= Attribute name |= Column |= Prototype 75 75 | content | content | longtext 76 76 | creationDate | creationDate | dateTime 78 +| lastModified | lastModified | dateTime 77 77 78 78 If you did everything well, the list of attributes should look like this: 79 79 ... ... @@ -92,7 +92,7 @@ 92 92 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**. 97 +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.) 96 96 97 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. 98 98 ... ... @@ -110,15 +110,17 @@ 110 110 111 111 {{code}} 112 112 113 -@Override 115 + @Override 114 114 public void awakeFromInsertion(EOEditingContext editingContext) { 115 - super.awakeFromInsertion(editingContext); 116 - this.setCreationDate(new NSTimestamp()); 117 + super.awakeFromInsertion(editingContext); 118 + NSTimestamp now = new NSTimestamp(); 119 + setCreationDate(now); 120 + 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 th atvalue.125 +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 ... ... @@ -431,4 +431,4 @@ 431 431 432 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 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]]. 438 +The REST part of this tutorial is now complete, [[you can now move to the next part of the tutorial>>Your First Framework]].