## ============================================================================ ## Filename : WebSearchCmdTemplate.vm ## Note(s) : This template is used to generate a SearchCommand Java class. ## ## Note: The generated code is dependent on the ThinkUI framework. ## Please refer to the SQL Client documentation for details. ## ## Copyright (c) 2007 ThinkUI Software Inc. All rights reserved. ## ============================================================================ ## ## **************************************************************************** ## The following variables are available in this template. For more ## information on any of the following variable, please refer to the user guide. ## **************************************************************************** ## $projectName ## $authorName ## $headerText ## $objectName ## $objectVar ## $objectCaption ## $className ## $packageName ## $prjPkgName ## $prjClassPrefix ## $superClassName ## $date ## $codeGen ## #if ($packageName) package $packageName; #end #parse( "ClassHeaderInclude.vm" ) import thinkui.command.Command; import thinkui.${prjPkgName}.criteria.${objectName}SearchData; import thinkui.${prjPkgName}.proxies.${prjClassPrefix}Proxy; import thinkui.${prjPkgName}.web.${prjClassPrefix}SessionManager; import thinkui.common.SearchCriteriaData; import thinkui.common.SearchResultsData; import thinkui.web.${superClassName}; import thinkui.web.WebCommandContext; /** * Implements a command to search for the ${objectName} objects. */ public class ${className} extends ${superClassName} { /** * ${className} constructor. */ public ${className}() { super(); } protected final SearchCriteriaData createSearchDataCriteria(WebCommandContext ctx) throws Exception { ${objectName}SearchData criteria = new ${objectName}SearchData(); // Perform any needed initializations of the search criteria here. // If appropriate, use a proxy to create the search criteria instead. return criteria; } protected final SearchCriteriaData getSearchDataCriteria(WebCommandContext ctx) throws Exception { // Get the criteria and copy parameters from the posted values to this cmd ${prjClassPrefix}SessionManager sessionMgr = new ${prjClassPrefix}SessionManager(ctx); ${objectName}SearchData criteria = sessionMgr.get${objectName}SearchData(); if (criteria == null || (isNewSearch() && isClearSearchCriteria())) { criteria = (${objectName}SearchData) createSearchDataCriteria(ctx); sessionMgr.set${objectName}SearchData(criteria); } // Only allow the search criteria to be updated if this is a new search. // Otherwise, the Prev/Next actions will be inconsistent with the search results. if (isNewSearch()) { // Propagate parameters on the command to the criteria. criteria.copyFrom(this); ctx.setDataObjectValues(criteria); #if ($auditTrailColumns) fixFromToCreateDateTimeCriteria(criteria); #end } return criteria; } protected final SearchResultsData performSearch( WebCommandContext ctx, SearchCriteriaData criteria) throws Exception { ${prjClassPrefix}Proxy proxy = (${prjClassPrefix}Proxy) ctx.lookupProxy(${prjClassPrefix}Proxy.NAME); try { SearchResultsData searchResults = proxy.find${objectName}((${objectName}SearchData) criteria); return searchResults; } finally { proxy.remove(); } } protected final Command getShowResultsCommand(WebCommandContext ctx) { Show${className} cmd = new Show${className}(); cmd.setClearSearchCriteria(false); return cmd; } }