EOFDirtyDoc
by Kenny Leung, NeXT Technical Support
Overview
EOControllers alert their delegates when the user has completed an edit, but not when the user begins editing. If you are trying to implement a document-style paradigm for editing your objects, this delayed reaction does not fit very well. You need to know when editing has begun so you can enable controls and mark the window dirty.
How It Works
When you begin editing a control such as a TextField or a Form, EOControlAssociation is set up as the textdelegate for that editing session. Similarly, EOTextAssociation is set up as the delegate of a Text object in a scrollview. These associations already pass some text delegate messages on to the controller's delegate, just not all of them.
The category
TextDelegation is added to EOAssociation which implements Text's delegate method textWillChange:. All this method does is invoke controller:associationDidBeginEditing: in the EOController's delegate.
Adding textWillChange: to EOAssociation works for all of the standard text interface objects except for NXTableView. This is because NXTableView uses formatters to do its display and editing, and the protocol is a little different. When you edit text in an NXTableView, NXEditableFormatter is set up as the textdelegate. It catches textWillChange: and passes it on to EOColumnAssociation via the methods formatterWillChangeValueFor::sender: and formatterWillChangeValueFor::sender: (described in the NXFormatterValidation informal protocol). Since which message actually gets sent depends on the setup of the NXTableView, we have to implement both of these methods in EOColumnAssociation. Again, these methods are implenented as a category
of EOColumnAssociation, and all they do is invoke controller:associationDidBeginEditing: in EOController's delegate.
Database Data
This example uses the People database on Oracle. (See the PeopleDBScripts directory.) The EOModel is included in the project directory. This should work with little or no modification with the People data on Sybase. Alternatively, you can hook this up with almost any data you want.
Further Work
You will notice when you hit the Discard button, the data in the scrolling text will not revert properly. The workaround for this bug is to re-fetch the object from the database.
Valid for NEXTSTEP Release 3.2 installed with the Enterprise Objects Framework Release 1.0.
Valid for NEXTSTEP Release 3.3 installed with the Enterprise Objects Framework Release 1.1.
| April 1995 | Created example |