Wiki source code of Using a custom EOEditingContext (ERXEC) Subclass
Last modified by Kieran Kelleher on 2007/07/03 11:53
Hide last authors
| author | version | line-number | content |
|---|---|---|---|
| |
1.1 | 1 | ==== Create the EditingContext Subclass ==== |
| 2 | |||
| 3 | {{code}} | ||
| 4 | |||
| |
3.1 | 5 | public class MyEditingContext extends ERXEC { |
| |
1.1 | 6 | |
| 7 | public MyEditingContext(EOObjectStore anObjectStore) { | ||
| 8 | super(anObjectStore); | ||
| 9 | } | ||
| |
3.1 | 10 | |
| |
1.1 | 11 | public MyEditingContext() { |
| 12 | super(); | ||
| 13 | } | ||
| |
3.1 | 14 | |
| |
1.1 | 15 | // Your custom logic here... |
| |
3.1 | 16 | |
| |
1.1 | 17 | } |
| 18 | |||
| 19 | {{/code}} | ||
| 20 | |||
| 21 | ==== Create the ERXEC.DefaultFactory Subclass ==== | ||
| 22 | |||
| 23 | {{code}} | ||
| 24 | |||
| |
3.1 | 25 | public class MyEditingContextFactory extends ERXEC.DefaultFactory { |
| |
1.1 | 26 | |
| 27 | public MyEditingContextFactory() { | ||
| 28 | super(); | ||
| 29 | } | ||
| |
3.1 | 30 | |
| |
1.1 | 31 | protected EOEditingContext _createEditingContext(EOObjectStore parent) { |
| 32 | return new MyEditingContext(parent == null ? EOEditingContext.defaultParentObjectStore() : parent);; | ||
| |
3.1 | 33 | } |
| |
1.1 | 34 | } |
| 35 | |||
| 36 | {{/code}} | ||
| 37 | |||
| 38 | ==== Tell Wonder to Use Your Custom Factory ==== | ||
| 39 | |||
| 40 | In your Application constructor, set your custom editing context factory as the default factory for ERXEC as shown here for example: | ||
| 41 | |||
| 42 | {{code}} | ||
| 43 | |||
| |
3.1 | 44 | public Application() { |
| |
1.1 | 45 | super(); |
| 46 | |||
| 47 | // Configure the Editing Context factory for my subclass of ERXEC | ||
| 48 | ERXEC.setFactory( new MyEditingContextFactory() ); | ||
| 49 | |||
| 50 | // More app initialization code...... | ||
| 51 | |||
| 52 | } | ||
| 53 | |||
| 54 | {{/code}} | ||
| 55 | |||
| |
3.1 | 56 | ==== Creating an Instance of Your Custom Editing Context Subclass ==== |
| |
1.1 | 57 | |
| 58 | {{code}} | ||
| 59 | |||
| |
3.1 | 60 | EOEditingContext ec = ERXEC.newEditingContext(); |
| |
1.1 | 61 | |
| 62 | {{/code}} |