Retired Document
Important: This document may not represent best practices for current development. Links to downloads and other resources may no longer be valid.
Building Custom List Controllers
The public methods provided by the controller factory (com.webobjects.eogeneration.EOControllerFactory
) allow you to dynamically generate user interfaces for many types of tasks throughout your application. However, it doesn’t provide methods for all types of tasks, such as list controllers. This topic describes how to programmatically create a list controller.
Problem: You want to display a list controller containing the enterprise objects returned by a fetch.
Solution: Programmatically create a list controller.
The following method constructs a list controller by first creating a generic controller, then by asking the controller factory for a list controller based on the generic controller and an entity name, and then by invoking listObjectsWithFetchSpecification
to fetch enterprise objects into the list controller.
public void listWithEntityName(String entityName, EOFetchSpecification fs) { |
EOControllerFactory f = EOControllerFactory.sharedControllerFactory(); |
EOController controller = f.controllerWithSpecification(new NSDictionary (new |
Object[] {entityName, EOControllerFactory.ListTask, |
EOControllerFactory.TopLevelWindowQuestion}, new Object[] |
{EOControllerFactory.EntitySpecification, EOControllerFactory.TaskSpecification, |
EOControllerFactory.QuestionSpecification}), true); |
if (controller != null) { |
EOListController listController = (EOListController)f.controllerWithEntityName(controller, |
EOControllerFactory.List.class, entityName); |
listController.listObjectsWithFetchSpecification(fs); |
listController.setEditability(EOEditable.NeverEditable); |
listController.makeVisible(); |
} |
} |
Copyright © 2002, 2005 Apple Computer, Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2005-08-11