Wiki source code of Using a custom EOEditingContext (ERXEC) Subclass
Last modified by Kieran Kelleher on 2007/07/03 11:53
Show last authors
| author | version | line-number | content |
|---|---|---|---|
| 1 | ==== Create the EditingContext Subclass ==== | ||
| 2 | |||
| 3 | {{code}} | ||
| 4 | |||
| 5 | public class MyEditingContext extends ERXEC { | ||
| 6 | |||
| 7 | public MyEditingContext(EOObjectStore anObjectStore) { | ||
| 8 | super(anObjectStore); | ||
| 9 | } | ||
| 10 | |||
| 11 | public MyEditingContext() { | ||
| 12 | super(); | ||
| 13 | } | ||
| 14 | |||
| 15 | // Your custom logic here... | ||
| 16 | |||
| 17 | } | ||
| 18 | |||
| 19 | {{/code}} | ||
| 20 | |||
| 21 | ==== Create the ERXEC.DefaultFactory Subclass ==== | ||
| 22 | |||
| 23 | {{code}} | ||
| 24 | |||
| 25 | public class MyEditingContextFactory extends ERXEC.DefaultFactory { | ||
| 26 | |||
| 27 | public MyEditingContextFactory() { | ||
| 28 | super(); | ||
| 29 | } | ||
| 30 | |||
| 31 | protected EOEditingContext _createEditingContext(EOObjectStore parent) { | ||
| 32 | return new MyEditingContext(parent == null ? EOEditingContext.defaultParentObjectStore() : parent);; | ||
| 33 | } | ||
| 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 | |||
| 44 | public Application() { | ||
| 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 | |||
| 56 | ==== Creating an Instance of Your Custom Editing Context Subclass ==== | ||
| 57 | |||
| 58 | {{code}} | ||
| 59 | |||
| 60 | EOEditingContext ec = ERXEC.newEditingContext(); | ||
| 61 | |||
| 62 | {{/code}} |