Table of Contents Previous Section
Binding to Complex Qualifiers
In Enterprise Objects Framework 3.0, you can bind user interface elements directly to variables in a complex qualifier that you created using the new Query Builder in EOModeler.For example, suppose you want to create a WebObjects application that allows users to perform a complex query on the Movies entity in the Movies database. Suppose you want to allow users to query on the title, the date released, and the studio. You could use the queryMatch, queryMin, and queryMax support in display group to easily construct such query. For example:
(title = $title) AND (dateReleased = $date) AND (studio = $studio)However, queryMatch support is limited to ANDed criteria; it isn't sufficient for more complex queries such as:
(title = $title) OR (dateReleased = $date) OR (studio = $studio)For this qualifier you could define the qualifier in EOModeler and then bind to it in your user interface. In general, you would set this up by following these steps:
- In EOModeler, open the Movies model file and select the Movies entity.
- Create a fetch specification associated with the Movies entity by clicking the New Fetch Specification button.
- Use Query Builder's user interface to set up a query on the title, dateReleased, and studio attributes of the entity (see the section "Query Builder"). On the right side of each expression, use a $ syntax to denote the qualifier variable. For example, your fetch specification might look like this:
(title = $title) OR (dateReleased = $date) OR (studio = $studio)
- Use WebObjects builder to create a component that allows the user to enter the query criteria. You might create text fields for the title and date released and a pop-up list for the studio, for example.
- Drag the fetch specification from EOModeler into your component. This has the effect of creating a new display group for your specification's entity.
- Choose "Add and Configure."
- Configure the new display group, setting its fetch specification to the one you defined in your model.
- In WebObjects Builder, bind the user interface elements to the queryBindings.title, queryBindings.date, and queryBindings.studio keys of your display group (movieDisplayGroup, for example).
Qualifier bindings are also useful when you want to bind a value to more than one qualifier component as in the following:
(title like $searchString) OR (description like $searchString)In this example, searchString could contain a user-provided keyword surrounded with wildcard characters.
The following tables describe the API added to support binding to complex qualifiers.
EOClassDescription | |
---|---|
defaultFormatterForKeyPath: | Similar to defaultFormatterForKey:, except this method takes a key path (roles.roleName, for example). |
Table of Contents Next Section