Last modified by Bastian Triller on 2021/08/07 03:59

From version 9.1
edited by Pascal Robert
on 2012/08/06 05:45
Change comment: There is no comment for this version
To version 3.1
edited by Pascal Robert
on 2012/08/06 05:04
Change comment: There is no comment for this version

Summary

Details

Page properties
Content
... ... @@ -11,54 +11,8 @@
11 11  * The main page will display a list of blog entries, with a link to see the blog entry.
12 12  * The main page will have a link to an "admin" page that will show a login form.
13 13  * After login, a list of blog entries with links to edit, delete and create blog entries will be show.
14 -* We need a form to edit/create blog entries.
14 +* We need a form to edit/create blog entries.
15 15  
16 16  Let's start by creating a new project in Eclipse. You need to create a **Wonder Application** project type, and name it **StatefulBlog**.
17 17  
18 18  [[image:Capture d’écran 2012-08-06 à 04.56.13.png||border="1"]]
19 -
20 -Just like the D2W tutorial, you need to link the application with the **BlogCommon**, **Ajax** and **H2PlugIn** frameworks. To do so, right-click on **StatefulBlog** and select **Build Path** > **Configure Build Path**. 
21 -
22 -[[image:Capture d’écran 2012-07-29 à 14.25.46.png||border="1"]]
23 -
24 -In the **Libraries** tab, click on **Add Library**. Select **WebObjects Frameworks** and click **Next**. Check **Ajax**, **BlogCommon** and **H2PlugIn** from the list and click **Finish**. The **Libraries** tab should look like this:
25 -
26 -[[image:Capture d’écran 2012-08-06 à 05.15.32.png||border="1"]]
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.
29 -
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 -
32 -{{code}}
33 -
34 -import com.webobjects.appserver.WOContext;
35 -import com.webobjects.eoaccess.EODatabaseDataSource;
36 -import com.webobjects.eocontrol.EOEditingContext;
37 -
38 -import er.extensions.batching.ERXBatchingDisplayGroup;
39 -import er.extensions.components.ERXComponent;
40 -import er.extensions.eof.ERXEC;
41 -
42 -public class Main extends ERXComponent {
43 -
44 - public Main(WOContext context) {
45 - super(context);
46 - EODatabaseDataSource dataSource = new EODatabaseDataSource(editingContext(), BlogEntry.ENTITY_NAME);
47 - ERXBatchingDisplayGroup<BlogEntry> dg = new ERXBatchingDisplayGroup<BlogEntry>();
48 - dg.setNumberOfObjectsPerBatch(20);
49 - dg.setDataSource(dataSource);
50 - dg.setObjectArray(BlogEntry.fetchAllBlogEntries(editingContext(), BlogEntry.LAST_MODIFIED.descs()));
51 - }
52 -
53 - private EOEditingContext _ec;
54 -
55 - private EOEditingContext editingContext() {
56 - if (_ec == null) {
57 - _ec = ERXEC.newEditingContext();
58 - }
59 - return _ec;
60 - }
61 -
62 -}
63 -
64 -{{/code}}