|
The WODisplayGroup performs all database accesses for your application. The
more commonly used methods are listed below, sorted by the type of operation
they perform.
Displaying Results
These methods give you access to database objects and allow you to display them.
- allObjects
- All of the records to be displayed. For example, if your application has a
query that results in one hundred records being fetched but you have set
up the display group to only display ten at a time, allObjects contains all
one hundred records.
- displayedObjects
- The records actually being displayed. For example, if your application has a
query that results in one hundred records being fetched but you have set
up the display group to only display ten at a time, displayedObjects contains those ten records.
- selectedObjects
- The records in the current selection.
- selectedObject
- A single selected record. Usually, this returns the first record in the selectedObjects array.
Managing Batches
These methods control the grouping of records into manageable batches to display.
(You set the batch size on the WODisplayGroup options panel.)
- displayPreviousBatch
- Select the previously-displayed batch of records and then reloads the
page.
- displayNextBatch
- Selects the next batch of records and then reloads the page.
- batchCount
- The number of batches to display. For example, if you're fetching two hundred records and the batch size is ten, batchCount returns twenty (twenty
batches of ten records each).
- batchIndex
- The number of the batch currently displayed, where 1 is the first batch displayed. For example, if the batch size is ten records and displayedObjects
is showing records 11 through 20, the batchIndex is 2.
Querying
These methods are used in applications that perform queries.
- executeQuery
- Builds a qualifier using inputObjectForQualifier and the pattern matching
you set on the display group options panel, and then fetches the records
that match that qualifier. The qualifier is not preserved.
- inputObjectForQualifier
- Returns an entity object that is used to create the qualifier. For example, if
you wanted the application to search on movie titles, you would bind a text
field to inputObjectForQualifier.title. (title comes from the entity that created the WODisplayGroup.)
- secondObjectForQualifier
- Used for from-to queries to specify the "to" value. This method must use
the same property as inputObjectForQualifier. For example, if you
wanted to query all movies released between two dates, you would bind
the first field inputObjectForQualifier.dateReleased and the second field
to secondObjectForQualifier.dateReleased. The resulting qualifier would
fetch all movies release after the date specified in inputObjectForQualifier but before the date specified in secondObjectForQualifier.
Modifying the Database
These methods modify the database.
- insert
- Adds a new empty record. You should provide a dictionary containing
default values for the record and use the setInsertedObjectDefaultValues: to specify that the WODisplayGroup should use that dictionary to create all new values. For example, these statements ensure that all new records contain a value for movie title:
[dictionary setObject:@"New title"]
forKey:@"title"];
[movies setInsertedObjectDefaultValues:dictionary];
- delete
- Deletes the selected records.
If you're modifying a database, you must explicitly save the changes. Write a
method that uses the session's EOEditingContext to save the changes. For example:
[self.session.defaultEditingContext saveChanges];
See the EOEditingContext class description in the Enterprise Objects Framework
Reference.
|