From: Wouter Z. <dra...@us...> - 2003-12-26 13:35:09
|
User: draftdog Date: 03/12/26 05:35:08 Added: andromda-bpm4struts/src/templates StrutsFormAbstract.vsl Log: functionality from StrutsForm moved here, this allows the implementation class to add custom features such as validation Revision Changes Path 1.1 cartridges/andromda-bpm4struts/src/templates/StrutsFormAbstract.vsl Index: StrutsFormAbstract.vsl =================================================================== ## ## Package declaration and imports ## package $transform.getPackageName($class); import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionMapping; import javax.servlet.http.HttpServletRequest; ## ## Start of the class declaration ## public abstract class ${class.name}Abstract extends ActionForm { private String trigger = null; ## ## Each attribute needs to be rendered as a private field ## #foreach ($feature in $class.feature) #if ($transform.staticHelper.isAttribute($feature)) #set ($attributeTypePackage = $transform.getPackageName($feature.type)) #if ($attributeTypePackage == "java.lang") #set ($attributeTypePackage = "")## java.lang is implicitely imported, no need to mess up the code #end #if ($attributeTypePackage != "") #set ($attributeTypePackage = "${attributeTypePackage}.") #end #set ($attributeType = "$attributeTypePackage$feature.type.name") private $attributeType $feature.name; #end #end public abstract void reset(ActionMapping mapping, HttpServletRequest request); public abstract ActionErrors validate(ActionMapping mapping, HttpServletRequest request); /** * Gets the value of the event that triggered the action. */ public String getTrigger() { return trigger; } /** * Sets the value of the event that triggered the action. */ public void setTrigger(String trigger) { this.trigger = trigger; } ## ## A getter and setter for each attribute ## #foreach ($feature in $class.feature) #if ($transform.staticHelper.isAttribute($feature)) #set ($attributeTypePackage = $transform.getPackageName($feature.type)) #if ($attributeTypePackage == "java.lang") #set ($attributeTypePackage = "")## java.lang is implicitely imported, no need to mess up the code #end #if ($attributeTypePackage != "") #set ($attributeTypePackage = "${attributeTypePackage}.") #end #set ($attributeType = "$attributeTypePackage$feature.type.name") public $attributeType get$str.upperCaseFirstLetter($feature.name)() { return $feature.name; } public void set$str.upperCaseFirstLetter($feature.name)($attributeType $feature.name) { this.$feature.name = $feature.name; } #end #end public String toString() { return "[ " + #foreach ($feature in $class.feature) #if ($transform.staticHelper.isAttribute($feature)) String.valueOf($feature.name) + ' ' + #end #end "]"; } } |