Changes for page Your First Stateful Project
Last modified by Bastian Triller on 2021/08/07 03:59
From version 10.1
edited by Pascal Robert
on 2012/08/06 05:45
on 2012/08/06 05:45
Change comment:
There is no comment for this version
To version 5.1
edited by Pascal Robert
on 2012/08/06 05:52
on 2012/08/06 05:52
Change comment:
There is no comment for this version
Summary
-
Page properties (1 modified, 0 added, 0 removed)
Details
- Page properties
-
- Content
-
... ... @@ -25,12 +25,14 @@ 25 25 26 26 [[image:Capture d’écran 2012-08-06 à 05.15.32.png||border="1"]] 27 27 28 -We are ready to code !Open the **Components** folder of the project, and open **Main WO**. In the **Related** view (bottom-right), you see that all related files of the component are listed, and we need to open the Java code associated with the component. To do so, in the **Related** view, double-click on **Main.java** to open the Java class into an editor.28 +We are ready to code Open the **Components** folder of the project, and open **Main WO**. In the **Related** view (bottom-right), you see that all related files of the component are listed, and we need to open the Java code associated with the component. To do so, in the **Related** view, double-click on **Main.java** to open the Java class into an editor. 29 29 30 30 In **Main.java**, we need some Java code to get the list of blog entries so that we can show that list into the component. The following code will do what we need: 31 31 32 32 {{code}} 33 33 34 +import your.app.model.BlogEntry; 35 + 34 34 import com.webobjects.appserver.WOContext; 35 35 import com.webobjects.eoaccess.EODatabaseDataSource; 36 36 import com.webobjects.eocontrol.EOEditingContext; ... ... @@ -41,6 +41,9 @@ 41 41 42 42 public class Main extends ERXComponent { 43 43 46 + private EOEditingContext _ec; 47 + private BlogEntry _blogEntryItem; 48 + 44 44 public Main(WOContext context) { 45 45 super(context); 46 46 EODatabaseDataSource dataSource = new EODatabaseDataSource(editingContext(), BlogEntry.ENTITY_NAME); ... ... @@ -50,8 +50,6 @@ 50 50 dg.setObjectArray(BlogEntry.fetchAllBlogEntries(editingContext(), BlogEntry.LAST_MODIFIED.descs())); 51 51 } 52 52 53 - private EOEditingContext _ec; 54 - 55 55 private EOEditingContext editingContext() { 56 56 if (_ec == null) { 57 57 _ec = ERXEC.newEditingContext(); ... ... @@ -58,7 +58,15 @@ 58 58 } 59 59 return _ec; 60 60 } 61 - 64 + 65 + public void setBlogEntryItem(BlogEntry blogEntryItem) { 66 + this._blogEntryItem = blogEntryItem; 67 + } 68 + 69 + public BlogEntry blogEntryItem() { 70 + return this._blogEntryItem; 71 + } 72 + 62 62 } 63 63 64 64 {{/code}}