## ============================================================================ ## Filename : WebNewCmdTemplate.vm ## Note(s) : This template is used to generate a NewCommand 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 ## $className ## $packageName ## $prjPkgName ## $prjClassPrefix ## $superClassName ## $date ## $auditTrailColumns ## $codeGen ## #if ($packageName) package $packageName; #end #parse( "ClassHeaderInclude.vm" ) import thinkui.command.Command; import thinkui.command.CommandContext; import thinkui.security.DefaultApplicationPermission; import thinkui.security.ApplicationPermission; import thinkui.security.ApplicationPermissionSupport; import thinkui.${prjPkgName}.objects.${objectName}; import thinkui.${prjPkgName}.criteria.${objectName}SearchData; import thinkui.${prjPkgName}.proxies.${prjClassPrefix}Proxy; import thinkui.${prjPkgName}.web.Permissions; import thinkui.${prjPkgName}.web.${prjClassPrefix}SessionManager; import thinkui.web.AbstractWebCommand; import thinkui.web.WebCommandContext; /** * Implements the command to add more ${objectName} objects. The command simply * initializes a new ${objectName} object in the session and forward to the * ShowView${objectName}Command. */ public class ${className} extends ${superClassName} implements ApplicationPermissionSupport { /** * ${className} constructor. */ public ${className}() { super(); } /* public final ApplicationPermission getPermission() { return Permissions.ADMINISTRATOR_ROLE; } */ /** * Execute the command with the specified context. */ public final Object execute(CommandContext context) throws Exception { WebCommandContext ctx = (WebCommandContext) context; ${prjClassPrefix}SessionManager sessionMgr = new ${prjClassPrefix}SessionManager(ctx); ${prjClassPrefix}Proxy proxy = (${prjClassPrefix}Proxy) ctx.lookupProxy(${prjClassPrefix}Proxy.NAME); try { ${objectName} ${objectVar} = proxy.get${objectName}(null); // Default initial values to search criteria (if any). ${objectName}SearchData searchData = sessionMgr.get${objectName}SearchData(); if (searchData != null) { ${objectVar}.copyFrom(searchData); } // TODO -- Uncomment if applicable, otherwise remove generated code. //${objectVar}.copyFrom(this); // Copy the _ID (if any). #if ($auditTrailColumns) ${objectVar}.setUser(ctx.getUser()); #end sessionMgr.set${objectName}(${objectVar}); } finally { proxy.remove(); } Command nextCommand = new ShowView${objectName}Command(); nextCommand.copyFrom(this); setNextCommand(nextCommand); return NO_RESULT; } }