Example 8.29 Implementing Value List Handler Pattern package corepatterns.apps.psa.handlers; import java.util.*; import corepatterns.apps.psa.dao.*; import corepatterns.apps.psa.util.*; import corepatterns.apps.psa.core.*; public class ProjectListHandler extends ValueListHandler { private ProjectDAO dao = null; // use ProjectVO as a template to determine // search criteria private ProjectVO projectCriteria = null; // Client creates a ProjectVO instance, sets the // values to use for search criteria and passes // the ProjectVO instance as projectCriteria // to the constructor and to setCriteria() method public ProjectListHandler(ProjectVO projectCriteria) throws ProjectException, ListHandlerException { try { this.projectCriteria = projectCriteria; this.dao = PSADAOFactory.getProjectDAO(); executeSearch(); } catch (Exception e) { // Handle exception, throw ListHandlerException } } public void setCriteria(ProjectVO projectCriteria) { this.projectCriteria = projectCriteria; } // executes search. Client can invoke this // provided that the search criteria has been // properly set. Used to perform search to refresh // the list with the latest data. public void executeSearch() throws ListHandlerException { try { if (projectCriteria == null) { throw new ListHandlerException( "Project Criteria required..."); } List resultsList = dao.executeSelect(projectCriteria); setList(resultsList); } catch (Exception e) { // Handle exception, throw ListHandlerException } } }